fix(telegram): cannot send video message (#2536)#5430
fix(telegram): cannot send video message (#2536)#5430Soulter merged 1 commit intoAstrBotDevs:masterfrom
Conversation
Summary of ChangesHello @CCCCCCTV, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 此拉取请求旨在解决 Telegram 机器人无法发送视频且没有明确错误日志的问题。通过增强 Telegram 平台事件处理逻辑,现在可以正确识别和发送视频消息,并修正了消息线程参数的传递方式,从而提升了机器人在 Telegram 平台上的多媒体消息处理能力和稳定性。 Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Hey - 我发现了 1 个问题,并给出了一些整体性的反馈:
- 在
send_streaming中,payload现在已经包含了message_thread_id,但你在视频分支调用_send_media_with_action时又显式传入了message_thread_id=message_thread_id,这会导致重复的关键字参数;建议在所有使用到它的分支中,要么从 payload 中移除它,要么从显式参数中移除它。 - 在
send_with_client中,新的Video分支没有转发任何图文说明(与图片分支中使用caption=i.text or None不同),所以如果Video段可以包含说明文字,你可能也希望把caption传给send_video,以保持一致性。
给 AI Agent 的提示词
Please address the comments from this code review:
## Overall Comments
- In `send_streaming`, `payload` now includes `message_thread_id`, but you also pass `message_thread_id=message_thread_id` explicitly into `_send_media_with_action` for videos, which will cause a duplicate keyword argument; consider removing it from either the payload or the explicit arguments for all branches that use it.
- In `send_with_client`, the new `Video` branch does not forward any caption text (unlike the image branch using `caption=i.text or None`), so if `Video` segments can carry captions you may want to pass `caption` through to `send_video` as well for consistency.
## Individual Comments
### Comment 1
<location path="astrbot/core/platform/sources/telegram/tg_event.py" line_range="421" />
<code_context>
+ ChatAction.UPLOAD_VIDEO,
+ self.client.send_video,
+ user_name=user_name,
+ message_thread_id=message_thread_id,
+ video=path,
+ **cast(Any, payload),
</code_context>
<issue_to_address>
**issue (bug_risk):** Passing message_thread_id both explicitly and via **payload may cause a duplicate keyword error.
Since `payload["message_thread_id"] = message_thread_id` is set earlier in the streaming path, expanding `**payload` here while also passing `message_thread_id` explicitly will raise `TypeError: got multiple values for keyword argument 'message_thread_id'` when `message_thread_id` is truthy. Either drop the explicit argument here or stop adding `message_thread_id` to `payload` when you pass it separately.
</issue_to_address>帮我变得更有用!请对每条评论点下 👍 或 👎,我会根据你的反馈改进代码评审质量。
Original comment in English
Hey - I've found 1 issue, and left some high level feedback:
- In
send_streaming,payloadnow includesmessage_thread_id, but you also passmessage_thread_id=message_thread_idexplicitly into_send_media_with_actionfor videos, which will cause a duplicate keyword argument; consider removing it from either the payload or the explicit arguments for all branches that use it. - In
send_with_client, the newVideobranch does not forward any caption text (unlike the image branch usingcaption=i.text or None), so ifVideosegments can carry captions you may want to passcaptionthrough tosend_videoas well for consistency.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `send_streaming`, `payload` now includes `message_thread_id`, but you also pass `message_thread_id=message_thread_id` explicitly into `_send_media_with_action` for videos, which will cause a duplicate keyword argument; consider removing it from either the payload or the explicit arguments for all branches that use it.
- In `send_with_client`, the new `Video` branch does not forward any caption text (unlike the image branch using `caption=i.text or None`), so if `Video` segments can carry captions you may want to pass `caption` through to `send_video` as well for consistency.
## Individual Comments
### Comment 1
<location path="astrbot/core/platform/sources/telegram/tg_event.py" line_range="421" />
<code_context>
+ ChatAction.UPLOAD_VIDEO,
+ self.client.send_video,
+ user_name=user_name,
+ message_thread_id=message_thread_id,
+ video=path,
+ **cast(Any, payload),
</code_context>
<issue_to_address>
**issue (bug_risk):** Passing message_thread_id both explicitly and via **payload may cause a duplicate keyword error.
Since `payload["message_thread_id"] = message_thread_id` is set earlier in the streaming path, expanding `**payload` here while also passing `message_thread_id` explicitly will raise `TypeError: got multiple values for keyword argument 'message_thread_id'` when `message_thread_id` is truthy. Either drop the explicit argument here or stop adding `message_thread_id` to `payload` when you pass it separately.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
01a3067 to
84f9273
Compare
|
Generated docs update PR (pending manual review): AI change summary:
Experimental bot notice:
|
Fixes #2536 修复 Telegram 机器人无法发送视频且日志无明显报错的问题。
Modifications / 改动点
修复
astrbot/core/platform/sources/telegram/tg_event.py中的视频发送逻辑,确保视频文件正确传递给 Telegram API,从而解决发送失败但无报错的问题。
Checklist / 检查清单
requirements.txt和pyproject.toml文件相应位置。/ I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations inrequirements.txtandpyproject.toml.Summary by Sourcery
在普通发送和流式发送中正确处理 Telegram 视频消息,并修复基于线程的 Telegram 消息回复元数据问题。
Bug 修复:
message_thread_id而非reply_to_message_id,纠正线程元数据的使用。Original summary in English
Summary by Sourcery
Handle Telegram video messages correctly in both normal and streaming sends and fix thread-based reply metadata for Telegram messages.
Bug Fixes:
message_thread_idinstead ofreply_to_message_idfor threaded Telegram messages.