Middleware
This commit is contained in:
24
bot.go
24
bot.go
@ -10,12 +10,21 @@ import (
|
||||
)
|
||||
|
||||
type bot struct {
|
||||
chatID int64
|
||||
me *echo.User
|
||||
echo.API
|
||||
data StateData
|
||||
lock sync.Mutex
|
||||
state Runnable
|
||||
chatID int64
|
||||
me *echo.User
|
||||
data StateData
|
||||
lock sync.Mutex
|
||||
state Runnable
|
||||
handler UpdateHandler
|
||||
}
|
||||
|
||||
func DefaultHandler(u *Update) error {
|
||||
err := u.Bot.state.Call(u)
|
||||
if err != nil {
|
||||
u.LogError("", err, true)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (b *bot) Update(u *echo.Update) {
|
||||
@ -30,8 +39,5 @@ func (b *bot) Update(u *echo.Update) {
|
||||
|
||||
b.lock.Lock()
|
||||
defer b.lock.Unlock()
|
||||
err := b.state.Call(upd)
|
||||
if err != nil {
|
||||
upd.LogError("", err, true)
|
||||
}
|
||||
b.handler(upd)
|
||||
}
|
||||
|
Reference in New Issue
Block a user