feat(tgbot): register usage, inbound, restart and clearall in the bot command menu

The Telegram command menu listed only start/help/status/id although usage, inbound and restart were already handled, and resetting all traffic was reachable only through inline keyboards. Register all handled commands with localized descriptions and add an admin-gated /clearall command that reuses the existing reset-all confirmation keyboard, so nothing destructive runs without an explicit confirm.

Closes #5307
This commit is contained in:
MHSanaei
2026-07-03 09:36:53 +02:00
parent 220dcb1579
commit 1f04912b6f
15 changed files with 84 additions and 13 deletions
+4
View File
@@ -345,6 +345,10 @@ func (t *Tgbot) trySetBotCommands(bot *telego.Bot) {
{Command: "help", Description: t.I18nBot("tgbot.commands.helpDesc")},
{Command: "status", Description: t.I18nBot("tgbot.commands.statusDesc")},
{Command: "id", Description: t.I18nBot("tgbot.commands.idDesc")},
{Command: "usage", Description: t.I18nBot("tgbot.commands.usageDesc")},
{Command: "inbound", Description: t.I18nBot("tgbot.commands.inboundDesc")},
{Command: "restart", Description: t.I18nBot("tgbot.commands.restartDesc")},
{Command: "clearall", Description: t.I18nBot("tgbot.commands.clearallDesc")},
},
})
if err != nil {
@@ -237,6 +237,21 @@ func (t *Tgbot) answerCommand(message *telego.Message, chatId int64, isAdmin boo
} else {
handleUnknownCommand()
}
case "clearall":
onlyMessage = true
if isAdmin {
inlineKeyboard := tu.InlineKeyboard(
tu.InlineKeyboardRow(
tu.InlineKeyboardButton(t.I18nBot("tgbot.buttons.cancelReset")).WithCallbackData(t.encodeQuery("reset_all_traffics_cancel")),
),
tu.InlineKeyboardRow(
tu.InlineKeyboardButton(t.I18nBot("tgbot.buttons.confirmResetTraffic")).WithCallbackData(t.encodeQuery("reset_all_traffics_c")),
),
)
t.SendMsgToTgbot(chatId, t.I18nBot("tgbot.messages.AreYouSure"), inlineKeyboard)
} else {
handleUnknownCommand()
}
default:
handleUnknownCommand()
}