fix(telegram): use effective_message in _handle_media_message for channel posts (#52126) - #52131
Conversation
…nnel posts Telegram channel broadcasts deliver messages via update.channel_post, not update.message. The _handle_media_message handler used update.message directly, causing all channel file attachments to be silently dropped. Use _effective_update_message() (the same pattern used by _handle_text_message and _handle_command) so channel-post documents, photos, voice, and other media are properly downloaded and cached. Fixes NousResearch#52126
Duplicate of #51747, which applies the identical |
|
Closing as duplicate of #51747, which applies the identical Both PRs solve the same root cause: channel-post media attachments (documents, photos) are silently dropped because Superseded by #51747. |
What does this PR do?
Fixes silent dropping of file attachments (documents, PDFs, images, voice, etc.) sent to Telegram channels. The
_handle_media_messagehandler usedupdate.messagedirectly, which isNonefor channel broadcasts (PTB puts them inupdate.channel_post). Switches to_effective_update_message()— the same pattern already used by_handle_text_messageand_handle_command.Related Issue
Fixes #52126
Type of Change
Changes Made
plugins/platforms/telegram/adapter.py: Replaceupdate.messagereferences in_handle_media_message()withmsg = self._effective_update_message(update)so channel-post media (documents, photos, voice, audio, video, stickers) is properly downloaded and cached.tests/gateway/test_telegram_channel_posts.py: Add regression testtest_media_handler_processes_channel_post_documentverifying channel-post documents are processed, not silently dropped.tests/gateway/test_telegram_documents.py: Update_make_update()fixture to setupdate.effective_message = msgso existing document tests work with the_effective_update_message()code path.How to Test
free_response_chatsandallowed_chatsin config.yaml to include the channelpytest tests/gateway/test_telegram_channel_posts.py tests/gateway/test_telegram_documents.py -q— all tests passChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/ACode Intelligence
plugins/platforms/telegram/adapter.py:_handle_media_message(callers: 1, flows: media message dispatch)_handle_text_messageand_handle_commandalready use_effective_update_message()for the same channel-post routing