@zaofan/dsh-qqbot 1.10.9 → 1.10.11
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 +86 -2
- package/README_EN.md +31 -0
- package/client/qqbot-settings.js +6313 -6196
- package/dist/channel-tools.d.ts +0 -12
- package/dist/channel-tools.d.ts.map +1 -1
- package/dist/channel-tools.js +202 -20
- package/dist/channel-tools.js.map +1 -1
- package/dist/config.d.ts +18 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +11 -0
- package/dist/config.js.map +1 -1
- package/dist/features/botplay.d.ts.map +1 -1
- package/dist/features/botplay.js +6 -2
- package/dist/features/botplay.js.map +1 -1
- package/dist/features/ext-capabilities.d.ts +2 -0
- package/dist/features/ext-capabilities.d.ts.map +1 -1
- package/dist/features/ext-capabilities.js +6 -0
- package/dist/features/ext-capabilities.js.map +1 -1
- package/dist/features/ext-outbound.d.ts +238 -0
- package/dist/features/ext-outbound.d.ts.map +1 -0
- package/dist/features/ext-outbound.js +518 -0
- package/dist/features/ext-outbound.js.map +1 -0
- package/dist/features/ext-reload.d.ts +19 -0
- package/dist/features/ext-reload.d.ts.map +1 -1
- package/dist/features/ext-reload.js +40 -0
- package/dist/features/ext-reload.js.map +1 -1
- package/dist/features/msg-history.d.ts +78 -0
- package/dist/features/msg-history.d.ts.map +1 -0
- package/dist/features/msg-history.js +312 -0
- package/dist/features/msg-history.js.map +1 -0
- package/dist/features/msg-recent.d.ts +72 -0
- package/dist/features/msg-recent.d.ts.map +1 -0
- package/dist/features/msg-recent.js +131 -0
- package/dist/features/msg-recent.js.map +1 -0
- package/dist/features/qq-user-questions.d.ts +6 -0
- package/dist/features/qq-user-questions.d.ts.map +1 -1
- package/dist/features/qq-user-questions.js +17 -3
- package/dist/features/qq-user-questions.js.map +1 -1
- package/dist/gateway/bootstrap.d.ts.map +1 -1
- package/dist/gateway/bootstrap.js +83 -4
- package/dist/gateway/bootstrap.js.map +1 -1
- package/dist/gateway/middleware-setup.d.ts.map +1 -1
- package/dist/gateway/middleware-setup.js +55 -0
- package/dist/gateway/middleware-setup.js.map +1 -1
- package/dist/session/session-manager.d.ts.map +1 -1
- package/dist/session/session-manager.js +5 -2
- package/dist/session/session-manager.js.map +1 -1
- package/dist/transport/inbound.d.ts.map +1 -1
- package/dist/transport/inbound.js +90 -4
- package/dist/transport/inbound.js.map +1 -1
- package/dist/transport/msg-content-cache.d.ts +50 -0
- package/dist/transport/msg-content-cache.d.ts.map +1 -1
- package/dist/transport/msg-content-cache.js +58 -14
- package/dist/transport/msg-content-cache.js.map +1 -1
- package/dist/transport/outbound-buffer.d.ts +31 -1
- package/dist/transport/outbound-buffer.d.ts.map +1 -1
- package/dist/transport/outbound-buffer.js +49 -1
- package/dist/transport/outbound-buffer.js.map +1 -1
- package/dist/transport/outbound.d.ts.map +1 -1
- package/dist/transport/outbound.js +20 -0
- package/dist/transport/outbound.js.map +1 -1
- package/examples/ext-commands//344/274/232/350/257/235/345/210/227/350/241/250.mjs +756 -742
- package/examples/ext-commands//345/224/244/351/206/222.mjs +71 -0
- package/examples/ext-commands//345/255/220/344/274/232/350/257/235.mjs +16 -5
- package/examples/ext-outbound/README.md +139 -0
- package/examples/ext-outbound/sticker-semantic.mjs +524 -0
- package/examples/ext-tools/sticker_auto.mjs +260 -0
- package/examples/ext-tools/vote.mjs +534 -323
- package/package.json +144 -144
package/README.md
CHANGED
|
@@ -91,7 +91,7 @@ QQ 官方**没有开放踢人接口**,所以这一块走"你自己的 QQ 号 +
|
|
|
91
91
|
> 调官方 API / 持久化 / 身份…)就是插件内部模块在用的同一套封装,所以你写的东西不是"外挂",
|
|
92
92
|
> 只是**长在同一条链上的另一个模块**。
|
|
93
93
|
|
|
94
|
-
**🧩
|
|
94
|
+
**🧩 六套扩展点,挑一个放进去就行**
|
|
95
95
|
|
|
96
96
|
| 你想做的事 | 放哪个目录 | 什么时候跑 |
|
|
97
97
|
|---|---|---|
|
|
@@ -100,8 +100,9 @@ QQ 官方**没有开放踢人接口**,所以这一块走"你自己的 QQ 号 +
|
|
|
100
100
|
| 卡片按钮点了要做事 | `botplay/` | 有人点按钮 |
|
|
101
101
|
| 启动时恢复任务 / 起定时器 / 预取 | `hooks/` | 插件启动时跑一次 |
|
|
102
102
|
| **管每一条消息的命运** | `inbound/` | **每条消息都过一遍** |
|
|
103
|
+
| **管每一条出站消息 / 补发媒体** | `outbound/` | **每条要发出去的消息都过一遍** |
|
|
103
104
|
|
|
104
|
-
**🧰
|
|
105
|
+
**🧰 一套能力包,六套通用**(不用为每套各记一套 API)
|
|
105
106
|
|
|
106
107
|
```js
|
|
107
108
|
await env.text('hi') / env.markdown('# 标题') / env.markdownCard(md, keyboard)
|
|
@@ -394,6 +395,40 @@ dsh: disabling profile plugin row "mcp-chrome": Plugin ... is incompatible with
|
|
|
394
395
|
|
|
395
396
|
想强行运行,可用官方提供的**确切版本例外**(`dsh plugin allow-version`,或插件管理页里授予),但官方警告"可能崩溃或数据丢失",自行权衡。
|
|
396
397
|
|
|
398
|
+
### 升级 dsh 0.2.1-rc.2 后,发消息直接「本轮运行失败」/ `unknown prompt variable "{{cwd}}"`?
|
|
399
|
+
|
|
400
|
+
dsh **0.2.1-rc.2** 起系统提示词的变量插值改为**严格模式**:组装阶段只注册 `provider`、`model` 两个变量,
|
|
401
|
+
`{{cwd}}` **不再注册**(当前工作目录改由「工作目录服务」作为运行时上下文注入)。于是组装阶段直接抛错,
|
|
402
|
+
**模型请求根本发不出去** —— 表现是「本轮运行失败」,不是模型回话失败:
|
|
403
|
+
|
|
404
|
+
```
|
|
405
|
+
unknown prompt variable "{{cwd}}" ... registered variables: provider, model
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
- 官方内置的预设模板新版已删掉这两句,**用官方预设不受影响**;
|
|
409
|
+
- 会挂的是**从旧模板复制出来的自定义预设** —— 副本里的 `prefix` / `suffix` 明文还留着:
|
|
410
|
+
- `由 {{model}} 驱动……当前工作目录 {{cwd}}`
|
|
411
|
+
- `Your working directory is {{cwd}}.`
|
|
412
|
+
|
|
413
|
+
**修复**:把 `{{cwd}}` 那半句删掉(保留 `{{model}}`)。工作目录不会丢,框架会以运行时上下文照常提供给模型。
|
|
414
|
+
预设现在只存在 profile 的 `cordis.patch.yml` 里,可以直接跑仓库自带脚本批量清(只动**用户复制出来的预设明文**,
|
|
415
|
+
不碰内置模板;默认只处理挂了 QQ 工具的预设):
|
|
416
|
+
|
|
417
|
+
```powershell
|
|
418
|
+
# ① 先看会改什么(不写盘)
|
|
419
|
+
node scripts/fix-preset-cwd.mjs --dry-run
|
|
420
|
+
|
|
421
|
+
# ② 真修(自动备份为 cordis.patch.yml.bak-cwdfix-<时间戳>)
|
|
422
|
+
node scripts/fix-preset-cwd.mjs
|
|
423
|
+
|
|
424
|
+
# 其它 profile / 指定文件
|
|
425
|
+
node scripts/fix-preset-cwd.mjs --scan
|
|
426
|
+
node scripts/fix-preset-cwd.mjs --file ~/.dsh/profiles/web/cordis.patch.yml
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
脚本幂等:`suffix:` 删空后会补成 `''`(避免 YAML 解析成 null),重复跑不会二次破坏。
|
|
430
|
+
改完保存即热重载,宿主会重新合并出 `cordis.yml`(可 `grep -c '{{cwd}}'` 确认归零)。
|
|
431
|
+
|
|
397
432
|
## 🤖 自定义事件 + 「让 AI 写」(v1.6.7)
|
|
398
433
|
|
|
399
434
|
普通的互动卡片只能「点按钮 → 回一句固定文本」,能力被编辑器框死。
|
|
@@ -611,6 +646,55 @@ AI 侧的工具叫 **`qq_group_admin`**:
|
|
|
611
646
|
- **不常驻**:拿到凭据立刻关;等扫码最多留 5 分钟;宿主退出时会一起带走(不留孤儿进程)
|
|
612
647
|
- 凭据只存在你自己的机器上,仓库里不含任何凭据
|
|
613
648
|
|
|
649
|
+
## ♻️ 撤回消息与自动撤回(v1.10.11+)
|
|
650
|
+
|
|
651
|
+
机器人**是群管理员**时,可以撤回**普通成员**的消息(官方窗口 2 分钟,超时就撤不了,这是平台限制)。
|
|
652
|
+
|
|
653
|
+
### 三个工具
|
|
654
|
+
|
|
655
|
+
| 工具 | 作用 |
|
|
656
|
+
| --- | --- |
|
|
657
|
+
| `group_recall` | 撤某人最近一条 / 群里最近一条 / 指定 message_id |
|
|
658
|
+
| `group_msg_search` | 按关键词或类型搜台账(**含机器人自己发的**),返回 message_id |
|
|
659
|
+
| `group_recall_batch` | 批量撤(给 msg_ids,或给关键词/类型让它自己挑)+ 可选批量禁言发送者 |
|
|
660
|
+
|
|
661
|
+
`gid` 是**可选**的:不传 = 当前会话所在的群;要撤别的群(机器人也是那个群的管理员)才传。
|
|
662
|
+
|
|
663
|
+
### 自动撤回(设置面板 → 🔨 锤子 → ♻️ 自动撤回)
|
|
664
|
+
|
|
665
|
+
命中关键词或附件类型 → 消息**一进来就撤**,不等 AI。配置项 `groupAdmin.autoRecall`:
|
|
666
|
+
|
|
667
|
+
```yaml
|
|
668
|
+
autoRecall:
|
|
669
|
+
enabled: true
|
|
670
|
+
mode: keep # keep=仍进 AI(只撤消息);drop=连 AI 都收不到
|
|
671
|
+
keywords: ["加我微信"]
|
|
672
|
+
kinds: [] # text / image / voice / video / file,按附件类型命中
|
|
673
|
+
muteSeconds: 0 # >0 时顺带禁言发送者
|
|
674
|
+
dryRun: false # true = 只记日志、不真撤
|
|
675
|
+
```
|
|
676
|
+
|
|
677
|
+
> **实现位置很关键**:挂在 **debounce 之前**的中间件里。
|
|
678
|
+
> 写在 `bot.on('message')` 里会被 debounce 吃掉(它 consume 后自己调 `handleInbound`);
|
|
679
|
+
> 写在 `handleInbound` 里又要等派发,等到了往往已过 2 分钟窗口 —— 两种都实测踩过。
|
|
680
|
+
|
|
681
|
+
## 📒 消息历史台账(v1.10.11+)
|
|
682
|
+
|
|
683
|
+
```
|
|
684
|
+
{dataRoot}/.qqbot/msg-history/
|
|
685
|
+
├── _索引.txt # 目录 ↔ 群名 对照,方便人工辨认
|
|
686
|
+
├── group_<群openid>/
|
|
687
|
+
│ ├── 群名.txt # 文件名就是群名
|
|
688
|
+
│ └── 2026-10-20.jsonl # 一天一个文件
|
|
689
|
+
└── c2c_<对方openid>/
|
|
690
|
+
└── 2026-10-20.jsonl
|
|
691
|
+
```
|
|
692
|
+
|
|
693
|
+
- 一行一条:`message_id` / 发送者 / 昵称 / 类型 / 正文摘要 / 时间 / 是否机器人
|
|
694
|
+
- 默认保留 **7 天**(启动时 + 每 200 次写清理过期文件;目录空了自动删)
|
|
695
|
+
- 入站与出站都记;`group_msg_search` / `group_recall*` 就是读它
|
|
696
|
+
- 与引用补全用的 `.qqbot/msg-content.jsonl` **互不干扰**(后者只存被引用消息的正文与图片路径)
|
|
697
|
+
|
|
614
698
|
## 🚫 无上下文模式(按会话省 token)
|
|
615
699
|
|
|
616
700
|
让某个 QQ 会话**每轮只记得最近几条对话**,更早的历史自动折叠 —— 群聊省 token 利器。
|
package/README_EN.md
CHANGED
|
@@ -187,6 +187,37 @@ npm install --legacy-peer-deps # install-time resolution only; runtime behav
|
|
|
187
187
|
|
|
188
188
|
> Tracked: once upstream #37 is fixed and version lines converge, this section can be removed.
|
|
189
189
|
|
|
190
|
+
### After upgrading to dsh 0.2.1-rc.2: every turn fails with `unknown prompt variable "{{cwd}}"`
|
|
191
|
+
|
|
192
|
+
Starting with **0.2.1-rc.2**, dsh resolves system-prompt variables in **strict mode** and only registers
|
|
193
|
+
`provider` and `model`. `{{cwd}}` is **no longer registered** (the working directory is now injected as
|
|
194
|
+
runtime context by the workspace service), so prompt assembly throws before any model request is sent —
|
|
195
|
+
the symptom is "this turn failed", not a bad model reply:
|
|
196
|
+
|
|
197
|
+
```
|
|
198
|
+
unknown prompt variable "{{cwd}}" ... registered variables: provider, model
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
- Presets shipped with dsh already dropped those sentences; **official presets are fine**.
|
|
202
|
+
- What breaks are **custom presets copied from an old template** — their `prefix` / `suffix` text still contains:
|
|
203
|
+
- `由 {{model}} 驱动……当前工作目录 {{cwd}}`
|
|
204
|
+
- `Your working directory is {{cwd}}.`
|
|
205
|
+
|
|
206
|
+
**Fix**: delete the `{{cwd}}` clause (keep `{{model}}`). The working directory is not lost — the framework still
|
|
207
|
+
provides it as runtime context. Presets now live only in the profile's `cordis.patch.yml`, and the bundled script
|
|
208
|
+
cleans them up (it only touches **user-copied preset text**, never built-in templates; by default only presets used
|
|
209
|
+
by the QQ channel):
|
|
210
|
+
|
|
211
|
+
```powershell
|
|
212
|
+
node scripts/fix-preset-cwd.mjs --dry-run # preview only
|
|
213
|
+
node scripts/fix-preset-cwd.mjs # apply (backs up to cordis.patch.yml.bak-cwdfix-<ts>)
|
|
214
|
+
node scripts/fix-preset-cwd.mjs --scan # every profile
|
|
215
|
+
node scripts/fix-preset-cwd.mjs --file <path> # a specific file
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
The script is idempotent and rewrites an emptied `suffix:` as `''` so YAML does not turn it into `null`.
|
|
219
|
+
Saving the file hot-reloads the profile; verify with `grep -c '{{cwd}}' ~/.dsh/profiles/web/cordis.yml`.
|
|
220
|
+
|
|
190
221
|
### 📱 Deploy on Android — the pocket 24/7 setup
|
|
191
222
|
|
|
192
223
|
[dsh-mobile-apk](https://github.com/kelai141/dsh-mobile-apk) is a community-built **Android shell APK for dsh**
|