@yangfan1998/dsh-qqbot-plus 0.1.0 → 0.1.2
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 +111 -91
- package/extensions/README.md +3 -0
- package/extensions/outbound/random-sticker.mjs +96 -0
- package/package.json +9 -1
package/README.md
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
1
|
# @yangfan1998/dsh-qqbot-plus
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**DeepSeek Harness 的 QQ 机器人整合包:装一次,带网关、识图、语音和 B 站工具。**
|
|
4
4
|
|
|
5
|
-
`@yangfan1998/dsh-qqbot-plus`
|
|
5
|
+
`@yangfan1998/dsh-qqbot-plus` 会挂载 [`@zaofan/dsh-qqbot`](https://www.npmjs.com/package/@zaofan/dsh-qqbot) 网关,并额外提供:
|
|
6
6
|
|
|
7
|
-
- `qqbot_describe_image` —
|
|
8
|
-
- `tts_speak` — Edge TTS
|
|
9
|
-
- `bili_read` / `bili_search` / `bili_hot` / `bili_frames` —
|
|
7
|
+
- `qqbot_describe_image` — 图片理解 / OCR
|
|
8
|
+
- `tts_speak` — Edge TTS 语音(mp3)
|
|
9
|
+
- `bili_read` / `bili_search` / `bili_hot` / `bili_frames` — B 站视频、弹幕、评论、缩略图理解
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
它是 **bundle**,不是 QQ 网关的 fork。网关仍然是 `@zaofan/dsh-qqbot`,可以独立升级。
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
本机另外还有 9 个自写插件(热榜 / 论文 / QQ 音乐 / token 用量 / 视频生成 / 群聊心跳等),
|
|
14
|
+
它们不发布到 npm,只放在 profile 的 `plugins/` 目录;清单见 [STATUS.md](./STATUS.md)。
|
|
15
|
+
|
|
16
|
+
> 当前版本:`0.1.2`(仓库)。npm 上最新已发布为 `0.1.1`,`0.1.2` 尚未发布成功(本机 npm 登录态失效)。
|
|
17
|
+
>
|
|
18
|
+
> 本机实际部署状态(桌面版托管、插件清单、已知问题)见 [STATUS.md](./STATUS.md)。
|
|
14
19
|
|
|
15
20
|
---
|
|
16
21
|
|
|
17
|
-
##
|
|
22
|
+
## 环境要求
|
|
18
23
|
|
|
19
|
-
|
|
|
24
|
+
| 项目 | 要求 |
|
|
20
25
|
|---|---|
|
|
21
26
|
| Node.js | `>= 22.13` |
|
|
22
27
|
| DeepSeek Harness | `>= 0.2.1-alpha.2` |
|
|
23
|
-
| QQ
|
|
24
|
-
|
|
|
25
|
-
| TTS
|
|
26
|
-
|
|
|
28
|
+
| QQ 机器人 | QQ 开放平台的 AppID + AppSecret |
|
|
29
|
+
| 识图模型 | 支持图片输入的 LLM 路由(默认 `zhipu/aliyun/qwen3-vl-plus`) |
|
|
30
|
+
| TTS(可选) | `edge-tts` 可执行文件在 `PATH`,或配置 `tts.bin` |
|
|
31
|
+
| B 站(可选) | 公开数据不需要 Key;`BILIBILI_SESSDATA` 可解锁字幕 |
|
|
27
32
|
|
|
28
33
|
---
|
|
29
34
|
|
|
30
|
-
##
|
|
35
|
+
## 安装
|
|
31
36
|
|
|
32
|
-
###
|
|
37
|
+
### 方式一:从 npm 安装(推荐)
|
|
33
38
|
|
|
34
39
|
```bash
|
|
35
|
-
|
|
36
|
-
npm pack
|
|
37
|
-
# produces yangfan1998-dsh-qqbot-plus-0.1.0.tgz
|
|
38
|
-
|
|
39
|
-
dsh plugin --profile <your-profile> add ./yangfan1998-dsh-qqbot-plus-0.1.0.tgz
|
|
40
|
+
dsh plugin --profile <你的profile> add @yangfan1998/dsh-qqbot-plus
|
|
40
41
|
```
|
|
41
42
|
|
|
42
|
-
|
|
43
|
+
如果 pnpm 报 `ERR_PNPM_IGNORED_BUILDS`(QQ 网关依赖的 `onnxruntime-node` / `protobufjs`):
|
|
43
44
|
|
|
44
45
|
```bash
|
|
45
|
-
cd ~/.dsh/profiles
|
|
46
|
+
cd ~/.dsh/profiles/<你的profile>
|
|
46
47
|
pnpm approve-builds --all
|
|
47
48
|
```
|
|
48
49
|
|
|
49
|
-
|
|
50
|
-
auto-append bundle packages in all DSH versions):
|
|
50
|
+
然后把这个 bundle 加进 profile 的 `package.json`(部分 DSH 版本的插件管理器不会自动追加):
|
|
51
51
|
|
|
52
52
|
```json
|
|
53
53
|
{
|
|
@@ -63,59 +63,67 @@ auto-append bundle packages in all DSH versions):
|
|
|
63
63
|
}
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
启动前先确认组合树:
|
|
67
67
|
|
|
68
68
|
```bash
|
|
69
|
-
dsh --profile
|
|
70
|
-
dsh --profile
|
|
69
|
+
dsh --profile <你的profile> --dump-config | grep -A3 'id: im-qqbot'
|
|
70
|
+
dsh --profile <你的profile> --dump-config | grep -A3 'id: qqbot-plus'
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
-
###
|
|
73
|
+
### 方式二:从本地 tarball 安装
|
|
74
74
|
|
|
75
75
|
```bash
|
|
76
|
-
|
|
76
|
+
cd /path/to/dsh-qqbot-plus
|
|
77
|
+
npm pack
|
|
78
|
+
# 生成 yangfan1998-dsh-qqbot-plus-0.1.0.tgz
|
|
79
|
+
|
|
80
|
+
dsh plugin --profile <你的profile> add ./yangfan1998-dsh-qqbot-plus-0.1.0.tgz
|
|
77
81
|
```
|
|
78
82
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
83
|
+
### 方式三:已经有 QQ 网关的 profile
|
|
84
|
+
|
|
85
|
+
这个包默认会插入 `im-qqbot`。如果你已经装了 `@zaofan/dsh-qqbot`,**不要**把本包加入 `dsh.profile.bundles`,否则会出现重复的 `im-qqbot`。
|
|
86
|
+
|
|
87
|
+
改为:安装本包后,把 [`cordis.tools-only.yml`](./cordis.tools-only.yml) 里的 `- insert:` 段复制到你 profile 自己的 `cordis.patch.yml`。
|
|
82
88
|
|
|
83
89
|
---
|
|
84
90
|
|
|
85
|
-
##
|
|
91
|
+
## 配置凭据
|
|
86
92
|
|
|
87
|
-
|
|
93
|
+
bundle 的 `cordis.patch.yml` 使用 `__FROM_ENV__` 读取 `appId` / `appSecret`。
|
|
88
94
|
|
|
89
|
-
###
|
|
95
|
+
### 方式 A:环境变量
|
|
90
96
|
|
|
91
97
|
```bash
|
|
92
98
|
export QQBOT_APPID=1905977275
|
|
93
|
-
export QQBOT_APP_SECRET
|
|
99
|
+
export QQBOT_APP_SECRET=你的secret
|
|
94
100
|
```
|
|
95
101
|
|
|
96
|
-
###
|
|
102
|
+
### 方式 B:直接写 profile patch
|
|
97
103
|
|
|
98
|
-
|
|
104
|
+
编辑 profile 的 `cordis.patch.yml` 里的 `im-qqbot` 行:
|
|
99
105
|
|
|
100
106
|
```yaml
|
|
101
107
|
- id: im-qqbot
|
|
102
108
|
name: '@zaofan/dsh-qqbot'
|
|
103
109
|
config:
|
|
104
110
|
appId: '1905977275'
|
|
105
|
-
appSecret: '
|
|
111
|
+
appSecret: '你的secret'
|
|
106
112
|
```
|
|
107
113
|
|
|
108
|
-
|
|
114
|
+
不要把真实密钥提交到 Git。
|
|
115
|
+
|
|
116
|
+
如果想让机器人接收非 @ 的群消息,群主还需要在 QQ 机器人资料页开启“接收群消息/通知”。
|
|
109
117
|
|
|
110
118
|
---
|
|
111
119
|
|
|
112
|
-
##
|
|
120
|
+
## 工具配置
|
|
113
121
|
|
|
114
|
-
|
|
122
|
+
bundle 自带安全默认值。覆盖时改 `qqbot-plus` 行:
|
|
115
123
|
|
|
116
124
|
```yaml
|
|
117
125
|
- id: qqbot-plus
|
|
118
|
-
name: @yangfan1998/dsh-qqbot-plus
|
|
126
|
+
name: '@yangfan1998/dsh-qqbot-plus'
|
|
119
127
|
config:
|
|
120
128
|
vision:
|
|
121
129
|
provider: zhipu
|
|
@@ -134,58 +142,61 @@ The bundle's `cordis.patch.yml` ships safe defaults. Override them in the `qqbot
|
|
|
134
142
|
replyLimit: 5
|
|
135
143
|
```
|
|
136
144
|
|
|
137
|
-
###
|
|
145
|
+
### 识图
|
|
138
146
|
|
|
139
|
-
|
|
147
|
+
只要你的 LLM 路由里有支持 `image` 输入的模型即可。模型必须在 `llm-pi-ai`(或其他 LLM 插件)的 provider 配置里存在。
|
|
140
148
|
|
|
141
|
-
|
|
149
|
+
模型不可用时,`qqbot_describe_image` 会自动禁用;不会拖垮整个插件。
|
|
142
150
|
|
|
143
|
-
|
|
151
|
+
### 语音
|
|
152
|
+
|
|
153
|
+
`tts_speak` 调用外部 `edge-tts`,默认把 mp3 写到 `downloads/tts`。
|
|
144
154
|
|
|
145
155
|
```bash
|
|
146
156
|
python3 -m pip install edge-tts
|
|
147
|
-
#
|
|
157
|
+
# 或者指向已有 venv:
|
|
148
158
|
# tts.bin: /path/to/venv/bin/edge-tts
|
|
149
159
|
```
|
|
150
160
|
|
|
151
|
-
|
|
161
|
+
`edge-tts` 不可用时,工具会返回明确错误,不会让插件崩溃。
|
|
152
162
|
|
|
153
|
-
###
|
|
163
|
+
### B 站
|
|
154
164
|
|
|
155
|
-
|
|
165
|
+
公开视频的元数据、弹幕、评论不需要 Cookie;字幕通常需要登录:
|
|
156
166
|
|
|
157
167
|
```bash
|
|
158
|
-
export BILIBILI_SESSDATA
|
|
168
|
+
export BILIBILI_SESSDATA=你的SESSDATA
|
|
159
169
|
```
|
|
160
170
|
|
|
161
|
-
|
|
171
|
+
B 站会限流匿名请求;工具内部做了节流,并缓存匿名 `buvid3` Cookie。
|
|
162
172
|
|
|
163
173
|
---
|
|
164
174
|
|
|
165
|
-
##
|
|
175
|
+
## 工具列表
|
|
166
176
|
|
|
167
|
-
|
|
|
177
|
+
| 工具 | 用途 |
|
|
168
178
|
|---|---|
|
|
169
|
-
| `qqbot_describe_image` |
|
|
170
|
-
| `tts_speak` |
|
|
171
|
-
| `bili_read` |
|
|
172
|
-
| `bili_search` |
|
|
173
|
-
| `bili_hot` |
|
|
174
|
-
| `bili_frames` |
|
|
179
|
+
| `qqbot_describe_image` | 看一张本地图片或 URL;OCR、表格、截图、照片 |
|
|
180
|
+
| `tts_speak` | 用 Edge TTS 生成短语音 mp3;再用 `send_media(kind="voice")` 发出 |
|
|
181
|
+
| `bili_read` | 视频元数据、弹幕、热评(含楼中楼)、可选字幕 |
|
|
182
|
+
| `bili_search` | 按标题/关键词搜 B 站,返回 BV 和匹配度 |
|
|
183
|
+
| `bili_hot` | B 站热门榜 |
|
|
184
|
+
| `bili_frames` | 视频缩略图拼图 → 视觉模型概述;分辨率低,不要当事实 |
|
|
175
185
|
|
|
176
186
|
---
|
|
177
187
|
|
|
178
|
-
##
|
|
188
|
+
## 可选扩展
|
|
179
189
|
|
|
180
|
-
|
|
190
|
+
包内带了两个 `{dataRoot}/.qqbot-extensions` 扩展:
|
|
181
191
|
|
|
182
|
-
- `extensions/inbound/bili-card-url.mjs` —
|
|
183
|
-
- `extensions/outbound/abs-image-paths.mjs` —
|
|
192
|
+
- `extensions/inbound/bili-card-url.mjs` — 从 QQ 小程序卡片的 raw 数据里提取 B 站 URL。只接受 URL,不接受裸 `BV...`,因为 QQ message id 里可能刚好包含假 BV。
|
|
193
|
+
- `extensions/outbound/abs-image-paths.mjs` — 发图前把 markdown 里的相对图片路径改成绝对路径。
|
|
194
|
+
- `extensions/outbound/random-sticker.mjs` — 回复发完后按概率从正式图库补一张表情包;只作用于群聊,默认 15% 概率、同一会话 10 分钟冷却。
|
|
184
195
|
|
|
185
|
-
|
|
196
|
+
复制到 QQ 机器人的数据根:
|
|
186
197
|
|
|
187
198
|
```bash
|
|
188
|
-
DATA_ROOT="/path/to/qqbot/data-root" #
|
|
199
|
+
DATA_ROOT="/path/to/qqbot/data-root" # 通常是 <im-qqbot.cwd>/dshqqbot
|
|
189
200
|
PKG_DIR="$(node -e "console.log(require.resolve('@yangfan1998/dsh-qqbot-plus'))" | xargs dirname)"
|
|
190
201
|
|
|
191
202
|
mkdir -p "$DATA_ROOT/.qqbot-extensions/inbound" "$DATA_ROOT/.qqbot-extensions/outbound"
|
|
@@ -193,43 +204,52 @@ cp "$PKG_DIR/extensions/inbound/bili-card-url.mjs" "$DATA_ROOT/.qqbot-extensions
|
|
|
193
204
|
cp "$PKG_DIR/extensions/outbound/abs-image-paths.mjs" "$DATA_ROOT/.qqbot-extensions/outbound/"
|
|
194
205
|
```
|
|
195
206
|
|
|
196
|
-
`abs-image-paths`
|
|
207
|
+
`abs-image-paths` 默认用 `process.cwd()` 解析相对路径;如果宿主 cwd 和 `im-qqbot.cwd` 不一致,设置 `QQBOT_CWD`。
|
|
208
|
+
|
|
209
|
+
`random-sticker` 可调:
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
QQBOT_STICKER_PROB=0.15 # 每次回复补图概率
|
|
213
|
+
QQBOT_STICKER_COOLDOWN_MIN=10 # 同一会话最短间隔(分钟)
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
它只从 `{dataRoot}/lib/library` 或 `{dataRoot}/表情包/lib/library` 里选图,不会用候选区/回收站的图。
|
|
197
217
|
|
|
198
218
|
---
|
|
199
219
|
|
|
200
|
-
##
|
|
220
|
+
## 不包含什么
|
|
201
221
|
|
|
202
|
-
-
|
|
203
|
-
-
|
|
204
|
-
-
|
|
205
|
-
-
|
|
206
|
-
-
|
|
222
|
+
- 不包含 QQ AppID / AppSecret / API Key / Cookie
|
|
223
|
+
- 不包含人设或群守则(自带你的)
|
|
224
|
+
- 不包含表情包图库(第三方素材授权问题)
|
|
225
|
+
- 不包含 Web 设置页;通过 `cordis.patch.yml` 或环境变量配置
|
|
226
|
+
- 不包含 `launchd` / systemd 服务文件;部署方式由你决定
|
|
207
227
|
|
|
208
228
|
---
|
|
209
229
|
|
|
210
|
-
##
|
|
230
|
+
## 安全说明
|
|
211
231
|
|
|
212
|
-
-
|
|
213
|
-
-
|
|
214
|
-
- `tts_speak`
|
|
215
|
-
-
|
|
232
|
+
- B 站工具会访问 `bilibili.com`、`b23.tv` 和 `api.bilibili.com`。
|
|
233
|
+
- 识图工具只下载你传入的 `http(s)` 图片,不扫描任意文件。
|
|
234
|
+
- `tts_speak` 会用配置的 `edge-tts` 可执行文件执行文本参数;不要把 `tts.bin` 指向不可信脚本。
|
|
235
|
+
- 本包不内置任何凭据。建议用专门的 QQ 机器人账号运行。
|
|
216
236
|
|
|
217
237
|
---
|
|
218
238
|
|
|
219
|
-
##
|
|
239
|
+
## 发布检查
|
|
220
240
|
|
|
221
|
-
- [ ] `npm pack`
|
|
222
|
-
- [ ]
|
|
223
|
-
- [ ]
|
|
224
|
-
- [ ]
|
|
225
|
-
- [ ]
|
|
226
|
-
- [ ]
|
|
227
|
-
- [ ] `npm publish
|
|
228
|
-
- [ ]
|
|
229
|
-
- [ ]
|
|
241
|
+
- [ ] `npm pack` 后在全新测试 profile 安装
|
|
242
|
+
- [ ] 确认 `im-qqbot` + `qqbot-plus` 都激活
|
|
243
|
+
- [ ] 用真实图片验证 `qqbot_describe_image`
|
|
244
|
+
- [ ] 用 `edge-tts` 验证 `tts_speak`
|
|
245
|
+
- [ ] 用公开 BV 验证 `bili_read`
|
|
246
|
+
- [ ] 更新 `package.json` 里的版本/作者/仓库
|
|
247
|
+
- [ ] `npm publish`(需要 npm 账号和 2FA)
|
|
248
|
+
- [ ] 推到自己的 GitHub 仓库(不要复用别人的凭据)
|
|
249
|
+
- [ ] 加 `dsh-plugin` topic,提交到 DSH 插件市场
|
|
230
250
|
|
|
231
251
|
---
|
|
232
252
|
|
|
233
|
-
##
|
|
253
|
+
## 许可证
|
|
234
254
|
|
|
235
|
-
MIT
|
|
255
|
+
MIT,见 [LICENSE](./LICENSE)。
|
package/extensions/README.md
CHANGED
|
@@ -16,5 +16,8 @@ the QQ bot's data root:
|
|
|
16
16
|
- `abs-image-paths.mjs`: rewrites relative markdown image paths to absolute
|
|
17
17
|
paths so the QQ uploader can find them. It resolves against `process.cwd()`;
|
|
18
18
|
set `QQBOT_CWD` when the host cwd differs from `im-qqbot.cwd`.
|
|
19
|
+
- `random-sticker.mjs`: after a group reply, picks a sticker from the formal
|
|
20
|
+
`lib/library` with a configurable probability (`QQBOT_STICKER_PROB`, default
|
|
21
|
+
0.15) and per-peer cooldown (`QQBOT_STICKER_COOLDOWN_MIN`, default 10).
|
|
19
22
|
|
|
20
23
|
Reload extensions with `/tools-reload` (or restart the bot).
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* random-sticker.mjs — 回复发完后,按概率自动补一张表情包。
|
|
3
|
+
*
|
|
4
|
+
* 用 fork 的出站 turnEnd 阶段:正文已经发完,补图走先被动后主动通道,
|
|
5
|
+
* 不阻塞正文。只从 {dataRoot}/lib/library 里选「正式库」的图。
|
|
6
|
+
*
|
|
7
|
+
* 环境变量:
|
|
8
|
+
* QQBOT_STICKER_PROB=0.15 每次回复补图概率
|
|
9
|
+
* QQBOT_STICKER_COOLDOWN_MIN=10 同一会话最短间隔(分钟)
|
|
10
|
+
*/
|
|
11
|
+
import { readdir, stat } from 'node:fs/promises'
|
|
12
|
+
import { join, extname } from 'node:path'
|
|
13
|
+
|
|
14
|
+
export const name = 'random-sticker'
|
|
15
|
+
|
|
16
|
+
const IMAGE_EXT = new Set(['.jpg', '.jpeg', '.png', '.gif', '.webp'])
|
|
17
|
+
const PROB = Math.max(0, Math.min(1, Number(process.env.QQBOT_STICKER_PROB ?? 0.15)))
|
|
18
|
+
const COOLDOWN_MS = Math.max(0, Number(process.env.QQBOT_STICKER_COOLDOWN_MIN ?? 10)) * 60_000
|
|
19
|
+
const RECENT_KEEP = 8
|
|
20
|
+
|
|
21
|
+
/** peerId -> last sent ms */
|
|
22
|
+
const lastSentAt = new Map()
|
|
23
|
+
/** 最近发过的文件,避免连续重复 */
|
|
24
|
+
const recent = []
|
|
25
|
+
|
|
26
|
+
async function listLibrary(dataRoot) {
|
|
27
|
+
const candidates = [
|
|
28
|
+
join(String(dataRoot || ''), 'lib', 'library'),
|
|
29
|
+
join(String(dataRoot || ''), '表情包', 'lib', 'library'),
|
|
30
|
+
join(process.cwd(), '表情包', 'lib', 'library'),
|
|
31
|
+
]
|
|
32
|
+
for (const dir of candidates) {
|
|
33
|
+
if (!dir || dir.includes('undefined')) continue
|
|
34
|
+
let entries
|
|
35
|
+
try {
|
|
36
|
+
entries = await readdir(dir, { withFileTypes: true })
|
|
37
|
+
} catch {
|
|
38
|
+
continue
|
|
39
|
+
}
|
|
40
|
+
const out = []
|
|
41
|
+
for (const e of entries) {
|
|
42
|
+
if (!e.isFile()) continue
|
|
43
|
+
const ext = extname(e.name).toLowerCase()
|
|
44
|
+
if (!IMAGE_EXT.has(ext)) continue
|
|
45
|
+
const path = join(dir, e.name)
|
|
46
|
+
try {
|
|
47
|
+
const info = await stat(path)
|
|
48
|
+
if (info.isFile() && info.size > 0 && info.size <= 10 * 1024 * 1024) out.push(path)
|
|
49
|
+
} catch { /* skip */ }
|
|
50
|
+
}
|
|
51
|
+
if (out.length > 0) return out
|
|
52
|
+
}
|
|
53
|
+
return []
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function pick(files) {
|
|
57
|
+
if (files.length === 0) return null
|
|
58
|
+
const fresh = files.filter((p) => !recent.includes(p))
|
|
59
|
+
const pool = fresh.length > 0 ? fresh : files
|
|
60
|
+
return pool[Math.floor(Math.random() * pool.length)] ?? null
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export async function onOutbound(ctx, next) {
|
|
64
|
+
try {
|
|
65
|
+
if (ctx.phase !== 'turnEnd' || !ctx.isLastChunk) return next()
|
|
66
|
+
if (ctx.kind === 'media' || ctx.kind === 'card' || ctx.kind === 'forward') return next()
|
|
67
|
+
const scope = String(ctx.target?.scope ?? '')
|
|
68
|
+
if (scope && scope !== 'group') return next()
|
|
69
|
+
const text = String(ctx.text ?? '').trim()
|
|
70
|
+
if (!text || text.length < 2) return next()
|
|
71
|
+
if (/\[MEDIA:|!\[|qqbot-media:|\[表情/.test(text)) return next()
|
|
72
|
+
|
|
73
|
+
const peer = String(ctx.target?.peerId ?? '')
|
|
74
|
+
const now = Date.now()
|
|
75
|
+
const last = lastSentAt.get(peer) ?? 0
|
|
76
|
+
if (last && now - last < COOLDOWN_MS) return next()
|
|
77
|
+
if (Math.random() >= PROB) return next()
|
|
78
|
+
|
|
79
|
+
const files = await listLibrary(ctx.dataRoot)
|
|
80
|
+
const path = pick(files)
|
|
81
|
+
if (!path) return next()
|
|
82
|
+
lastSentAt.set(peer, now)
|
|
83
|
+
recent.push(path)
|
|
84
|
+
while (recent.length > RECENT_KEEP) recent.shift()
|
|
85
|
+
|
|
86
|
+
ctx.background(async () => {
|
|
87
|
+
try {
|
|
88
|
+
const ok = await ctx.sendMedia({ path })
|
|
89
|
+
if (!ok) ctx.note?.('random-sticker: sendMedia returned false')
|
|
90
|
+
} catch (e) {
|
|
91
|
+
ctx.logger?.warn?.(`[random-sticker] send failed: ${e instanceof Error ? e.message : String(e)}`)
|
|
92
|
+
}
|
|
93
|
+
})
|
|
94
|
+
} catch { /* 出站扩展永远不能影响正文 */ }
|
|
95
|
+
return next()
|
|
96
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yangfan1998/dsh-qqbot-plus",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "One-install DeepSeek Harness QQ bot bundle: @zaofan/dsh-qqbot gateway plus vision, Edge TTS and Bilibili reading tools.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -52,5 +52,13 @@
|
|
|
52
52
|
"engines": {
|
|
53
53
|
"dsh": ">=0.2.1-alpha.2"
|
|
54
54
|
}
|
|
55
|
+
},
|
|
56
|
+
"repository": {
|
|
57
|
+
"type": "git",
|
|
58
|
+
"url": "git+https://github.com/FanFFF/dsh-qqbot-plus.git"
|
|
59
|
+
},
|
|
60
|
+
"homepage": "https://github.com/FanFFF/dsh-qqbot-plus#readme",
|
|
61
|
+
"bugs": {
|
|
62
|
+
"url": "https://github.com/FanFFF/dsh-qqbot-plus/issues"
|
|
55
63
|
}
|
|
56
64
|
}
|