fix(telegram): reply to /start only in private chats
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 10s
CI / integration (pull_request) Successful in 18s
CI / ui (pull_request) Has been skipped
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m7s

The main bot is now an admin in the moderated discussion group and receives its
messages (allowed_updates includes message). Its default handler replied to
every message with a Mini App launch button — an inline web_app button, which
Telegram permits only in private chats — so replying in the group failed with
BUTTON_TYPE_INVALID (silently: the send fails, no user-facing error). Reply only
in a private chat; in the group the bot only manages permissions. The promo bot
gets the same guard.
This commit is contained in:
Ilia Denisov
2026-06-21 17:28:01 +02:00
parent fa8abf22db
commit c494da553a
4 changed files with 53 additions and 1 deletions
+7
View File
@@ -191,6 +191,13 @@ func (t *Bot) handleStart(ctx context.Context, api *tgbot.Bot, update *models.Up
if update.Message == nil {
return
}
// Reply only in a private chat: the Mini App launch button is an inline web_app
// button, which Telegram permits only in private chats — replying to a group message
// (the bot is an admin in the moderated chat and now receives its messages) fails with
// BUTTON_TYPE_INVALID. In the group the bot only manages permissions, it never chats.
if update.Message.Chat.Type != models.ChatTypePrivate {
return
}
startParam := startPayload(update.Message.Text)
if _, err := api.SendMessage(ctx, &tgbot.SendMessageParams{
ChatID: update.Message.Chat.ID,