Documentation ¶
Overview ¶
Package botmaid is a package for managing bots.
Index ¶
- func Contains(s interface{}, a interface{}) bool
- func ListToString(list []string, format string, separator string, and string) string
- type API
- type APICqhttp
- func (a *APICqhttp) API(end string, m map[string]interface{}) (interface{}, error)
- func (a *APICqhttp) ParseUserID(u *Update, s string) (int64, error)
- func (a *APICqhttp) Platform() string
- func (a *APICqhttp) Pull(pc *PullConfig) (UpdateChannel, ErrorChannel)
- func (a *APICqhttp) Push(update *Update) (*Update, error)
- type APITelegramBot
- func (a *APITelegramBot) API(end string, m map[string]interface{}) (interface{}, error)
- func (a *APITelegramBot) ParseUserID(u *Update, s string) (int64, error)
- func (a *APITelegramBot) Platform() string
- func (a *APITelegramBot) Pull(pc *PullConfig) (UpdateChannel, ErrorChannel)
- func (a *APITelegramBot) Push(update *Update) (*Update, error)
- type Bot
- type BotMaid
- func (bm *BotMaid) AddCommand(c *Command)
- func (bm *BotMaid) AddTimer(t *Timer)
- func (bm *BotMaid) At(u *User) string
- func (bm *BotMaid) BeAt(u *Update) bool
- func (bm *BotMaid) Broadcast(key string, m *Message)
- func (bm *BotMaid) Delete(u *Update) (*Update, error)
- func (bm *BotMaid) HelpCommandDo(u *Update, f *pflag.FlagSet) bool
- func (bm *BotMaid) HelpRespCommandDo(u *Update, f *pflag.FlagSet) bool
- func (bm *BotMaid) IsBanned(c *Chat) bool
- func (bm *BotMaid) IsMaster(u *User) bool
- func (bm *BotMaid) MasterCommandDo(u *Update, f *pflag.FlagSet) bool
- func (bm *BotMaid) Reply(u *Update, s string) (*Update, error)
- func (bm *BotMaid) ReplyType(u *Update, s, t string) (*Update, error)
- func (bm *BotMaid) Start() error
- func (bm *BotMaid) SubscribeCommandDo(u *Update, f *pflag.FlagSet) bool
- func (bm *BotMaid) VersetCommandDo(u *Update, f *pflag.FlagSet) bool
- func (bm *BotMaid) VersetCommandHelpSetFlag(f *pflag.FlagSet)
- func (bm *BotMaid) VersionCommandDo(u *Update, f *pflag.FlagSet) bool
- func (bm *BotMaid) VersionCommandHelpSetFlag(f *pflag.FlagSet)
- type Chat
- type Command
- type CommandSlice
- type ErrorChannel
- type Help
- 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) Platform() string ParseUserID(u *Update, s string) (int64, error) // contains filtered or unexported methods }
API is an interface including some common behaviors for APIs.
type APICqhttp ¶
type APICqhttp struct { AccessToken string Secret string APIEndpoint string WebsocketEndpoint string }
APICqhttp is a struct stores some basic information of the CQHTTP. Please search in CQHTTP document for details.
func (*APICqhttp) ParseUserID ¶
ParseUserID parses the ID of the User in the At string.
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) ParseUserID ¶
func (a *APITelegramBot) ParseUserID(u *Update, s string) (int64, error)
ParseUserID parses the ID of the User in the At string.
func (*APITelegramBot) Platform ¶
func (a *APITelegramBot) Platform() string
Platform returns a string showing the platform of the bot.
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 Helps []*Help Words map[string]string SubEntries []string // contains filtered or unexported fields }
BotMaid includes a slice of Bot and some methods to use them.
func (*BotMaid) AddCommand ¶
AddCommand adds a command into the []Command.
func (*BotMaid) HelpRespCommandDo ¶
func (*BotMaid) MasterCommandDo ¶
func (*BotMaid) SubscribeCommandDo ¶
func (*BotMaid) VersetCommandDo ¶
func (*BotMaid) VersetCommandHelpSetFlag ¶
func (*BotMaid) VersionCommandDo ¶
func (*BotMaid) VersionCommandHelpSetFlag ¶
type Command ¶
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 Message ¶
type Message struct { ID int64 Type string Content string Args []string Command string Flags map[string]*pflag.FlagSet Update *Update }
Message is a struct for a message of an update.
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.