Skip to content

fix(telegram): require entity mentions for group gating - #12637

Closed
MonkeyLeeT wants to merge 1 commit into
NousResearch:mainfrom
MonkeyLeeT:codex/fix-12545-telegram-mention-gating
Closed

fix(telegram): require entity mentions for group gating#12637
MonkeyLeeT wants to merge 1 commit into
NousResearch:mainfrom
MonkeyLeeT:codex/fix-12545-telegram-mention-gating

Conversation

@MonkeyLeeT

Copy link
Copy Markdown

Summary

Fix Telegram group mention gating so only real Telegram mention entities wake the bot.

Root Cause

TelegramAdapter._message_mentions_bot() returned True on any raw @<bot_username> substring before checking Telegram entities. That let unrelated text like foo@hermes_bot.example and longer handles like @hermes_botx bypass require_mention=true.

Changes

  • remove the raw substring fast-path from gateway/platforms/telegram.py
  • keep the existing entity-based mention and text_mention handling intact
  • add regression tests for email-domain and longer-handle false positives in tests/gateway/test_telegram_group_gating.py

Validation

  • scripts/run_tests.sh tests/gateway/test_telegram_group_gating.py -q

Closes #12545.

@MonkeyLeeT MonkeyLeeT changed the title [codex] fix Telegram group mention false positives fix(telegram): require entity mentions for group gating Apr 19, 2026
@MonkeyLeeT
MonkeyLeeT marked this pull request as ready for review April 19, 2026 21:08
@MonkeyLeeT
MonkeyLeeT force-pushed the codex/fix-12545-telegram-mention-gating branch 3 times, most recently from 3cd3638 to 6a8ac5b Compare April 20, 2026 16:38
@MonkeyLeeT
MonkeyLeeT force-pushed the codex/fix-12545-telegram-mention-gating branch from 6a8ac5b to c01aaad Compare April 20, 2026 19:18
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the contribution @MonkeyLeeT — closing as redundant. Commit e330112 on main refactored _message_mentions_bot() to use entity-only detection (MENTION and TEXT_MENTION entities), dropping the raw substring fallback that caused the foo@hermes_bot.example false positive you fixed here. Same fix, landed independently ~5 hours after your PR opened. Appreciate you catching this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

telegram: group mention gating treats raw substrings as valid mentions

2 participants