mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-29 06:31:32 +00:00
fix: ignore Telegram start pings
This commit is contained in:
parent
8807b1c727
commit
efa952531b
4 changed files with 59 additions and 0 deletions
|
|
@ -26,6 +26,16 @@ def _make_runner():
|
|||
return object.__new__(GatewayRunner)
|
||||
|
||||
|
||||
def test_start_is_known_gateway_command():
|
||||
"""Telegram sends /start automatically; gateway should intercept it as a no-op."""
|
||||
from hermes_cli.commands import GATEWAY_KNOWN_COMMANDS, resolve_command
|
||||
|
||||
cmd = resolve_command("start")
|
||||
assert "start" in GATEWAY_KNOWN_COMMANDS
|
||||
assert cmd is not None
|
||||
assert cmd.name == "start"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_help_sanitizes_slash_command_mentions_for_telegram(monkeypatch):
|
||||
"""Telegram help output must not expose invalid uppercase/hyphenated slashes."""
|
||||
|
|
|
|||
|
|
@ -330,6 +330,42 @@ async def test_command_messages_do_not_leave_sentinel():
|
|||
)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_start_command_is_noop_and_does_not_show_help():
|
||||
"""Telegram /start is a platform ping; it must not dump /help output."""
|
||||
runner = _make_runner()
|
||||
event = _make_event(text="/start")
|
||||
session_key = build_session_key(event.source)
|
||||
|
||||
runner._handle_help_command = AsyncMock(return_value="Help text")
|
||||
|
||||
result = await runner._handle_message(event)
|
||||
|
||||
assert result == ""
|
||||
runner._handle_help_command.assert_not_awaited()
|
||||
assert session_key not in runner._running_agents
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_start_command_is_noop_during_active_session():
|
||||
"""A mid-run /start must not interrupt the active agent or show commands."""
|
||||
runner = _make_runner()
|
||||
event = _make_event(text="/start")
|
||||
session_key = build_session_key(event.source)
|
||||
|
||||
fake_agent = MagicMock()
|
||||
fake_agent.get_activity_summary.return_value = {"seconds_since_activity": 0}
|
||||
runner._running_agents[session_key] = fake_agent
|
||||
runner._handle_help_command = AsyncMock(return_value="Help text")
|
||||
|
||||
result = await runner._handle_message(event)
|
||||
|
||||
assert result == ""
|
||||
runner._handle_help_command.assert_not_awaited()
|
||||
fake_agent.interrupt.assert_not_called()
|
||||
assert session_key not in runner.adapters[Platform.TELEGRAM]._pending_messages
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize(
|
||||
("command_text", "handler_attr", "handler_result"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue