From 03be4df6e2c47c82f63103ac73ed08b1330f685e Mon Sep 17 00:00:00 2001 From: ShukeBta <272197458+ShukeBta@users.noreply.github.com> Date: Mon, 15 Jun 2026 01:43:24 +0800 Subject: [PATCH] Hide duplicate Telegram bot command aliases --- internal/service/telegram_api_test.go | 15 +++++++++++++++ internal/service/telegram_commands.go | 2 -- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/internal/service/telegram_api_test.go b/internal/service/telegram_api_test.go index 7d57051..a365840 100644 --- a/internal/service/telegram_api_test.go +++ b/internal/service/telegram_api_test.go @@ -150,6 +150,16 @@ func TestRegisterTelegramBotCommands(t *testing.T) { } func TestTelegramCommandMenusSeparateGroupAndAdminCommands(t *testing.T) { + privateNames := telegramCommandNames(telegramPrivateBotCommandMenu()) + for _, hiddenAlias := range []string{"myinfo", "count"} { + if privateNames[hiddenAlias] { + t.Fatalf("private menu should hide compatibility alias %s", hiddenAlias) + } + if !telegramSupportedCommand("/" + hiddenAlias) { + t.Fatalf("compatibility alias /%s should remain executable", hiddenAlias) + } + } + groupNames := telegramCommandNames(telegramGroupBotCommandMenu()) for _, forbidden := range []string{"status", "search", "downloads", "stats", "users", "cleanup", "cleanup_rule", "register", "redeem"} { if groupNames[forbidden] { @@ -167,6 +177,11 @@ func TestTelegramCommandMenusSeparateGroupAndAdminCommands(t *testing.T) { t.Fatalf("admin menu should include %s", required) } } + for _, hiddenAlias := range []string{"myinfo", "count"} { + if adminNames[hiddenAlias] { + t.Fatalf("admin menu should hide compatibility alias %s", hiddenAlias) + } + } } func telegramCommandNames(commands []telegramBotCommand) map[string]bool { diff --git a/internal/service/telegram_commands.go b/internal/service/telegram_commands.go index acfea37..fbcab21 100644 --- a/internal/service/telegram_commands.go +++ b/internal/service/telegram_commands.go @@ -213,8 +213,6 @@ func telegramPrivateBotCommandMenu() []telegramBotCommand { {Command: "menu", Description: "打开功能菜单"}, {Command: "help", Description: "查看命令帮助"}, {Command: "account", Description: "查看账号状态"}, - {Command: "myinfo", Description: "查看账号状态"}, - {Command: "count", Description: "查看媒体库数量"}, {Command: "signin", Description: "签到"}, {Command: "devices", Description: "查看登录设备"}, {Command: "kick", Description: "踢下线设备"},