Skip to content

fix(telegram): add channel_post and edited_channel_post handlers#3683

Open
Bartok9 wants to merge 2 commits intoNousResearch:mainfrom
Bartok9:fix/telegram-channel-post-handling
Open

fix(telegram): add channel_post and edited_channel_post handlers#3683
Bartok9 wants to merge 2 commits intoNousResearch:mainfrom
Bartok9:fix/telegram-channel-post-handling

Conversation

@Bartok9
Copy link
Copy Markdown
Contributor

@Bartok9 Bartok9 commented Mar 29, 2026

Summary

Telegram channels post messages through update.channel_post instead of update.message. Previously the adapter only registered handlers for regular messages, causing channel content to be silently dropped even when the bot was a channel admin.

Changes

  • Add handlers for channel_post and edited_channel_post update types
  • Handle text, command, and media messages from channels
  • Extract sender info from sender_chat (channels don't have from_user)
  • Reuse existing batching/caching logic for consistency
  • Add comprehensive test coverage for channel post handling

Technical Details

The fix adds three new handlers that mirror the existing message handlers:

  • _handle_channel_text_message - batched text message handling
  • _handle_channel_command - immediate command processing
  • _handle_channel_media_message - photo/video/audio/document handling with caching

The _build_message_event method was updated to extract user info from sender_chat when from_user is None (which is the case for channel posts).

Testing

Added test_telegram_channel_posts.py with tests for:

  • Channel text message processing
  • Edited channel post handling
  • Command processing from channels
  • User info extraction from sender_chat
  • Edge cases (null posts, posts without text)

Fixes #3634

Bartok Moltbot added 2 commits March 29, 2026 03:33
Telegram channels post messages through update.channel_post instead of
update.message. Previously the adapter only registered handlers for
regular messages, causing channel content to be silently dropped even
when the bot was a channel admin.

Changes:
- Add handlers for channel_post and edited_channel_post update types
- Handle text, command, and media messages from channels
- Extract sender info from sender_chat (channels don't have from_user)
- Reuse existing batching/caching logic for consistency

The channel directory and session routing should now correctly include
channels where the bot is an admin.

Fixes NousResearch#3634
- Use 'platform' not '_platform' (matches base adapter)
- Remove invalid 'name' setter (name is a read-only property)
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.

Telegram adapter does not process channel_post updates

1 participant