qq-bot-roost 1.1.7 → 1.1.9
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 +59 -17
- package/docs/AI/345/256/277/344/270/273/346/216/245/345/205/245.md +1 -1
- package/docs/DSH/346/216/245/345/205/245.md +3 -3
- package/docs/images/qq-group.jpg +0 -0
- package/docs//345/217/221/347/211/210/346/270/205/345/215/225.md +33 -21
- package/docs//345/233/236/346/273/232/351/242/204/346/241/210.md +6 -6
- package/docs//345/256/277/344/270/273/345/215/217/350/256/256v1.md +19 -0
- package/docs//346/217/222/344/273/266/345/274/200/345/217/221/350/247/204/350/214/203.md +1 -1
- package/docs//346/236/266/346/236/204/350/257/264/346/230/216.md +1 -1
- package/docs//351/205/215/347/275/256/345/217/202/350/200/203.md +5 -0
- package/package.json +7 -6
- package/src/api.js +34 -4
- package/src/bot.js +8 -6
- package/src/check.js +141 -0
- package/src/delivery.js +5 -3
- package/src/doctor.js +26 -8
- package/src/gateway.js +26 -0
- package/src/gitee.js +6 -3
- package/src/hashdir.js +10 -0
- package/src/host/dispatch.js +5 -0
- package/src/host/methods.js +26 -1
- package/src/ledger.js +69 -9
- package/src/main.js +57 -4
- package/src/markdown.js +33 -9
- package/src/message.js +11 -1
- package/src/mirror.js +7 -4
- package/src/onebot/actions.js +8 -0
- package/src/outbound.js +78 -18
- package/src/plugin/api-record.js +2 -0
- package/src/plugin/market.js +3 -3
- package/src/proxy.js +11 -1
- package/src/repo.js +22 -0
- package/src/storage/events-schema.js +32 -1
- package/src/storage/schema.js +29 -1
- package/src/updater.js +5 -5
- package/src/web/media.js +232 -0
- package/src/web/server.js +61 -15
- package/web/app.js +805 -165
- package/web/index.html +128 -7
- package/web/qq-group.jpg +0 -0
- package/web/style.css +343 -17
package/README.md
CHANGED
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
|
|
9
9
|
<img src="https://img.shields.io/badge/Node.js-22.13%2B-339933?logo=node.js&logoColor=white" alt="Node.js 22.13+">
|
|
10
10
|
<img src="https://img.shields.io/badge/dependencies-0-brightgreen" alt="零依赖">
|
|
11
|
-
<img src="https://img.shields.io/badge/tests-
|
|
11
|
+
<img src="https://img.shields.io/badge/tests-1343%20passed-brightgreen" alt="测试 1343 项">
|
|
12
12
|
<img src="https://img.shields.io/badge/plugins-JS%20%7C%20Python%20%7C%20Go%20%7C%20any-blue" alt="多语言插件">
|
|
13
|
-
<img src="https://img.shields.io/badge/version-1.1.
|
|
13
|
+
<img src="https://img.shields.io/badge/version-1.1.9-blueviolet" alt="版本 1.1.9">
|
|
14
14
|
<img src="https://img.shields.io/badge/license-AGPL--3.0--only-blue" alt="AGPL-3.0-only">
|
|
15
|
-
<a href="https://github.com/
|
|
15
|
+
<a href="https://github.com/roost-qq/qq-bot-roost/actions"><img src="https://img.shields.io/github/actions/workflow/status/roost-qq/qq-bot-roost/ci.yml?branch=master" alt="CI"></a>
|
|
16
16
|
|
|
17
17
|
[快速开始](#3-分钟跑起来) | [写插件](docs/插件开发规范.md) | [外部插件协议](docs/插件协议.md) | [配置参考](docs/配置参考.md) | [常见问题](docs/常见问题.md) | [贡献](CONTRIBUTING.md)
|
|
18
18
|
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
|
|
107
107
|
**插件系统**
|
|
108
108
|
|
|
109
|
-
- **插件不在本仓库**:全部放在 [qq-bot-roost-plugins](https://github.com/
|
|
109
|
+
- **插件不在本仓库**:全部放在 [qq-bot-roost-plugins](https://github.com/roost-qq/qq-bot-roost-plugins),
|
|
110
110
|
面板「插件 → 市场」一键安装,**有新版会自动提示、一键更新**
|
|
111
111
|
- **下载源可换**:国内直连 GitHub 经常超时,面板里能选 GitHub 官方 / Gitee 镜像
|
|
112
112
|
(作者维护,内容逐字节相同)/ 自建前缀,**带一键测速**;`auto` 模式直连失败会
|
|
@@ -221,7 +221,7 @@ INFO [webui] 可视化面板: http://127.0.0.1:15207/
|
|
|
221
221
|
想在服务器 / NAS 上跑,用容器更省事:
|
|
222
222
|
|
|
223
223
|
```bash
|
|
224
|
-
git clone https://github.com/
|
|
224
|
+
git clone https://github.com/roost-qq/qq-bot-roost.git
|
|
225
225
|
cd qq-bot-roost
|
|
226
226
|
cp config/bot.example.json config/bot.json # 首次,然后填 AppID / AppSecret
|
|
227
227
|
docker compose up -d
|
|
@@ -252,6 +252,37 @@ docker compose up -d
|
|
|
252
252
|
|
|
253
253
|
---
|
|
254
254
|
|
|
255
|
+
## 网络与代理
|
|
256
|
+
|
|
257
|
+
框架只在**下载类**出站上走代理:插件市场索引与包、框架更新、镜像测速、Gitee 拉取。
|
|
258
|
+
QQ 官方接口、扫码登录、文件预签名上传**一律直连**——这些是国内地址,
|
|
259
|
+
套一层本地代理只会更慢,甚至被对端拒掉。
|
|
260
|
+
|
|
261
|
+
配置在 `config/bot.json` 的 `network.proxy`,三个取值:
|
|
262
|
+
|
|
263
|
+
| 值 | 行为 |
|
|
264
|
+
|---|---|
|
|
265
|
+
| `auto`(默认) | 先读 Windows 系统代理,再读环境变量 |
|
|
266
|
+
| `off` | 全部直连,不读任何代理设置 |
|
|
267
|
+
| `http://127.0.0.1:7890` | 只用这一个,不再猜(也接受不带 `http://` 的写法) |
|
|
268
|
+
|
|
269
|
+
`auto` 的顺序是**系统代理优先**(Clash / v2rayN 那个「系统代理」开关改的就是它),
|
|
270
|
+
其次 `HTTPS_PROXY` / `HTTP_PROXY`,例外列表取 `NO_PROXY`。反过来(环境变量优先)
|
|
271
|
+
在桌面场景更容易踩坑:机器上留着一个早就失效的 `HTTPS_PROXY`,框架会一直用那个坏的。
|
|
272
|
+
只支持 http / https 代理,SOCKS 请用 Clash 之类的混合端口。
|
|
273
|
+
|
|
274
|
+
Windows 上读系统代理靠 `reg query`。企业策略、安全软件或沙箱可能直接拦掉 `reg.exe`,
|
|
275
|
+
表现是「浏览器能打开、框架连不上」。设 `ROOST_NO_SYSTEM_PROXY=1` 绕开:
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
ROOST_NO_SYSTEM_PROXY=1 node src/main.js
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
设了它就完全不碰注册表,只认 `network.proxy` / 环境变量 / 直连。当前实际生效的代理
|
|
282
|
+
及其来源(系统设置 / 环境变量 / 手动)在面板**「插件管理」页 →「插件市场」卡片**里能直接看到。
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
255
286
|
## 收事件:WebSocket 还是 Webhook
|
|
256
287
|
|
|
257
288
|
官方两种都支持,框架都实现了:
|
|
@@ -461,7 +492,7 @@ bot/
|
|
|
461
492
|
│ ├── web/server.js 面板服务端(REST + SSE)
|
|
462
493
|
│ └── plugin/ 插件加载、配置、依赖、子进程宿主、面板页面注册
|
|
463
494
|
├── test/
|
|
464
|
-
│ ├── selftest.mjs 框架自检(
|
|
495
|
+
│ ├── selftest.mjs 框架自检(694 项)
|
|
465
496
|
│ ├── e2e.mjs 端到端测试(253 项,起真实服务打接口)
|
|
466
497
|
│ ├── qrlogin.mjs 扫码建机器人(8 项)
|
|
467
498
|
│ └── deps.mjs 插件依赖安装(11 项)
|
|
@@ -497,21 +528,21 @@ openid 完全不同。共享 `roles.json` 等于所有权限记录全部对不
|
|
|
497
528
|
|
|
498
529
|
| 仓库 | 说明 |
|
|
499
530
|
|------|------|
|
|
500
|
-
| [qq-bot-roost-plugins](https://github.com/
|
|
501
|
-
| [dsh-roost](https://github.com/
|
|
531
|
+
| [qq-bot-roost-plugins](https://github.com/roost-qq/qq-bot-roost-plugins) | 插件市场源,面板「插件 → 市场」从这里装 |
|
|
532
|
+
| [dsh-roost](https://github.com/roost-qq/dsh-roost) | DSH 插件:让 AI 通过本框架住进 QQ(走官方接口,不 hook 客户端) |
|
|
502
533
|
|
|
503
534
|
---
|
|
504
535
|
|
|
505
536
|
## 开发
|
|
506
537
|
|
|
507
538
|
```bash
|
|
508
|
-
npm test #
|
|
509
|
-
npm run test:e2e #
|
|
510
|
-
npm run test:all #
|
|
539
|
+
npm test # 框架自检
|
|
540
|
+
npm run test:e2e # 端到端测试(起 mock 服务打全部接口,跑在临时目录)
|
|
541
|
+
npm run test:all # 全量测试:自检 + 扫码 + 依赖 + e2e(真机驱动要真机,没配就跳过)
|
|
511
542
|
npm run check:secrets # 扫硬编码凭据(CI 也跑这个,提交前建议过一遍)
|
|
512
543
|
node src/main.js --mock # 不连 QQ,命令行发假消息调插件
|
|
513
544
|
node src/main.js --mock --serve # 只开面板,调界面
|
|
514
|
-
node src/main.js --check #
|
|
545
|
+
node src/main.js --check # 只体检:凭证 + 网关 + intents / 面板暴露面 / 插件目录,不启动机器人
|
|
515
546
|
```
|
|
516
547
|
|
|
517
548
|
> **真凭据不要写进代码**,放 `config/bot.json`(已在 .gitignore 里)。
|
|
@@ -594,10 +625,9 @@ mock 模式下:直接输入文本 = 模拟一条群 @ 消息;`!as <openid>`
|
|
|
594
625
|
|
|
595
626
|
**贡献者**
|
|
596
627
|
|
|
597
|
-
|
|
598
|
-
<!-- <a href="https://github.com/OWNER/REPO/graphs/contributors"><img src="https://contrib.rocks/image?repo=OWNER/REPO" alt="contributors"></a> -->
|
|
628
|
+
<a href="https://github.com/roost-qq/qq-bot-roost/graphs/contributors"><img src="https://contrib.rocks/image?repo=roost-qq/qq-bot-roost" alt="contributors"></a>
|
|
599
629
|
|
|
600
|
-
|
|
630
|
+
感谢所有贡献者。
|
|
601
631
|
|
|
602
632
|
---
|
|
603
633
|
|
|
@@ -613,9 +643,21 @@ mock 模式下:直接输入文本 = 模拟一条群 @ 消息;`!as <openid>`
|
|
|
613
643
|
|
|
614
644
|
---
|
|
615
645
|
|
|
646
|
+
## 💬 交流群
|
|
647
|
+
|
|
648
|
+
安装踩坑、用法讨论、插件开发与想法都欢迎来聊。提问时尽量带上版本号和相关日志。
|
|
649
|
+
|
|
650
|
+
群号:**1130901545**
|
|
651
|
+
|
|
652
|
+
<div align="center">
|
|
653
|
+
<img src="docs/images/qq-group.jpg" alt="roost 交流群二维码" width="240" />
|
|
654
|
+
</div>
|
|
655
|
+
|
|
656
|
+
---
|
|
657
|
+
|
|
616
658
|
## 许可
|
|
617
659
|
|
|
618
|
-
本项目采用 **GNU Affero General Public License v3.0 only(AGPL-3.0-only)**,是 OSI 认证的开源许可证。完整条款见 [LICENSE](LICENSE)
|
|
660
|
+
本项目采用 **GNU Affero General Public License v3.0 only(AGPL-3.0-only)**,是 OSI 认证的开源许可证。完整条款见 [LICENSE](LICENSE)。
|
|
619
661
|
|
|
620
662
|
| 场景 | 允许? |
|
|
621
663
|
|------|--------|
|
|
@@ -623,7 +665,7 @@ mock 模式下:直接输入文本 = 模拟一条群 @ 消息;`!as <openid>`
|
|
|
623
665
|
| 商业使用、收费分发、集成进商业产品 | ✅ 允许,但受下列条件约束 |
|
|
624
666
|
| 分发源码或二进制给他人 | ✅ 必须同样以 AGPL-3.0-only 授权、保留声明并提供完整对应源码 |
|
|
625
667
|
| 修改后通过网络向用户提供服务 | ✅ 视为分发,须向使用者提供对应源码(AGPL 第 13 条) |
|
|
626
|
-
| 改用更宽松许可、闭源再分发 | ❌
|
|
668
|
+
| 改用更宽松许可、闭源再分发 | ❌ 不允许 |
|
|
627
669
|
|
|
628
670
|
两点要说明白:
|
|
629
671
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Roost 可以被**外部 AI 宿主**驱动:它收消息、发消息、调官方接口,
|
|
4
4
|
宿主(DeepSeek Harness 等)只管想和说。
|
|
5
5
|
|
|
6
|
-
这条通道最初是为 [dsh-roost](https://github.com/
|
|
6
|
+
这条通道最初是为 [dsh-roost](https://github.com/roost-qq/dsh-roost) 做的,
|
|
7
7
|
但它是通用的——任何能发 HTTP 的程序都能接。
|
|
8
8
|
|
|
9
9
|
> 本文是**接入指南**(怎么连、怎么调、常见错)。方法表、握手、scope、补拉语义的
|
|
@@ -88,14 +88,14 @@ npx @deepseek-ai/dsh plugin --profile desktop add dsh-roost
|
|
|
88
88
|
### 方式三:从 GitHub
|
|
89
89
|
|
|
90
90
|
```bash
|
|
91
|
-
npx @deepseek-ai/dsh plugin --profile desktop add github:
|
|
91
|
+
npx @deepseek-ai/dsh plugin --profile desktop add github:roost-qq/qq-bot-roost
|
|
92
92
|
```
|
|
93
93
|
|
|
94
94
|
**这条目前装不了。** 原因:`dsh plugin add github:...` 会把整个仓库当插件包,
|
|
95
95
|
但插件的 `package.json` 在 `integrations/dsh-roost/` 子目录里,
|
|
96
96
|
而 pnpm 的 git 依赖没有可靠的「指定子目录」语法。
|
|
97
97
|
|
|
98
|
-
要支持这种方式,得把插件拆成独立仓库(`
|
|
98
|
+
要支持这种方式,得把插件拆成独立仓库(`roost-qq/dsh-roost`)。
|
|
99
99
|
**在拆之前,用方式一。**
|
|
100
100
|
|
|
101
101
|
---
|
|
@@ -237,7 +237,7 @@ AI 看到后者只会瞎猜,看到前者才知道该建议你启动 Roost。
|
|
|
237
237
|
## 后续
|
|
238
238
|
|
|
239
239
|
- [ ] 发到 npm,让 `dsh plugin add dsh-roost` 可用
|
|
240
|
-
- [ ] 拆独立仓库,支持 `github:
|
|
240
|
+
- [ ] 拆独立仓库,支持 `github:roost-qq/dsh-roost`
|
|
241
241
|
- [ ] 提交到 DSH 插件市场收录
|
|
242
242
|
|
|
243
243
|
---
|
|
Binary file
|
|
@@ -6,17 +6,19 @@
|
|
|
6
6
|
|
|
7
7
|
## 0. 总流程(先看这个)
|
|
8
8
|
|
|
9
|
-
1. 从 master
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
1. 从 master 拉分支,跑 **`npm run release:prepare <版本>`**(bump + 两处徽章 + 文档测试数 +
|
|
10
|
+
指纹一次做完),再补 `RELEASE_NOTES.md` 顶部段的正文(下面 1–3 步)
|
|
11
|
+
2. 开 PR → **给 PR 打 `release` 标签** → CI 全绿(框架仓 8 项必需检查)→ 合并进 master
|
|
12
|
+
3. 合并即触发 `release.yml`,两个 job 全自动、**不需要点任何 Approve**:
|
|
13
|
+
- **发版前校验**:版本必须递增、notes 顶部段版本 = package.json、指纹与内容一致、
|
|
14
|
+
关联 PR 必须带 `release` 标签
|
|
15
|
+
- **建 tag / 验签 / Release / 发 npm / 发后自检**:CI 代签 → 验签门禁 → 建 tag → 建 Release
|
|
16
|
+
→ 上传 `SHA256SUMS`+`.sig` 附件 → 发 npm → 发后自检 → `beta` 对齐
|
|
16
17
|
4. 核对两端(第 6 步)——CI 已经自动核对过的项目,这里只是二次确认
|
|
17
18
|
|
|
18
19
|
关键变化:**不再手动推 tag、不再本地签名、不再本地发 npm、不再本地对 beta**。
|
|
19
|
-
|
|
20
|
+
人只决定**版本号**和 **notes 正文**,其余由 `release:prepare` 与 CI 串起来。
|
|
21
|
+
**发版开关是 PR 上的 `release` 标签**(2026-11-21 起,environment 审批已删):合并即发。
|
|
20
22
|
分支保护已开(require PR + CI 检查),直接 push master/main 会被拒(管理员可绕过,但日常别用)。
|
|
21
23
|
|
|
22
24
|
## 1. 改完代码、跑测试
|
|
@@ -26,14 +28,20 @@
|
|
|
26
28
|
|
|
27
29
|
> 指纹**不要在这一步跑**,见第 2 步。
|
|
28
30
|
|
|
29
|
-
## 2.
|
|
31
|
+
## 2. 改版本号与文档(`npm run release:prepare <版本>` 会一次做完这一整节)
|
|
32
|
+
|
|
33
|
+
> 手工做的话顺序是:先 bump 再生成指纹。自动化就一条命令:
|
|
34
|
+
> `npm run release:prepare 1.1.8`(`--dry-run` 只看要改什么,`--no-test` 跳过测试统计)。
|
|
35
|
+
> 它**不写 notes 正文、不提交**,这两件事仍由人做。
|
|
30
36
|
|
|
31
37
|
- [ ] `package.json` 的 `version` —— **先改这个**
|
|
32
|
-
- [ ] `RELEASE_NOTES.md
|
|
33
|
-
- [ ] **`README.md`
|
|
38
|
+
- [ ] `RELEASE_NOTES.md`:新版本段落写在**最上面**(`release:prepare` 只插骨架,正文要人写)
|
|
39
|
+
- [ ] **`README.md` 里会过期的数字都要对一遍**(`release:prepare` 会按实测值自动改):
|
|
34
40
|
- 版本徽章(`badge/version-x.y.z`)——**这是硬门禁**:`ci.yml` 的 `版本徽章` job
|
|
35
41
|
已进必需检查,徽章和 `package.json` 不一致,PR 直接过不了
|
|
36
|
-
- 测试数量徽章(`
|
|
42
|
+
- 测试数量徽章(`1337 passed` 这种,改了测试就会变)
|
|
43
|
+
- 目录树里的「框架自检(N 项)」「端到端测试(N 项)」
|
|
44
|
+
- 命令速查里的「自检 N + qrlogin N + …,另跑 N 个 node:test 文件(共 N 项)」和「全量约 N 项」
|
|
37
45
|
- 官方接口数量、插件数量、文档里写死的行号/文件名
|
|
38
46
|
- 这些是硬编码的,代码改了不跟着改就会挂一个错的数字在上面
|
|
39
47
|
- [ ] 其他提到版本号的文档(`docs/*.md` 里的「当前版本」段)
|
|
@@ -71,7 +79,7 @@
|
|
|
71
79
|
|
|
72
80
|
- [ ] **什么都不用做**。`SIGN_IN_CI=true` 已开,发版 job 会自己签:
|
|
73
81
|
- 私钥来自 `Release` environment 的 secret `TRUST_PRIVATE_PEM`,
|
|
74
|
-
|
|
82
|
+
只在发版 job 里注入(审批规则 2026-11-21 已删,合并即发),用完立即从 runner 删除
|
|
75
83
|
- `SHA256SUMS` 变了就重签,签名仍有效则跳过(重跑幂等)
|
|
76
84
|
- 签完用内嵌公钥验一遍(**验签门禁**),私钥公钥不配对直接红,不发版
|
|
77
85
|
- 最后把 `SHA256SUMS` 和 `.sig` **成对挂到 Release 附件**——
|
|
@@ -102,21 +110,25 @@
|
|
|
102
110
|
## 4. 开 PR 并合并(不再手动推 tag)
|
|
103
111
|
|
|
104
112
|
- [ ] `git add -A && git commit`(确认 `SHA256SUMS` 进了提交;框架仓 `.sig` 由 CI 生成,不必带)
|
|
105
|
-
- [ ] `git push` 推分支 → 开 PR → 等 CI 全绿 → 合并进 master
|
|
113
|
+
- [ ] `git push` 推分支 → 开 PR → **给 PR 打 `release` 标签** → 等 CI 全绿 → 合并进 master
|
|
114
|
+
- **标签是唯一的发版开关**(2026-11-21 起):没打标签的 PR 合并后 `release.yml` 判 `skip`,
|
|
115
|
+
只进代码不发版;summary 里会写明是「缺 release 标签」
|
|
106
116
|
- **不要手动 `git tag` / `git push origin v<版本>`**——tag 由 CI 建,手动推会造成「tag 存在 but 内容没校验」的坏状态
|
|
107
117
|
- [ ] 合并后看 `发版`(release.yml)这个 workflow:
|
|
108
|
-
- `发版前校验` job
|
|
109
|
-
|
|
118
|
+
- `发版前校验` job:版本递增、notes 顶部段版本 = package.json、指纹与内容一致、
|
|
119
|
+
关联 PR 带 `release` 标签,任一不过就红且不发版
|
|
120
|
+
- 校验通过后**直接发**:`Release` environment 的审批规则已在 2026-11-21 删除,
|
|
121
|
+
**不需要再去 Actions 页点 Approve**(environment 本身保留——私钥 secret 与 npm OIDC 环境名挂在上面)
|
|
110
122
|
|
|
111
|
-
- [ ]
|
|
112
|
-
→ 上传 `SHA256SUMS` + `.sig` 附件 → 发 npm → 发后自检
|
|
113
|
-
|
|
114
|
-
|
|
123
|
+
- [ ] 确认该 job 依次完成:验签门禁 → 建 tag `v<版本>` → 建 GitHub Release
|
|
124
|
+
→ 上传 `SHA256SUMS` + `.sig` 附件 → 发 npm → 发后自检 → `beta` 对齐
|
|
125
|
+
(只看「有没有触发」不算数,要看每一步都绿;发后自检会核对
|
|
126
|
+
`releases/latest`、npm 版本、以及两个附件是否真的挂上去了)
|
|
115
127
|
|
|
116
128
|
### ⚠️ GitHub Release 由 CI 自动建(但要核对)
|
|
117
129
|
|
|
118
130
|
PR 合并后 `release.yml` 的 `建 tag / 验签 / Release / 发 npm / 发后自检` job 会**自动建 Release**,不用再手工建。
|
|
119
|
-
前提:notes 顶部段版本 =
|
|
131
|
+
前提:notes 顶部段版本 = 版本号、指纹校验都通过、关联 PR 带 `release` 标签;
|
|
120
132
|
不通过 CI 会红且**不建**,这时要先修 notes/指纹再重发 PR,别手工硬建绕过校验。
|
|
121
133
|
|
|
122
134
|
只推 tag **不建 Release** 的话,框架的检查更新就失效了:
|
|
@@ -18,9 +18,10 @@
|
|
|
18
18
|
git switch -c hotfix/rollback-<ver>
|
|
19
19
|
# 改 package.json version 为新的补丁号(如 0.6.15)
|
|
20
20
|
git commit -am "rollback: 回到 <good-tag> 行为"
|
|
21
|
-
|
|
21
|
+
# 补齐 RELEASE_NOTES.md + README 徽章,开带 release 标签的 PR
|
|
22
|
+
# 合并后由 CI 自动建 tag + 发版,不要手动推送 tag
|
|
22
23
|
```
|
|
23
|
-
3.
|
|
24
|
+
3. 推送:只推 GitHub 分支;Gitee 由原生 Pull 镜像自动同步,无需操作。
|
|
24
25
|
4. 在 `RELEASE_NOTES.md` 写清「本次回滚了什么、为什么」。
|
|
25
26
|
|
|
26
27
|
**用户侧**
|
|
@@ -55,16 +56,15 @@ git push origin main
|
|
|
55
56
|
1. `git log -- index.json` 找到上一个好提交
|
|
56
57
|
2. `git checkout <good-commit> -- index.json`
|
|
57
58
|
3. `node scripts/build-index.mjs --check` 确认一致
|
|
58
|
-
4.
|
|
59
|
+
4. 推送(只推 GitHub,Gitee 由镜像自动同步)
|
|
59
60
|
|
|
60
61
|
---
|
|
61
62
|
|
|
62
63
|
## 4. 双仓不一致(Gitee 滞后)
|
|
63
64
|
|
|
64
65
|
- 现象:用户 `auto` 模式切到 Gitee 后装到旧版。
|
|
65
|
-
-
|
|
66
|
-
|
|
67
|
-
- 若 `secrets.GITEE_TOKEN` 过期:换新令牌后重跑。
|
|
66
|
+
- 处理:Gitee 侧由原生 Pull 镜像自动拉取 GitHub 提交,一般几分钟内自动追平,
|
|
67
|
+
无需维护者干预。若长期未追平,到 Gitee 仓库检查镜像 Pull 配置是否正常。
|
|
68
68
|
|
|
69
69
|
---
|
|
70
70
|
|
|
@@ -193,6 +193,25 @@ data: {"at":1731400000000}
|
|
|
193
193
|
用 `msg.get` 查。`notice` 事件是 `{seq, at, event, data}`,`data` 是框架
|
|
194
194
|
回调原样传入的对象。
|
|
195
195
|
|
|
196
|
+
### 账本行的 `source` 字段(v4)
|
|
197
|
+
|
|
198
|
+
`msg.get` / `ledger.recent` / `ledger.context` 返回的行都带 `source`,说明
|
|
199
|
+
**这条是从哪个口子进来的或出去的**,和 `plugin`(谁说的)是两个维度:
|
|
200
|
+
|
|
201
|
+
| `source` | 含义 |
|
|
202
|
+
|---|---|
|
|
203
|
+
| `gateway` / `webhook` | 入站:官方 WebSocket 网关 / Webhook 回调 |
|
|
204
|
+
| `plugin` | 出站:框架内插件发起(具体是谁看 `plugin`),含 `msg.replyStream` |
|
|
205
|
+
| `host` | 出站:自有宿主协议(本协议 `msg.send` / `msg.stream`) |
|
|
206
|
+
| `onebot` | 出站:OneBot v11 兼容层(客户端 `send_msg` 等) |
|
|
207
|
+
| `api` / `mock` / `dev` / `import` | 内部直连兜底 / 模拟消息 / 面板注入 / 导入补录 |
|
|
208
|
+
| `''` | 早于 v4 的老记录。**空串表示「不知道」,不要当入站判据** |
|
|
209
|
+
|
|
210
|
+
宿主侧最常用的一条:写记忆时想区分「用户说的」和「机器人/第三方客户端说的」,
|
|
211
|
+
**正向判入站**(`source === 'gateway' || source === 'webhook'`),别反向用
|
|
212
|
+
`source !== ...` —— 老行和内部兜底都是空串,反过来会把它们误判成入站。
|
|
213
|
+
只要第三方客户端发的,按 `source === 'onebot'` 过滤。
|
|
214
|
+
|
|
196
215
|
## 4. 方法表
|
|
197
216
|
|
|
198
217
|
`system.capabilities` 会返回完整清单(含每个方法所需 scope),这里列分组。
|
|
@@ -697,7 +697,7 @@ export default {
|
|
|
697
697
|
- 存档结构变更时,考虑在 `setup()` 里做一次迁移,而不是让旧数据变孤儿
|
|
698
698
|
|
|
699
699
|
完整的发布流程、版本比较规则、更新时会发生什么,见插件仓库的
|
|
700
|
-
[插件更新规范](https://github.com/
|
|
700
|
+
[插件更新规范](https://github.com/roost-qq/qq-bot-roost-plugins/blob/main/docs/插件更新规范.md)。
|
|
701
701
|
|
|
702
702
|
### 5.4 其他
|
|
703
703
|
|
|
@@ -349,7 +349,7 @@ SSE 用 `Map<res, botId>` 记录每个连接在看哪个机器人,各自推各
|
|
|
349
349
|
### `plugins/`(本地,不入库)
|
|
350
350
|
|
|
351
351
|
插件代码**不属于框架**,`plugins/` 已加 `.gitignore`。官方插件在
|
|
352
|
-
[qq-bot-roost-plugins](https://github.com/
|
|
352
|
+
[qq-bot-roost-plugins](https://github.com/roost-qq/qq-bot-roost-plugins),
|
|
353
353
|
面板「插件 → 市场」一键安装。本地现有的四个是示例/自用:
|
|
354
354
|
`dice`(参数解析)、`echo`(消息监听 + 运行数据示例)、`hello-py`(外部 Python)、
|
|
355
355
|
`kun`(完整玩法)。
|
|
@@ -282,6 +282,11 @@ Node 低于 22.5 或没编译 sqlite 时,`enabled` 设成什么都不影响—
|
|
|
282
282
|
|
|
283
283
|
> 多机器人下环境变量容易串,**建议只用来做临时调试**,正式配置写文件。
|
|
284
284
|
|
|
285
|
+
面板 / Webhook / 日志 / 代理这些**运行态**变量不对应任何配置字段,所以不在上表里:
|
|
286
|
+
`ROOST_WEBUI_HOST` / `ROOST_WEBUI_PORT` / `ROOST_WEBUI_KEY`、`ROOST_WEBHOOK_ENABLED` /
|
|
287
|
+
`ROOST_WEBHOOK_PORT`、`ROOST_LOG_LEVEL`、`ROOST_NO_SYSTEM_PROXY`。前几个见 README
|
|
288
|
+
「Docker 部署」,`ROOST_NO_SYSTEM_PROXY` 见 README「网络与代理」。
|
|
289
|
+
|
|
285
290
|
---
|
|
286
291
|
|
|
287
292
|
## 从旧版本升级
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qq-bot-roost",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "栖 Roost:零依赖的 QQ 官方机器人框架,填 AppID/AppSecret 即连,插件可写任意语言",
|
|
6
6
|
"license": "AGPL-3.0-only",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/
|
|
9
|
+
"url": "git+https://github.com/roost-qq/qq-bot-roost.git"
|
|
10
10
|
},
|
|
11
11
|
"bugs": {
|
|
12
|
-
"url": "https://github.com/
|
|
12
|
+
"url": "https://github.com/roost-qq/qq-bot-roost/issues"
|
|
13
13
|
},
|
|
14
|
-
"homepage": "https://github.com/
|
|
14
|
+
"homepage": "https://github.com/roost-qq/qq-bot-roost#readme",
|
|
15
15
|
"keywords": [
|
|
16
16
|
"qq-bot",
|
|
17
17
|
"qqbot",
|
|
@@ -29,9 +29,10 @@
|
|
|
29
29
|
"start": "node src/main.js",
|
|
30
30
|
"mock": "node src/main.js --mock",
|
|
31
31
|
"check": "node src/main.js --check",
|
|
32
|
-
"
|
|
32
|
+
"release:prepare": "node scripts/release-prepare.mjs",
|
|
33
|
+
"test": "node test/selftest.mjs && node test/qrlogin.mjs && node test/deps.mjs && node test/npm-registry.mjs && node test/deps-external.mjs && node --test test/trust.mjs && node --test test/manifest.mjs && node --test test/market-cache.mjs && node --test test/market-kind.mjs && node --test test/instance-proc.mjs && node --test test/proxy.mjs && node --test test/trace.mjs && node --test test/fuzz-tar.mjs && node --test test/group-name.mjs && node --test test/message-fields.mjs && node --test test/people-list.mjs && node --test test/ledger-people.mjs && node --test test/ledger-search.mjs && node --test test/people-search.mjs && node --test test/host-ledger.mjs && node --test test/sync-beta-tag.mjs && node --test test/identity.mjs && node --test test/identity-commands.mjs && node --test test/mail.mjs && node --test test/ledger-outbound.mjs && node --test test/api-record.mjs && node --test test/transport-regressions.mjs && node --test test/check-mode.mjs && node --test test/reply-auto.mjs && node --test test/plugin-observability.mjs && node --test test/outbound-dry.mjs && node --test test/ext-deps-migrate.mjs && node --test test/onebot-keep.mjs && node --test test/onebot-deps.mjs && node --test test/onebot-config.mjs && node --test test/onebot-segments.mjs && node --test test/onebot-outbound-at.mjs && node --test test/onebot-translate.mjs && node --test test/onebot-voice.mjs && node --test test/onebot-loopback.mjs && node --test test/host-protocol.mjs && node --test test/host-config.mjs && node --test test/host-tool-methods.mjs && node --test test/host-ext-bridge.mjs && node --test test/web-token-echo.mjs && node --test test/group-manage.mjs && node --test test/wakeup-payload.mjs && node --test test/typing.mjs && node --test test/media-convert.mjs && node --test test/gateway-interaction-ack.mjs && node --test test/host-dev.mjs && node --test test/dev-browser.mjs && node --test test/dev-cooldown.mjs && node --test test/onebot-profile.mjs && node --test test/dev-remember.mjs && node --test test/dev-scope.mjs && node --test test/dev-renew.mjs && node --test test/dev-ticket.mjs && node --test test/nickname.mjs && node --test test/url-guard.mjs && node --test test/plugin-update.mjs && node --test test/market-source.mjs",
|
|
33
34
|
"test:e2e": "node test/e2e.mjs",
|
|
34
|
-
"test:all": "node test/selftest.mjs && node test/qrlogin.mjs && node test/deps.mjs && node test/npm-registry.mjs && node test/deps-external.mjs && node --test test/trust.mjs && node --test test/manifest.mjs && node --test test/market-cache.mjs && node --test test/market-kind.mjs && node --test test/instance-proc.mjs && node --test test/proxy.mjs && node --test test/trace.mjs && node --test test/fuzz-tar.mjs && node --test test/group-name.mjs && node --test test/message-fields.mjs && node --test test/people-list.mjs && node --test test/ledger-people.mjs && node --test test/ledger-search.mjs && node --test test/people-search.mjs && node --test test/host-ledger.mjs && node --test test/sync-beta-tag.mjs && node --test test/identity.mjs && node --test test/identity-commands.mjs && node --test test/mail.mjs && node --test test/ledger-outbound.mjs && node --test test/api-record.mjs && node --test test/reply-auto.mjs && node test/e2e.mjs && node test/live-driver.mjs && node --test test/ext-deps-migrate.mjs && node --test test/onebot-keep.mjs && node --test test/onebot-deps.mjs && node --test test/onebot-config.mjs && node --test test/onebot-segments.mjs && node --test test/onebot-outbound-at.mjs && node --test test/onebot-translate.mjs && node --test test/onebot-voice.mjs && node --test test/onebot-loopback.mjs && node --test test/host-protocol.mjs && node --test test/host-config.mjs && node --test test/host-tool-methods.mjs && node --test test/host-ext-bridge.mjs && node --test test/web-token-echo.mjs && node --test test/group-manage.mjs && node --test test/wakeup-payload.mjs && node --test test/typing.mjs && node --test test/media-convert.mjs && node --test test/host-dev.mjs && node --test test/dev-browser.mjs && node --test test/dev-cooldown.mjs && node --test test/onebot-profile.mjs && node --test test/dev-remember.mjs && node --test test/dev-scope.mjs && node --test test/dev-renew.mjs && node --test test/dev-ticket.mjs && node --test test/nickname.mjs && node --test test/url-guard.mjs && node --test test/plugin-update.mjs && node --test test/market-source.mjs",
|
|
35
|
+
"test:all": "node test/selftest.mjs && node test/qrlogin.mjs && node test/deps.mjs && node test/npm-registry.mjs && node test/deps-external.mjs && node --test test/trust.mjs && node --test test/manifest.mjs && node --test test/market-cache.mjs && node --test test/market-kind.mjs && node --test test/instance-proc.mjs && node --test test/proxy.mjs && node --test test/trace.mjs && node --test test/fuzz-tar.mjs && node --test test/group-name.mjs && node --test test/message-fields.mjs && node --test test/people-list.mjs && node --test test/ledger-people.mjs && node --test test/ledger-search.mjs && node --test test/people-search.mjs && node --test test/host-ledger.mjs && node --test test/sync-beta-tag.mjs && node --test test/identity.mjs && node --test test/identity-commands.mjs && node --test test/mail.mjs && node --test test/ledger-outbound.mjs && node --test test/api-record.mjs && node --test test/transport-regressions.mjs && node --test test/check-mode.mjs && node --test test/reply-auto.mjs && node test/e2e.mjs && node test/live-driver.mjs && node --test test/ext-deps-migrate.mjs && node --test test/onebot-keep.mjs && node --test test/onebot-deps.mjs && node --test test/onebot-config.mjs && node --test test/onebot-segments.mjs && node --test test/onebot-outbound-at.mjs && node --test test/onebot-translate.mjs && node --test test/onebot-voice.mjs && node --test test/onebot-loopback.mjs && node --test test/host-protocol.mjs && node --test test/host-config.mjs && node --test test/host-tool-methods.mjs && node --test test/host-ext-bridge.mjs && node --test test/web-token-echo.mjs && node --test test/group-manage.mjs && node --test test/wakeup-payload.mjs && node --test test/typing.mjs && node --test test/media-convert.mjs && node --test test/host-dev.mjs && node --test test/dev-browser.mjs && node --test test/dev-cooldown.mjs && node --test test/onebot-profile.mjs && node --test test/dev-remember.mjs && node --test test/dev-scope.mjs && node --test test/dev-renew.mjs && node --test test/dev-ticket.mjs && node --test test/nickname.mjs && node --test test/url-guard.mjs && node --test test/plugin-update.mjs && node --test test/market-source.mjs",
|
|
35
36
|
"check:secrets": "node scripts/check-secrets.mjs",
|
|
36
37
|
"create": "node scripts/create-plugin.mjs",
|
|
37
38
|
"test:plugin": "node scripts/test-plugin.mjs",
|
package/src/api.js
CHANGED
|
@@ -368,7 +368,15 @@ export class QQApi {
|
|
|
368
368
|
*/
|
|
369
369
|
if (!retried && isSafeToRetryNetworkError(code)) {
|
|
370
370
|
log.warn(`连接没建起来,重试一次:${method} ${path}(${code})`);
|
|
371
|
-
|
|
371
|
+
/**
|
|
372
|
+
* `multipart` 必须一起透传。
|
|
373
|
+
*
|
|
374
|
+
* 漏掉它的后果不是「多发一条」,而是**把带附件的请求变成 JSON**:
|
|
375
|
+
* 报文里 `file_image` 是 Buffer,`JSON.stringify` 后成了
|
|
376
|
+
* `{"type":"Buffer","data":[…]}`,平台必然 400 —— 重试等于白打一次,
|
|
377
|
+
* 还把真正的错误(连接没建起来)盖成一条看不懂的 400。
|
|
378
|
+
*/
|
|
379
|
+
return this.#request(method, path, body, { retried: true, headers, multipart });
|
|
372
380
|
}
|
|
373
381
|
throw new Error(`网络错误 ${method} ${path}: ${reason}`);
|
|
374
382
|
}
|
|
@@ -381,7 +389,7 @@ export class QQApi {
|
|
|
381
389
|
const stale = this.tokens.token;
|
|
382
390
|
log.warn('接口返回 401,刷新访问凭证');
|
|
383
391
|
await this.tokens.refresh(stale);
|
|
384
|
-
if (method === 'GET') return this.#request(method, path, body, { retried: true, headers });
|
|
392
|
+
if (method === 'GET') return this.#request(method, path, body, { retried: true, headers, multipart });
|
|
385
393
|
throw new Error(`HTTP 401 ${method} ${path}: 凭证已刷新,但写请求不自动重试(避免重复发送)`);
|
|
386
394
|
}
|
|
387
395
|
|
|
@@ -636,7 +644,14 @@ export class QQApi {
|
|
|
636
644
|
}
|
|
637
645
|
if (!res.ok) {
|
|
638
646
|
const detail = await res.text().catch(() => '');
|
|
639
|
-
|
|
647
|
+
const err = new Error(`分片 PUT 失败 HTTP ${res.status}${detail ? `:${detail.slice(0, 200)}` : ''}`);
|
|
648
|
+
/**
|
|
649
|
+
* 把状态码挂出来。调用方(`uploadLocalFileSharded`)要靠它区分
|
|
650
|
+
* 「签名过期 / 413 超限」(重试无意义)和「5xx / 网络抖动」(值得重试)。
|
|
651
|
+
* 只给一句 message 的话,只能靠正则猜,迟早猜错。
|
|
652
|
+
*/
|
|
653
|
+
err.status = res.status;
|
|
654
|
+
throw err;
|
|
640
655
|
}
|
|
641
656
|
return res.headers?.get('etag') ?? '';
|
|
642
657
|
}
|
|
@@ -761,7 +776,22 @@ export class QQApi {
|
|
|
761
776
|
return;
|
|
762
777
|
} catch (e) {
|
|
763
778
|
lastErr = e;
|
|
764
|
-
|
|
779
|
+
/**
|
|
780
|
+
* 只有**明确可重试**的才继续等:
|
|
781
|
+
* · `40093001`:官方点名「BDH 通道异常」,给了 `retry_timeout`;
|
|
782
|
+
* · 网络层抖动 / 5xx:可能下一次就好。
|
|
783
|
+
*
|
|
784
|
+
* 以前除 `40093002` 外一律重试,于是 presigned URL 过期(403)、
|
|
785
|
+
* 413 超限、404 这类**重试一万次也不会变**的错,会按默认
|
|
786
|
+
* `retry_timeout=300s` 一片一片耗完——用户看到的是「发文件卡死五分钟」。
|
|
787
|
+
*/
|
|
788
|
+
const qqCode = Number(e?.qqCode ?? 0);
|
|
789
|
+
const status = Number(e?.status ?? 0);
|
|
790
|
+
if (qqCode === 40093002) throw e; // 日配额,重试无用
|
|
791
|
+
const retriable = qqCode === 40093001
|
|
792
|
+
|| status >= 500
|
|
793
|
+
|| (!status && /timeout|timed out|超时|ECONNRESET|EPIPE|socket hang up|fetch failed|网络错误/i.test(String(e?.message ?? '')));
|
|
794
|
+
if (!retriable) throw e;
|
|
765
795
|
await new Promise((r) => setTimeout(r, retryDelayMs));
|
|
766
796
|
}
|
|
767
797
|
}
|
package/src/bot.js
CHANGED
|
@@ -453,7 +453,7 @@ export class BotRuntime {
|
|
|
453
453
|
try {
|
|
454
454
|
wh.register(cfg.appId, {
|
|
455
455
|
secret: cfg.appSecret,
|
|
456
|
-
onEvent: (event, d, payload) => this.dispatch(event, d,
|
|
456
|
+
onEvent: (event, d, payload) => this.dispatch(event, d, 'webhook'),
|
|
457
457
|
onError: (e) => this.log.error(`Webhook 事件处理失败: ${e.message}`),
|
|
458
458
|
});
|
|
459
459
|
this.state = 'online';
|
|
@@ -494,7 +494,7 @@ export class BotRuntime {
|
|
|
494
494
|
tokens: this.tokens,
|
|
495
495
|
intents: cfg.intents,
|
|
496
496
|
metrics: this.metrics,
|
|
497
|
-
onDispatch: (event, d, p) => this.dispatch(event, d,
|
|
497
|
+
onDispatch: (event, d, p) => this.dispatch(event, d, 'gateway'),
|
|
498
498
|
});
|
|
499
499
|
|
|
500
500
|
try {
|
|
@@ -977,7 +977,7 @@ export class BotRuntime {
|
|
|
977
977
|
* id 用事件名 + 场景 + 操作人 + 时间戳拼出**稳定**值,官方重推同一条时
|
|
978
978
|
* `ledger.append` 的 dedupe 唯一约束会把它挡掉,不会记重。
|
|
979
979
|
*/
|
|
980
|
-
#recordNotice(eventName, d) {
|
|
980
|
+
#recordNotice(eventName, d, source = '') {
|
|
981
981
|
if (!this.ledger?.append) return;
|
|
982
982
|
const CHANNEL_NOTICE = /^(GUILD|CHANNEL|FORUM|AUDIO|MESSAGE_REACTION|MESSAGE_AUDIT|PUBLIC_MESSAGE_DELETE|DIRECT_MESSAGE_DELETE)/;
|
|
983
983
|
if (!CHANNEL_NOTICE.test(eventName)) return;
|
|
@@ -1008,6 +1008,8 @@ export class BotRuntime {
|
|
|
1008
1008
|
userName: '',
|
|
1009
1009
|
content: `[事件] ${eventName}${sub}${d?.name ? ` ${String(d.name).slice(0, 80)}` : ''}`,
|
|
1010
1010
|
raw: d,
|
|
1011
|
+
/** 和消息事件同一口径:这条事件是网关推的还是 Webhook 推的 */
|
|
1012
|
+
source,
|
|
1011
1013
|
});
|
|
1012
1014
|
} catch (e) {
|
|
1013
1015
|
this.log.warn(`频道事件入账失败(不影响分发):${e?.message ?? e}`);
|
|
@@ -1018,7 +1020,7 @@ export class BotRuntime {
|
|
|
1018
1020
|
* 这个方法和单机器人时的逻辑一致,只是绑到了某个实例上。
|
|
1019
1021
|
* 所有事件都会转交给插件,未知事件也不例外。
|
|
1020
1022
|
*/
|
|
1021
|
-
async dispatch(eventName, d) {
|
|
1023
|
+
async dispatch(eventName, d, source = '') {
|
|
1022
1024
|
const { cfg, registry, roles, groups, session, pipeline, outbound } = this;
|
|
1023
1025
|
|
|
1024
1026
|
this.metrics.lastEventAt = Date.now();
|
|
@@ -1034,7 +1036,7 @@ export class BotRuntime {
|
|
|
1034
1036
|
/* ---- 非消息事件 ---- */
|
|
1035
1037
|
if (!isMessageEvent(eventName)) {
|
|
1036
1038
|
/** 和消息事件一样「入账第一」,放在任何处理/过滤之前 */
|
|
1037
|
-
this.#recordNotice(eventName, d);
|
|
1039
|
+
this.#recordNotice(eventName, d, source);
|
|
1038
1040
|
if (!isKnownEvent(eventName)) {
|
|
1039
1041
|
this.log.warn(`收到未登记的事件 ${eventName},已转交插件。建议在 src/events.js 补登记`);
|
|
1040
1042
|
}
|
|
@@ -1098,7 +1100,7 @@ export class BotRuntime {
|
|
|
1098
1100
|
}
|
|
1099
1101
|
|
|
1100
1102
|
/* ---- 消息事件 ---- */
|
|
1101
|
-
const msg = buildMessage(eventName, d, { api: this.api, cfg, outbound, session, identity: this.identity });
|
|
1103
|
+
const msg = buildMessage(eventName, d, { api: this.api, cfg, outbound, session, identity: this.identity, source });
|
|
1102
1104
|
|
|
1103
1105
|
/**
|
|
1104
1106
|
* 群名不在官方事件里(只有 `group_openid`),但框架有缓存。
|