bot

package
v0.0.0-...-bda44bd Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ListenerCtxKey ctxKey = "listener"
View Source
var MessageCtxKey ctxKey = "message"

Functions

func MentionMatcher

func MentionMatcher(userID string) *regexp.Regexp

func NoOpHandlerFunc

func NoOpHandlerFunc(context.Context, discordclient.Message)

NoOpHandlerFunc does no operations againdst a message. This can be an equivalent to nil.

func PrefixMatcher

func PrefixMatcher(prefix string) *regexp.Regexp

func ReplyToMessage

func ReplyToMessage(listenerCtx context.Context, message interface{}) error

ReplyToMessage will use the message context to reply to a message. Message may be one of two types: - *discordgo.MessageSend - string

func ScaffoldBot

func ScaffoldBot(config BotScaffolding) error

func Tokenize

func Tokenize(message discordclient.Message) []string

Types

type BotScaffolding

type BotScaffolding struct {
	BotToken       string
	BotClientID    string
	RootUsers      []string
	AllowBots      bool
	AllowEdits     bool
	AllowDeletes   bool
	GatewayIntents discordgo.Intent
	Handler        HandlerFunc
}

type Command

type Command struct {
	CommandName string
	Handler     HandlerFunc
}

type CommandGroup

type CommandGroup []Command

func (CommandGroup) RegisterCommands

func (cg CommandGroup) RegisterCommands(commandTrie *trie.PathTrie, prefix string)

type CommandMux

type CommandMux struct {
	// contains filtered or unexported fields
}

func NewCommandMux

func NewCommandMux(matcher *regexp.Regexp) CommandMux

func (CommandMux) Handler

func (c CommandMux) Handler(ctx context.Context, message discordclient.Message)

func (CommandMux) RegisterCommandGroup

func (c CommandMux) RegisterCommandGroup(prefix string, group CommandGroup)

type HandlerFunc

type HandlerFunc func(context.Context, discordclient.Message)

type Listener

type Listener struct {
	DiscordClient *discordclient.DiscordClient
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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