Documentation
¶
Overview ¶
Package botmaid is a package for managing bots.
Index ¶
- func At(u *User) []string
- func In(a interface{}, s ...interface{}) bool
- func IsCommand(u *Update, c ...interface{}) bool
- func ListToString(list []string, format string, separator string, andWord string) string
- type API
- type APICqhttp
- type APITelegramBot
- type Bot
- type BotMaid
- func (bm *BotMaid) AddCommand(c *Command)
- func (bm *BotMaid) AddTimer(t Timer)
- func (bm *BotMaid) BeAt(u *Update) bool
- func (bm *BotMaid) Broadcast(key string, m *Message)
- func (bm *BotMaid) IsBanned(u *User) bool
- func (bm *BotMaid) IsMaster(u *User) bool
- func (bm *BotMaid) Start() error
- func (bm *BotMaid) SwitchBroadcast(key string, c *Chat, b *Bot)
- type Chat
- type Command
- type CommandSlice
- type ErrorChannel
- type HelpMenu
- type Message
- type PullConfig
- type Timer
- type Update
- type UpdateChannel
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type API ¶
type API interface { Pull(*PullConfig) (UpdateChannel, ErrorChannel) Push(*Update) (*Update, error) }
API is an interface including some common behaviors for APIs.
GetUpdates always gets updates and errors into the channels with a given config.
Push always pushes an update and returns it back if existing.
Delete always deletes a specific update.
type APICqhttp ¶
APICqhttp is a struct stores some basic information of the CQHTTP. Please search in CQHTTP document for details.
func (*APICqhttp) Pull ¶
func (a *APICqhttp) Pull(pc *PullConfig) (UpdateChannel, ErrorChannel)
Pull pulls updates and errors into the channels with a given config.
type APITelegramBot ¶
APITelegramBot is a struct stores some basic information of the Telegram Bot API. Please search in official API document for details.
func (*APITelegramBot) API ¶
func (a *APITelegramBot) API(end string, m map[string]interface{}) (interface{}, error)
API returns the body of an HTTP response to the Telegram Bot API.
func (*APITelegramBot) Pull ¶
func (a *APITelegramBot) Pull(pc *PullConfig) (UpdateChannel, ErrorChannel)
Pull pulls updates and errors into the channels with a given config.
type BotMaid ¶
type BotMaid struct { Bots map[string]*Bot Conf *botMaidConfig Redis *redis.Client Commands CommandSlice Timers []Timer HelpMenus []HelpMenu 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(*Update) bool Priority int Menu, MenuText, Help string Names []string ArgsMinLen, ArgsMaxLen int Master 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 PullConfig ¶
PullConfig is a struct for pulling.
Limit decides the number of updates pulled once. Timeout decides the timeout of long polling. RetryWaitingTime decides decides the time waiting after pulling an error.