bot: add global-scope Use function

pull/341/head
Demian 4 years ago
parent bc180b4a47
commit b2ce91acc7

@ -55,6 +55,7 @@ func NewBot(pref Settings) (*Bot, error) {
bot.Me = user
}
bot.group = bot.Group()
return bot, nil
}
@ -67,6 +68,7 @@ type Bot struct {
Poller Poller
OnError func(error, Context)
group *Group
handlers map[string]HandlerFunc
synchronous bool
verbose bool
@ -139,6 +141,11 @@ type Command struct {
Description string `json:"description"`
}
// Use adds middleware to the global bot chain.
func (b *Bot) Use(middleware ...MiddlewareFunc) {
b.group.Use(middleware...)
}
// Group returns a new group.
func (b *Bot) Group() *Group {
return &Group{b: b}

Loading…
Cancel
Save