mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-07-10 06:36:06 +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()
|
||||
}
|
||||
|
||||
@@ -2007,7 +2007,11 @@
|
||||
"startDesc": "عرض القائمة الرئيسية",
|
||||
"helpDesc": "مساعدة البوت",
|
||||
"statusDesc": "التحقق من حالة البوت",
|
||||
"idDesc": "عرض معرف Telegram الخاص بك"
|
||||
"idDesc": "عرض معرف Telegram الخاص بك",
|
||||
"usageDesc": "عرض استهلاك العميل: /usage البريد",
|
||||
"inboundDesc": "البحث في الواردات: /inbound الاسم (مشرف)",
|
||||
"restartDesc": "إعادة تشغيل نواة Xray (مشرف)",
|
||||
"clearallDesc": "تصفير استهلاك جميع العملاء (مشرف)"
|
||||
},
|
||||
"messages": {
|
||||
"cpuThreshold": "حمل المعالج {{ .Percent }}% عدى الحد المسموح ({{ .Threshold }}%)",
|
||||
|
||||
@@ -2007,7 +2007,11 @@
|
||||
"startDesc": "Show the main menu",
|
||||
"helpDesc": "Bot help",
|
||||
"statusDesc": "Check bot status",
|
||||
"idDesc": "Show your Telegram ID"
|
||||
"idDesc": "Show your Telegram ID",
|
||||
"usageDesc": "Show client usage: /usage email",
|
||||
"inboundDesc": "Search inbounds: /inbound remark (admin)",
|
||||
"restartDesc": "Restart Xray core (admin)",
|
||||
"clearallDesc": "Reset all clients' traffic (admin)"
|
||||
},
|
||||
"messages": {
|
||||
"cpuThreshold": "CPU Load {{ .Percent }}% exceeds the threshold of {{ .Threshold }}%",
|
||||
|
||||
@@ -2007,7 +2007,11 @@
|
||||
"startDesc": "Mostrar el menú principal",
|
||||
"helpDesc": "Ayuda del bot",
|
||||
"statusDesc": "Comprobar el estado del bot",
|
||||
"idDesc": "Mostrar tu ID de Telegram"
|
||||
"idDesc": "Mostrar tu ID de Telegram",
|
||||
"usageDesc": "Ver el uso del cliente: /usage correo",
|
||||
"inboundDesc": "Buscar entradas: /inbound nombre (admin)",
|
||||
"restartDesc": "Reiniciar el núcleo de Xray (admin)",
|
||||
"clearallDesc": "Restablecer el tráfico de todos los clientes (admin)"
|
||||
},
|
||||
"messages": {
|
||||
"cpuThreshold": "El uso de CPU {{ .Percent }}% es mayor que el umbral {{ .Threshold }}%",
|
||||
|
||||
@@ -2007,7 +2007,11 @@
|
||||
"startDesc": "نمایش منوی اصلی",
|
||||
"helpDesc": "راهنمای ربات",
|
||||
"statusDesc": "بررسی وضعیت ربات",
|
||||
"idDesc": "نمایش شناسه تلگرام شما"
|
||||
"idDesc": "نمایش شناسه تلگرام شما",
|
||||
"usageDesc": "مشاهده مصرف کاربر: /usage ایمیل",
|
||||
"inboundDesc": "جستجوی ورودیها: /inbound نام (مدیر)",
|
||||
"restartDesc": "راهاندازی مجدد هسته Xray (مدیر)",
|
||||
"clearallDesc": "صفر کردن ترافیک همه کاربران (مدیر)"
|
||||
},
|
||||
"messages": {
|
||||
"cpuThreshold": "بار پردازنده {{ .Percent }}% بیشتر از آستانه است {{ .Threshold }}%",
|
||||
|
||||
@@ -2007,7 +2007,11 @@
|
||||
"startDesc": "Tampilkan menu utama",
|
||||
"helpDesc": "Bantuan bot",
|
||||
"statusDesc": "Periksa status bot",
|
||||
"idDesc": "Tampilkan ID Telegram Anda"
|
||||
"idDesc": "Tampilkan ID Telegram Anda",
|
||||
"usageDesc": "Lihat pemakaian klien: /usage email",
|
||||
"inboundDesc": "Cari inbound: /inbound nama (admin)",
|
||||
"restartDesc": "Mulai ulang inti Xray (admin)",
|
||||
"clearallDesc": "Reset trafik semua klien (admin)"
|
||||
},
|
||||
"messages": {
|
||||
"cpuThreshold": "Beban CPU {{ .Percent }}% melebihi batas {{ .Threshold }}%",
|
||||
|
||||
@@ -2007,7 +2007,11 @@
|
||||
"startDesc": "メインメニューを表示",
|
||||
"helpDesc": "ボットのヘルプ",
|
||||
"statusDesc": "ボットの状態を確認",
|
||||
"idDesc": "Telegram IDを表示"
|
||||
"idDesc": "Telegram IDを表示",
|
||||
"usageDesc": "クライアント使用量を表示: /usage メール",
|
||||
"inboundDesc": "インバウンド検索: /inbound 備考(管理者)",
|
||||
"restartDesc": "Xray コアを再起動(管理者)",
|
||||
"clearallDesc": "全クライアントのトラフィックをリセット(管理者)"
|
||||
},
|
||||
"messages": {
|
||||
"cpuThreshold": "CPU使用率は{{ .Percent }}%、しきい値{{ .Threshold }}%を超えました",
|
||||
|
||||
@@ -2007,7 +2007,11 @@
|
||||
"startDesc": "Mostrar menu principal",
|
||||
"helpDesc": "Ajuda do bot",
|
||||
"statusDesc": "Verificar status do bot",
|
||||
"idDesc": "Mostrar seu ID do Telegram"
|
||||
"idDesc": "Mostrar seu ID do Telegram",
|
||||
"usageDesc": "Ver o uso do cliente: /usage email",
|
||||
"inboundDesc": "Buscar entradas: /inbound nome (admin)",
|
||||
"restartDesc": "Reiniciar o núcleo Xray (admin)",
|
||||
"clearallDesc": "Zerar o tráfego de todos os clientes (admin)"
|
||||
},
|
||||
"messages": {
|
||||
"cpuThreshold": "A carga da CPU {{ .Percent }}% excede o limite de {{ .Threshold }}%",
|
||||
|
||||
@@ -2007,7 +2007,11 @@
|
||||
"startDesc": "Показать главное меню",
|
||||
"helpDesc": "Справка по боту",
|
||||
"statusDesc": "Проверить статус бота",
|
||||
"idDesc": "Показать ваш Telegram ID"
|
||||
"idDesc": "Показать ваш Telegram ID",
|
||||
"usageDesc": "Показать трафик клиента: /usage email",
|
||||
"inboundDesc": "Поиск входящих: /inbound имя (админ)",
|
||||
"restartDesc": "Перезапустить ядро Xray (админ)",
|
||||
"clearallDesc": "Сбросить трафик всех клиентов (админ)"
|
||||
},
|
||||
"messages": {
|
||||
"cpuThreshold": "Загрузка процессора составляет {{ .Percent }}%, что превышает пороговое значение {{ .Threshold }}%",
|
||||
|
||||
@@ -2007,7 +2007,11 @@
|
||||
"startDesc": "Ana menüyü göster",
|
||||
"helpDesc": "Bot yardımı",
|
||||
"statusDesc": "Bot durumunu kontrol et",
|
||||
"idDesc": "Telegram Kimliğinizi gösterir"
|
||||
"idDesc": "Telegram Kimliğinizi gösterir",
|
||||
"usageDesc": "İstemci kullanımını göster: /usage e-posta",
|
||||
"inboundDesc": "Gelenleri ara: /inbound ad (yönetici)",
|
||||
"restartDesc": "Xray çekirdeğini yeniden başlat (yönetici)",
|
||||
"clearallDesc": "Tüm istemcilerin trafiğini sıfırla (yönetici)"
|
||||
},
|
||||
"messages": {
|
||||
"cpuThreshold": "CPU Yükü ({{ .Percent }}%), {{ .Threshold }}% eşiğini aşıyor",
|
||||
|
||||
@@ -2007,7 +2007,11 @@
|
||||
"startDesc": "Показати головне меню",
|
||||
"helpDesc": "Довідка по боту",
|
||||
"statusDesc": "Перевірити статус бота",
|
||||
"idDesc": "Показати ваш Telegram ID"
|
||||
"idDesc": "Показати ваш Telegram ID",
|
||||
"usageDesc": "Показати трафік клієнта: /usage email",
|
||||
"inboundDesc": "Пошук вхідних: /inbound назва (адмін)",
|
||||
"restartDesc": "Перезапустити ядро Xray (адмін)",
|
||||
"clearallDesc": "Скинути трафік усіх клієнтів (адмін)"
|
||||
},
|
||||
"messages": {
|
||||
"cpuThreshold": "Навантаження ЦП {{ .Percent }}% перевищує порогове значення {{ .Threshold }}%",
|
||||
|
||||
@@ -2007,7 +2007,11 @@
|
||||
"startDesc": "Hiển thị menu chính",
|
||||
"helpDesc": "Trợ giúp bot",
|
||||
"statusDesc": "Kiểm tra trạng thái bot",
|
||||
"idDesc": "Hiển thị ID Telegram của bạn"
|
||||
"idDesc": "Hiển thị ID Telegram của bạn",
|
||||
"usageDesc": "Xem mức dùng của khách: /usage email",
|
||||
"inboundDesc": "Tìm inbound: /inbound tên (quản trị)",
|
||||
"restartDesc": "Khởi động lại lõi Xray (quản trị)",
|
||||
"clearallDesc": "Đặt lại lưu lượng mọi khách hàng (quản trị)"
|
||||
},
|
||||
"messages": {
|
||||
"cpuThreshold": "Sử dụng CPU {{ .Percent }}% vượt quá ngưỡng {{ .Threshold }}%",
|
||||
|
||||
@@ -2007,7 +2007,11 @@
|
||||
"startDesc": "显示主菜单",
|
||||
"helpDesc": "机器人帮助",
|
||||
"statusDesc": "检查机器人状态",
|
||||
"idDesc": "显示您的 Telegram ID"
|
||||
"idDesc": "显示您的 Telegram ID",
|
||||
"usageDesc": "查看客户端用量:/usage 邮箱",
|
||||
"inboundDesc": "搜索入站:/inbound 备注(管理员)",
|
||||
"restartDesc": "重启 Xray 内核(管理员)",
|
||||
"clearallDesc": "重置所有客户端流量(管理员)"
|
||||
},
|
||||
"messages": {
|
||||
"cpuThreshold": "CPU 使用率为 {{ .Percent }}%,超过阈值 {{ .Threshold }}%",
|
||||
|
||||
@@ -2007,7 +2007,11 @@
|
||||
"startDesc": "顯示主選單",
|
||||
"helpDesc": "機器人幫助",
|
||||
"statusDesc": "檢查機器人狀態",
|
||||
"idDesc": "顯示您的 Telegram ID"
|
||||
"idDesc": "顯示您的 Telegram ID",
|
||||
"usageDesc": "查看客戶端用量:/usage 郵箱",
|
||||
"inboundDesc": "搜尋入站:/inbound 備註(管理員)",
|
||||
"restartDesc": "重啟 Xray 核心(管理員)",
|
||||
"clearallDesc": "重置所有客戶端流量(管理員)"
|
||||
},
|
||||
"messages": {
|
||||
"cpuThreshold": "CPU 使用率為 {{ .Percent }}%,超過閾值 {{ .Threshold }}%",
|
||||
|
||||
Reference in New Issue
Block a user