fix(telegram): detect unsupported rich stream edits

This commit is contained in:
chengyongru
2026-08-31 18:39:35 +08:00
committed by chengyongru
parent 195e4c281d
commit 3c25f826ea
2 changed files with 11 additions and 2 deletions
+7 -1
View File
@@ -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
@@ -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)