feat: add qqbot chat channel by buua436 · Pull Request #16140 · infiniflow/ragflow (original) (raw)
📝 Walkthrough
Walkthrough
Adds a new QQBotChannel integration: a QQBotAccount dataclass, an asyncio/websocket gateway client running in a dedicated OS thread with heartbeat and session-resume logic, inbound event normalization for four message types, outbound REST send, HTTP helpers, factory registration, bootstrap inclusion, and a UI filter extension.
Changes
QQBot Channel Integration
| Layer / File(s) | Summary |
|---|---|
| Account model, constants, and chat-id helpers api/channels/qqbot/channel.py | Introduces module imports, logger, URL constants, QQBotAccount dataclass, message sequence generation, and outbound/inbound chat_id normalization helpers per chat type. |
| QQBotChannel lifecycle and websocket thread api/channels/qqbot/channel.py | Implements start/stop lifecycle: spawns a daemon thread with its own asyncio event loop that runs the gateway reconnect loop (_run, _run_ws_session), then tears down tasks and joins the thread on stop. |
| Gateway payload handling, heartbeat, and identify/resume api/channels/qqbot/channel.py | _handle_ws_payload routes all gateway opcodes (heartbeat ack, identify/resume trigger, reconnect, invalid-session, READY, RESUMED, dispatch). _heartbeat_loop sends periodic heartbeat frames. _send_identify_or_resume sends either a resume or fresh identify payload with token, shard, and intents. |
| Inbound event normalization and outbound send api/channels/qqbot/channel.py | _normalize_incoming_event maps C2C, group, direct-message, and channel AT-message gateway events to IncomingMessage. send() validates chat_id, selects the correct REST path by chat type, builds the JSON payload with msg_seq and optional reply reference, and posts via _request_json. |
| HTTP helpers, factory, and channel registration api/channels/qqbot/channel.py | _get_access_token and _get_gateway_url fetch gateway credentials; _request_json centralizes authenticated HTTP with timeout and error handling. _build() validates config fields, constructs QQBotChannel/QQBotAccount, and registers the builder under "qqbot". |
| Bootstrap wiring and UI template filter api/channels/bootstrap.py, api/channels/qqbot/__init__.py, web/src/pages/user-setting/chat-channel/index.tsx | Adds "qqbot" to _BUNDLED_CHANNELS, adds the package-level channel import in __init__.py, and expands the channelTemplates filter in the React settings page to include ChatChannelKey.QQBOT. |
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs
- infiniflow/ragflow#16065: Modifies the same
channelTemplatesfilter inweb/src/pages/user-setting/chat-channel/index.tsx, restricting channels toDISCORDandFEISHU. - infiniflow/ragflow#16125: Also expands the same
channelTemplatesfilter inweb/src/pages/user-setting/chat-channel/index.tsxby addingTELEGRAM.
Suggested reviewers
- wangq8
Poem
🐰 A new bot hops into the queue,
QQBot channels now come into view!
Websockets ping with a heartbeat beat,
Opcodes and intents — oh what a feat!
The rabbit wired it, clean and bright,
Now QQ messages flow just right! 🎉
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | The title 'feat: add qqbot chat channel' clearly summarizes the main change - adding QQBot as a new chat channel implementation. |
| Description check | ✅ Passed | The description addresses the problem statement and includes the required type-of-change checkbox, fulfilling the template requirements with adequate detail. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment @coderabbitai help to get the list of available commands and usage tips.