fix(telegram): apply _effective_update_message to _handle_media_message - #28813
fix(telegram): apply _effective_update_message to _handle_media_message#28813EloquentBrush0x wants to merge 1 commit into
Conversation
PR NousResearch#28531 fixed _handle_text_message, _handle_command, and _handle_location_message to use _effective_update_message so channel posts (update.channel_post; update.message == None) are routed correctly. _handle_media_message was missed: the `if not update.message: return` guard silently dropped all media channel posts (photos, videos, audio, documents, stickers). Apply the same pattern: resolve msg via _effective_update_message at the top of the handler and remove the now-redundant `msg = update.message` assignment. Add a regression test to test_telegram_channel_posts.py.
|
Thanks for the focused fix. I verified the premise against current remote Problems
Suggested changes
This is an automated hermes-sweeper review. |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for the focused regression fix. The premise remains valid on current main.
Problems
- The active adapter moved from
gateway/platforms/telegram.pytoplugins/platforms/telegram/adapter.pyin560010547, so this branch cannot be applied unchanged. - Current
_handle_media_messagestill rejects a channel post atplugins/platforms/telegram/adapter.py:7764, and its auth/observe paths continue to readupdate.messageat:7766-7786. Resolving only the original guard would leave those branches inconsistent with the effective message.
Suggested changes
- Salvage the fix in
plugins/platforms/telegram/adapter.py: bindmsg = self._effective_update_message(update)once and use it throughout_handle_media_message. - Port the media channel-post regression test into
tests/gateway/test_telegram_channel_posts.py; current coverage there stops at text and command handlers (:150-181).
This is an automated hermes-sweeper review.
| async def _handle_media_message(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: | ||
| """Handle incoming media messages, downloading images to local cache.""" | ||
| if not update.message: | ||
| msg = self._effective_update_message(update) |
There was a problem hiding this comment.
The active adapter has since moved to plugins/platforms/telegram/adapter.py (5600105). When salvaging this line, use the resolved msg for the current handler's authorization and unmentioned-group observation branches too; they still read update.message directly at current main :7766-7786.
Summary
PR #28531 introduced
_effective_update_messageand applied it to_handle_text_message,_handle_command, and_handle_location_messageso that Telegram channel posts (
update.channel_post;update.message == None)are routed correctly.
_handle_media_messagewas missed.Bug: the
if not update.message: returnguard at the top of_handle_media_messageexits immediately for every channel post, silentlydropping all channel media (photos, videos, audio, documents, stickers).
Fix: resolve
msgvia_effective_update_messageat the top of thehandler and remove the now-redundant
msg = update.messageassignment.Identical to the pattern already applied to the three sibling handlers.
Changes
gateway/platforms/telegram.py: apply_effective_update_messageto_handle_media_message(mirrors_handle_location_message)tests/gateway/test_telegram_channel_posts.py: addtest_media_handler_uses_effective_message_for_channel_post; extend_make_channel_messagewith media attribute stubsTest plan
scripts/run_tests.sh tests/gateway/test_telegram_channel_posts.py -q→ 4/4scripts/run_tests.sh tests/gateway/test_telegram_group_gating.py tests/gateway/test_telegram_channel_posts.py -q→ 30/30