обработка обновлений последовательно для каждого юзера благодаря mutex

This commit is contained in:
Artem Tsyrulnikov
2026-01-04 19:35:41 +03:00
parent 5251ec3015
commit 592ade7dce
9 changed files with 235 additions and 190 deletions

View File

@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"strings"
"sync"
"example.com/m/adapter/backend"
"github.com/NicoNex/echotron/v3"
@@ -37,6 +38,7 @@ type Exec struct {
type Bot struct {
echotron.API
mu sync.Mutex
ChatID int64
exec *Exec
CurrentState State
@@ -205,6 +207,9 @@ func (b *Bot) SendMessageWithURLButton(text, buttonText, url string) {
}
func (b *Bot) Update(u *echotron.Update) {
b.mu.Lock()
defer b.mu.Unlock()
log.Info().
Int64("chat_id", b.ChatID).
Str("current_state", fmt.Sprintf("%T", b.CurrentState)).