fix: make Telegram rich messages opt in
maintainer edit: Telegram Web cannot render sendRichMessage payloads, so keep the rich path available only for explicit opt-in instead of enabling it by default.
This commit is contained in:
@@ -351,9 +351,8 @@ 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
|
||||
# Opt in to Bot API 10.1 sendRichMessage for richer markdown rendering.
|
||||
rich_messages: bool = False
|
||||
stream_edit_interval: float = Field(default=_STREAM_EDIT_INTERVAL_DEFAULT, ge=0.1)
|
||||
webhook_url: str = ""
|
||||
webhook_listen_host: str = "127.0.0.1"
|
||||
|
||||
@@ -471,7 +471,7 @@ async def test_send_rich_capability_error_latches_and_falls_back() -> None:
|
||||
from telegram.error import BadRequest
|
||||
|
||||
channel = TelegramChannel(
|
||||
TelegramConfig(enabled=True, token="123:abc", allow_from=["*"]),
|
||||
TelegramConfig(enabled=True, token="123:abc", allow_from=["*"], rich_messages=True),
|
||||
MessageBus(),
|
||||
)
|
||||
channel._app = _FakeApp(lambda: None)
|
||||
@@ -490,7 +490,7 @@ async def test_send_rich_bad_request_does_not_latch_capability() -> None:
|
||||
from telegram.error import BadRequest
|
||||
|
||||
channel = TelegramChannel(
|
||||
TelegramConfig(enabled=True, token="123:abc", allow_from=["*"]),
|
||||
TelegramConfig(enabled=True, token="123:abc", allow_from=["*"], rich_messages=True),
|
||||
MessageBus(),
|
||||
)
|
||||
channel._app = _FakeApp(lambda: None)
|
||||
@@ -506,10 +506,10 @@ async def test_send_rich_bad_request_does_not_latch_capability() -> None:
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_rich_messages_config_disabled_skips_sendRichMessage() -> None:
|
||||
"""When rich_messages=False, sendRichMessage should not be called."""
|
||||
async def test_rich_messages_default_skips_send_rich_message() -> None:
|
||||
"""By default, sendRichMessage should not be called."""
|
||||
channel = TelegramChannel(
|
||||
TelegramConfig(enabled=True, token="123:abc", allow_from=["*"], rich_messages=False),
|
||||
TelegramConfig(enabled=True, token="123:abc", allow_from=["*"]),
|
||||
MessageBus(),
|
||||
)
|
||||
channel._app = _FakeApp(lambda: None)
|
||||
|
||||
Reference in New Issue
Block a user