Changed State

This commit is contained in:
2023-01-20 00:27:29 +03:00
parent 5842815c95
commit 1a8decf4d4
3 changed files with 43 additions and 5 deletions

7
bot.go
View File

@ -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)
}