Documentation ¶
Overview ¶
Package botmaid is a package for managing bots.
Index ¶
- func In(a interface{}, s ...interface{}) bool
- func ListToString(list []string, format string, separator string, andWord string) string
- type API
- type APICqhttp
- type APITelegramBot
- type Bot
- type BotMaid
- type Chat
- type Command
- type CommandSlice
- type ErrorChannel
- type GetUpdatesConfig
- type HelpMenu
- type Message
- type Timer
- type Update
- type UpdateChannel
- type User
- type Word
- type WordSlice
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type API ¶
type API interface { GetUpdates(GetUpdatesConfig) (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) GetUpdates ¶ added in v1.9.0
func (a *APICqhttp) GetUpdates(pc GetUpdatesConfig) (UpdateChannel, ErrorChannel)
GetUpdates gets 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) GetUpdates ¶ added in v1.9.0
func (a *APITelegramBot) GetUpdates(pc GetUpdatesConfig) (UpdateChannel, ErrorChannel)
GetUpdates gets updates and errors into the channels with a given config.
type Bot ¶
Bot includes some information of a bot.
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, *Bot) 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 GetUpdatesConfig ¶ added in v1.4.0
GetUpdatesConfig is a struct for getting updates.
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.