@cxyhhhhh/openclaw-qqbot 1.6.7-alpha.1 → 1.7.1-dev.202606041635

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/README.md +104 -24
  2. package/README.zh.md +104 -24
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.js +1 -0
  5. package/dist/src/api.d.ts +54 -9
  6. package/dist/src/api.js +182 -48
  7. package/dist/src/approval-handler.d.ts +47 -0
  8. package/dist/src/approval-handler.js +372 -0
  9. package/dist/src/channel.js +88 -12
  10. package/dist/src/config.d.ts +1 -1
  11. package/dist/src/config.js +5 -3
  12. package/dist/src/gateway.js +221 -217
  13. package/dist/src/message-queue.d.ts +5 -0
  14. package/dist/src/outbound-deliver.js +8 -8
  15. package/dist/src/outbound.d.ts +15 -0
  16. package/dist/src/outbound.js +52 -3
  17. package/dist/src/ref-index-store.d.ts +31 -0
  18. package/dist/src/ref-index-store.js +49 -1
  19. package/dist/src/request-context.d.ts +7 -0
  20. package/dist/src/request-context.js +7 -0
  21. package/dist/src/runtime.js +3 -0
  22. package/dist/src/slash-commands.d.ts +7 -2
  23. package/dist/src/slash-commands.js +795 -38
  24. package/dist/src/streaming.d.ts +6 -9
  25. package/dist/src/streaming.js +25 -40
  26. package/dist/src/tools/channel.js +1 -3
  27. package/dist/src/tools/remind.js +17 -9
  28. package/dist/src/transport/index.d.ts +10 -0
  29. package/dist/src/transport/index.js +9 -0
  30. package/dist/src/transport/webhook-transport.d.ts +67 -0
  31. package/dist/src/transport/webhook-transport.js +245 -0
  32. package/dist/src/transport/webhook-verify.d.ts +48 -0
  33. package/dist/src/transport/webhook-verify.js +98 -0
  34. package/dist/src/types.d.ts +117 -21
  35. package/dist/src/types.js +5 -0
  36. package/dist/src/update-checker.d.ts +3 -1
  37. package/dist/src/update-checker.js +13 -2
  38. package/dist/src/utils/audio-convert.js +37 -9
  39. package/dist/src/utils/chunked-upload.d.ts +11 -2
  40. package/dist/src/utils/chunked-upload.js +63 -11
  41. package/dist/src/utils/media-send.d.ts +12 -2
  42. package/dist/src/utils/media-send.js +84 -38
  43. package/dist/src/utils/media-tags.js +2 -1
  44. package/dist/src/utils/pkg-version.js +19 -9
  45. package/dist/src/utils/text-parsing.d.ts +4 -5
  46. package/dist/src/utils/text-parsing.js +17 -12
  47. package/index.ts +1 -0
  48. package/openclaw.plugin.json +6 -1
  49. package/package.json +4 -1
  50. package/scripts/postinstall-link-sdk.js +66 -9
  51. package/scripts/upgrade-via-npm.ps1 +9 -0
  52. package/scripts/upgrade-via-npm.sh +998 -385
  53. package/scripts/upgrade-via-source.sh +234 -87
  54. package/skills/qqbot-remind/SKILL.md +21 -11
  55. package/skills/qqbot-upgrade/SKILL.md +50 -0
  56. package/src/api.ts +228 -46
  57. package/src/approval-handler.ts +505 -0
  58. package/src/channel.ts +93 -11
  59. package/src/config.ts +5 -3
  60. package/src/gateway.ts +230 -215
  61. package/src/message-queue.ts +5 -0
  62. package/src/openclaw-plugin-sdk.d.ts +129 -2
  63. package/src/outbound-deliver.ts +21 -8
  64. package/src/outbound.ts +62 -2
  65. package/src/ref-index-store.ts +78 -1
  66. package/src/request-context.ts +10 -0
  67. package/src/runtime.ts +3 -0
  68. package/src/slash-commands.ts +836 -38
  69. package/src/streaming.ts +29 -54
  70. package/src/tools/channel.ts +1 -5
  71. package/src/tools/remind.ts +17 -9
  72. package/src/transport/index.ts +11 -0
  73. package/src/transport/webhook-transport.ts +332 -0
  74. package/src/transport/webhook-verify.ts +119 -0
  75. package/src/types.ts +135 -21
  76. package/src/typings/openclaw-webhook-ingress.d.ts +66 -0
  77. package/src/update-checker.ts +14 -2
  78. package/src/utils/audio-convert.ts +37 -9
  79. package/src/utils/chunked-upload.ts +76 -12
  80. package/src/utils/media-send.ts +89 -38
  81. package/src/utils/media-tags.ts +2 -1
  82. package/src/utils/pkg-version.ts +18 -8
  83. package/src/utils/text-parsing.ts +21 -11
package/README.md CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  **Connect your AI assistant to QQ — private chat, group chat, and rich media, all in one plugin.**
12
12
 
13
- ### 🚀 Current Version: `v1.6.5`
13
+ ### 🚀 Current Version: `v1.7.1`
14
14
 
15
15
  [![License](https://img.shields.io/badge/license-MIT-green)](./LICENSE)
16
16
  [![QQ Bot](https://img.shields.io/badge/QQ_Bot-API_v2-red)](https://bot.q.qq.com/wiki/)
@@ -25,7 +25,7 @@
25
25
 
26
26
  Scan to join the QQ group chat
27
27
 
28
- <img width="400" alt="QQ QR Code" src="./docs/images/developer_group.png" />
28
+ <img width="400" alt="QQ QR Code" src="./docs/images/developer-group.png" />
29
29
 
30
30
 
31
31
  </div>
@@ -37,6 +37,7 @@ Scan to join the QQ group chat
37
37
  | Feature | Description |
38
38
  |---------|-------------|
39
39
  | 🔒 **Multi-Scene** | C2C private chat, group @messages |
40
+ | 🌐 **Dual Transport** | WebSocket (default) or Webhook (HTTP callback) — switch via config |
40
41
  | 🖼️ **Rich Media** | Send & receive images, voice, video, and files |
41
42
  | 🎙️ **Voice (STT/TTS)** | Speech-to-text transcription & text-to-speech replies |
42
43
  | 🔥 **One-Click Hot Upgrade** | Send `/bot-upgrade` in private chat to upgrade — no server login needed |
@@ -45,7 +46,9 @@ Scan to join the QQ group chat
45
46
  | ⌨️ **Typing Indicator** | "Bot is typing..." status shown in real-time |
46
47
  | 📝 **Markdown** | Full Markdown formatting support |
47
48
  | 🛠️ **Commands** | Native OpenClaw command integration |
48
- | 💬 **Quoted Context** | Resolve QQ `REFIDX_*` quoted messages and inject quote body into AI context |
49
+ | 💬 **Quoted Context** | Parses the original message a user is replying to and injects it into AI context, so the model always knows exactly which message is being referenced |
50
+ | 📦 **Large File Support** | Auto chunked upload for large files (parallel upload with retry), up to 100 MB |
51
+ | 🔐 **Command Execution Approval** | AI requests approval via Inline Keyboard buttons before executing commands — tap to allow or deny |
49
52
 
50
53
  ---
51
54
 
@@ -53,15 +56,11 @@ Scan to join the QQ group chat
53
56
 
54
57
  > **Note:** This plugin serves as a **message channel** only — it relays messages between QQ and OpenClaw. Capabilities like image understanding, voice transcription, drawing, etc. depend on the **AI model** you configure and the **skills** installed in OpenClaw, not on this plugin itself.
55
58
 
56
- ### 💬 Quoted Message Context (REFIDX)
59
+ ### 💬 Quoted Message Context
57
60
 
58
- QQ quote events carry index keys (e.g. `REFIDX_xxx`) instead of full original message body. The plugin now resolves these indices from a local persistent store and injects quote context into AI input, so replies better understand “which message is being quoted”.
61
+ When a user quotes a message in QQ, the plugin automatically parses the quoted message content and injects it into the AI context, so the model clearly knows "which message the user is replying to" and gives more accurate responses. Supports text and media messages (image/voice/video/file), and works across devices.
59
62
 
60
- - Inbound and outbound messages with `ref_idx` are automatically indexed.
61
- - Store path: `~/.openclaw/qqbot/data/ref-index.jsonl` (survives gateway restart).
62
- - Quote body may include text + media summary (image/voice/video/file).
63
-
64
- <img width="360" src="docs/images/ref_msg.png" alt="Quoted Message Context Demo" />
63
+ <img width="360" src="docs/images/ref-msg.png" alt="Quoted Message Context Demo" />
65
64
 
66
65
  ### 🎙️ Voice Messages (STT)
67
66
 
@@ -71,7 +70,7 @@ With STT configured, the plugin automatically transcribes voice messages to text
71
70
  >
72
71
  > **QQBot**: Tomorrow (March 7, Saturday) Shenzhen weather forecast 🌤️ ...
73
72
 
74
- <img width="360" src="docs/images/fc7b2236896cfba3a37c94be5d59ce3e_720.jpg" alt="Voice STT Demo" />
73
+ <img width="360" src="docs/images/voice-stt.jpg" alt="Voice STT Demo" />
75
74
 
76
75
  ### 📄 File Understanding
77
76
 
@@ -81,7 +80,7 @@ Send any file to the bot — novels, reports, spreadsheets — AI automatically
81
80
  >
82
81
  > **QQBot**: Got it! You uploaded the Chinese version of "War and Peace" by Leo Tolstoy. This appears to be the opening of Chapter 1...
83
82
 
84
- <img width="360" src="docs/images/07bff56ab68e03173d2af586eeb3bcee_720.jpg" alt="File Understanding Demo" />
83
+ <img width="360" src="docs/images/file-understand.jpg" alt="File Understanding Demo" />
85
84
 
86
85
  ### 🖼️ Image Understanding
87
86
 
@@ -91,7 +90,7 @@ If your main model supports vision (e.g. Tencent Hunyuan `hunyuan-vision`), AI c
91
90
  >
92
91
  > **QQBot**: Haha, so cute! Is that a QQ penguin in a lobster costume? 🦞🐧 ...
93
92
 
94
- <img width="360" src="docs/images/59d421891f813b0d3c0cbe12574b6a72_720.jpg" alt="Image Understanding Demo" />
93
+ <img width="360" src="docs/images/image-understand.jpg" alt="Image Understanding Demo" />
95
94
 
96
95
  ### 🎨 Image Sending
97
96
 
@@ -101,7 +100,7 @@ If your main model supports vision (e.g. Tencent Hunyuan `hunyuan-vision`), AI c
101
100
 
102
101
  AI can send images directly. Supports local paths and URLs. Formats: jpg/png/gif/webp/bmp.
103
102
 
104
- <img width="360" src="docs/images/4645f2b3a20822b7f8d6664a708529eb_720.jpg" alt="Image Generation Demo" />
103
+ <img width="360" src="docs/images/image-send.jpg" alt="Image Generation Demo" />
105
104
 
106
105
  ### 🔊 Voice Sending
107
106
 
@@ -111,7 +110,7 @@ AI can send images directly. Supports local paths and URLs. Formats: jpg/png/gif
111
110
 
112
111
  AI can send voice messages directly. Formats: mp3/wav/silk/ogg. No ffmpeg required.
113
112
 
114
- <img width="360" src="docs/images/21dce8bfc553ce23d1bd1b270e9c516c.jpg" alt="TTS Voice Demo" />
113
+ <img width="360" src="docs/images/voice-send.jpg" alt="TTS Voice Demo" />
115
114
 
116
115
  ### ⏰ Scheduled Reminder (Proactive Message)
117
116
 
@@ -129,9 +128,21 @@ This capability depends on OpenClaw cron scheduling and proactive messaging. If
129
128
  >
130
129
  > **QQBot**: *(sends a .txt file)*
131
130
 
132
- AI can send files directly. Any format, up to 20MB.
131
+ AI can send files directly, in any format.
132
+
133
+ <img width="360" src="docs/images/file-send.jpg" alt="File Sending Demo" />
134
+
135
+ Since v1.6.6, large file transfer is supported: images up to 20MB, videos up to 30MB, attachments up to 100MB, with a daily transfer limit of 2GB.
136
+
137
+ <img width="360" src="docs/images/large-file-transfer.jpg" alt="Large File Transfer Demo" />
138
+
139
+ ### 🔐 Command Execution Approval
133
140
 
134
- <img width="360" src="docs/images/17cada70df90185d45a2d6dd36e92f2f_720.jpg" alt="File Sending Demo" />
141
+ When the AI needs to execute a command, the plugin sends an approval request via QQ message with interactive buttons — tap **✅ Allow Once**, **⭐ Always Allow**, or **❌ Deny** to control whether the command runs.
142
+
143
+ Use the `/bot-approve` command to manage the approval mode (allowlist / off / strict).
144
+
145
+ <img width="360" src="docs/images/approve.png" alt="Command Execution Approval Demo" />
135
146
 
136
147
  ### 🎬 Video Sending
137
148
 
@@ -141,7 +152,7 @@ AI can send files directly. Any format, up to 20MB.
141
152
 
142
153
  AI can send videos directly. Supports local files and URLs.
143
154
 
144
- <img width="360" src="docs/images/85d03b8a216f267ab7b2aee248a18a41_720.jpg" alt="Video Sending Demo" />
155
+ <img width="360" src="docs/images/video-send.jpg" alt="Video Sending Demo" />
145
156
 
146
157
  > **Under the hood:** Upload dedup caching, ordered queue delivery, and multi-layer audio format fallback.
147
158
 
@@ -187,6 +198,11 @@ Credentials are automatically backed up before upgrade. Version existence is ver
187
198
 
188
199
  > ⚠️ Hot upgrade is currently not supported on Windows. Sending `/bot-upgrade` on Windows will return a manual upgrade guide instead.
189
200
 
201
+ > ⚠️ v1.6.6 and below do not support hot upgrade via `/bot-upgrade`. Please upgrade using the following command:
202
+ > ```bash
203
+ > curl -fsSL https://raw.githubusercontent.com/tencent-connect/openclaw-qqbot/main/scripts/upgrade-via-npm.sh | bash
204
+ > ```
205
+
190
206
  <img width="360" src="docs/images/hot-update.jpg" alt="Hot Upgrade Demo" />
191
207
 
192
208
  #### `/bot-logs` — Log Export
@@ -207,6 +223,26 @@ All commands support a `?` suffix to show usage:
207
223
  >
208
224
  > **QQBot**: 📖 /bot-upgrade usage: …
209
225
 
226
+ #### `/bot-approve` — Approval Configuration
227
+
228
+ > **You**: `/bot-approve`
229
+ >
230
+ > **QQBot**: 🔐 Command Execution Approval — Enable / Disable / Strict mode / Reset / View current config
231
+
232
+ Manage the AI command execution approval policy. Supported subcommands:
233
+
234
+ | Subcommand | Description |
235
+ |------------|-------------|
236
+ | `/bot-approve on` | Enable approval (allowlist mode, recommended) |
237
+ | `/bot-approve off` | Disable approval — commands execute directly |
238
+ | `/bot-approve always` | Strict mode — every execution requires approval |
239
+ | `/bot-approve reset` | Restore framework defaults |
240
+ | `/bot-approve status` | View current approval config |
241
+
242
+ #### `/bot-clear-storage` — Clear files generated through QQBot conversations and downloaded resources (stored on the host running OpenClaw)
243
+
244
+ `/bot-clear-storage` lists files generated by the conversation and files in the downloaded resources directory. Use `/bot-clear-storage --force` to confirm deletion.
245
+
210
246
  ---
211
247
 
212
248
  ## 🚀 Getting Started
@@ -220,15 +256,15 @@ All commands support a `?` suffix to show usage:
220
256
  2. After scanning, tap **Agree** on your phone — you'll land on the bot configuration page.
221
257
  3. Click **Create Bot** to create a new QQ bot.
222
258
 
223
- <img width="720" alt="Create Bot" src="docs/images/create_robot.png" />
259
+ <img width="720" alt="Create Bot" src="docs/images/create-robot.png" />
224
260
 
225
261
  > ⚠️ The bot will automatically appear in your QQ message list and send a first message. However, it will reply "The bot has gone to Mars" until you complete the configuration steps below.
226
262
 
227
- <img width="400" alt="Bot Say Hello" src="docs/images/bot_say_hello.jpg" />
263
+ <img width="400" alt="Bot Say Hello" src="docs/images/bot-say-hello.jpg" />
228
264
 
229
265
  4. Find **AppID** and **AppSecret** on the bot's page, click **Copy** for each, and save them somewhere safe (e.g., a notepad). **AppSecret is not stored in plaintext — if you leave the page without saving it, you'll have to regenerate a new one.**
230
266
 
231
- <img width="720" alt="Find AppID and AppSecret" src="docs/images/find_appid_secret.png" />
267
+ <img width="720" alt="Find AppID and AppSecret" src="docs/images/find-appid-secret.png" />
232
268
 
233
269
  > For a step-by-step walkthrough with screenshots, see the [official guide](https://cloud.tencent.com/developer/article/2626045).
234
270
 
@@ -243,7 +279,7 @@ curl -fsSL https://raw.githubusercontent.com/tencent-connect/openclaw-qqbot/main
243
279
 
244
280
  One command does it all: download script → cleanup old plugins → install → configure channel → restart service. Once done, open QQ and start chatting!
245
281
 
246
- > `--appid` and `--secret` are **required for first-time install**. For subsequent upgrades:
282
+ > `--appid` and `--secret` are **required for first-time install**. For subsequent upgrades, run the following command to upgrade to the latest version:
247
283
  > ```bash
248
284
  > curl -fsSL https://raw.githubusercontent.com/tencent-connect/openclaw-qqbot/main/scripts/upgrade-via-npm.sh | bash
249
285
  > ```
@@ -373,12 +409,56 @@ openclaw message send --channel "qqbot" \
373
409
 
374
410
  #### How It Works
375
411
 
376
- - When `openclaw gateway` starts, all accounts with `enabled: true` launch their own WebSocket connections
412
+ - When `openclaw gateway` starts, all accounts with `enabled: true` launch their own connections (WebSocket or Webhook depending on `transport` config)
377
413
  - Each account maintains an independent Token cache (isolated by `appId`), preventing cross-contamination
378
414
  - Incoming message logs are prefixed with `[qqbot:accountId]` for easy debugging
379
415
 
380
416
  ---
381
417
 
418
+ ### Webhook Transport Mode
419
+
420
+ By default, the plugin connects to QQ via **WebSocket** (outbound connection, no public IP required). You can switch to **Webhook** mode where QQ platform POSTs events to your HTTP endpoint.
421
+
422
+ | | WebSocket (default) | Webhook |
423
+ |---|---|---|
424
+ | Connection | Plugin connects to QQ gateway | QQ platform POSTs to your server |
425
+ | Public IP | Not required | Required |
426
+ | Use case | Development, single instance | Production, horizontal scaling, Serverless |
427
+ | Session resume | Supported (RESUME) | Stateless, no resume needed |
428
+ | Signature | Built-in | Ed25519 auto-verified by plugin |
429
+
430
+ #### Configuration
431
+
432
+ ```json
433
+ {
434
+ "channels": {
435
+ "qqbot": {
436
+ "appId": "111111111",
437
+ "clientSecret": "your-secret",
438
+ "transport": "webhook",
439
+ "webhook": {
440
+ "path": "/qqbot/webhook"
441
+ }
442
+ }
443
+ }
444
+ }
445
+ ```
446
+
447
+ | Field | Default | Description |
448
+ |-------|---------|-------------|
449
+ | `transport` | `"websocket"` | `"websocket"` or `"webhook"` |
450
+ | `webhook.path` | `"/qqbot/webhook"` | HTTP path for receiving callbacks |
451
+
452
+ #### Platform Setup
453
+
454
+ 1. Go to [QQ Open Platform](https://q.qq.com/) → Bot Settings → Message Receiving
455
+ 2. Select **HTTP Callback**
456
+ 3. Enter your callback URL: `https://your-domain.com/qqbot/webhook`
457
+ 4. The platform sends an `op:13` validation request — the plugin handles it automatically
458
+ 5. Once validated, all events will be POSTed to your endpoint
459
+
460
+ ---
461
+
382
462
  ### Voice Configuration (STT / TTS)
383
463
 
384
464
  #### STT (Speech-to-Text) — Transcribe Incoming Voice Messages
@@ -458,7 +538,7 @@ Special thanks to [@sliverp](https://github.com/sliverp) for outstanding contrib
458
538
  Thanks to [Tencent Cloud Lighthouse](https://cloud.tencent.com/product/lighthouse) for the deep collaboration. For raising crawfish, choose Tencent Cloud Lighthouse!
459
539
 
460
540
  <a href="https://cloud.tencent.com/product/lighthouse">
461
- <img alt="Tencent Cloud Lighthouse" src="./docs/images/lighthouse_head.png" height="500" style="max-width:80%; height:auto;"/>
541
+ <img alt="Tencent Cloud Lighthouse" src="./docs/images/lighthouse-head.png" height="500" style="max-width:80%; height:auto;"/>
462
542
  </a>
463
543
 
464
544
  ## ⭐ Star History
package/README.zh.md CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  **让你的 AI 助手接入 QQ — 私聊、群聊、富媒体,一个插件全搞定。**
11
11
 
12
- ### 🚀 当前版本: `v1.6.5`
12
+ ### 🚀 当前版本: `v1.7.1`
13
13
 
14
14
  [![License](https://img.shields.io/badge/license-MIT-green)](./LICENSE)
15
15
  [![QQ Bot](https://img.shields.io/badge/QQ_Bot-API_v2-red)](https://bot.q.qq.com/wiki/)
@@ -21,7 +21,7 @@
21
21
 
22
22
  扫描二维码加入群聊,一起交流
23
23
 
24
- <img width="400" alt="QQ 群二维码" src="./docs/images/developer_group.png" />
24
+ <img width="400" alt="QQ 群二维码" src="./docs/images/developer-group.png" />
25
25
 
26
26
  </div>
27
27
 
@@ -32,6 +32,7 @@
32
32
  | 功能 | 说明 |
33
33
  |------|------|
34
34
  | 🔒 **多场景支持** | C2C 私聊、群聊 @消息 |
35
+ | 🌐 **双传输模式** | WebSocket(默认)或 Webhook(HTTP 回调)— 配置切换 |
35
36
  | 🖼️ **富媒体消息** | 支持图片、语音、视频、文件的收发 |
36
37
  | 🎙️ **语音能力 (STT/TTS)** | 语音转文字自动转录 & 文字转语音回复 |
37
38
  | 🔥 **一键热更新** | 私聊发送 `/bot-upgrade` 即可完成版本升级,无需登录服务器 |
@@ -40,7 +41,9 @@
40
41
  | ⌨️ **输入状态** | 实时显示"Bot 正在输入中…"状态 |
41
42
  | 📝 **Markdown** | 完整支持 Markdown 格式消息 |
42
43
  | 🛠️ **原生命令** | 支持 OpenClaw 原生命令 |
43
- | 💬 **引用上下文** | 解析 QQ `REFIDX_*` 引用消息,并将引用内容注入 AI 上下文 |
44
+ | 💬 **引用上下文** | 解析用户回复的原始消息内容,注入 AI 上下文,让模型准确理解"在回复哪条消息" |
45
+ | 📦 **大文件支持** | 大文件自动分片并行上传,最大支持 100 MB |
46
+ | 🔐 **命令执行审批** | AI 执行命令前通过按钮消息请求审批,点击即可允许或拒绝 |
44
47
 
45
48
  ---
46
49
 
@@ -48,15 +51,11 @@
48
51
 
49
52
  > **说明:** 本插件仅作为**消息通道**,负责在 QQ 和 OpenClaw 之间传递消息。图片理解、语音转录、AI 画图等能力取决于你配置的 **AI 模型**以及在 OpenClaw 中安装的 **skill**,而非插件本身提供。
50
53
 
51
- ### 💬 引用消息上下文(REFIDX)
54
+ ### 💬 引用消息上下文
52
55
 
53
- QQ 的引用事件通常只携带索引键(如 `REFIDX_xxx`),不直接返回原始消息全文。插件已支持从本地持久化索引中解析引用内容,并注入 AI 上下文,帮助模型更准确理解“用户引用的是哪条消息”。
56
+ 用户在 QQ 中引用某条消息发送时,插件会自动解析被引用的消息内容并注入 AI 上下文,让模型清楚地知道"用户在回复哪条消息",从而给出更准确的回复。支持文本及媒体消息(图片/语音/视频/文件),换设备后同样可用。
54
57
 
55
- - 入站/出站消息中的 `ref_idx` 会自动建立索引。
56
- - 存储位置:`~/.openclaw/qqbot/data/ref-index.jsonl`(网关重启后仍可恢复)。
57
- - 引用内容支持文本 + 媒体摘要(图片/语音/视频/文件)。
58
-
59
- <img width="360" src="docs/images/ref_msg.png" alt="引用消息上下文演示" />
58
+ <img width="360" src="docs/images/ref-msg.png" alt="引用消息上下文演示" />
60
59
 
61
60
  ### 🎙️ 语音消息(STT)
62
61
 
@@ -66,7 +65,7 @@ QQ 的引用事件通常只携带索引键(如 `REFIDX_xxx`),不直接返
66
65
  >
67
66
  > **QQBot**:明天(3月7日 周六)深圳的天气预报 🌤️ ...
68
67
 
69
- <img width="360" src="docs/images/fc7b2236896cfba3a37c94be5d59ce3e_720.jpg" alt="听语音演示" />
68
+ <img width="360" src="docs/images/voice-stt.jpg" alt="听语音演示" />
70
69
 
71
70
  ### 📄 文件理解
72
71
 
@@ -76,7 +75,7 @@ QQ 的引用事件通常只携带索引键(如 `REFIDX_xxx`),不直接返
76
75
  >
77
76
  > **QQBot**:收到!你上传了列夫·托尔斯泰的《战争与和平》中文版文本。从内容来看,这是第一章的开头……你想让我做什么?
78
77
 
79
- <img width="360" src="docs/images/07bff56ab68e03173d2af586eeb3bcee_720.jpg" alt="AI理解用户发送的文件" />
78
+ <img width="360" src="docs/images/file-understand.jpg" alt="AI理解用户发送的文件" />
80
79
 
81
80
  ### 🖼️ 图片理解
82
81
 
@@ -86,7 +85,7 @@ QQ 的引用事件通常只携带索引键(如 `REFIDX_xxx`),不直接返
86
85
  >
87
86
  > **QQBot**:哈哈,好可爱!这是QQ企鹅穿上小龙虾套装吗?🦞🐧 ...
88
87
 
89
- <img width="360" src="docs/images/59d421891f813b0d3c0cbe12574b6a72_720.jpg" alt="图片理解演示" />
88
+ <img width="360" src="docs/images/image-understand.jpg" alt="图片理解演示" />
90
89
 
91
90
  ### 🎨 图片发送
92
91
 
@@ -96,7 +95,7 @@ QQ 的引用事件通常只携带索引键(如 `REFIDX_xxx`),不直接返
96
95
 
97
96
  AI 可直接发送图片,支持本地文件路径和网络 URL。格式:jpg/png/gif/webp/bmp。
98
97
 
99
- <img width="360" src="docs/images/4645f2b3a20822b7f8d6664a708529eb_720.jpg" alt="发图片演示" />
98
+ <img width="360" src="docs/images/image-send.jpg" alt="发图片演示" />
100
99
 
101
100
  ### 🔊 语音发送
102
101
 
@@ -106,7 +105,7 @@ AI 可直接发送图片,支持本地文件路径和网络 URL。格式:jpg/
106
105
 
107
106
  AI 可直接发送语音消息。格式:mp3/wav/silk/ogg,无需安装 ffmpeg。
108
107
 
109
- <img width="360" src="docs/images/21dce8bfc553ce23d1bd1b270e9c516c.jpg" alt="发语音演示" />
108
+ <img width="360" src="docs/images/voice-send.jpg" alt="发语音演示" />
110
109
 
111
110
  ### ⏰ 定时提醒(主动消息)
112
111
 
@@ -124,9 +123,21 @@ AI 可直接发送语音消息。格式:mp3/wav/silk/ogg,无需安装 ffmpeg
124
123
  >
125
124
  > **QQBot**:*(发送 .txt 文件)*
126
125
 
127
- AI 可直接发送文件。任意格式,最大 20MB。
126
+ AI 可直接发送文件,任意格式均可。
127
+
128
+ <img width="360" src="docs/images/file-send.jpg" alt="发文件演示" />
129
+
130
+ v1.6.6 起支持大文件传输:图片最大 20MB,视频最大 30MB,附件最大 100MB,每日累计传输上限 2GB。
131
+
132
+ <img width="360" src="docs/images/large-file-transfer.jpg" alt="大文件传输演示" />
133
+
134
+ ### 🔐 命令执行审批
128
135
 
129
- <img width="360" src="docs/images/17cada70df90185d45a2d6dd36e92f2f_720.jpg" alt="发文件演示" />
136
+ AI 需要执行命令时,插件会通过 QQ 消息发送带按钮的审批请求,你可以点击 **✅ 允许一次**、**⭐ 始终允许** 或 **❌ 拒绝** 来控制命令是否执行。
137
+
138
+ 通过 `/bot-approve` 指令可以管理审批模式(白名单 / 关闭 / 严格模式)。
139
+
140
+ <img width="360" src="docs/images/approve.png" alt="命令执行审批演示" />
130
141
 
131
142
  ### 🎬 视频发送
132
143
 
@@ -136,7 +147,7 @@ AI 可直接发送文件。任意格式,最大 20MB。
136
147
 
137
148
  AI 可直接发送视频,支持本地文件和公网 URL。
138
149
 
139
- <img width="360" src="docs/images/85d03b8a216f267ab7b2aee248a18a41_720.jpg" alt="发视频演示" />
150
+ <img width="360" src="docs/images/video-send.jpg" alt="发视频演示" />
140
151
 
141
152
  > **底层细节:** 上传去重缓存、有序队列发送、音频格式多层降级。
142
153
 
@@ -182,6 +193,11 @@ AI 可直接发送视频,支持本地文件和公网 URL。
182
193
 
183
194
  > ⚠️ 热更新指令暂不支持 Windows 系统,在 Windows 上发送 `/bot-upgrade` 会返回手动升级指引。
184
195
 
196
+ > ⚠️ v1.6.6 及以下版本暂不支持通过 `/bot-upgrade` 执行热更新,请通过以下命令升级:
197
+ > ```bash
198
+ > curl -fsSL https://raw.githubusercontent.com/tencent-connect/openclaw-qqbot/main/scripts/upgrade-via-npm.sh | bash
199
+ > ```
200
+
185
201
  <img width="360" src="docs/images/hot-update.jpg" alt="一键热更新演示" />
186
202
 
187
203
  #### `/bot-logs` — 日志导出
@@ -202,6 +218,26 @@ AI 可直接发送视频,支持本地文件和公网 URL。
202
218
  >
203
219
  > **QQBot**:📖 /bot-upgrade 用法:…
204
220
 
221
+ #### `/bot-approve` — 审批配置管理
222
+
223
+ > **你**:`/bot-approve`
224
+ >
225
+ > **QQBot**:🔐 命令执行审批配置 — 开启审批 / 关闭审批 / 严格模式 / 恢复默认 / 查看当前配置
226
+
227
+ 管理 AI 命令执行审批策略,支持以下子命令:
228
+
229
+ | 子命令 | 说明 |
230
+ |--------|------|
231
+ | `/bot-approve on` | 开启审批(白名单模式,推荐) |
232
+ | `/bot-approve off` | 关闭审批,命令直接执行 |
233
+ | `/bot-approve always` | 严格模式,每次执行都需审批 |
234
+ | `/bot-approve reset` | 恢复框架默认值 |
235
+ | `/bot-approve status` | 查看当前审批配置 |
236
+
237
+ #### `/bot-clear-storage` — 清理通过 QQBot 对话产生的文件以及下载的资源(保存在 OpenClaw 运行环境的主机上)
238
+
239
+ `/bot-clear-storage` 列出对话产生的文件以及下载的资源目录里的文件,使用`/bot-clear-storage -- force`确定删除。
240
+
205
241
  ---
206
242
 
207
243
  ## 🚀 快速开始
@@ -215,15 +251,15 @@ AI 可直接发送视频,支持本地文件和公网 URL。
215
251
  2. 手机 QQ 扫码后选择**同意**,即完成注册,进入 QQ 机器人配置页。
216
252
  3. 点击**创建机器人**,即可直接新建一个 QQ 机器人。
217
253
 
218
- <img width="720" alt="创建机器人" src="docs/images/create_robot.png" />
254
+ <img width="720" alt="创建机器人" src="docs/images/create-robot.png" />
219
255
 
220
256
  > ⚠️ 机器人创建后会自动出现在你的 QQ 消息列表中,并发送第一条消息。但在完成下面的配置之前,发消息会提示"该机器人去火星了",属于正常现象。
221
257
 
222
- <img width="400" alt="机器人打招呼" src="docs/images/bot_say_hello.jpg" />
258
+ <img width="400" alt="机器人打招呼" src="docs/images/bot-say-hello.jpg" />
223
259
 
224
260
  4. 在机器人页面中找到 **AppID** 和 **AppSecret**,分别点击右侧**复制**按钮,保存到记事本或备忘录中。**AppSecret 不支持明文保存,离开页面后再查看会强制重置,请务必妥善保存。**
225
261
 
226
- <img width="720" alt="找到 AppID 和 AppSecret" src="docs/images/find_appid_secret.png" />
262
+ <img width="720" alt="找到 AppID 和 AppSecret" src="docs/images/find-appid-secret.png" />
227
263
 
228
264
  > 详细图文教程请参阅 [官方指南](https://cloud.tencent.com/developer/article/2626045)。
229
265
 
@@ -238,7 +274,7 @@ curl -fsSL https://raw.githubusercontent.com/tencent-connect/openclaw-qqbot/main
238
274
 
239
275
  一行命令搞定:下载脚本 → 清理旧插件 → 安装 → 配置通道 → 启动服务。完成后打开 QQ 即可开始聊天!
240
276
 
241
- > 首次安装**必须**传 `--appid` 和 `--secret`。后续升级如已有配置:
277
+ > 首次安装**必须**传 `--appid` 和 `--secret`。后续升级执行此指令可以升级为最新版:
242
278
  > ```bash
243
279
  > curl -fsSL https://raw.githubusercontent.com/tencent-connect/openclaw-qqbot/main/scripts/upgrade-via-npm.sh | bash
244
280
  > ```
@@ -368,12 +404,56 @@ openclaw message send --channel "qqbot" \
368
404
 
369
405
  #### 工作原理
370
406
 
371
- - 启动 `openclaw gateway` 后,所有 `enabled: true` 的账户会同时启动 WebSocket 连接
407
+ - 启动 `openclaw gateway` 后,所有 `enabled: true` 的账户会同时启动连接(WebSocket 或 Webhook,取决于 `transport` 配置)
372
408
  - 每个账户独立维护 Token 缓存(基于 `appId` 隔离),互不干扰
373
409
  - 接收消息时,日志会带上 `[qqbot:accountId]` 前缀方便排查
374
410
 
375
411
  ---
376
412
 
413
+ ### Webhook 传输模式
414
+
415
+ 默认情况下,插件通过 **WebSocket** 连接 QQ 平台(出站连接,无需公网 IP)。你也可以切换为 **Webhook** 模式,由 QQ 平台主动 POST 事件到你的 HTTP 端点。
416
+
417
+ | | WebSocket(默认) | Webhook |
418
+ |---|---|---|
419
+ | 连接方式 | 插件主动连接 QQ 网关 | QQ 平台 POST 到你的服务器 |
420
+ | 公网 IP | 不需要 | 需要 |
421
+ | 适用场景 | 开发调试、单实例部署 | 生产环境、水平扩展、Serverless |
422
+ | 会话恢复 | 支持 RESUME | 无状态,无需恢复 |
423
+ | 签名验证 | 平台内置 | 插件自动 Ed25519 验签 |
424
+
425
+ #### 配置方式
426
+
427
+ ```json
428
+ {
429
+ "channels": {
430
+ "qqbot": {
431
+ "appId": "111111111",
432
+ "clientSecret": "your-secret",
433
+ "transport": "webhook",
434
+ "webhook": {
435
+ "path": "/qqbot/webhook"
436
+ }
437
+ }
438
+ }
439
+ }
440
+ ```
441
+
442
+ | 字段 | 默认值 | 说明 |
443
+ |------|--------|------|
444
+ | `transport` | `"websocket"` | `"websocket"` 或 `"webhook"` |
445
+ | `webhook.path` | `"/qqbot/webhook"` | 接收回调的 HTTP 路径 |
446
+
447
+ #### 平台配置步骤
448
+
449
+ 1. 登录 [QQ 开放平台](https://q.qq.com/) → 开发设置 → 消息接收方式
450
+ 2. 选择 **HTTP 回调**
451
+ 3. 填写回调 URL:`https://your-domain.com/qqbot/webhook`
452
+ 4. 平台发送 `op:13` 验证请求,插件自动处理签名验证
453
+ 5. 验证通过后,所有事件将以 POST 方式推送到该地址
454
+
455
+ ---
456
+
377
457
  ### 语音能力配置(STT / TTS)
378
458
 
379
459
  #### STT(语音转文字)— 自动转录用户发来的语音消息
@@ -453,7 +533,7 @@ STT 支持两级配置,按优先级查找:
453
533
  感谢[腾讯云Lighthouse](https://cloud.tencent.com/product/lighthouse)的深度合作,养小龙虾,首选腾讯云Lighthouse!
454
534
 
455
535
  <a href="https://cloud.tencent.com/product/lighthouse">
456
- <img alt="腾讯云 Lighthouse" src="./docs/images/lighthouse_head.png" height="500" style="max-width:80%; height:auto;"/>
536
+ <img alt="腾讯云 Lighthouse" src="./docs/images/lighthouse-head.png" height="500" style="max-width:80%; height:auto;"/>
457
537
  </a>
458
538
 
459
539
  ## ⭐ Star History
package/dist/index.d.ts CHANGED
@@ -15,3 +15,4 @@ export * from "./src/api.js";
15
15
  export * from "./src/config.js";
16
16
  export * from "./src/gateway.js";
17
17
  export * from "./src/outbound.js";
18
+ export * from "./src/transport/index.js";
package/dist/index.js CHANGED
@@ -24,3 +24,4 @@ export * from "./src/api.js";
24
24
  export * from "./src/config.js";
25
25
  export * from "./src/gateway.js";
26
26
  export * from "./src/outbound.js";
27
+ export * from "./src/transport/index.js";