mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +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:
parent
4936b19144
commit
06d6903d3c
1 changed files with 5 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue