fix(telegram): escape chunk indicators in MarkdownV2 (#1478)
This commit is contained in:
parent
7148534401
commit
a56937735e
2 changed files with 33 additions and 1 deletions
|
|
@ -322,6 +322,14 @@ class TelegramAdapter(BasePlatformAdapter):
|
|||
# Format and split message if needed
|
||||
formatted = self.format_message(content)
|
||||
chunks = self.truncate_message(formatted, self.MAX_MESSAGE_LENGTH)
|
||||
if len(chunks) > 1:
|
||||
# truncate_message appends a raw " (1/2)" suffix. Escape the
|
||||
# MarkdownV2-special parentheses so Telegram doesn't reject the
|
||||
# chunk and fall back to plain text.
|
||||
chunks = [
|
||||
re.sub(r" \((\d+)/(\d+)\)$", r" \\(\1/\2\\)", chunk)
|
||||
for chunk in chunks
|
||||
]
|
||||
|
||||
message_ids = []
|
||||
thread_id = metadata.get("thread_id") if metadata else None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue