qq-bot-roost 1.0.15 → 1.0.16-beta.1
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 +1 -1
- package/package.json +58 -58
- package/src/api.js +11 -2
- package/src/host/media.js +25 -1
- package/src/host/methods.js +933 -756
- package/src/onebot/voice.js +53 -0
- package/src/outbound.js +19 -11
- package/src/plugin/loader.js +5 -4
- package/src/semver.js +19 -0
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<img src="https://img.shields.io/badge/dependencies-0-brightgreen" alt="零依赖">
|
|
11
11
|
<img src="https://img.shields.io/badge/tests-1034%20passed-brightgreen" alt="测试 1034 项">
|
|
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.0.
|
|
13
|
+
<img src="https://img.shields.io/badge/version-1.0.16--beta.1-blueviolet" alt="版本 1.0.16-beta.1">
|
|
14
14
|
<img src="https://img.shields.io/badge/license-AGPL--3.0--only-blue" alt="AGPL-3.0-only">
|
|
15
15
|
<a href="https://github.com/tdcq9594/qq-bot-roost/actions"><img src="https://img.shields.io/github/actions/workflow/status/tdcq9594/qq-bot-roost/ci.yml?branch=master" alt="CI"></a>
|
|
16
16
|
|
package/package.json
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "qq-bot-roost",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"description": "栖 Roost:零依赖的 QQ 官方机器人框架,填 AppID/AppSecret 即连,插件可写任意语言",
|
|
6
|
-
"license": "AGPL-3.0-only",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/tdcq9594/qq-bot-roost.git"
|
|
10
|
-
},
|
|
11
|
-
"bugs": {
|
|
12
|
-
"url": "https://github.com/tdcq9594/qq-bot-roost/issues"
|
|
13
|
-
},
|
|
14
|
-
"homepage": "https://github.com/tdcq9594/qq-bot-roost#readme",
|
|
15
|
-
"keywords": [
|
|
16
|
-
"qq-bot",
|
|
17
|
-
"qqbot",
|
|
18
|
-
"bot-framework",
|
|
19
|
-
"qq-official-bot",
|
|
20
|
-
"roost",
|
|
21
|
-
"multi-bot",
|
|
22
|
-
"plugin",
|
|
23
|
-
"zero-dependency"
|
|
24
|
-
],
|
|
25
|
-
"engines": {
|
|
26
|
-
"node": ">=22.13"
|
|
27
|
-
},
|
|
28
|
-
"scripts": {
|
|
29
|
-
"start": "node src/main.js",
|
|
30
|
-
"mock": "node src/main.js --mock",
|
|
31
|
-
"check": "node src/main.js --check",
|
|
32
|
-
"test": "node test/selftest.mjs && node test/qrlogin.mjs && node test/deps.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/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 test/plugin-observability.mjs && node --test test/outbound-dry.mjs && node --test test/ext-deps-migrate.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/web-token-echo.mjs",
|
|
33
|
-
"test:e2e": "node test/e2e.mjs",
|
|
34
|
-
"test:all": "node test/selftest.mjs && node test/qrlogin.mjs && node test/deps.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/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-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/web-token-echo.mjs",
|
|
35
|
-
"check:secrets": "node scripts/check-secrets.mjs",
|
|
36
|
-
"create": "node scripts/create-plugin.mjs",
|
|
37
|
-
"test:plugin": "node scripts/test-plugin.mjs",
|
|
38
|
-
"live": "node scripts/live-test.mjs",
|
|
39
|
-
"market:index": "node scripts/build-market-index.mjs",
|
|
40
|
-
"sums": "node scripts/build-sums.mjs",
|
|
41
|
-
"sums:check": "node scripts/build-sums.mjs --check",
|
|
42
|
-
"sums:verify": "node scripts/build-sums.mjs --verify",
|
|
43
|
-
"test:coverage": "node --experimental-test-coverage --test-coverage-lines=95 --test-coverage-branches=80 --test-coverage-include=src/trust.js --test-coverage-include=src/plugin/manifest.js --test-coverage-include=src/trace.js --test test/trust.mjs test/manifest.mjs test/trace.mjs"
|
|
44
|
-
},
|
|
45
|
-
"author": {
|
|
46
|
-
"name": "倦飞之鸟"
|
|
47
|
-
},
|
|
48
|
-
"files": [
|
|
49
|
-
"src",
|
|
50
|
-
"web",
|
|
51
|
-
"sdk",
|
|
52
|
-
"types",
|
|
53
|
-
"docs",
|
|
54
|
-
"config/*.example.json",
|
|
55
|
-
"README.md",
|
|
56
|
-
"LICENSE"
|
|
57
|
-
]
|
|
58
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "qq-bot-roost",
|
|
3
|
+
"version": "1.0.16-beta.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "栖 Roost:零依赖的 QQ 官方机器人框架,填 AppID/AppSecret 即连,插件可写任意语言",
|
|
6
|
+
"license": "AGPL-3.0-only",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/tdcq9594/qq-bot-roost.git"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/tdcq9594/qq-bot-roost/issues"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/tdcq9594/qq-bot-roost#readme",
|
|
15
|
+
"keywords": [
|
|
16
|
+
"qq-bot",
|
|
17
|
+
"qqbot",
|
|
18
|
+
"bot-framework",
|
|
19
|
+
"qq-official-bot",
|
|
20
|
+
"roost",
|
|
21
|
+
"multi-bot",
|
|
22
|
+
"plugin",
|
|
23
|
+
"zero-dependency"
|
|
24
|
+
],
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=22.13"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"start": "node src/main.js",
|
|
30
|
+
"mock": "node src/main.js --mock",
|
|
31
|
+
"check": "node src/main.js --check",
|
|
32
|
+
"test": "node test/selftest.mjs && node test/qrlogin.mjs && node test/deps.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/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 test/plugin-observability.mjs && node --test test/outbound-dry.mjs && node --test test/ext-deps-migrate.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/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",
|
|
33
|
+
"test:e2e": "node test/e2e.mjs",
|
|
34
|
+
"test:all": "node test/selftest.mjs && node test/qrlogin.mjs && node test/deps.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/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-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/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",
|
|
35
|
+
"check:secrets": "node scripts/check-secrets.mjs",
|
|
36
|
+
"create": "node scripts/create-plugin.mjs",
|
|
37
|
+
"test:plugin": "node scripts/test-plugin.mjs",
|
|
38
|
+
"live": "node scripts/live-test.mjs",
|
|
39
|
+
"market:index": "node scripts/build-market-index.mjs",
|
|
40
|
+
"sums": "node scripts/build-sums.mjs",
|
|
41
|
+
"sums:check": "node scripts/build-sums.mjs --check",
|
|
42
|
+
"sums:verify": "node scripts/build-sums.mjs --verify",
|
|
43
|
+
"test:coverage": "node --experimental-test-coverage --test-coverage-lines=95 --test-coverage-branches=80 --test-coverage-include=src/trust.js --test-coverage-include=src/plugin/manifest.js --test-coverage-include=src/trace.js --test test/trust.mjs test/manifest.mjs test/trace.mjs"
|
|
44
|
+
},
|
|
45
|
+
"author": {
|
|
46
|
+
"name": "倦飞之鸟"
|
|
47
|
+
},
|
|
48
|
+
"files": [
|
|
49
|
+
"src",
|
|
50
|
+
"web",
|
|
51
|
+
"sdk",
|
|
52
|
+
"types",
|
|
53
|
+
"docs",
|
|
54
|
+
"config/*.example.json",
|
|
55
|
+
"README.md",
|
|
56
|
+
"LICENSE"
|
|
57
|
+
]
|
|
58
|
+
}
|
package/src/api.js
CHANGED
|
@@ -122,7 +122,8 @@ const PASSIVE_MAX_SEQ = 5;
|
|
|
122
122
|
* 构造发送报文。抽成纯函数是为了能单测——`#payload` 是私有方法,测试摸不到。
|
|
123
123
|
*
|
|
124
124
|
* @param {object} opts 驼峰字段:content / msgType / msgId / msgSeq / eventId /
|
|
125
|
-
* markdown / keyboard / media / card / ark / messageReference
|
|
125
|
+
* markdown / keyboard / media / card / ark / messageReference /
|
|
126
|
+
* isWakeup(互动召回,官方独立额度)
|
|
126
127
|
* @param {(msgId:string)=>number} nextSeq 取下一个 msg_seq
|
|
127
128
|
* @returns {object} 官方要的 snake_case 报文
|
|
128
129
|
*/
|
|
@@ -133,6 +134,7 @@ export function buildSendPayload(opts = {}, nextSeq = () => 1) {
|
|
|
133
134
|
msgId,
|
|
134
135
|
msgSeq,
|
|
135
136
|
eventId,
|
|
137
|
+
isWakeup,
|
|
136
138
|
markdown,
|
|
137
139
|
keyboard,
|
|
138
140
|
media,
|
|
@@ -153,6 +155,13 @@ export function buildSendPayload(opts = {}, nextSeq = () => 1) {
|
|
|
153
155
|
* 与 msg_id 二选一。
|
|
154
156
|
*/
|
|
155
157
|
if (eventId) payload.event_id = eventId;
|
|
158
|
+
/**
|
|
159
|
+
* 4.6 互动召回(官方口径):用户主动对话后 30 天内,当天 / 1–3 天 /
|
|
160
|
+
* 3–7 天 / 7–30 天四个窗口各 1 条。带上它服务端不校验
|
|
161
|
+
* msg_id / event_id 有效期,也不算普通主动推送的额度。
|
|
162
|
+
* 上游(dsh-roost)按窗口记账,这里只负责把声明透传出去。
|
|
163
|
+
*/
|
|
164
|
+
if (isWakeup === true) payload.is_wakeup = true;
|
|
156
165
|
if (markdown) {
|
|
157
166
|
// 官方:填了 markdown 后 content 必须为空,否则 40034008 / 304061
|
|
158
167
|
payload.content = '';
|
|
@@ -1092,7 +1101,7 @@ export class QQApi {
|
|
|
1092
1101
|
if (!this.groupInvited) {
|
|
1093
1102
|
throw new Error(
|
|
1094
1103
|
'群管内邀功能未开启。群成员列表 / 踢人 / 群黑名单需要官方白名单,' +
|
|
1095
|
-
'
|
|
1104
|
+
'申请通过后到 Roost 面板(浏览器打开的那个)「配置 → 群管能力」打开',
|
|
1096
1105
|
);
|
|
1097
1106
|
}
|
|
1098
1107
|
}
|
package/src/host/media.js
CHANGED
|
@@ -26,7 +26,7 @@ import path from 'node:path';
|
|
|
26
26
|
import { FILE_TYPE, IMAGE_CONTENT_TYPES } from '../api.js';
|
|
27
27
|
import { netFetch } from '../proxy.js';
|
|
28
28
|
import * as deps from '../ext-deps.js';
|
|
29
|
-
import { toSilk, uploadVoice, MAX_VOICE_BYTES } from '../onebot/voice.js';
|
|
29
|
+
import { toSilk, toSilkDry, uploadVoice, MAX_VOICE_BYTES } from '../onebot/voice.js';
|
|
30
30
|
import { sendOut, receivedAtOf } from './dispatch.js';
|
|
31
31
|
|
|
32
32
|
/** 官方所有富媒体类型的硬上限;会话累计超过就拒,别等 API 报 850031 */
|
|
@@ -288,6 +288,30 @@ export function registerMedia(def, { R, err, log = () => {} }) {
|
|
|
288
288
|
return { id: data.id, msgId: data.id, ...(data.pending ? { pending: true } : {}), ...(data.requestId ? { requestId: data.requestId } : {}), upload: { via: up.via, size: up.size } };
|
|
289
289
|
});
|
|
290
290
|
|
|
291
|
+
/**
|
|
292
|
+
* 5.3 语音试听:把「即将发出的那一份字节」过一遍 SILK 编码校验。
|
|
293
|
+
*
|
|
294
|
+
* 与 `media.send` 用同一个 `onebot/voice.js` 的编码实现,但**到编码为止**:
|
|
295
|
+
* 不 `uploadVoice`、不 `sendOut`、不进投递账本、不占主动额度、不写任何盘。
|
|
296
|
+
* 也刻意不调 `ensureSilk()`:试听是「听一下」,不该偷偷开始装 62MB 依赖。
|
|
297
|
+
*
|
|
298
|
+
* 老框架(没有这个方法)时宿主侧会拿到 NOT_FOUND,按「未校验」处理,
|
|
299
|
+
* 试听本身照样能播——不因为框架没升级就把试听按钮弄成灰的。
|
|
300
|
+
*/
|
|
301
|
+
def('media.convert', 'message', '只校验语音能否转成 QQ 的 SILK(不上传、不发送、不装依赖、不落盘)', async (p) => {
|
|
302
|
+
const buf = decodeB64(p.dataBase64, err);
|
|
303
|
+
/** `cached()` / `load()` 都只取已装好的模块,不触发安装 */
|
|
304
|
+
const silkMod = deps.cached('silk-wasm') || await deps.load('silk-wasm');
|
|
305
|
+
if (!silkMod) {
|
|
306
|
+
return { ok: false, reason: 'silk_missing', message: '没装 silk-wasm:真正发语音时框架会自动安装,试听不装' };
|
|
307
|
+
}
|
|
308
|
+
try {
|
|
309
|
+
return await toSilkDry(buf, silkMod);
|
|
310
|
+
} catch (e) {
|
|
311
|
+
return { ok: false, reason: 'convert_failed', message: String(e?.message || e) };
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
|
|
291
315
|
def('media.markdownImage', 'message', '上传 Markdown 素材图,返回可复用的 qqbot-media:// 引用(默认保留)', async (p) => {
|
|
292
316
|
return await uploadInput(p, {
|
|
293
317
|
scene: p.scene === 'group' ? 'group' : 'c2c',
|