Skip to content

feat: add QQ Bot integration with Official API v2 and voice STT#7268

Closed
topcheer wants to merge 1 commit into
NousResearch:mainfrom
topcheer:main
Closed

feat: add QQ Bot integration with Official API v2 and voice STT#7268
topcheer wants to merge 1 commit into
NousResearch:mainfrom
topcheer:main

Conversation

@topcheer

@topcheer topcheer commented Apr 10, 2026

Copy link
Copy Markdown

What does this PR do?

Adds complete QQ Bot integration using the Official QQ Bot API v2. The adapter connects to QQ's WebSocket Gateway for inbound events and uses the REST API (api.sgroup.qq.com) for outbound messages and media uploads.

The implementation follows the same architecture as the OpenClaw qqbot plugin (@openclaw/qqbot), the most battle-tested QQ Bot adapter in the ecosystem.

Related Issue

N/A (new platform integration)

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

Core adapter

  • gateway/platforms/qq.py — New QQAdapter (~1785 lines) using Official QQ Bot API v2
  • gateway/platforms/__init__.py — QQAdapter import/export
  • gateway/config.pyPlatform.QQ enum + env override for Official API v2 credentials
  • gateway/run.py — QQ adapter registration in _get_adapter_for_platform()

Voice STT

  • _process_attachments() — unified attachment processing for all message types (C2C/group/guild/DM)
  • _stt_voice_attachment() — 3-tier fallback: QQ asr_refer_textvoice_wav_url → configurable STT
  • _resolve_stt_config() / _call_stt() — configurable STT backend (OpenAI-compatible API)

Platform integration

  • hermes_cli/setup.py — new _setup_qq() + _GATEWAY_PLATFORMS registration + any_messaging + missing_home
  • hermes_cli/gateway.py — QQ _PLATFORMS entry with STT configuration vars
  • hermes_cli/config.pyQQ_STT_* / QQ_ALLOWED_USERS / QQ_HOME_CHANNEL env vars
  • hermes_cli/status.py — QQ status display
  • hermes_cli/tools_config.py — QQ toolset config
  • tools/send_message_tool.py — QQ send_message support
  • toolsets.pyhermes-gateway includes hermes-qq
  • cron/scheduler.py — QQ platform map
  • gateway/channel_directory.py — channel directory QQ support
  • agent/prompt_builder.py — QQ system prompt

Tests

  • tests/gateway/test_qq.py — 27 unit tests

Documentation

  • website/docs/user-guide/messaging/qq.md — new QQ Bot setup guide
  • website/docs/user-guide/messaging/index.md — QQ added to comparison table, architecture diagram, toolsets table, nav links
  • website/docs/reference/environment-variables.md — QQ env vars documented
  • cli-config.yaml.example — QQ added to supported platform keys and defaults
  • AGENTS.md — QQ added to platforms list

How to Test

  1. hermes setup gateway — select QQ, enter App ID + App Secret from q.qq.com
  2. Verify the bot connects via WebSocket Gateway: hermes gateway run
  3. Send a voice message in a QQ DM — verify it's transcribed using QQ's built-in ASR (no extra config)
  4. Send a text message in a group with @mention — verify the bot responds
  5. python -m pytest tests/gateway/test_qq.py -q — 27 tests pass

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (feat: add QQ Bot integration with Official API v2 and voice STT)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/gateway/test_qq.py -q and all tests pass (27 passed)
  • I've added tests for my changes (27 tests covering init, ACL, voice detection, STT config, message type detection)
  • I've tested on my platform: macOS

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings)
    • website/docs/user-guide/messaging/qq.md — new setup guide
    • website/docs/user-guide/messaging/index.md — comparison table, architecture, toolsets, nav
    • website/docs/reference/environment-variables.md — QQ env vars
  • I've updated cli-config.yaml.example — QQ added to supported platform keys and defaults
  • I've updated AGENTS.md — QQ added to platforms list
  • I've considered cross-platform impact — no platform-specific paths, no hardcoded ~/.hermes
  • I've updated tool descriptions/schemas — N/A (no new tools, uses existing send_message)

For New Skills

N/A (platform adapter, not a skill)

Copilot AI review requested due to automatic review settings April 10, 2026 16:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new QQ Bot messaging integration and wires it into the gateway/CLI tooling, including voice transcription support configuration, plus updates to toolset registration and platform routing.

Changes:

  • Introduces QQAdapter for Official QQ Bot API v2 (WebSocket gateway inbound + REST outbound), with attachment handling and optional STT fallback.
  • Registers QQ across CLI setup/config/status, toolsets, scheduler delivery, channel directory, and send_message routing.
  • Modifies gateway runner behavior around model/provider handling and command processing (notably /yolo, /usage, and model routing plumbing).

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 20 comments.

Show a summary per file
File Description
gateway/platforms/qq.py New QQ platform adapter implementation (gateway + REST + attachment/STT logic).
gateway/run.py Registers QQ adapter and adjusts gateway runner command/model behavior.
gateway/config.py Adds Platform.QQ and environment overrides for QQ credentials/home channel.
gateway/platforms/__init__.py Exports QQAdapter alongside other adapters.
hermes_cli/setup.py Adds interactive QQ setup flow (credentials + allowlist + STT prompts).
hermes_cli/gateway.py Adds QQ platform entry and documents required env vars for gateway runner UI.
hermes_cli/config.py Adds QQ env vars to known env key set used by config/.env tooling.
hermes_cli/status.py Displays QQ status fields (App ID + home channel).
hermes_cli/tools_config.py Adds QQ toolset mapping and platform enablement detection.
tools/send_message_tool.py Adds QQ as a send_message target and implements _send_qq().
toolsets.py Adds hermes-qq toolset and includes it in hermes-gateway.
cron/scheduler.py Adds QQ to cron delivery platform map.
gateway/channel_directory.py Adds QQ to session-derived channel directory population.
agent/prompt_builder.py Adds QQ-specific system prompt guidance for media sending.
.gitignore Ignores .ggcode/.
tests/gateway/test_qq.py Adds QQ tests (currently appear mismatched to the new adapter).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread toolsets.py Outdated
Comment thread tools/send_message_tool.py Outdated
Comment thread hermes_cli/tools_config.py Outdated
Comment thread gateway/config.py Outdated
Comment thread tests/gateway/test_qq.py Outdated
Comment thread hermes_cli/config.py Outdated
Comment thread gateway/run.py
Comment thread tests/gateway/test_qq.py Outdated
Comment thread gateway/run.py Outdated
Comment thread gateway/run.py
- Implement QQ Bot adapter using Official QQ Bot API v2 (WebSocket Gateway + REST API)
- Voice processing: prioritize QQ's built-in asr_refer_text, then voice_wav_url, then configurable STT
- Unified attachment processing (images, voice, files) for all message types (C2C/group/guild/DM)
- Configurable STT backend via config.yaml or QQ_STT_* environment variables
- Add QQ to hermes setup gateway, hermes gateway menu, config, status, and toolsets
- Add QQ platform integration: scheduler, channel directory, send_message_tool, cron support
- Add tests for QQ adapter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants