Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bot ¶
type Bot struct {
// contains filtered or unexported fields
}
Bot contains the connection information and commands used to communicate with Discord.
func New ¶
func New(cfg *config.Config, s DiscordSession) (*Bot, error)
New returns a new instance of a Bot and establishes the connection to discord.
func (*Bot) AddCommand ¶
func (b *Bot) AddCommand(command SlateCommand)
AddCommand allows a new command to be registered with the bot
func (*Bot) Commands ¶
func (b *Bot) Commands() []SlateCommand
Commands returns the list of commands
type DiscordFactory ¶
type DiscordFactory func(cfg *config.Config) (DiscordSession, error)
DiscordFactory describes a factory function used to create a discord session.
cfg: The slate configuration object.
type DiscordSession ¶
type DiscordSession interface { // AddHandler adds a function handler to Discord. AddHandler(interface{}) func() // ChannelMessageSend allows a message to be sent to a channel on Discord // todo: Remove the hard reference to discordgo ChannelMessageSend(string, string) (*discordgo.Message, error) // Open establishes the websocket connection to Discord. Open() error // Close closes the websocket connection to Discord. Close() error }
DiscordSession describes the functions required to work with discord
func MockDiscordFactory ¶
func MockDiscordFactory(cfg *config.Config) (DiscordSession, error)
MockDiscordFactory is a DiscordFactory mock function for the MockDiscordSession
type MockCommand ¶
MockCommand is a mock command handler
func (*MockCommand) SetFlags ¶
func (c *MockCommand) SetFlags(f *flag.FlagSet)
SetFlags sets the flags for the commands
func (*MockCommand) Synopsis ¶
func (*MockCommand) Synopsis() string
Synopsis returns the synospis of the command
func (*MockCommand) Usage ¶
func (*MockCommand) Usage() string
Usage returns the usage of the command
type MockDiscordSession ¶
MockDiscordSession mocks a discord session object
func (*MockDiscordSession) AddHandler ¶
func (m *MockDiscordSession) AddHandler(h interface{}) func()
AddHandler is a stub
func (*MockDiscordSession) ChannelMessageSend ¶
func (m *MockDiscordSession) ChannelMessageSend(ch string, message string) (*discordgo.Message, error)
ChannelMessageSend is a stub
type SlateCommand ¶
type SlateCommand interface { // Name describes the string used to route input to this command Name() string // Synopsis describes what the command will do Synopsis() string // Usage describes the helpfile and usage for this command Usage() string // SetFlags sets up any flags the command requires SetFlags(set *flag.FlagSet) // Execute is the handler which will be run when this command is called Execute(context.Context, *flag.FlagSet) string }
SlateCommand describes a command to be registered with slate.