mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-06 13:26:38 +08:00
Hide duplicate Telegram bot command aliases
This commit is contained in:
@@ -150,6 +150,16 @@ func TestRegisterTelegramBotCommands(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestTelegramCommandMenusSeparateGroupAndAdminCommands(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())
|
groupNames := telegramCommandNames(telegramGroupBotCommandMenu())
|
||||||
for _, forbidden := range []string{"status", "search", "downloads", "stats", "users", "cleanup", "cleanup_rule", "register", "redeem"} {
|
for _, forbidden := range []string{"status", "search", "downloads", "stats", "users", "cleanup", "cleanup_rule", "register", "redeem"} {
|
||||||
if groupNames[forbidden] {
|
if groupNames[forbidden] {
|
||||||
@@ -167,6 +177,11 @@ func TestTelegramCommandMenusSeparateGroupAndAdminCommands(t *testing.T) {
|
|||||||
t.Fatalf("admin menu should include %s", required)
|
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 {
|
func telegramCommandNames(commands []telegramBotCommand) map[string]bool {
|
||||||
|
|||||||
@@ -213,8 +213,6 @@ func telegramPrivateBotCommandMenu() []telegramBotCommand {
|
|||||||
{Command: "menu", Description: "打开功能菜单"},
|
{Command: "menu", Description: "打开功能菜单"},
|
||||||
{Command: "help", Description: "查看命令帮助"},
|
{Command: "help", Description: "查看命令帮助"},
|
||||||
{Command: "account", Description: "查看账号状态"},
|
{Command: "account", Description: "查看账号状态"},
|
||||||
{Command: "myinfo", Description: "查看账号状态"},
|
|
||||||
{Command: "count", Description: "查看媒体库数量"},
|
|
||||||
{Command: "signin", Description: "签到"},
|
{Command: "signin", Description: "签到"},
|
||||||
{Command: "devices", Description: "查看登录设备"},
|
{Command: "devices", Description: "查看登录设备"},
|
||||||
{Command: "kick", Description: "踢下线设备"},
|
{Command: "kick", Description: "踢下线设备"},
|
||||||
|
|||||||
Reference in New Issue
Block a user