Telegram slash commands and require_mention in group chats
Cluster 6033. Data as of
Nothing open on GitHub. Fix merged in #13438 on 21 Apr 2026. Check it covers your case.
The short answer
- Known?
- Yes. 3 related items grouped here, 1 issue already closed.
- Fix event
- A fix was merged to main in PR #13438. Check it covers your case. No release data is tracked.
- Tracker
- The maintainers' tracker marks this
resolved, deciding PR #13438. That is separate from the fix event. - Still open
- Nothing open on GitHub.
The members concern Telegram slash commands apparently bypassing the require_mention setting in groups, reportedly leading to duplicate responses when multiple bots are present. One item reports the problem, and the other two are pull requests that propose making slash commands respect require_mention; one of them is described as a salvage of #6036.
Open issues0
Open PRs0
Fixes on record
-
#13438 fix(telegram): slash commands respect require_mention in groups (salvage of #6036)
files:
gateway/platforms/telegram.py,scripts/release.py,tests/gateway/test_telegram_group_gating.pyShow the diff
-
gateway/platforms/telegram.py@@ -2333,10 +2333,16 @@ def _should_process_message(self, message: Message, *, is_command: bool = False) DMs remain unrestricted. Group/supergroup messages are accepted when: - the chat is explicitly allowlisted in ``free_response_chats`` - ``require_mention`` is disabled - - the message is a command - the message replies to the bot - the bot is @mentioned - the text/caption matches a configured regex wake-word pattern + + When ``require_mention`` is enabled, slash commands are not given + special treatment — they must pass the same mention/reply checks + as any other group message. Users can still trigger commands via + the Telegram bot menu (``/command@botname``) or by explicitly + mentioning the bot (``@botname /command``), both of which are + recognised as mentions by :meth:`_message_mentions_bot`. """ if not self._is_group_chat(message): return True @@ -2351,8 +2357,6 @@ def _should_process_message(self, message: Message, *, is_command: bool = False) return True if not self._telegram_require_mention(): return True - if is_command: - return True if self._is_reply_to_bot(message): return True if self._message_mentions_bot(message): -
scripts/release.py@@ -326,6 +326,7 @@ "[email protected]": "aniruddhaadak80", "[redacted:email]": "jerilynzheng", "[redacted:email]": "Aslaaen", + "[redacted:email]": "pinion05", } -
tests/gateway/test_telegram_group_gating.py@@ -71,7 +71,17 @@ def test_group_messages_can_require_direct_trigger_via_config(): assert adapter._should_process_message(_group_message("hello everyone")) is False assert adapter._should_process_message(_group_message("hi @hermes_bot", entities=[_mention_entity("hi @hermes_bot")])) is True assert adapter._should_process_message(_group_message("replying", reply_to_bot=True)) is True - assert adapter._should_process_message(_group_message("/status"), is_command=True) is True + # Commands must also respect require_mention when it is enabled + assert adapter._should_process_message(_group_message("/status"), is_command=True) is False + # But commands with @mention still pass (Telegram emits a MENTION entity + # for /cmd@botname — the bot menu and python-telegram-bot's CommandHandler + # rely on this same mechanism) + assert adapter._should_process_message( + _group_message("/status@hermes_bot", entities=[_mention_entity("/status@hermes_bot")]) + ) is True + # And commands still pass unconditionally when require_mention is disabled + adapter_no_mention = _make_adapter(require_mention=False) + assert adapter_no_mention._should_process_message(_group_message("/status"), is_command=True) is True def test_free_response_chats_bypass_mention_requirement():
-
1 PR closed without merging
From the close comments: closed without comment 1
- #6036 fix: slash commands now respect require_mention in Telegram groups · closed without comment
Closed issues · 1
- Closed#6033Telegram: slash commands bypass require_mention causing duplicate responses in multi-bot groups
How this cluster was grouped
-
Link evidence (
structural links throughout): every member is connected by structural evidence: shared changed files, or a closing/superseded reference. -
Pairwise link density
0.67: the share of item pairs that carry a link, counting a structural link in full and a relevance-only link at 0.36.1.00means every pair is linked.
Pick up a Lab task
Check whether a fix covers the open issues here, with your own agent. Bring back evidence for maintainers.
Open the LabAt a glance
- Merged PRs
- #13438
- Closed issues
- 1
- Attempts
- 1 PR closed without merging
- Fix link checked
- 21 Apr 2026. This confirmation is old and may be out of date (a revert or reopen would not have invalidated it here); re-verify.