Skip to content

fix(gateway): bridge top-level require_mention to Telegram config#19317

Closed
konsisumer wants to merge 1 commit into
NousResearch:mainfrom
konsisumer:fix/telegram-require-mention-top-level
Closed

fix(gateway): bridge top-level require_mention to Telegram config#19317
konsisumer wants to merge 1 commit into
NousResearch:mainfrom
konsisumer:fix/telegram-require-mention-top-level

Conversation

@konsisumer
Copy link
Copy Markdown
Contributor

Bot responds to every group message despite require_mention: true in config.yaml when that key is placed at the top level (same level as group_sessions_per_user).

What changed and why

  • gateway/config.py: when require_mention is found at the top level of config.yaml and no telegram.require_mention is already set, the value is now bridged to platforms_data["telegram"]["extra"]["require_mention"] (picked up by _telegram_require_mention() via its primary config.extra check) and to TELEGRAM_REQUIRE_MENTION env var (secondary fallback). A platform-specific telegram.require_mention still overrides the top-level shorthand.
  • tests/gateway/test_telegram_group_gating.py: two new tests cover the top-level shorthand and confirm that telegram.require_mention: false overrides a top-level require_mention: true.
  • website/docs/user-guide/messaging/telegram.md: corrected the list of accepted message types under require_mention: true — bare /cmd (without @botname) is rejected; only /cmd@botname (Telegram bot-menu form) passes.

How to test

  1. Add require_mention: true and group_sessions_per_user: true at the top level of ~/.hermes/config.yaml (no telegram: section).
  2. Start the gateway and add the bot to a Telegram group.
  3. Send a plain group message without @mentioning the bot — it should be ignored.
  4. Send @botname hello — the bot should respond.
  5. Run pytest tests/gateway/test_telegram_group_gating.py -v — all 14 tests pass.

What platforms tested on

  • macOS on darwin-arm64 (local)

Fixes #3979

Users commonly place `require_mention: true` at the top level of
config.yaml alongside `group_sessions_per_user`, expecting it to gate
Telegram group messages. The key was silently ignored because the
config loader only checked `yaml_cfg["telegram"]["require_mention"]`.

When `require_mention` is found at the top level and no telegram-specific
value is set, the fix now:
- adds it to platforms_data["telegram"]["extra"] so _telegram_require_mention()
  picks it up via the primary config.extra path
- sets TELEGRAM_REQUIRE_MENTION env var for the secondary fallback path

A telegram-specific value (telegram.require_mention) still takes
precedence over the top-level shorthand.

Also corrects telegram.md: bare /cmd without @botName is rejected when
require_mention is enabled; only /cmd@botname (bot-menu form) passes.

Fixes NousResearch#3979
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/telegram Telegram bot adapter area/config Config system, migrations, profiles labels May 3, 2026
@alt-glitch
Copy link
Copy Markdown
Collaborator

Fixes #3979 — bridges top-level to Telegram platform config when no is set.

@teknium1
Copy link
Copy Markdown
Contributor

teknium1 commented May 3, 2026

Salvaged via #19429 onto current main — your commit's authorship was preserved. Thanks @konsisumer!

@teknium1 teknium1 closed this May 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/telegram Telegram bot adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Telegram: require_mention ignored in groups — bot responds to every message

3 participants