Enable Telegram channel support in telegram plugin#1003
Open
Tristan-Wilson wants to merge 2 commits intoanthropics:mainfrom
Open
Enable Telegram channel support in telegram plugin#1003Tristan-Wilson wants to merge 2 commits intoanthropics:mainfrom
Tristan-Wilson wants to merge 2 commits intoanthropics:mainfrom
Conversation
Telegram's Bot API prevents bots from seeing other bots' messages in
groups, but this restriction doesn't apply to channels. This adds
channel_post handlers so the plugin can receive messages posted to
Telegram channels, enabling bot-to-bot communication via a private
channel.
Changes:
- Add ChannelPolicy type and channels field to Access config
- Add 'channel' case in gate() (handles undefined ctx.from)
- Add channel_post handlers for text, photo, document, voice, audio, video
- Adjust handleInbound() to fall back to ctx.channelPost when ctx.message
is undefined
- Update assertAllowedChat() to check channels
To activate, add a channel to access.json:
{ "channels": { "-100XXXXXXXXXX": { "allowFrom": [] } } }
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Without this, Grammy's long-polling doesn't subscribe to channel_post updates, so the bot never receives messages posted to channels even though the handlers are registered. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
mrf1n
approved these changes
Mar 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
channel_postsupport to the Telegram plugin, enabling bot-to-bot communication via Telegram channels.Telegram Bot API prevents bots from seeing other bots messages in groups — this is a hard platform limitation. However, this restriction does not apply to channels, where posts arrive as
channel_postupdates instead ofmessageupdates. This PR adds the necessary handlers and access control to receive and send channel posts, enabling use cases like coordinating multiple Claude Code instances via a private Telegram channel.Change 1: Channel post handlers and access control
ChannelPolicytype andchannelsfield toAccessconfig inaccess.jsonchannelcase ingate()— placed before thectx.fromcheck since channel posts may lack sender infochannel_post:*handlers for text, photo, document, voice, audio, video (mirrors existingmessage:*handlers)handleInbound()to fall back toctx.channelPostwhenctx.messageis undefined, and handle missingctx.fromassertAllowedChat()to checkchannelskeys for outbound messages (reply, react, etc.)Change 2: Include channel_post in polling allowed_updates
Grammy default long-polling does not subscribe to
channel_postupdates. Without explicitly including it inallowed_updates, the bot never receives channel posts even though the handlers are registered. This addsallowed_updates: ["message", "message_reaction", "channel_post"]to thebot.start()call.Configuration
Add a channel to
~/.claude/channels/telegram/access.json:{ "channels": { "-100XXXXXXXXXX": { "allowFrom": [] } } }allowFromaccepts all posts in the channel (the channel being listed is sufficient authorization)allowFromTest plan
reply(chat_id=...)channel_postupdates from the channel