fix(tgbot): answer the callbacks the bot cannot route (#6493)

Telegram keeps a tapped button in its loading state until the callback is
answered, and three paths dropped the tap without answering: a payload that
matched no case in the email-scoped switch, one that matched nothing in the
switch that follows it, and a button whose hash had aged out of the 20-minute
storage, which replied with a chat message only.

All three answer now. The email-scoped switch is reached only by an admin's
payload carrying arguments, and today an unknown action there falls out of the
switch into a return that tells the operator nothing.

The expired-hash path keeps the chat message as well, because
sendCallbackAnswerTgBot is a single unretried call while SendMsgToTgbot retries
connection errors, and after a panel restart that notice is the only
explanation the admin gets.
This commit is contained in:
BlindMaster24
2026-09-13 12:47:22 +03:00
committed by GitHub
parent 02c6c3a9c6
commit aaa5e61cad
2 changed files with 92 additions and 0 deletions
@@ -316,6 +316,9 @@ func (t *Tgbot) answerCallback(callbackQuery *telego.CallbackQuery, isAdmin bool
// get query from hash storage
decodedQuery, err := t.decodeQuery(callbackQuery.Data)
if err != nil {
// A button older than the 20-minute hash window is the common case
// here; the answer clears it, the message outlives a failed send.
t.sendCallbackAnswerTgBot(callbackQuery.ID, t.I18nBot("tgbot.noQuery"))
t.SendMsgToTgbot(chatId, t.I18nBot("tgbot.noQuery"))
return
}
@@ -884,6 +887,10 @@ func (t *Tgbot) answerCallback(callbackQuery *telego.CallbackQuery, isAdmin bool
return
}
t.editMessageCallbackTgBot(callbackQuery.Message.GetChat().ID, callbackQuery.Message.GetMessageID(), picker)
default:
// An unknown action with arguments is still a tap, and an
// unanswered tap spins until Telegram times it out.
t.sendCallbackAnswerTgBot(callbackQuery.ID, t.I18nBot("tgbot.answers.errorOperation"))
}
return
} else {
@@ -1327,6 +1334,10 @@ func (t *Tgbot) answerCallback(callbackQuery *telego.CallbackQuery, isAdmin bool
case "client_qr_links":
t.sendClientQRLinks(chatId, email)
}
// Nothing matched: an unknown button still has to be answered, or it
// keeps spinning until Telegram times the callback out.
t.sendCallbackAnswerTgBot(callbackQuery.ID, t.I18nBot("tgbot.answers.errorOperation"))
}
}