Skip to content

Your lightweight open-source personal agent.

fix(telegram): detect unsupported rich stream edits

chengyongru3c25f826ea9f
diff --git a/nanobot/channels/telegram/runtime.py b/nanobot/channels/telegram/runtime.py
index 090a38914..38429924a 100644
--- a/nanobot/channels/telegram/runtime.py
+++ b/nanobot/channels/telegram/runtime.py
@@ -938,7 +938,13 @@ class TelegramChannel(BaseChannel):
# edit overwrite the already-successful rich result.
self.logger.debug("Rich stream edit already applied for {}", chat_id)
return True
- if self._is_rich_capability_error(exc):
+ # Before Bot API 10.1, editMessageText ignores rich_message and
+ # reports the absent text argument instead.
+ pre_rich_edit_server = (
+ bool(content)
+ and str(exc).strip().lower() == "message text is empty"
+ )
+ if self._is_rich_capability_error(exc) or pre_rich_edit_server:
self.logger.debug("editMessageText rich_message not available, disabling")
self._rich_send_disabled = True
return False
diff --git a/nanobot/channels/telegram/tests/test_telegram_channel.py b/nanobot/channels/telegram/tests/test_telegram_channel.py
index d4240c4f9..e91a19995 100644
--- a/nanobot/channels/telegram/tests/test_telegram_channel.py
+++ b/nanobot/channels/telegram/tests/test_telegram_channel.py
@@ -2777,7 +2777,10 @@ async def test_send_delta_stream_end_rich_capability_error_latches_and_falls_bac
MessageBus(),
)
_install_ready_app(channel)
- channel._app.bot.do_api_request = AsyncMock(side_effect=BadRequest("Method not found"))
+ # Before Bot API 10.1, editMessageText ignores rich_message and requires text.
+ channel._app.bot.do_api_request = AsyncMock(
+ side_effect=BadRequest("Message text is empty")
+ )
channel._app.bot.edit_message_text = AsyncMock()
channel._stream_bufs["123"] = _StreamBuf(text="hello", message_id=7, last_edit=0.0)