feat(telegram): support quick-command-only menus
This commit is contained in:
@@ -26,6 +26,7 @@ from hermes_cli.commands import (
|
||||
slack_subcommand_map,
|
||||
telegram_bot_commands,
|
||||
telegram_menu_commands,
|
||||
telegram_quick_menu_commands,
|
||||
)
|
||||
|
||||
|
||||
@@ -1153,6 +1154,47 @@ class TestTelegramMenuCommands:
|
||||
# No empty string in menu names
|
||||
assert "" not in menu_names
|
||||
|
||||
def test_quick_menu_commands_include_profile_quick_commands_only(self):
|
||||
menu, hidden = telegram_quick_menu_commands(
|
||||
{
|
||||
"agent-health": {
|
||||
"type": "exec",
|
||||
"command": "echo ok",
|
||||
"description": "Show agent health",
|
||||
},
|
||||
"hidden": {
|
||||
"type": "exec",
|
||||
"command": "echo hidden",
|
||||
"description": "Hidden command",
|
||||
"show_in_telegram_menu": False,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
assert hidden == 0
|
||||
assert menu == [("agent_health", "Show agent health")]
|
||||
|
||||
def test_quick_menu_commands_sanitize_dedupe_and_trim_descriptions(self):
|
||||
menu, hidden = telegram_quick_menu_commands(
|
||||
{
|
||||
"agent-health": {
|
||||
"description": "A" * 80,
|
||||
},
|
||||
"agent_health": {
|
||||
"description": "Duplicate after sanitization",
|
||||
},
|
||||
"+++": {
|
||||
"description": "Sanitizes to empty",
|
||||
},
|
||||
},
|
||||
max_commands=1,
|
||||
)
|
||||
|
||||
assert hidden == 0
|
||||
assert len(menu) == 1
|
||||
assert menu[0][0] == "agent_health"
|
||||
assert menu[0][1] == ("A" * 37) + "..."
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Backward-compat aliases
|
||||
|
||||
Reference in New Issue
Block a user