Changed State
This commit is contained in:
7
bot.go
7
bot.go
@ -2,6 +2,7 @@ package nechotron
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
echo "github.com/NicoNex/echotron/v3"
|
||||
@ -12,6 +13,8 @@ type bot struct {
|
||||
chatID int64
|
||||
me *echo.User
|
||||
echo.API
|
||||
data StateData
|
||||
lock sync.Mutex
|
||||
state *State
|
||||
}
|
||||
|
||||
@ -25,7 +28,9 @@ func (b *bot) Update(u *echo.Update) {
|
||||
Ctx: ctx,
|
||||
}
|
||||
|
||||
newState, err := b.state.Fn(upd)
|
||||
b.lock.Lock()
|
||||
defer b.lock.Unlock()
|
||||
newState, err := b.state.Call(upd)
|
||||
if err != nil {
|
||||
upd.LogError("", err, true)
|
||||
}
|
||||
|
Reference in New Issue
Block a user