Skip to content

Telegram: gate implicit topic replies behind a config flag - #69

Open
strk-ai-agent wants to merge 1 commit into
ominiverdi:mainfrom
strk-ai-agent:feat/telegram-gate-implicit-topic-replies
Open

Telegram: gate implicit topic replies behind a config flag#69
strk-ai-agent wants to merge 1 commit into
ominiverdi:mainfrom
strk-ai-agent:feat/telegram-gate-implicit-topic-replies

Conversation

@strk-ai-agent

Copy link
Copy Markdown
Contributor

Adds a new telegram.respondToImplicitTopicReplies flag (default true).

When set to false, the bot in a forum supergroup topic with threadIsolation: true only answers messages that match:

  • the configured trigger (e.g. !oc ...),
  • an @botname mention (when respondToMentions: true, default),
  • a swipe-reply to the bot's own message (when respondToReplies: true, default), or
  • an attachment (caption-less in a DM or in an active topic).

Plain messages in an active topic are dropped, while per-topic session isolation is preserved. Set respondToMentions: false and respondToReplies: false too if you want only trigger-prefixed messages and attachment-bearing messages to be forwarded.

Implementation notes:

  • The decision tree in handleUpdate is extracted into a pure resolveTelegramQuery helper so the new flag is covered by unit tests in isolation from the Telegram Bot API and the session manager.
  • 27 new unit tests in tests/unit/telegram-resolve-query.test.ts cover the routing rules, including the new flag.
  • README / docs already document how respondToMentions and respondToReplies work; this PR adds a parallel respondToImplicitTopicReplies to docs/TELEGRAM_SETUP.md.

Verification:

  • bun run typecheck
  • bun run check:connectors
  • bun test (383 pass, 0 fail)

Add telegram.respondToImplicitTopicReplies (default true) so that
forum-topic per-session isolation can be kept without forwarding every
plain message in an active topic. When set to false, the bot in a topic
only answers when the message matches the trigger, an @mention, a
swipe-reply to the bot, or carries an attachment.

The decision tree in handleUpdate is extracted into a pure resolveTelegramQuery
helper so the new flag is covered by unit tests in isolation from the
Telegram Bot API and the session manager.

Assisted-By: MiniMax-M3 [via opencode]
@strk

strk commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

I've tested and am successfully using this feature. It's backward compatible (nothing changes unless you add a new configuration). I can finally have Telegram topics w/out the bot answering every single line

Approved !

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.

2 participants