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 committed 2026-07-03 09:36:53 +02:00 Unverified
1 parent 220dcb1579
commit 1f04912b6f
15 files changed
+84 -13

No files matched your search

+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()
}
+5 -1
View File
@@ -2007,7 +2007,11 @@
"startDesc": "عرض القائمة الرئيسية",
"helpDesc": "مساعدة البوت",
"statusDesc": "التحقق من حالة البوت",
"idDesc": "عرض معرف Telegram الخاص بك"
"idDesc": "عرض معرف Telegram الخاص بك",
"usageDesc": "عرض استهلاك العميل: /usage البريد",
"inboundDesc": "البحث في الواردات: /inbound الاسم (مشرف)",
"restartDesc": "إعادة تشغيل نواة Xray (مشرف)",
"clearallDesc": "تصفير استهلاك جميع العملاء (مشرف)"
},
"messages": {
"cpuThreshold": "حمل المعالج {{ .Percent }}% عدى الحد المسموح ({{ .Threshold }}%)",
Loaded 3 of 15 files, more files were not shown because too many files have changed in this diff. Show more