mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-21 03:39:54 +00:00
fix(telegram): escape Markdown special chars in send_exec_approval
The command preview and description were wrapped in Markdown v1 inline code (backticks) without escaping, causing Telegram API parse errors when the command itself contained backticks or asterisks. Fixes: 'Can't parse entities: can't find end of the entity'
This commit is contained in:
@@ -1076,10 +1076,13 @@ class TelegramAdapter(BasePlatformAdapter):
|
||||
|
||||
try:
|
||||
cmd_preview = command[:3800] + "..." if len(command) > 3800 else command
|
||||
# Escape backticks that would break Markdown v1 inline code parsing
|
||||
safe_cmd = cmd_preview.replace("`", "'")
|
||||
safe_desc = description.replace("`", "'").replace("*", "∗")
|
||||
text = (
|
||||
f"⚠️ *Command Approval Required*\n\n"
|
||||
f"`{cmd_preview}`\n\n"
|
||||
f"Reason: {description}"
|
||||
f"`{safe_cmd}`\n\n"
|
||||
f"Reason: {safe_desc}"
|
||||
)
|
||||
|
||||
# Resolve thread context for thread replies
|
||||
|
||||
Reference in New Issue
Block a user