Skip to content

Commit 189ebbf

Browse files
authored
Stop truncating long Telegram replies in format_response (#172)
format_response() truncated any text over MAX_MSG_LEN and appended a "... (truncated)" marker. But send() already splits outgoing text into MAX_MSG_LEN-sized chunks delivered as sequential messages, so truncating first permanently dropped the tail of long replies. Return the text unchanged and let send() handle chunking.
1 parent b70d1ef commit 189ebbf

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

nerve/channels/telegram.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -571,9 +571,13 @@ async def send(self, message: OutboundMessage) -> None:
571571
self._cache_message(sent.message_id, chat_id, chunk)
572572

573573
def format_response(self, text: str) -> str:
574-
"""Truncate for Telegram if needed."""
575-
if len(text) > MAX_MSG_LEN:
576-
return text[:MAX_MSG_LEN - 20] + "\n\n... (truncated)"
574+
"""Return text unchanged.
575+
576+
Long messages must NOT be truncated here: send() already splits text into
577+
MAX_MSG_LEN-sized chunks and delivers them as sequential messages. Truncating
578+
first (the old behaviour) defeated that chunking and dropped the tail of long
579+
replies with a "... (truncated)" marker.
580+
"""
577581
return text
578582

579583
# ------------------------------------------------------------------ #

0 commit comments

Comments
 (0)