hermes - ✅(Solved) Fix [Feature] Add TELEGRAM_ALLOW_BOTS support (similar to DISCORD_ALLOW_BOTS) [1 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Telegram now officially supports Bot-to-Bot Communication. When enabled via BotFather, bots can see messages from other bots in groups. However, Hermes currently has no mechanism to control how Telegram bot messages are handled, leading to infinite reply loops between Hermes instances.

Discord already has DISCORD_ALLOW_BOTS with none/mentions/all modes (see gateway/run.py:2867-2874). Requesting the same for Telegram.

Root Cause

Setting require_mention: true does NOT prevent this because _should_process_message() (telegram.py:2326) treats replies as mentions:

PR fix notes

PR #13331: fix(telegram): add allow-bots gate

Description (problem / solution / changelog)

Fixes #13083.

Root cause: Telegram had group mention controls, but no equivalent to the Discord/Slack bot-message modes. Messages from other bots could be processed without an explicit Telegram-specific policy, while messages from Hermes itself needed to remain hard-blocked.

Fix summary:

  • Add telegram.allow_bots / TELEGRAM_ALLOW_BOTS with none, mentions, and all modes.
  • Always ignore messages authored by the Telegram bot itself.
  • Require explicit mention/reply for bot messages in mentions mode, and keep existing group gates in all mode.
  • Add regression coverage for default blocking, all/mentions modes, own-bot suppression, and config/env bridging.

Tests:

  • uv run --frozen --python 3.11 --extra dev pytest -o addopts= tests/gateway/test_telegram_group_gating.py -q
  • git diff --check -- gateway/config.py gateway/platforms/telegram.py tests/gateway/test_telegram_group_gating.py

Changed files

  • gateway/config.py (modified, +10/-0)
  • gateway/platforms/telegram.py (modified, +27/-0)
  • tests/gateway/test_telegram_group_gating.py (modified, +77/-1)
RAW_BUFFERClick to expand / collapse

Summary

Telegram now officially supports Bot-to-Bot Communication. When enabled via BotFather, bots can see messages from other bots in groups. However, Hermes currently has no mechanism to control how Telegram bot messages are handled, leading to infinite reply loops between Hermes instances.

Discord already has DISCORD_ALLOW_BOTS with none/mentions/all modes (see gateway/run.py:2867-2874). Requesting the same for Telegram.

Problem

When two Hermes bots are in the same Telegram group with Bot-to-Bot Communication Mode enabled:

  1. Bot A sends a message mentioning Bot B
  2. Bot B replies (using Telegram's reply feature)
  3. Gateway treats reply-to-bot as a mention (_is_reply_to_bot() returns True in _should_process_message())
  4. Bot A responds again → infinite loop

Setting require_mention: true does NOT prevent this because _should_process_message() (telegram.py:2326) treats replies as mentions:

extent analysis

TL;DR

Implement a mechanism to control how Telegram bot messages are handled, similar to Discord's DISCORD_ALLOW_BOTS feature, to prevent infinite reply loops between Hermes instances.

Guidance

  • Introduce a new configuration option for Telegram, e.g., TELEGRAM_ALLOW_BOTS, with modes like none, mentions, or all, to control bot message handling.
  • Modify the _should_process_message() function in telegram.py to consider the new configuration option when determining whether to process a message.
  • Update the gateway/run.py to include the new configuration option and handle Telegram bot messages accordingly.
  • Test the new feature with different configuration modes to ensure it prevents infinite reply loops.

Example

# Example configuration option
TELEGRAM_ALLOW_BOTS = 'none'  # or 'mentions', 'all'

# Example modification to _should_process_message()
def _should_process_message(message):
    if TELEGRAM_ALLOW_BOTS == 'none' and _is_reply_to_bot(message):
        return False
    # ... existing logic ...

Notes

The implementation details may vary depending on the existing codebase and requirements. This guidance provides a general direction to address the issue.

Recommendation

Apply a workaround by introducing a new configuration option, such as TELEGRAM_ALLOW_BOTS, to control how Telegram bot messages are handled, similar to the existing DISCORD_ALLOW_BOTS feature. This will allow for more fine-grained control over bot interactions and prevent infinite reply loops.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - ✅(Solved) Fix [Feature] Add TELEGRAM_ALLOW_BOTS support (similar to DISCORD_ALLOW_BOTS) [1 pull requests]