Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
fix: add rich_messages config to disable sendRichMessage for Telegram Web (#4488)
axelray-devc930aa37130f
diff --git a/nanobot/channels/telegram.py b/nanobot/channels/telegram.pyindex 8ce7641a9..743f7b240 100644--- a/nanobot/channels/telegram.py+++ b/nanobot/channels/telegram.py@@ -351,6 +351,9 @@ class TelegramConfig(Base):streaming: bool = True# Enable inline keyboard buttons in Telegram messages.inline_keyboards: bool = False+ # Use Bot API 10.1 sendRichMessage for markdown rendering.+ # Disable if Telegram Web shows "message not supported" errors.+ rich_messages: bool = Truestream_edit_interval: float = Field(default=_STREAM_EDIT_INTERVAL_DEFAULT, ge=0.1)webhook_url: str = ""webhook_listen_host: str = "127.0.0.1"@@ -803,6 +806,7 @@ class TelegramChannel(BaseChannel):# latches off permanently if the server doesn't support it.if (not render_as_blockquote+ and self.config.rich_messagesand not getattr(self, "_rich_send_disabled", False)):rich_ok = await self._try_send_rich(@@ -911,7 +915,7 @@ class TelegramChannel(BaseChannel):# Skip when a streaming preview already exists to avoid the# delete-and-resend pattern that causes flickering and drops# line breaks (issue #4470).- if not buf.message_id and not getattr(self, "_rich_send_disabled", False):+ if not buf.message_id and self.config.rich_messages and not getattr(self, "_rich_send_disabled", False):reply_params = Noneif reply_to_message_id := meta.get("message_id"):reply_params = {"message_id": int(reply_to_message_id), "allow_sending_without_reply": True}diff --git a/tests/channels/test_telegram_channel.py b/tests/channels/test_telegram_channel.pyindex 90b1e7e45..2d3f5c574 100644--- a/tests/channels/test_telegram_channel.py+++ b/tests/channels/test_telegram_channel.py@@ -505,6 +505,23 @@ async def test_send_rich_bad_request_does_not_latch_capability() -> None:assert len(channel._app.bot.sent_messages) == 1+async def test_rich_messages_config_disabled_skips_sendRichMessage() -> None:+ """When rich_messages=False, sendRichMessage should not be called."""+ channel = TelegramChannel(+ TelegramConfig(enabled=True, token="123:abc", allow_from=["*"], rich_messages=False),+ MessageBus(),+ )+ channel._app = _FakeApp(lambda: None)+ channel._app.bot.do_api_request = AsyncMock()++ await channel.send(OutboundMessage(channel="telegram", chat_id="123", content="**hello**"))++ channel._app.bot.do_api_request.assert_not_called()+ assert len(channel._app.bot.sent_messages) == 1+ assert channel._app.bot.sent_messages[0]["text"]++@pytest.mark.asyncioasync def test_on_error_logs_network_issues_as_warning(monkeypatch) -> None:from telegram.error import NetworkError