discord

package
v0.0.0-...-7360598 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CmdBGHelp = "bghelp"
	// TODO autocomplete this from "p"
	CmdPrice        = "price"
	CmdBuyersGuide  = "buyers-guide"
	CmdClear        = "clear"
	CmdRealm        = "realm"
	CmdShoppingList = "shopping-list"
)
View Source
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"
)
View Source
const AddBotLink = "https://wowbuyersguide.com/"
View Source
const EphemeralFlag = 1 << 6

https://discord.com/developers/docs/resources/channel#message-object-message-flags

View Source
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

View Source
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

func ParsePriceParamString(queryString string) (*int, error)

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

func ParseRankQueryString(queryString string) (string, int, error)

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.

func StartBot

func StartBot(bot *discordgo.Session) error

StartBot starts the discord bot

func StopBot

func StopBot(bot *discordgo.Session) error

StopBot stops the discord bot

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 (*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 (dh *Handler) BuyersGuideExtendedMessageHandler(queryString string, opts handlerExtraArgs, ctx *model.AucBotContext, s *discordgo.Session, m discordMessageCreateAdapter)

func (*Handler) ChoiceMessageHandler

func (dh *Handler) ChoiceMessageHandler(_ string, opts handlerExtraArgs, ctx *model.AucBotContext, s *discordgo.Session, m discordMessageCreateAdapter)

func (*Handler) ClearMessageHandler

func (dh *Handler) ClearMessageHandler(queryString string, _ handlerExtraArgs, ctx *model.AucBotContext, s *discordgo.Session, m discordMessageCreateAdapter)

func (*Handler) ComponentMessageHandler

func (dh *Handler) ComponentMessageHandler(queryString string, _ handlerExtraArgs, ctx *model.AucBotContext, s *discordgo.Session, m discordMessageCreateAdapter)

func (*Handler) GroupMessageHandler

func (dh *Handler) GroupMessageHandler(queryString string, _ handlerExtraArgs, ctx *model.AucBotContext, s *discordgo.Session, m discordMessageCreateAdapter)

func (*Handler) HelpMessageHandler

func (dh *Handler) HelpMessageHandler(queryString string, _ handlerExtraArgs, ctx *model.AucBotContext, s *discordgo.Session, m discordMessageCreateAdapter)

func (*Handler) PriceMessageHandler

func (dh *Handler) PriceMessageHandler(queryString string, opts handlerExtraArgs, ctx *model.AucBotContext, s *discordgo.Session, m discordMessageCreateAdapter)

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 (dh *Handler) RealmMessageHandler(queryString string, opts handlerExtraArgs, ctx *model.AucBotContext, s *discordgo.Session, m discordMessageCreateAdapter)

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 (dh *Handler) RegisterSlashCommands(sess *discordgo.Session, discordApplicationID string) (*MessageHandler, error)

func (*Handler) ShoppingListAddHandler

func (dh *Handler) ShoppingListAddHandler(_ string, opts handlerExtraArgs, ctx *model.AucBotContext, s *discordgo.Session, m discordMessageCreateAdapter)

func (*Handler) ShoppingListHandler

func (dh *Handler) ShoppingListHandler(queryString string, _ handlerExtraArgs, ctx *model.AucBotContext, s *discordgo.Session, m discordMessageCreateAdapter)

func (*Handler) ShoppingListOptionsChoiceHandler

func (dh *Handler) ShoppingListOptionsChoiceHandler(_ string, opts handlerExtraArgs, ctx *model.AucBotContext, s *discordgo.Session, m discordMessageCreateAdapter)

func (*Handler) ShoppingListOptionsHandler

func (dh *Handler) ShoppingListOptionsHandler(_ string, _ handlerExtraArgs, ctx *model.AucBotContext, s *discordgo.Session, m discordMessageCreateAdapter)

func (*Handler) ShoppingListRemoveHandler

func (dh *Handler) ShoppingListRemoveHandler(_ string, opts handlerExtraArgs, ctx *model.AucBotContext, s *discordgo.Session, m discordMessageCreateAdapter)

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL