mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-08 03:01:47 +00:00
fix(telegram): keep DM topic typing scoped
This commit is contained in:
parent
0664bf961a
commit
41545f7ec5
2 changed files with 25 additions and 5 deletions
|
|
@ -2516,6 +2516,7 @@ class TelegramAdapter(BasePlatformAdapter):
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if message_thread_id is not None and self._is_thread_not_found_error(e):
|
if message_thread_id is not None and self._is_thread_not_found_error(e):
|
||||||
|
if str(_typing_thread) == self._GENERAL_TOPIC_THREAD_ID:
|
||||||
await self._bot.send_chat_action(
|
await self._bot.send_chat_action(
|
||||||
chat_id=int(chat_id),
|
chat_id=int(chat_id),
|
||||||
action="typing",
|
action="typing",
|
||||||
|
|
|
||||||
|
|
@ -179,6 +179,25 @@ async def test_send_typing_retries_without_general_thread_when_not_found():
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_send_typing_does_not_fall_back_to_root_for_dm_topic():
|
||||||
|
"""Typing failures in DM topics should not show an indicator in All Messages."""
|
||||||
|
adapter = _make_adapter()
|
||||||
|
call_log = []
|
||||||
|
|
||||||
|
async def mock_send_chat_action(**kwargs):
|
||||||
|
call_log.append(dict(kwargs))
|
||||||
|
raise FakeBadRequest("Message thread not found")
|
||||||
|
|
||||||
|
adapter._bot = SimpleNamespace(send_chat_action=mock_send_chat_action)
|
||||||
|
|
||||||
|
await adapter.send_typing("12345", metadata={"thread_id": "22182"})
|
||||||
|
|
||||||
|
assert call_log == [
|
||||||
|
{"chat_id": 12345, "action": "typing", "message_thread_id": 22182},
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_send_retries_without_thread_on_thread_not_found():
|
async def test_send_retries_without_thread_on_thread_not_found():
|
||||||
"""When message_thread_id causes 'thread not found', retry without it."""
|
"""When message_thread_id causes 'thread not found', retry without it."""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue