Skip to content

feat: add QQ Bot media/file attachment support to send_message - #30347

Open
Henry-916 wants to merge 1 commit into
NousResearch:mainfrom
Henry-916:feat/qqbot-media-send
Open

feat: add QQ Bot media/file attachment support to send_message#30347
Henry-916 wants to merge 1 commit into
NousResearch:mainfrom
Henry-916:feat/qqbot-media-send

Conversation

@Henry-916

Copy link
Copy Markdown

Summary

This PR adds native image, video, audio, and file attachment delivery to QQ Bot via the send_message tool's MEDIA:<path> tag syntax.

Problem

QQ Bot had no path for MEDIA tag delivery. When users included MEDIA:/path/to/image.jpg in a message to QQ Bot, the send_message tool dropped attachments with a "not supported" warning — despite the QQ Bot adapter already having full send_image_file / send_document / chunked upload infrastructure.

Other platforms (Telegram, Discord, Signal, Yuanbao, Feishu) already had this support, but QQ Bot was missing from the media-supported platforms list.

Changes

tools/send_message_tool.py

  • Added _send_qqbot_media() async handler with chunked upload + RichMedia messaging
  • Added QQ Bot to the media-platform routing in _send_to_platform()
  • Updated the media-supported warning to include qqbot

gateway/run.py

  • Register QQAdapter singleton on creation via set_active_adapter()

gateway/platforms/qqbot/adapter.py

  • Added get_active_adapter() / set_active_adapter() singleton registry
  • Added send_qqbot_direct() helper for adapter-based media delivery

gateway/platforms/qqbot/__init__.py

  • Exported new public API functions

Testing

  • JPG image via MEDIA: tag → native image in QQ ✓
  • HTML file via MEDIA: tag → downloadable file in QQ ✓
  • Text + media combo messages ✓
  • Text-only messages unaffected ✓

@alt-glitch alt-glitch added type/feature New feature or request comp/gateway Gateway runner, session dispatch, delivery platform/qqbot QQ Bot adapter P2 Medium — degraded but workaround exists labels May 22, 2026
@gavin-luo

Copy link
Copy Markdown

I have also developed a plugin with identical functionality. It is designed as a plugin to avoid interfering with core code and main program flow.
It works with both lightweight models (gemma-4-E4B-it-Q4_K_M-unsloth.gguf) and high-performance models (DeepSeek-4-pro).
My goal is to enable Chinese users to send files and media via QQBot smoothly. Any compatible solution is acceptable.
You can find my plugin below, which runs stably on multiple Hermes Agent instances:
https://github.com/gavin-luo/HermesAgent-QQbot-file-sender

我也开发了一个相同功能的插件,做成“插件”方式是为了不干扰核心代码/主线流程。在弱小模型(gemma-4-E4B-it-Q4_K_M-unsloth.gguf)和强大模型(DeepSeek-4-pro )中均能使用。
我希望是让中国用户能无障碍的使用QQbot 发送文件和媒体,无论选择哪一种方案都能接受。
我开发的插件在下面,目前在我的多个 Hermes Agent中使用良好:
https://github.com/gavin-luo/HermesAgent-QQbot-file-sender

@Henry-916

Copy link
Copy Markdown
Author

Hey gavin-luo, thanks for sharing! Your plugin approach is definitely cleaner — no core code intrusion 👍

I went the PR route mainly because the QQ Bot adapter already had built-in send_image_file / send_document infrastructure, so it was just a matter of wiring it through send_message_tool. If upstream prefers the plugin approach, I'm totally fine closing this PR.

That said, your adapter registration pattern seems more flexible — would be great to sync up on where the two approaches overlap sometime!


gavin-luo,感谢分享!插件方案确实更优雅,不入侵核心代码 👍

我走 PR 路线主要是当时 Hermes 的 QQ Bot adapter 已经 built-in 了 send_image_file / send_document 这些基础设施,就差 send_message_tool 那边 routing 过去,顺手就改了。如果上游倾向合插件方案,我这边也没问题,大不了把 PR 关掉。

话说回来,插件方案的适配器注册方式感觉更灵活,有空可以交流一下两个方案的兼容点~

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for identifying a real gap: current send_message still omits QQBot MEDIA attachments (tools/send_message_tool.py:1034-1080), while QQAdapter already has native media methods (gateway/platforms/qqbot/adapter.py:2785-2941).

Problems

  • The new route calls a duplicate REST uploader, not the added send_qqbot_direct helper. It hard-codes chat_type = "c2c", omits guild delivery, and reports success even after missing files, missing file_info, or failed media POSTs (PR d7103c9d, tools/send_message_tool.py new _send_qqbot_media hunk at +1996).
  • The new sender loads ~/.hermes/.env directly, bypassing profile-aware get_hermes_home() behavior (hermes_constants.py:55-77).
  • No tests cover the new send_message route; existing QQ media coverage is adapter-level only (tests/gateway/test_qqbot.py:653-663).

Suggested changes

  • Route through the live QQAdapter and its existing send_image_file / send_video / send_voice / send_document methods, checking returned SendResult values.
  • Preserve adapter chat-type detection and profile-scoped configuration, and add focused routing/error tests.

Automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 13, 2026
@alt-glitch alt-glitch removed sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades labels Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/qqbot QQ Bot adapter sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants