Documentation ¶
Index ¶
- Constants
- Variables
- func LegacySlashCommandWarningHandler(qs string, ctx *model.AucBotContext, s *discordgo.Session, ...)
- func ParsePriceParamString(queryString string) (*int, error)
- func ParseRankQueryString(queryString string) (string, int, error)
- func StartBot(bot *discordgo.Session) error
- func StopBot(bot *discordgo.Session) error
- type APIPassthroughSession
- func (a *APIPassthroughSession) AccessTypeTag() model.AccessTypeTag
- func (a *APIPassthroughSession) ChannelID() string
- func (a *APIPassthroughSession) ChannelSessionID() string
- func (a *APIPassthroughSession) Context() *model.AucBotContext
- func (a *APIPassthroughSession) MessageID() string
- func (a *APIPassthroughSession) SetToken(token string)
- func (a *APIPassthroughSession) Token() string
- func (a *APIPassthroughSession) UserSessionID() string
- func (a *APIPassthroughSession) Username() string
- type Handler
- func (dh *Handler) BuyersGuideExtendedMessageHandler(queryString string, opts handlerExtraArgs, ctx *model.AucBotContext, ...)
- func (dh *Handler) ChoiceMessageHandler(_ string, opts handlerExtraArgs, ctx *model.AucBotContext, ...)
- func (dh *Handler) ClearMessageHandler(queryString string, _ handlerExtraArgs, ctx *model.AucBotContext, ...)
- func (dh *Handler) ComponentMessageHandler(queryString string, _ handlerExtraArgs, ctx *model.AucBotContext, ...)
- func (dh *Handler) GroupMessageHandler(queryString string, _ handlerExtraArgs, ctx *model.AucBotContext, ...)
- func (dh *Handler) HelpMessageHandler(queryString string, _ handlerExtraArgs, ctx *model.AucBotContext, ...)
- func (dh *Handler) PriceMessageHandler(queryString string, opts handlerExtraArgs, ctx *model.AucBotContext, ...)
- func (dh *Handler) PriceRequestHandler(ctx *model.AucBotContext, s *discordgo.Session, alerts model.AlertByChannelID) map[string][]string
- func (dh *Handler) RealmMessageHandler(queryString string, opts handlerExtraArgs, ctx *model.AucBotContext, ...)
- func (dh *Handler) RegisterCommands() *MessageHandler
- func (dh *Handler) RegisterSlashCommands(sess *discordgo.Session, discordApplicationID string) (*MessageHandler, error)
- func (dh *Handler) ShoppingListAddHandler(_ string, opts handlerExtraArgs, ctx *model.AucBotContext, ...)
- func (dh *Handler) ShoppingListHandler(queryString string, _ handlerExtraArgs, ctx *model.AucBotContext, ...)
- func (dh *Handler) ShoppingListOptionsChoiceHandler(_ string, opts handlerExtraArgs, ctx *model.AucBotContext, ...)
- func (dh *Handler) ShoppingListOptionsHandler(_ string, _ handlerExtraArgs, ctx *model.AucBotContext, s *discordgo.Session, ...)
- func (dh *Handler) ShoppingListRemoveHandler(_ string, opts handlerExtraArgs, ctx *model.AucBotContext, ...)
- type LegacyHandlerEntry
- type MessageHandler
- type UserSession
- func (d *UserSession) AccessTypeTag() model.AccessTypeTag
- func (d *UserSession) ChannelID() string
- func (d *UserSession) ChannelSessionID() string
- func (d *UserSession) Context() *model.AucBotContext
- func (d *UserSession) MessageID() string
- func (d *UserSession) SetToken(token string)
- func (d *UserSession) Token() string
- func (d *UserSession) UserSessionID() string
- func (d *UserSession) Username() string
Constants ¶
const ( CmdBGHelp = "bghelp" // TODO autocomplete this from "p" CmdPrice = "price" CmdBuyersGuide = "buyers-guide" CmdClear = "clear" CmdRealm = "realm" CmdShoppingList = "shopping-list" )
const ( // ButtonCustomIDChoicePositive is the discord custom ID for choice clear action ButtonCustomIDChoicePositive = "choice_clear" // ButtonCustomIDChoiceNegative is the discord custom ID for choice clear decline action ButtonCustomIDChoiceNegative = "choice_ignore" // SelectCustomIDMultiItem is the discord custom ID for multi item select SelectCustomIDMultiItem = "multi_item" ButtonSLOptionsAlertsOnlyPositive = "sloptions_alertsonly_on" ButtonSLOptionsAlertsOnlyNegative = "sloptions_alertsonly_off" )
const AddBotLink = "https://wowbuyersguide.com/"
const EphemeralFlag = 1 << 6
https://discord.com/developers/docs/resources/channel#message-object-message-flags
const LoadingSpinnerThreshold = time.Millisecond * 500
LoadingSpinnerThreshold is a timeout for aucbot responses. A loading spinner will be shown after this time, before showing the response
Variables ¶
var ( ErrNoMatches = errors.New("no matches") ErrRankNotNumeric = errors.New("rank not numeric") )
Functions ¶
func LegacySlashCommandWarningHandler ¶
func LegacySlashCommandWarningHandler(qs string, ctx *model.AucBotContext, s *discordgo.Session, m *discordgo.MessageCreate)
func ParsePriceParamString ¶
ParsePriceParamString extracts a price target from a query string. This parameter should be in the form
"55g 44s" OR "55.44" Returns the price in copper (if any), and an error
func ParseRankQueryString ¶
ParseRankQueryString extracts an optional rank parameter from a query string. This parameter should be in the form
"item name .r(ank) <number> Returns the item query string, the rank (if any), and an error If no match occurs, returns the input string.
Types ¶
type APIPassthroughSession ¶
type APIPassthroughSession struct {
// contains filtered or unexported fields
}
APIPassthroughSession is a session which is directly provided
func NewAPIPassthrough ¶
func NewAPIPassthrough(ctx *model.AucBotContext, userSessionID, channelID, messageID, token, channelSessionID, username string, accessType model.AccessTypeTag) *APIPassthroughSession
func (*APIPassthroughSession) AccessTypeTag ¶
func (a *APIPassthroughSession) AccessTypeTag() model.AccessTypeTag
func (*APIPassthroughSession) ChannelID ¶
func (a *APIPassthroughSession) ChannelID() string
func (*APIPassthroughSession) ChannelSessionID ¶
func (a *APIPassthroughSession) ChannelSessionID() string
func (*APIPassthroughSession) Context ¶
func (a *APIPassthroughSession) Context() *model.AucBotContext
func (*APIPassthroughSession) MessageID ¶
func (a *APIPassthroughSession) MessageID() string
func (*APIPassthroughSession) SetToken ¶
func (a *APIPassthroughSession) SetToken(token string)
func (*APIPassthroughSession) Token ¶
func (a *APIPassthroughSession) Token() string
func (*APIPassthroughSession) UserSessionID ¶
func (a *APIPassthroughSession) UserSessionID() string
func (*APIPassthroughSession) Username ¶
func (a *APIPassthroughSession) Username() string
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler is a discord rendering layer for AucBotHandler
func NewHandler ¶
func NewHandler(abh transport.AucBotService) *Handler
NewHandler creates a new discord handler for the given Aucbot service
func (*Handler) BuyersGuideExtendedMessageHandler ¶
func (*Handler) ChoiceMessageHandler ¶
func (*Handler) ClearMessageHandler ¶
func (*Handler) ComponentMessageHandler ¶
func (*Handler) GroupMessageHandler ¶
func (*Handler) HelpMessageHandler ¶
func (*Handler) PriceMessageHandler ¶
func (*Handler) PriceRequestHandler ¶
func (dh *Handler) PriceRequestHandler(ctx *model.AucBotContext, s *discordgo.Session, alerts model.AlertByChannelID) map[string][]string
PriceRequestHandler sends messages from a price alert push. It returns a map of channelID -> messageIDs of sent messages
func (*Handler) RealmMessageHandler ¶
func (*Handler) RegisterCommands ¶
func (dh *Handler) RegisterCommands() *MessageHandler
RegisterCommands is where all commands and their corresponding strings are registered TODO this is deprecated and should be removed
func (*Handler) RegisterSlashCommands ¶
func (*Handler) ShoppingListAddHandler ¶
func (*Handler) ShoppingListHandler ¶
func (*Handler) ShoppingListOptionsChoiceHandler ¶
func (*Handler) ShoppingListOptionsHandler ¶
func (*Handler) ShoppingListRemoveHandler ¶
type LegacyHandlerEntry ¶
type LegacyHandlerEntry struct { Name string CommandList []*regexp.Regexp Handler func(string, *model.AucBotContext, *discordgo.Session, *discordgo.MessageCreate) }
LegacyHandlerEntry is a list of commands that should trigger the Handler These are full commands, like "!realm"
type MessageHandler ¶
type MessageHandler struct { InteractionHandlers map[string]interactionHandlerEntry // ComponentHandlers maps customID to handler ComponentHandlers map[string]interactionHandlerEntry LegacyHandlers []LegacyHandlerEntry Patch model.RecipeVersion RequestTimeoutSec int }
MessageHandler stores a collection of bot response functions, and a function to be registered to discordgo
func (*MessageHandler) InteractionMessageBroker ¶
func (mh *MessageHandler) InteractionMessageBroker(discordApplicationID string) func(session *discordgo.Session, interaction *discordgo.InteractionCreate)
func (*MessageHandler) LegacyMessageBroker ¶
func (mh *MessageHandler) LegacyMessageBroker(s *discordgo.Session, m *discordgo.MessageCreate)
LegacyMessageBroker is registered to discordgo and delegates to message handlers it will call the first function it finds that matches the incoming command TODO this is deprecated and should be removed once slash commands are fully phased in
type UserSession ¶
type UserSession struct {
// contains filtered or unexported fields
}
UserSession is a discord "session" that implements Session
func (*UserSession) AccessTypeTag ¶
func (d *UserSession) AccessTypeTag() model.AccessTypeTag
func (*UserSession) ChannelID ¶
func (d *UserSession) ChannelID() string
ChannelID returns the discord channelID
func (*UserSession) ChannelSessionID ¶
func (d *UserSession) ChannelSessionID() string
ChannelSessionID returns a key depending on whether the session is a DM or channel message
func (*UserSession) Context ¶
func (d *UserSession) Context() *model.AucBotContext
Context returns the ctx with unique ID
func (*UserSession) MessageID ¶
func (d *UserSession) MessageID() string
func (*UserSession) SetToken ¶
func (d *UserSession) SetToken(token string)
func (*UserSession) Token ¶
func (d *UserSession) Token() string
func (*UserSession) UserSessionID ¶
func (d *UserSession) UserSessionID() string
UserSessionID returns the channel session ID + the authorID
func (*UserSession) Username ¶
func (d *UserSession) Username() string
Username returns the discord username of the user requesting a response