mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
fix(telegram): handle parentheses in URLs during MarkdownV2 link conversion
The link regex in format_message used [^)]+ for the URL portion, which stopped at the first ) character. URLs with nested parentheses (e.g. Wikipedia links like Python_(programming_language)) were improperly parsed. Use a better regex, which is the same the Slack adapter uses.
This commit is contained in:
parent
ac4e8cb43a
commit
11369a78f9
1 changed files with 1 additions and 1 deletions
|
|
@ -2075,7 +2075,7 @@ class TelegramAdapter(BasePlatformAdapter):
|
|||
url = m.group(2).replace('\\', '\\\\').replace(')', '\\)')
|
||||
return _ph(f'[{display}]({url})')
|
||||
|
||||
text = re.sub(r'\[([^\]]+)\]\(([^)]+)\)', _convert_link, text)
|
||||
text = re.sub(r'\[([^\]]+)\]\(([^()]*(?:\([^()]*\)[^()]*)*)\)', _convert_link, text)
|
||||
|
||||
# 4) Convert markdown headers (## Title) → bold *Title*
|
||||
def _convert_header(m):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue