Revert "feat(send_message): auto-detect @username mentions and create Telegram entities"

This reverts commit cf814c96f6.
This commit is contained in:
Teknium
2026-05-18 23:56:17 -07:00
parent 22120ef00f
commit bbd2b46537
+3 -11
View File
@@ -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