package nechotron import ( "context" "sync" "time" echo "github.com/NicoNex/echotron/v3" "github.com/google/uuid" ) type bot struct { chatID int64 me *echo.User echo.API data StateData lock sync.Mutex state Runnable } func (b *bot) Update(u *echo.Update) { ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() upd := &Update{ U: U(*u), Bot: b, UpdateID: uuid.New(), Ctx: ctx, } b.lock.Lock() defer b.lock.Unlock() err := b.state.Call(upd) if err != nil { upd.LogError("", err, true) } }