@tencent-connect/openclaw-qqbot 1.0.1-alpha.0 → 1.0.2-alpha.0
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.
- package/README.md +37 -146
- package/README.zh.md +37 -146
- package/bin/qqbot-cli.js +6 -6
- package/dist/index.js +12 -0
- package/dist/src/api.d.ts +13 -1
- package/dist/src/api.js +21 -3
- package/dist/src/channel.d.ts +5 -0
- package/dist/src/channel.js +20 -6
- package/dist/src/config.js +2 -0
- package/dist/src/constants.d.ts +10 -0
- package/dist/src/constants.js +9 -0
- package/dist/src/gateway.js +1309 -838
- package/dist/src/onboarding.js +6 -1
- package/dist/src/outbound.d.ts +47 -1
- package/dist/src/outbound.js +253 -87
- package/dist/src/tools/channel-list.d.ts +10 -0
- package/dist/src/tools/channel-list.js +357 -0
- package/dist/src/tools/forum-thread.d.ts +11 -0
- package/dist/src/tools/forum-thread.js +262 -0
- package/dist/src/tools/guild-announces.d.ts +5 -0
- package/dist/src/tools/guild-announces.js +182 -0
- package/dist/src/tools/guild-list.d.ts +7 -0
- package/dist/src/tools/guild-list.js +136 -0
- package/dist/src/tools/guild-member.d.ts +9 -0
- package/dist/src/tools/guild-member.js +235 -0
- package/dist/src/tools/schedule.d.ts +5 -0
- package/dist/src/tools/schedule.js +208 -0
- package/dist/src/types.d.ts +35 -0
- package/dist/src/types.js +10 -1
- package/dist/src/utils/audio-convert.d.ts +0 -6
- package/dist/src/utils/audio-convert.js +0 -89
- package/dist/src/utils/media-tags.d.ts +79 -2
- package/dist/src/utils/media-tags.js +234 -3
- package/index.ts +12 -0
- package/package.json +6 -2
- package/scripts/{upgrade.sh → cleanup-legacy-plugins.sh} +3 -3
- package/scripts/set-markdown.sh +20 -20
- package/scripts/upgrade-via-npm.sh +204 -0
- package/scripts/{upgrade-and-run.sh → upgrade-via-source.sh} +212 -49
- package/src/api.ts +35 -4
- package/src/channel.ts +21 -6
- package/src/config.ts +2 -0
- package/src/constants.ts +13 -0
- package/src/gateway.ts +1298 -766
- package/src/onboarding.ts +8 -1
- package/src/openclaw-plugin-sdk.d.ts +51 -0
- package/src/outbound.ts +284 -99
- package/src/tools/channel-list.ts +486 -0
- package/src/tools/forum-thread.ts +409 -0
- package/src/tools/guild-announces.ts +261 -0
- package/src/tools/guild-list.ts +207 -0
- package/src/tools/guild-member.ts +355 -0
- package/src/tools/schedule.ts +314 -0
- package/src/types.ts +38 -0
- package/src/utils/media-tags.ts +280 -3
- package/tsconfig.json +1 -1
- package/scripts/draw_arch.py +0 -174
- package/scripts/npm-upgrade.sh +0 -120
- package/scripts/pull-latest.sh +0 -316
package/README.md
CHANGED
|
@@ -164,61 +164,62 @@ AI sends videos via `<qqvideo>path</qqvideo>`. Supports local files and URLs. La
|
|
|
164
164
|
|
|
165
165
|
> For a step-by-step walkthrough with screenshots, see the [official guide](https://cloud.tencent.com/developer/article/2626045).
|
|
166
166
|
|
|
167
|
-
### Step 2 — Install the Plugin
|
|
167
|
+
### Step 2 — Install / Upgrade the Plugin
|
|
168
168
|
|
|
169
|
-
**Option A:
|
|
169
|
+
**Option A: Remote One-Liner (Easiest, no clone required)**
|
|
170
170
|
|
|
171
171
|
```bash
|
|
172
|
-
|
|
172
|
+
curl -fsSL https://raw.githubusercontent.com/tencent-connect/openclaw-qqbot/main/scripts/upgrade-via-npm.sh \
|
|
173
|
+
| bash -s -- --appid YOUR_APPID --secret YOUR_SECRET
|
|
173
174
|
```
|
|
174
175
|
|
|
175
|
-
|
|
176
|
+
One command does it all: download script → cleanup old plugins → install → configure channel → restart service. Once done, open QQ and start chatting!
|
|
176
177
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
The script handles everything: cleanup old plugins → install deps → register plugin → configure channel → start service. Once done, skip to [Step 4](#step-4--start--test).
|
|
178
|
+
> `--appid` and `--secret` are **required for first-time install**. For subsequent upgrades:
|
|
179
|
+
> ```bash
|
|
180
|
+
> curl -fsSL https://raw.githubusercontent.com/tencent-connect/openclaw-qqbot/main/scripts/upgrade-via-npm.sh | bash
|
|
181
|
+
> ```
|
|
183
182
|
|
|
184
|
-
**Option
|
|
183
|
+
**Option B: Local Script (if you've cloned the repo)**
|
|
185
184
|
|
|
186
185
|
```bash
|
|
187
|
-
|
|
188
|
-
npm
|
|
189
|
-
|
|
186
|
+
# Via npm
|
|
187
|
+
bash ./scripts/upgrade-via-npm.sh --appid YOUR_APPID --secret YOUR_SECRET
|
|
188
|
+
|
|
189
|
+
# Or via source
|
|
190
|
+
bash ./scripts/upgrade-via-source.sh --appid YOUR_APPID --secret YOUR_SECRET
|
|
190
191
|
```
|
|
191
192
|
|
|
192
|
-
|
|
193
|
+
**Common flags:**
|
|
193
194
|
|
|
194
|
-
|
|
195
|
+
| Flag | Description |
|
|
196
|
+
|------|-------------|
|
|
197
|
+
| `--appid <id> --secret <secret>` | Configure channel (required for first install, or to change credentials) |
|
|
198
|
+
| `--version <version>` | Install a specific version (npm script only) |
|
|
199
|
+
| `--self-version` | Install the version from local `package.json` (npm script only) |
|
|
200
|
+
| `-h` / `--help` | Show full usage |
|
|
195
201
|
|
|
196
|
-
|
|
197
|
-
openclaw channels add --channel qqbot --token "AppID:AppSecret"
|
|
198
|
-
```
|
|
202
|
+
> Environment variables `QQBOT_APPID` / `QQBOT_SECRET` are also supported.
|
|
199
203
|
|
|
200
|
-
**Option
|
|
204
|
+
**Option C: Manual Install / Upgrade**
|
|
201
205
|
|
|
202
|
-
|
|
206
|
+
```bash
|
|
207
|
+
# Uninstall old plugins (skip if first install)
|
|
208
|
+
openclaw plugins uninstall qqbot
|
|
209
|
+
openclaw plugins uninstall openclaw-qqbot
|
|
203
210
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
"channels": {
|
|
207
|
-
"qqbot": {
|
|
208
|
-
"enabled": true,
|
|
209
|
-
"appId": "Your AppID",
|
|
210
|
-
"clientSecret": "Your AppSecret"
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
```
|
|
211
|
+
# Install latest
|
|
212
|
+
openclaw plugins install @tencent-connect/openclaw-qqbot@latest
|
|
215
213
|
|
|
216
|
-
|
|
214
|
+
# Configure channel (first install only)
|
|
215
|
+
openclaw channels add --channel qqbot --token "AppID:AppSecret"
|
|
217
216
|
|
|
218
|
-
|
|
219
|
-
openclaw gateway
|
|
217
|
+
# Start / restart
|
|
218
|
+
openclaw gateway restart
|
|
220
219
|
```
|
|
221
220
|
|
|
221
|
+
### Step 3 — Test
|
|
222
|
+
|
|
222
223
|
Open QQ, find your bot, and send a message!
|
|
223
224
|
|
|
224
225
|
<div align="center">
|
|
@@ -366,119 +367,9 @@ STT supports two-level configuration with priority fallback:
|
|
|
366
367
|
|
|
367
368
|
---
|
|
368
369
|
|
|
369
|
-
## 🔄 Upgrade
|
|
370
|
-
|
|
371
|
-
### Option 1: Upgrade via npm (Recommended)
|
|
372
|
-
|
|
373
|
-
Current latest npm version: `1.5.6`
|
|
374
|
-
|
|
375
|
-
```bash
|
|
376
|
-
bash ./scripts/npm-upgrade.sh
|
|
377
|
-
```
|
|
378
|
-
|
|
379
|
-
The script automatically backs up channel config → uninstalls old plugins → installs new version → restores config → restarts gateway.
|
|
380
|
-
|
|
381
|
-
```bash
|
|
382
|
-
# Specify exact version
|
|
383
|
-
bash ./scripts/npm-upgrade.sh --version 1.5.6
|
|
384
|
-
```
|
|
385
|
-
|
|
386
|
-
### Option 2: Upgrade via Source
|
|
387
|
-
|
|
388
|
-
Run the one-click script to upgrade and restart:
|
|
389
|
-
|
|
390
|
-
```bash
|
|
391
|
-
bash ./scripts/upgrade-and-run.sh
|
|
392
|
-
```
|
|
393
|
-
|
|
394
|
-
When no `--appid` / `--secret` is provided, the script reads existing config from `~/.openclaw/openclaw.json` automatically.
|
|
395
|
-
|
|
396
|
-
```bash
|
|
397
|
-
# First-time or override credentials
|
|
398
|
-
bash ./scripts/upgrade-and-run.sh --appid YOUR_APPID --secret YOUR_SECRET
|
|
399
|
-
```
|
|
400
|
-
|
|
401
|
-
<details>
|
|
402
|
-
<summary>Full Options</summary>
|
|
403
|
-
|
|
404
|
-
| Option | Description |
|
|
405
|
-
|--------|-------------|
|
|
406
|
-
| `--appid <id>` | QQ Bot AppID |
|
|
407
|
-
| `--secret <secret>` | QQ Bot AppSecret |
|
|
408
|
-
| `--markdown <yes\|no>` | Enable Markdown format (default: no) |
|
|
409
|
-
| `-h, --help` | Show help |
|
|
410
|
-
|
|
411
|
-
Environment variables `QQBOT_APPID`, `QQBOT_SECRET`, `QQBOT_TOKEN` (AppID:Secret) are also supported.
|
|
412
|
-
|
|
413
|
-
</details>
|
|
414
|
-
|
|
415
|
-
---
|
|
416
|
-
|
|
417
|
-
## 🔀 Migrating from Legacy Plugins
|
|
418
|
-
|
|
419
|
-
If you previously installed `qqbot`, `@sliverp/qqbot`, `@tencent-connect/qqbot`, or other related legacy plugins, you need to uninstall the old plugin before installing the new version.
|
|
420
|
-
|
|
421
|
-
### Recommended: Use npm-upgrade Script (Automatic)
|
|
422
|
-
|
|
423
|
-
```bash
|
|
424
|
-
bash ./scripts/npm-upgrade.sh
|
|
425
|
-
```
|
|
426
|
-
|
|
427
|
-
The script automatically uninstalls all legacy plugin variants (`qqbot`, `@sliverp/qqbot`, `openclaw-qq`, etc.), cleans up residual directories, and backs up/restores channel config.
|
|
428
|
-
|
|
429
|
-
### Manual Migration
|
|
430
|
-
|
|
431
|
-
**1. Back up your channel config**
|
|
432
|
-
|
|
433
|
-
Save the `channels.qqbot` section from `~/.openclaw/openclaw.json` (including `appId`, `clientSecret`, `allowFrom`, etc.) — you'll need to restore it later.
|
|
434
|
-
|
|
435
|
-
**2. Uninstall old plugins**
|
|
436
|
-
|
|
437
|
-
Run the appropriate uninstall command(s) based on what you had installed:
|
|
438
|
-
|
|
439
|
-
```bash
|
|
440
|
-
# Uninstall legacy plugin variants (pick the ones that apply)
|
|
441
|
-
openclaw plugins uninstall qqbot
|
|
442
|
-
openclaw plugins uninstall @sliverp/qqbot
|
|
443
|
-
openclaw plugins uninstall @tencent-connect/qqbot
|
|
444
|
-
openclaw plugins uninstall openclaw-qqbot
|
|
445
|
-
openclaw plugins uninstall openclaw-qq
|
|
446
|
-
```
|
|
447
|
-
|
|
448
|
-
If `plugins uninstall` doesn't fully clean up, manually remove residual directories:
|
|
449
|
-
|
|
450
|
-
```bash
|
|
451
|
-
rm -rf ~/.openclaw/extensions/qqbot
|
|
452
|
-
rm -rf ~/.openclaw/extensions/openclaw-qqbot
|
|
453
|
-
rm -rf ~/.openclaw/extensions/openclaw-qq
|
|
454
|
-
```
|
|
455
|
-
|
|
456
|
-
**3. Temporarily remove channel config**
|
|
457
|
-
|
|
458
|
-
> ⚠️ Important: `openclaw plugins install` validates the config file. If `channels.qqbot` exists but no plugin provides that channel, it will fail with `unknown channel id: qqbot`.
|
|
459
|
-
|
|
460
|
-
Before installing, temporarily remove the `channels.qqbot` section from `~/.openclaw/openclaw.json`.
|
|
461
|
-
|
|
462
|
-
**4. Install the new version**
|
|
463
|
-
|
|
464
|
-
```bash
|
|
465
|
-
openclaw plugins install @tencent-connect/openclaw-qqbot
|
|
466
|
-
```
|
|
467
|
-
|
|
468
|
-
**5. Restore channel config**
|
|
469
|
-
|
|
470
|
-
Write back the previously saved `channels.qqbot` config to `~/.openclaw/openclaw.json`.
|
|
471
|
-
|
|
472
|
-
**6. Restart the gateway**
|
|
473
|
-
|
|
474
|
-
```bash
|
|
475
|
-
openclaw gateway restart
|
|
476
|
-
```
|
|
477
|
-
|
|
478
|
-
---
|
|
479
|
-
|
|
480
370
|
## 📚 Documentation & Links
|
|
481
371
|
|
|
372
|
+
- [Upgrade Guide](docs/UPGRADE_GUIDE.md) — full upgrade paths and migration notes
|
|
482
373
|
- [Command Reference](docs/commands.md) — OpenClaw CLI commands
|
|
483
374
|
- [Changelog](CHANGELOG.md) — release notes
|
|
484
375
|
|
package/README.zh.md
CHANGED
|
@@ -161,61 +161,62 @@ AI 通过 `<qqvideo>路径</qqvideo>` 发送视频,支持本地文件和公网
|
|
|
161
161
|
|
|
162
162
|
> 详细图文教程请参阅 [官方指南](https://cloud.tencent.com/developer/article/2626045)。
|
|
163
163
|
|
|
164
|
-
### 第二步 —
|
|
164
|
+
### 第二步 — 安装 / 升级插件
|
|
165
165
|
|
|
166
|
-
|
|
166
|
+
**方式一:远程一键执行(最简单,无需 clone 仓库)**
|
|
167
167
|
|
|
168
168
|
```bash
|
|
169
|
-
|
|
169
|
+
curl -fsSL https://raw.githubusercontent.com/tencent-connect/openclaw-qqbot/main/scripts/upgrade-via-npm.sh \
|
|
170
|
+
| bash -s -- --appid YOUR_APPID --secret YOUR_SECRET
|
|
170
171
|
```
|
|
171
172
|
|
|
172
|
-
|
|
173
|
+
一行命令搞定:下载脚本 → 清理旧插件 → 安装 → 配置通道 → 启动服务。完成后打开 QQ 即可开始聊天!
|
|
173
174
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
脚本会自动完成:清理旧插件 → 安装依赖 → 注册插件 → 配置通道 → 启动服务。完成后可直接跳到[第四步](#第四步--启动并测试)。
|
|
175
|
+
> 首次安装**必须**传 `--appid` 和 `--secret`。后续升级如已有配置:
|
|
176
|
+
> ```bash
|
|
177
|
+
> curl -fsSL https://raw.githubusercontent.com/tencent-connect/openclaw-qqbot/main/scripts/upgrade-via-npm.sh | bash
|
|
178
|
+
> ```
|
|
180
179
|
|
|
181
|
-
|
|
180
|
+
**方式二:本地脚本(已 clone 仓库时使用)**
|
|
182
181
|
|
|
183
182
|
```bash
|
|
184
|
-
|
|
185
|
-
npm
|
|
186
|
-
|
|
183
|
+
# 通过 npm 安装
|
|
184
|
+
bash ./scripts/upgrade-via-npm.sh --appid YOUR_APPID --secret YOUR_SECRET
|
|
185
|
+
|
|
186
|
+
# 或通过源码安装
|
|
187
|
+
bash ./scripts/upgrade-via-source.sh --appid YOUR_APPID --secret YOUR_SECRET
|
|
187
188
|
```
|
|
188
189
|
|
|
189
|
-
|
|
190
|
+
**常用参数:**
|
|
190
191
|
|
|
191
|
-
|
|
192
|
+
| 参数 | 说明 |
|
|
193
|
+
|------|------|
|
|
194
|
+
| `--appid <id> --secret <secret>` | 配置通道(首次安装必填,或更换凭证时使用) |
|
|
195
|
+
| `--version <版本号>` | 安装指定版本(仅 npm 脚本) |
|
|
196
|
+
| `--self-version` | 安装本地 `package.json` 中的版本(仅 npm 脚本) |
|
|
197
|
+
| `-h` / `--help` | 查看完整用法 |
|
|
192
198
|
|
|
193
|
-
|
|
194
|
-
openclaw channels add --channel qqbot --token "AppID:AppSecret"
|
|
195
|
-
```
|
|
199
|
+
> 也可通过环境变量 `QQBOT_APPID` / `QQBOT_SECRET` 设置。
|
|
196
200
|
|
|
197
|
-
|
|
201
|
+
**方式三:手动安装 / 升级**
|
|
198
202
|
|
|
199
|
-
|
|
203
|
+
```bash
|
|
204
|
+
# 卸载旧插件(首次安装可跳过)
|
|
205
|
+
openclaw plugins uninstall qqbot
|
|
206
|
+
openclaw plugins uninstall openclaw-qqbot
|
|
200
207
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
"channels": {
|
|
204
|
-
"qqbot": {
|
|
205
|
-
"enabled": true,
|
|
206
|
-
"appId": "你的 AppID",
|
|
207
|
-
"clientSecret": "你的 AppSecret"
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
```
|
|
208
|
+
# 安装最新版本
|
|
209
|
+
openclaw plugins install @tencent-connect/openclaw-qqbot@latest
|
|
212
210
|
|
|
213
|
-
|
|
211
|
+
# 配置通道(首次安装必做)
|
|
212
|
+
openclaw channels add --channel qqbot --token "AppID:AppSecret"
|
|
214
213
|
|
|
215
|
-
|
|
216
|
-
openclaw gateway
|
|
214
|
+
# 启动 / 重启
|
|
215
|
+
openclaw gateway restart
|
|
217
216
|
```
|
|
218
217
|
|
|
218
|
+
### 第三步 — 测试
|
|
219
|
+
|
|
219
220
|
打开 QQ,找到你的机器人,发条消息试试!
|
|
220
221
|
|
|
221
222
|
<div align="center">
|
|
@@ -363,119 +364,9 @@ STT 支持两级配置,按优先级查找:
|
|
|
363
364
|
|
|
364
365
|
---
|
|
365
366
|
|
|
366
|
-
## 🔄 升级
|
|
367
|
-
|
|
368
|
-
### 方式一:通过 npm 升级(推荐)
|
|
369
|
-
|
|
370
|
-
当前最新 npm 版本:`1.5.6`
|
|
371
|
-
|
|
372
|
-
```bash
|
|
373
|
-
bash ./scripts/npm-upgrade.sh
|
|
374
|
-
```
|
|
375
|
-
|
|
376
|
-
脚本会自动备份通道配置 → 卸载旧插件 → 安装新版本 → 恢复配置 → 重启网关。
|
|
377
|
-
|
|
378
|
-
```bash
|
|
379
|
-
# 指定版本号
|
|
380
|
-
bash ./scripts/npm-upgrade.sh --version 1.5.6
|
|
381
|
-
```
|
|
382
|
-
|
|
383
|
-
### 方式二:通过源码升级
|
|
384
|
-
|
|
385
|
-
运行一键脚本即可升级并重启:
|
|
386
|
-
|
|
387
|
-
```bash
|
|
388
|
-
bash ./scripts/upgrade-and-run.sh
|
|
389
|
-
```
|
|
390
|
-
|
|
391
|
-
不传 `--appid` / `--secret` 参数时,脚本会自动读取 `~/.openclaw/openclaw.json` 中已有的配置。
|
|
392
|
-
|
|
393
|
-
```bash
|
|
394
|
-
# 首次配置或需要覆盖时
|
|
395
|
-
bash ./scripts/upgrade-and-run.sh --appid YOUR_APPID --secret YOUR_SECRET
|
|
396
|
-
```
|
|
397
|
-
|
|
398
|
-
<details>
|
|
399
|
-
<summary>完整选项</summary>
|
|
400
|
-
|
|
401
|
-
| 选项 | 说明 |
|
|
402
|
-
|------|------|
|
|
403
|
-
| `--appid <id>` | QQ 机器人 AppID |
|
|
404
|
-
| `--secret <secret>` | QQ 机器人 AppSecret |
|
|
405
|
-
| `--markdown <yes\|no>` | 是否启用 Markdown 消息格式(默认: no) |
|
|
406
|
-
| `-h, --help` | 显示帮助 |
|
|
407
|
-
|
|
408
|
-
也支持环境变量:`QQBOT_APPID`、`QQBOT_SECRET`、`QQBOT_TOKEN`(AppID:Secret)。
|
|
409
|
-
|
|
410
|
-
</details>
|
|
411
|
-
|
|
412
|
-
---
|
|
413
|
-
|
|
414
|
-
## 🔀 从旧版插件迁移
|
|
415
|
-
|
|
416
|
-
如果你之前安装的是 `qqbot`、`@sliverp/qqbot`、`@tencent-connect/qqbot` 等关联插件,需要先卸载旧插件再安装新版本。
|
|
417
|
-
|
|
418
|
-
### 推荐:使用 npm-upgrade 脚本(自动处理)
|
|
419
|
-
|
|
420
|
-
```bash
|
|
421
|
-
bash ./scripts/npm-upgrade.sh
|
|
422
|
-
```
|
|
423
|
-
|
|
424
|
-
脚本会自动卸载所有历史版本的插件(`qqbot`、`@sliverp/qqbot`、`openclaw-qq` 等)、清理残留目录、备份恢复通道配置。
|
|
425
|
-
|
|
426
|
-
### 手动迁移
|
|
427
|
-
|
|
428
|
-
**1. 备份你的通道配置**
|
|
429
|
-
|
|
430
|
-
先记录 `~/.openclaw/openclaw.json` 中 `channels.qqbot` 的内容(`appId`、`clientSecret`、`allowFrom` 等),后续需要恢复。
|
|
431
|
-
|
|
432
|
-
**2. 卸载旧插件**
|
|
433
|
-
|
|
434
|
-
根据你之前安装的插件名,执行对应的卸载命令:
|
|
435
|
-
|
|
436
|
-
```bash
|
|
437
|
-
# 卸载可能存在的旧版插件(按实际情况选择)
|
|
438
|
-
openclaw plugins uninstall qqbot
|
|
439
|
-
openclaw plugins uninstall @sliverp/qqbot
|
|
440
|
-
openclaw plugins uninstall @tencent-connect/qqbot
|
|
441
|
-
openclaw plugins uninstall openclaw-qqbot
|
|
442
|
-
openclaw plugins uninstall openclaw-qq
|
|
443
|
-
```
|
|
444
|
-
|
|
445
|
-
如果 `plugins uninstall` 未能完全清理,手动删除残留目录:
|
|
446
|
-
|
|
447
|
-
```bash
|
|
448
|
-
rm -rf ~/.openclaw/extensions/qqbot
|
|
449
|
-
rm -rf ~/.openclaw/extensions/openclaw-qqbot
|
|
450
|
-
rm -rf ~/.openclaw/extensions/openclaw-qq
|
|
451
|
-
```
|
|
452
|
-
|
|
453
|
-
**3. 临时移除通道配置**
|
|
454
|
-
|
|
455
|
-
> ⚠️ 重要:`openclaw plugins install` 会校验配置文件。如果配置中存在 `channels.qqbot` 但对应插件尚未安装,会报 `unknown channel id: qqbot` 错误并拒绝安装。
|
|
456
|
-
|
|
457
|
-
安装前需要临时从 `~/.openclaw/openclaw.json` 中移除 `channels.qqbot` 配置段。
|
|
458
|
-
|
|
459
|
-
**4. 安装新版本**
|
|
460
|
-
|
|
461
|
-
```bash
|
|
462
|
-
openclaw plugins install @tencent-connect/openclaw-qqbot
|
|
463
|
-
```
|
|
464
|
-
|
|
465
|
-
**5. 恢复通道配置**
|
|
466
|
-
|
|
467
|
-
将之前备份的 `channels.qqbot` 配置写回 `~/.openclaw/openclaw.json`。
|
|
468
|
-
|
|
469
|
-
**6. 重启网关**
|
|
470
|
-
|
|
471
|
-
```bash
|
|
472
|
-
openclaw gateway restart
|
|
473
|
-
```
|
|
474
|
-
|
|
475
|
-
---
|
|
476
|
-
|
|
477
367
|
## 📚 文档与链接
|
|
478
368
|
|
|
369
|
+
- [升级指南](docs/UPGRADE_GUIDE.zh.md) — 完整升级路径与迁移说明
|
|
479
370
|
- [命令参考](docs/commands.md) — OpenClaw CLI 常用命令
|
|
480
371
|
- [更新日志](CHANGELOG.md) — 各版本变更记录
|
|
481
372
|
|
package/bin/qqbot-cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* qqbot CLI - 用于升级和管理 qqbot 插件
|
|
5
5
|
*
|
|
6
6
|
* 用法:
|
|
7
7
|
* npx openclaw-qqbot upgrade # 升级插件
|
|
@@ -131,7 +131,7 @@ function runCommand(cmd, args = []) {
|
|
|
131
131
|
|
|
132
132
|
// 升级命令
|
|
133
133
|
function upgrade() {
|
|
134
|
-
console.log('===
|
|
134
|
+
console.log('=== qqbot 插件升级脚本 ===');
|
|
135
135
|
|
|
136
136
|
let foundInstallation = null;
|
|
137
137
|
let savedConfig = null;
|
|
@@ -175,7 +175,7 @@ function upgrade() {
|
|
|
175
175
|
}
|
|
176
176
|
} else {
|
|
177
177
|
console.log('未找到已保存的 qqbot 配置,请手动配置:');
|
|
178
|
-
console.log(` ${foundInstallation} channels add --channel qqbot --token "
|
|
178
|
+
console.log(` ${foundInstallation} channels add --channel qqbot --token "appid:appsecret"`);
|
|
179
179
|
return;
|
|
180
180
|
}
|
|
181
181
|
|
|
@@ -186,7 +186,7 @@ function upgrade() {
|
|
|
186
186
|
|
|
187
187
|
// 安装命令
|
|
188
188
|
function install() {
|
|
189
|
-
console.log('===
|
|
189
|
+
console.log('=== qqbot 插件安装 ===');
|
|
190
190
|
|
|
191
191
|
const cmd = detectInstallation();
|
|
192
192
|
if (!cmd) {
|
|
@@ -200,13 +200,13 @@ function install() {
|
|
|
200
200
|
|
|
201
201
|
console.log('\n=== 安装完成 ===');
|
|
202
202
|
console.log('\n请配置机器人通道:');
|
|
203
|
-
console.log(` ${cmd} channels add --channel qqbot --token "
|
|
203
|
+
console.log(` ${cmd} channels add --channel qqbot --token "appid:appsecret"`);
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
// 显示帮助
|
|
207
207
|
function showHelp() {
|
|
208
208
|
console.log(`
|
|
209
|
-
|
|
209
|
+
qqbot CLI - QQ机器人插件管理工具
|
|
210
210
|
|
|
211
211
|
用法:
|
|
212
212
|
npx openclaw-qqbot <命令>
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { emptyPluginConfigSchema } from "openclaw/plugin-sdk";
|
|
2
2
|
import { qqbotPlugin } from "./src/channel.js";
|
|
3
3
|
import { setQQBotRuntime } from "./src/runtime.js";
|
|
4
|
+
import { registerGuildTools } from "./src/tools/guild-list.js";
|
|
5
|
+
import { registerChannelTools } from "./src/tools/channel-list.js";
|
|
6
|
+
import { registerGuildAnnouncesTool } from "./src/tools/guild-announces.js";
|
|
7
|
+
import { registerGuildMemberTools } from "./src/tools/guild-member.js";
|
|
8
|
+
// import { registerScheduleTools } from "./src/tools/schedule.js";
|
|
9
|
+
import { registerForumThreadTools } from "./src/tools/forum-thread.js";
|
|
4
10
|
const plugin = {
|
|
5
11
|
id: "openclaw-qqbot",
|
|
6
12
|
name: "QQ Bot",
|
|
@@ -9,6 +15,12 @@ const plugin = {
|
|
|
9
15
|
register(api) {
|
|
10
16
|
setQQBotRuntime(api.runtime);
|
|
11
17
|
api.registerChannel({ plugin: qqbotPlugin });
|
|
18
|
+
registerGuildTools(api);
|
|
19
|
+
registerChannelTools(api);
|
|
20
|
+
registerGuildAnnouncesTool(api);
|
|
21
|
+
registerGuildMemberTools(api);
|
|
22
|
+
// registerScheduleTools(api);
|
|
23
|
+
registerForumThreadTools(api);
|
|
12
24
|
},
|
|
13
25
|
};
|
|
14
26
|
export default plugin;
|
package/dist/src/api.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* QQ Bot API 鉴权和请求封装
|
|
3
3
|
* [修复版] 已重构为支持多实例并发,消除全局变量冲突
|
|
4
4
|
*/
|
|
5
|
+
import { type StreamConfig } from "./types.js";
|
|
5
6
|
/**
|
|
6
7
|
* 初始化 API 配置
|
|
7
8
|
* @param options.markdownSupport - 是否支持 markdown 消息(默认 false,需要机器人具备该权限才能启用)
|
|
@@ -47,13 +48,24 @@ export declare function getGatewayUrl(accessToken: string): Promise<string>;
|
|
|
47
48
|
export interface MessageResponse {
|
|
48
49
|
id: string;
|
|
49
50
|
timestamp: number | string;
|
|
51
|
+
/** 流式消息ID,用于后续分片 */
|
|
52
|
+
stream_id?: string;
|
|
50
53
|
}
|
|
51
|
-
export declare function sendC2CMessage(accessToken: string, openid: string, content: string, msgId?: string): Promise<MessageResponse>;
|
|
54
|
+
export declare function sendC2CMessage(accessToken: string, openid: string, content: string, msgId?: string, stream?: StreamConfig): Promise<MessageResponse>;
|
|
52
55
|
export declare function sendC2CInputNotify(accessToken: string, openid: string, msgId?: string, inputSecond?: number): Promise<void>;
|
|
53
56
|
export declare function sendChannelMessage(accessToken: string, channelId: string, content: string, msgId?: string): Promise<{
|
|
54
57
|
id: string;
|
|
55
58
|
timestamp: string;
|
|
56
59
|
}>;
|
|
60
|
+
/**
|
|
61
|
+
* 发送频道私信消息
|
|
62
|
+
* @param guildId - 私信会话的 guild_id(由 DIRECT_MESSAGE_CREATE 事件提供)
|
|
63
|
+
* @param msgId - 被动回复时必填
|
|
64
|
+
*/
|
|
65
|
+
export declare function sendDmMessage(accessToken: string, guildId: string, content: string, msgId?: string): Promise<{
|
|
66
|
+
id: string;
|
|
67
|
+
timestamp: string;
|
|
68
|
+
}>;
|
|
57
69
|
export declare function sendGroupMessage(accessToken: string, groupOpenid: string, content: string, msgId?: string): Promise<MessageResponse>;
|
|
58
70
|
export declare function sendProactiveC2CMessage(accessToken: string, openid: string, content: string): Promise<{
|
|
59
71
|
id: string;
|
package/dist/src/api.js
CHANGED
|
@@ -248,7 +248,7 @@ export async function getGatewayUrl(accessToken) {
|
|
|
248
248
|
const data = await apiRequest(accessToken, "GET", "/gateway");
|
|
249
249
|
return data.url;
|
|
250
250
|
}
|
|
251
|
-
function buildMessageBody(content, msgId, msgSeq) {
|
|
251
|
+
function buildMessageBody(content, msgId, msgSeq, stream) {
|
|
252
252
|
const body = currentMarkdownSupport
|
|
253
253
|
? {
|
|
254
254
|
markdown: { content },
|
|
@@ -263,11 +263,18 @@ function buildMessageBody(content, msgId, msgSeq) {
|
|
|
263
263
|
if (msgId) {
|
|
264
264
|
body.msg_id = msgId;
|
|
265
265
|
}
|
|
266
|
+
if (stream) {
|
|
267
|
+
body.stream = {
|
|
268
|
+
state: stream.state,
|
|
269
|
+
index: stream.index,
|
|
270
|
+
...(stream.id ? { id: stream.id } : {}),
|
|
271
|
+
};
|
|
272
|
+
}
|
|
266
273
|
return body;
|
|
267
274
|
}
|
|
268
|
-
export async function sendC2CMessage(accessToken, openid, content, msgId) {
|
|
275
|
+
export async function sendC2CMessage(accessToken, openid, content, msgId, stream) {
|
|
269
276
|
const msgSeq = msgId ? getNextMsgSeq(msgId) : 1;
|
|
270
|
-
const body = buildMessageBody(content, msgId, msgSeq);
|
|
277
|
+
const body = buildMessageBody(content, msgId, msgSeq, stream);
|
|
271
278
|
return apiRequest(accessToken, "POST", `/v2/users/${openid}/messages`, body);
|
|
272
279
|
}
|
|
273
280
|
export async function sendC2CInputNotify(accessToken, openid, msgId, inputSecond = 60) {
|
|
@@ -289,6 +296,17 @@ export async function sendChannelMessage(accessToken, channelId, content, msgId)
|
|
|
289
296
|
...(msgId ? { msg_id: msgId } : {}),
|
|
290
297
|
});
|
|
291
298
|
}
|
|
299
|
+
/**
|
|
300
|
+
* 发送频道私信消息
|
|
301
|
+
* @param guildId - 私信会话的 guild_id(由 DIRECT_MESSAGE_CREATE 事件提供)
|
|
302
|
+
* @param msgId - 被动回复时必填
|
|
303
|
+
*/
|
|
304
|
+
export async function sendDmMessage(accessToken, guildId, content, msgId) {
|
|
305
|
+
return apiRequest(accessToken, "POST", `/dms/${guildId}/messages`, {
|
|
306
|
+
content,
|
|
307
|
+
...(msgId ? { msg_id: msgId } : {}),
|
|
308
|
+
});
|
|
309
|
+
}
|
|
292
310
|
export async function sendGroupMessage(accessToken, groupOpenid, content, msgId) {
|
|
293
311
|
const msgSeq = msgId ? getNextMsgSeq(msgId) : 1;
|
|
294
312
|
const body = buildMessageBody(content, msgId, msgSeq);
|
package/dist/src/channel.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import { type ChannelPlugin } from "openclaw/plugin-sdk";
|
|
2
2
|
import type { ResolvedQQBotAccount } from "./types.js";
|
|
3
|
+
import { createStreamSender, StreamSender } from "./outbound.js";
|
|
3
4
|
export declare const qqbotPlugin: ChannelPlugin<ResolvedQQBotAccount>;
|
|
5
|
+
/**
|
|
6
|
+
* 导出流式消息工具函数,供外部使用(仅 C2C 私聊支持)
|
|
7
|
+
*/
|
|
8
|
+
export { createStreamSender, StreamSender };
|
package/dist/src/channel.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { applyAccountNameToChannelSection, deleteAccountFromConfigSection, setAccountEnabledInConfigSection, } from "openclaw/plugin-sdk";
|
|
2
2
|
import { DEFAULT_ACCOUNT_ID, listQQBotAccountIds, resolveQQBotAccount, applyQQBotAccountConfig, resolveDefaultQQBotAccountId } from "./config.js";
|
|
3
|
-
import { sendText, sendMedia } from "./outbound.js";
|
|
3
|
+
import { sendText, sendMedia, createStreamSender, StreamSender } from "./outbound.js";
|
|
4
4
|
import { startGateway } from "./gateway.js";
|
|
5
5
|
import { qqbotOnboardingAdapter } from "./onboarding.js";
|
|
6
6
|
import { getQQBotRuntime } from "./runtime.js";
|
|
@@ -48,11 +48,21 @@ export const qqbotPlugin = {
|
|
|
48
48
|
media: true,
|
|
49
49
|
reactions: false,
|
|
50
50
|
threads: false,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
blockStreaming: true,
|
|
52
|
+
},
|
|
53
|
+
/**
|
|
54
|
+
* 流式配置
|
|
55
|
+
* blockStreamingCoalesceDefaults: 控制 block streaming 的合并策略
|
|
56
|
+
* - minChars: 至少累积多少字符后才触发 block deliver
|
|
57
|
+
* - idleMs: 空闲多少毫秒后强制 flush 当前 block
|
|
58
|
+
*
|
|
59
|
+
* 对于 QQ Bot:
|
|
60
|
+
* - C2C 私聊(streamSupport=true)通过 deliver 回调中的 StreamSender 实现增量流式
|
|
61
|
+
* disableBlockStreaming=true,不走 coalesce
|
|
62
|
+
* - 群聊/频道(或 C2C streamSupport=false)走框架的 block streaming pipeline,使用此 coalesce 配置
|
|
63
|
+
*/
|
|
64
|
+
streaming: {
|
|
65
|
+
blockStreamingCoalesceDefaults: { minChars: 800, idleMs: 800 },
|
|
56
66
|
},
|
|
57
67
|
reload: { configPrefixes: ["channels.qqbot"] },
|
|
58
68
|
// CLI onboarding wizard
|
|
@@ -335,3 +345,7 @@ export const qqbotPlugin = {
|
|
|
335
345
|
}),
|
|
336
346
|
},
|
|
337
347
|
};
|
|
348
|
+
/**
|
|
349
|
+
* 导出流式消息工具函数,供外部使用(仅 C2C 私聊支持)
|
|
350
|
+
*/
|
|
351
|
+
export { createStreamSender, StreamSender };
|
package/dist/src/config.js
CHANGED
|
@@ -64,6 +64,7 @@ export function resolveQQBotAccount(cfg, accountId) {
|
|
|
64
64
|
systemPrompt: qqbot?.systemPrompt,
|
|
65
65
|
imageServerBaseUrl: qqbot?.imageServerBaseUrl,
|
|
66
66
|
markdownSupport: qqbot?.markdownSupport ?? true,
|
|
67
|
+
streamSupport: qqbot?.streamSupport,
|
|
67
68
|
};
|
|
68
69
|
appId = normalizeAppId(qqbot?.appId);
|
|
69
70
|
}
|
|
@@ -100,6 +101,7 @@ export function resolveQQBotAccount(cfg, accountId) {
|
|
|
100
101
|
systemPrompt: accountConfig.systemPrompt,
|
|
101
102
|
imageServerBaseUrl: accountConfig.imageServerBaseUrl || process.env.QQBOT_IMAGE_SERVER_BASE_URL,
|
|
102
103
|
markdownSupport: accountConfig.markdownSupport !== false,
|
|
104
|
+
streamSupport: accountConfig.streamSupport === true,
|
|
103
105
|
config: accountConfig,
|
|
104
106
|
};
|
|
105
107
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** C2C 私聊消息 */
|
|
2
|
+
export declare const MSG_TYPE_C2C: "c2c";
|
|
3
|
+
/** 频道公开消息 */
|
|
4
|
+
export declare const MSG_TYPE_GUILD: "guild";
|
|
5
|
+
/** 频道私信 */
|
|
6
|
+
export declare const MSG_TYPE_DM: "dm";
|
|
7
|
+
/** 群聊消息 */
|
|
8
|
+
export declare const MSG_TYPE_GROUP: "group";
|
|
9
|
+
/** 消息类型联合类型 */
|
|
10
|
+
export type MessageType = typeof MSG_TYPE_C2C | typeof MSG_TYPE_GUILD | typeof MSG_TYPE_DM | typeof MSG_TYPE_GROUP;
|