diff --git a/tools/send_message_tool.py b/tools/send_message_tool.py index 302ddb16b4..892346fb9f 100644 --- a/tools/send_message_tool.py +++ b/tools/send_message_tool.py @@ -804,7 +804,7 @@ async def _send_telegram(token, chat_id, message, media_files=None, thread_id=No instead, bypassing MarkdownV2 conversion. """ try: - from telegram import Bot, MessageEntity + from telegram import Bot from telegram.constants import ParseMode # Auto-detect HTML tags — if present, skip MarkdownV2 and send as HTML. @@ -825,14 +825,6 @@ async def _send_telegram(token, chat_id, message, media_files=None, thread_id=No formatted = message send_parse_mode = ParseMode.MARKDOWN_V2 - # Detect @username patterns and create mention entities so - # require_mention on the receiving bot's Gateway can trigger. - _MENTION_RE = re.compile(r'@([a-zA-Z][a-zA-Z0-9_]{4,31})') - _entities = [ - MessageEntity(type="mention", offset=m.start(), length=len(m.group())) - for m in _MENTION_RE.finditer(formatted) - ] - # Honour a configured proxy (telegram.proxy_url in config.yaml, exported # as TELEGRAM_PROXY env var by load_gateway_config). Without this, the # standalone send path bypasses the proxy and times out in regions @@ -897,7 +889,7 @@ async def _send_telegram(token, chat_id, message, media_files=None, thread_id=No last_msg = await _send_telegram_message_with_retry( bot, chat_id=int_chat_id, text=formatted, - parse_mode=send_parse_mode, entities=_entities, **text_kwargs + parse_mode=send_parse_mode, **text_kwargs ) except Exception as md_error: # Thread not found — retry without message_thread_id so the @@ -931,7 +923,7 @@ async def _send_telegram(token, chat_id, message, media_files=None, thread_id=No last_msg = await _send_telegram_message_with_retry( bot, chat_id=int_chat_id, text=plain, - parse_mode=None, entities=_entities, **text_kwargs + parse_mode=None, **text_kwargs ) else: raise