AstrBot icon indicating copy to clipboard operation
AstrBot copied to clipboard

[Bug]Telegram 适配器对附件消息的 caption 处理不一致

Open Clhikari opened this issue 8 months ago • 1 comments

What happened / 发生了什么

当前观察到:

  • photo 分支会把 caption 写入 message.message_str,并追加 Comp.Plain(...)
  • document 分支没有处理 caption
  • video 分支也没有处理 caption

Reproduce / 如何复现?

  1. 在 Telegram 中发送一个文件或视频
  2. 同时填写说明文字(caption)
  3. 上层插件只能拿到 Comp.File / Comp.Video
  4. event.message_str 为空,说明文字丢失

AstrBot version, deployment method (e.g., Windows Docker Desktop deployment), provider used, and messaging platform used. / AstrBot 版本、部署方式(如 Windows Docker Desktop 部署)、使用的提供商、使用的消息平台适配器

telegram平台适配器

OS

Linux

Logs / 报错日志

建议统一处理 Telegram 附件 caption,至少覆盖:

  • photo
  • document
  • video

Are you willing to submit a PR? / 你愿意提交 PR 吗?

  • [x] Yes!

Code of Conduct

Clhikari avatar Mar 26 '26 09:03 Clhikari

确认这个 bug 存在。问题代码位于 tg_adapter.py 的 convert_message 函数:

  • photo(第 453-466 行):正确处理了 caption,写入 message_str 并追加 Comp.Plain,还处理了 caption_entities 的 mention
  • document(第 477-488 行):完全忽略 caption ❌
  • video(第 490-499 行):完全忽略 caption ❌

修复方案:在 document 和 video 分支中添加与 photo 相同的 caption 处理逻辑。另外建议也检查 audio、animation 等其他媒体类型是否有同样问题。

To reply, just mention @dosu.


Docs are dead. Just use Dosu.

Leave Feedback Ask Dosu about AstrBot Share Dosu with your team

dosubot[bot] avatar Mar 26 '26 09:03 dosubot[bot]