fix(telegram): use word-boundary matching for bot mention detection (#12545)
This commit is contained in:
@@ -2264,8 +2264,9 @@ class TelegramAdapter(BasePlatformAdapter):
|
||||
yield getattr(message, "caption", None) or "", getattr(message, "caption_entities", None) or []
|
||||
|
||||
for source_text, entities in _iter_sources():
|
||||
if bot_username and f"@{bot_username}" in source_text.lower():
|
||||
return True
|
||||
if bot_username:
|
||||
if re.search(rf'(?<!\w)@{re.escape(bot_username)}(?!\w)', source_text, re.IGNORECASE):
|
||||
return True
|
||||
for entity in entities:
|
||||
entity_type = str(getattr(entity, "type", "")).split(".")[-1].lower()
|
||||
if entity_type == "mention" and bot_username:
|
||||
|
||||
Reference in New Issue
Block a user