Documentation
¶
Overview ¶
Package botmaid is a package includes more useful public functions for bots.
Index ¶
- func GetArgument(c string) []string
- func SplitCommand(c string) []string
- type Bot
- type BotMaid
- func (bm *BotMaid) AddCommand(c Command)
- func (bm *BotMaid) AddTimer(t Timer)
- func (bm *BotMaid) Broadcast(tableName string, m *api.Message)
- func (bm *BotMaid) InitBroadcastTable(tableName string) error
- func (bm *BotMaid) Start() error
- func (bm *BotMaid) SwitchBroadcast(tableName string, place *api.Place, b *Bot)
- type Command
- type CommandSlice
- type DBBroadcastPlace
- type Timer
- type Word
- type WordSlice
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetArgument ¶ added in v1.3.0
GetArgument returns a slice with a command and an argument.
func SplitCommand ¶ added in v1.0.1
SplitCommand splits a string into a slice of string.
Types ¶
type Bot ¶
Bot includes some information of a bot.
func (*Bot) IsTestPlace ¶ added in v1.0.1
IsTestPlace checks if a place is test place of the bot.
func (*Bot) UserNameFromAt ¶ added in v1.3.0
UserNameFromAt returns the UserName of the user in the mention query.
type BotMaid ¶
type BotMaid struct {
Bots map[string]*Bot
Conf *toml.Tree
DB *sql.DB
Commands []Command
Timers []Timer
HelpMenus map[string]string
Words map[string][]string
RespTime time.Time
}
BotMaid includes a slice of Bot and some methods to use them.
func (*BotMaid) AddCommand ¶
AddCommand adds a command into the []Command.
func (*BotMaid) InitBroadcastTable ¶ added in v1.3.0
InitBroadcastTable creates a table with the standard structure of a broadcast.
type Command ¶
type Command struct {
Do func(*api.Event, *Bot) bool
Priority int
Menu, Help string
Names []string
Master, Test bool
}
Command is a func with priority value so that we can sort some Commands to make them in a specific order.
type CommandSlice ¶
type CommandSlice []Command
CommandSlice is a slice of Command that could be sort.
func (CommandSlice) Less ¶
func (cs CommandSlice) Less(i, j int) bool
Less returns true if CommandSlice[i] is less then CommandSlice[j].
func (CommandSlice) Swap ¶
func (cs CommandSlice) Swap(i, j int)
Swap swaps CommandSlice[i] and CommandSlice[j].
type DBBroadcastPlace ¶ added in v1.3.0
DBBroadcastPlace is a struct saved some information of the place to broadcast.