Documentation
¶
Overview ¶
Package botmaid is a package includes more useful public functions for bots.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RandomWordWithWeight ¶ added in v1.0.1
RandomWordWithWeight returns a random string from the Word slice according to the weight.
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.
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 Help ¶
type Help struct {
HelpMenu string
SelfIntro, UndefCommand []string
HelpSubMenu, HelpAlias map[string]string
}
Help stores a full help menus that would be used in '/help' command.