mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-09-02 01:01:52 +03:00
fix(telegram): detect unsupported rich stream edits
This commit is contained in:
@@ -938,7 +938,13 @@ class TelegramChannel(BaseChannel):
|
|||||||
# edit overwrite the already-successful rich result.
|
# edit overwrite the already-successful rich result.
|
||||||
self.logger.debug("Rich stream edit already applied for {}", chat_id)
|
self.logger.debug("Rich stream edit already applied for {}", chat_id)
|
||||||
return True
|
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.logger.debug("editMessageText rich_message not available, disabling")
|
||||||
self._rich_send_disabled = True
|
self._rich_send_disabled = True
|
||||||
return False
|
return False
|
||||||
|
|||||||
@@ -2777,7 +2777,10 @@ async def test_send_delta_stream_end_rich_capability_error_latches_and_falls_bac
|
|||||||
MessageBus(),
|
MessageBus(),
|
||||||
)
|
)
|
||||||
_install_ready_app(channel)
|
_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._app.bot.edit_message_text = AsyncMock()
|
||||||
channel._stream_bufs["123"] = _StreamBuf(text="hello", message_id=7, last_edit=0.0)
|
channel._stream_bufs["123"] = _StreamBuf(text="hello", message_id=7, last_edit=0.0)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user