fix: add rich_messages config to disable sendRichMessage for Telegram Web (#4488)

This commit is contained in:
axelray-dev
2026-06-25 16:10:33 +08:00
committed by Xubin Ren
parent 4378944459
commit c930aa3713
2 changed files with 22 additions and 1 deletions
+5 -1
View File
@@ -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 = True
stream_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_messages
and 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 = None
if reply_to_message_id := meta.get("message_id"):
reply_params = {"message_id": int(reply_to_message_id), "allow_sending_without_reply": True}