This commit is contained in:
Artem Tsyrulnikov
2026-01-09 13:11:32 +03:00
parent 9fbb6fdbbf
commit a0b12dbcca
10 changed files with 257 additions and 119 deletions

View File

@@ -12,6 +12,10 @@ import (
"github.com/rs/zerolog/log"
)
var emptyKeyboard = echotron.InlineKeyboardMarkup{
InlineKeyboard: [][]echotron.InlineKeyboardButton{},
}
type Exec struct {
handled bool
transitioned bool
@@ -77,23 +81,17 @@ func (b *Bot) GetOrCreateJWT(u *echotron.Update) error {
}
}
// Запрашиваем JWT с актуальными данными пользователя (или создаем нового если не существует)
jwt, err := b.Backend.GetJWTByTelegramUser(
context.Background(),
b.ChatID,
username,
firstName,
lastName,
)
jwt, err := b.Backend.GetJWTByTelegramUser(context.Background(), b.ChatID, username, firstName, lastName)
if err != nil {
return err
}
// Сохраняем в сессию
b.Session.JWT = jwt
if username != nil {
b.Session.UserName = *username
if firstName != nil {
b.Session.FirstName = *firstName
}
return nil
}
@@ -276,7 +274,11 @@ func (b *Bot) Update(u *echotron.Update) {
return
}
_ = b.GetOrCreateJWT(u)
err := b.GetOrCreateJWT(u)
if err != nil || b.Session.JWT == "" {
b.SendNew("❌ Ошибка авторизации. Попробуйте /start", emptyKeyboard)
return
}
exec := &Exec{}
b.exec = exec
@@ -336,10 +338,6 @@ func (b *Bot) Update(u *echotron.Update) {
}
func (b *Bot) cleanupKeyboard(messageID int) {
emptyKeyboard := echotron.InlineKeyboardMarkup{
InlineKeyboard: [][]echotron.InlineKeyboardButton{},
}
_, err := b.EditMessageReplyMarkup(
echotron.NewMessageID(b.ChatID, messageID),
&echotron.MessageReplyMarkupOptions{ReplyMarkup: emptyKeyboard},