mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-09-02 08:27:14 +00:00
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:
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user