@napuketto/adapter 0.16.2 → 0.16.4
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/dist/core/index.d.mts +2 -2
- package/dist/core/index.mjs +1 -1
- package/dist/{core-D5c78lFV.mjs → core-l7TM-aKF.mjs} +23 -2
- package/dist/core-l7TM-aKF.mjs.map +1 -0
- package/dist/{essence-Gnvq6YWT.mjs → essence-CU3kvItK.mjs} +12 -3
- package/dist/{essence-Gnvq6YWT.mjs.map → essence-CU3kvItK.mjs.map} +1 -1
- package/dist/gray-tip-DNo_Mi4E.d.mts.map +1 -1
- package/dist/{index-Dhd-kaUF.d.mts → index-jdSniAj1.d.mts} +13 -3
- package/dist/index-jdSniAj1.d.mts.map +1 -0
- package/dist/kurobot/index.d.mts +12 -5
- package/dist/kurobot/index.d.mts.map +1 -1
- package/dist/kurobot/index.mjs +9 -9
- package/dist/kurobot/index.mjs.map +1 -1
- package/dist/log-AtQxAmbQ.mjs +214 -0
- package/dist/log-AtQxAmbQ.mjs.map +1 -0
- package/dist/milky/index.d.mts +15 -15
- package/dist/milky/index.d.mts.map +1 -1
- package/dist/milky/index.mjs +212 -254
- package/dist/milky/index.mjs.map +1 -1
- package/dist/onebot11/index.d.mts +1 -1
- package/dist/onebot11/index.d.mts.map +1 -1
- package/dist/onebot11/index.mjs +238 -268
- package/dist/onebot11/index.mjs.map +1 -1
- package/dist/{raw-message-Cz0UOrND.mjs → raw-message-D5nMIebz.mjs} +3 -3
- package/dist/raw-message-D5nMIebz.mjs.map +1 -0
- package/dist/satori/index.d.mts +115 -115
- package/dist/satori/index.d.mts.map +1 -1
- package/dist/satori/index.mjs +15 -19
- package/dist/satori/index.mjs.map +1 -1
- package/package.json +4 -4
- package/dist/core-D5c78lFV.mjs.map +0 -1
- package/dist/index-Dhd-kaUF.d.mts.map +0 -1
- package/dist/log-BznNQnpx.mjs +0 -80
- package/dist/log-BznNQnpx.mjs.map +0 -1
- package/dist/media-DMMn74TC.mjs +0 -126
- package/dist/media-DMMn74TC.mjs.map +0 -1
- package/dist/raw-message-Cz0UOrND.mjs.map +0 -1
package/dist/onebot11/index.mjs
CHANGED
|
@@ -1,16 +1,102 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as firstNonEmptyString, c as MS_TO_SEC,
|
|
3
|
-
import { n as
|
|
4
|
-
import { i as
|
|
5
|
-
import {
|
|
6
|
-
import { ChatType, GrayTipSubType, GroupApi, GroupNotifyMsgStatus, GroupNotifyMsgType, NTGroupMemberRole, NTGroupRequestOperateTypes, TicketApi, TipGroupElementType, WebHonorType, kernelError, toCanonicalElements } from "@napuketto/kernel";
|
|
1
|
+
import { a as runAction, i as ActionRegistry, n as createServerSchema, r as BaseProtocolAdapter } from "../core-l7TM-aKF.mjs";
|
|
2
|
+
import { a as firstNonEmptyString, c as MS_TO_SEC, f as toUin, i as toUnixSeconds, l as NUMERIC_RE, n as senderNickname, o as stringOrUndefined, r as subscribeRawMessages, s as startupBaselineSec, u as numericUin } from "../raw-message-D5nMIebz.mjs";
|
|
3
|
+
import { a as ensureSilk, c as collectGrayTipUids, d as hasGrayTip, i as downloadBufferToFile, n as sliceRaw, o as fileUriToPath, r as truncRaw, s as prepareVideoElements, t as logEventFailure, u as firstUntranslatedGrayTip } from "../log-AtQxAmbQ.mjs";
|
|
4
|
+
import { a as narrowSysMsgBlobs, c as recognizeSysMsg, f as BuddyReqDedup, h as narrowBuddyReqs, i as OBSERVED_UNNAMED_SYSMSG_KEYS, m as filterBuddyReqs, n as extractEssenceSetSysMsg, p as batchUnreadNums, r as narrowEssenceGroupArg, s as processSysMsgBlob, t as EssenceListSync } from "../essence-CU3kvItK.mjs";
|
|
5
|
+
import { ChatType, GrayTipSubType, GroupApi, GroupNotifyMsgStatus, GroupNotifyMsgType, NTGroupMemberRole, NTGroupRequestOperateTypes, TicketApi, TipGroupElementType, WebHonorType, errorMessage, kernelError, toCanonicalElements } from "@napuketto/kernel";
|
|
7
6
|
import { z } from "zod";
|
|
8
7
|
import { randomUUID } from "node:crypto";
|
|
9
|
-
import { existsSync
|
|
8
|
+
import { existsSync } from "node:fs";
|
|
9
|
+
import { mkdir } from "node:fs/promises";
|
|
10
10
|
import { basename, join } from "node:path";
|
|
11
11
|
import { downloadUrl, inferExtension } from "@napuketto/media";
|
|
12
|
-
import { fileURLToPath } from "node:url";
|
|
13
12
|
import { HttpClient, HttpServer, WsClient, WsServer } from "@napuketto/network";
|
|
13
|
+
// src/onebot11/helper/message-unique.ts
|
|
14
|
+
/** OB11 message_id 上限(int32 max = 0x7FFF_FFFF)。 */
|
|
15
|
+
const INT32_MAX = 2147483647;
|
|
16
|
+
/** int32 下限。 */
|
|
17
|
+
const INT32_MIN = 1;
|
|
18
|
+
var MessageUnique = class {
|
|
19
|
+
/** NT msgId → OB11 message_id。 */
|
|
20
|
+
msgIdToInt = /* @__PURE__ */ new Map();
|
|
21
|
+
/** OB11 message_id → NT msgId。 */
|
|
22
|
+
intToMsgId = /* @__PURE__ */ new Map();
|
|
23
|
+
/** NT msgId → Peer(delete_msg / get_msg 等只有 message_id 时反查用)。 */
|
|
24
|
+
msgIdToPeer = /* @__PURE__ */ new Map();
|
|
25
|
+
/** 递增计数器。 */
|
|
26
|
+
cursor = 1;
|
|
27
|
+
/** 已释放的槽位(可复用)。 */
|
|
28
|
+
freed = /* @__PURE__ */ new Set();
|
|
29
|
+
/**
|
|
30
|
+
* 为新 NT 消息分配 OB11 message_id(幂等:同一 msgId 返回同一 id)。
|
|
31
|
+
* peer 可选:传入则记录,供 message_id → peer 反查。
|
|
32
|
+
*/
|
|
33
|
+
alloc(msgId, peer) {
|
|
34
|
+
const existing = this.msgIdToInt.get(msgId);
|
|
35
|
+
if (existing !== void 0) {
|
|
36
|
+
if (peer !== void 0) this.msgIdToPeer.set(msgId, peer);
|
|
37
|
+
return existing;
|
|
38
|
+
}
|
|
39
|
+
const id = this.nextFreeId();
|
|
40
|
+
this.msgIdToInt.set(msgId, id);
|
|
41
|
+
this.intToMsgId.set(id, msgId);
|
|
42
|
+
if (peer !== void 0) this.msgIdToPeer.set(msgId, peer);
|
|
43
|
+
this.freed.delete(id);
|
|
44
|
+
return id;
|
|
45
|
+
}
|
|
46
|
+
/** OB11 message_id → NT msgId。 */
|
|
47
|
+
getMsgId(messageId) {
|
|
48
|
+
return this.intToMsgId.get(messageId);
|
|
49
|
+
}
|
|
50
|
+
/** NT msgId → OB11 message_id(未分配返回 undefined)。 */
|
|
51
|
+
getMessageId(msgId) {
|
|
52
|
+
return this.msgIdToInt.get(msgId);
|
|
53
|
+
}
|
|
54
|
+
/** NT msgId → Peer(alloc 时未记录返回 undefined)。 */
|
|
55
|
+
getPeer(msgId) {
|
|
56
|
+
return this.msgIdToPeer.get(msgId);
|
|
57
|
+
}
|
|
58
|
+
/** 释放 NT msgId 占用的槽位(消息过期/删除时调用,可选)。 */
|
|
59
|
+
release(msgId) {
|
|
60
|
+
const id = this.msgIdToInt.get(msgId);
|
|
61
|
+
if (id === void 0) return;
|
|
62
|
+
this.msgIdToInt.delete(msgId);
|
|
63
|
+
this.intToMsgId.delete(id);
|
|
64
|
+
this.msgIdToPeer.delete(msgId);
|
|
65
|
+
this.freed.add(id);
|
|
66
|
+
}
|
|
67
|
+
/** 取下一个可用 id:优先释放池,否则递增(溢出后线性扫描空洞)。 */
|
|
68
|
+
nextFreeId() {
|
|
69
|
+
for (const id of this.freed) return id;
|
|
70
|
+
if (this.cursor > INT32_MAX) {
|
|
71
|
+
for (let i = INT32_MIN; i <= INT32_MAX; i += 1) if (!this.intToMsgId.has(i)) {
|
|
72
|
+
this.cursor = i + 1;
|
|
73
|
+
return i;
|
|
74
|
+
}
|
|
75
|
+
throw kernelError("MessageUnique 槽位耗尽(>2^31 条消息)", "INVALID_STATE");
|
|
76
|
+
}
|
|
77
|
+
const id = this.cursor;
|
|
78
|
+
this.cursor += 1;
|
|
79
|
+
return id;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* 从 OB11 message_id 反查 NT msgId + Peer。
|
|
84
|
+
* delete_msg / get_msg / set_msg_emoji_like / fetch_ptt_text / 精华消息等
|
|
85
|
+
* 只有 message_id 参数的动作共用(消息不存在抛 KernelError NOT_FOUND)。
|
|
86
|
+
*/
|
|
87
|
+
function resolveMsgIdAndPeer(messageId, unique) {
|
|
88
|
+
let shortId;
|
|
89
|
+
if (typeof messageId === "number") shortId = messageId;
|
|
90
|
+
else shortId = Number(messageId);
|
|
91
|
+
const msgId = unique.getMsgId(shortId);
|
|
92
|
+
if (msgId === void 0) throw kernelError(`消息 ${messageId} 不存在`, "NOT_FOUND");
|
|
93
|
+
const peer = unique.getPeer(msgId);
|
|
94
|
+
if (peer === void 0) throw kernelError(`消息 ${messageId} 无会话记录`, "NOT_FOUND");
|
|
95
|
+
return {
|
|
96
|
+
msgId,
|
|
97
|
+
peer
|
|
98
|
+
};
|
|
99
|
+
}
|
|
14
100
|
// src/onebot11/action/base-action.ts
|
|
15
101
|
/**
|
|
16
102
|
* OB11 动作运行时:声明式动作工厂 + 响应信封 + 错误码映射 + 共享解析助手。
|
|
@@ -71,6 +157,32 @@ async function resolveUid(uin, uinToUid) {
|
|
|
71
157
|
if (uid === void 0) throw kernelError(`用户 ${uin} 的 uid 解析失败`, "INVALID_PARAM");
|
|
72
158
|
return uid;
|
|
73
159
|
}
|
|
160
|
+
/** 解析目标 Peer(group_id 直通;user_id 经 uin→uid)。 */
|
|
161
|
+
async function resolveTargetPeer(payload, deps, missingHint) {
|
|
162
|
+
if (payload.group_id !== void 0) return {
|
|
163
|
+
chatType: ChatType.GROUP,
|
|
164
|
+
peerUid: String(payload.group_id)
|
|
165
|
+
};
|
|
166
|
+
if (payload.user_id !== void 0) return {
|
|
167
|
+
chatType: ChatType.C2C,
|
|
168
|
+
peerUid: await resolveUid(String(payload.user_id), deps.uinToUid)
|
|
169
|
+
};
|
|
170
|
+
throw kernelError(missingHint, "INVALID_PARAM");
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* 按 message_id(OB11 int32 或 NT msgId)拉取单条消息。
|
|
174
|
+
* 消息不存在/已被撤回 → 抛 KernelError NOT_FOUND。
|
|
175
|
+
*/
|
|
176
|
+
async function fetchMsgById(messageId, messageUnique, msgApi) {
|
|
177
|
+
const { msgId, peer } = resolveMsgIdAndPeer(messageId, messageUnique);
|
|
178
|
+
const [msg] = await msgApi.fetchMsgsByMsgId(peer, [msgId]);
|
|
179
|
+
if (msg === void 0) throw kernelError(`消息 ${messageId} 不存在或已被撤回`, "NOT_FOUND");
|
|
180
|
+
return {
|
|
181
|
+
msg,
|
|
182
|
+
peer,
|
|
183
|
+
msgId
|
|
184
|
+
};
|
|
185
|
+
}
|
|
74
186
|
// src/onebot11/action/friend/manage.ts
|
|
75
187
|
/**
|
|
76
188
|
* 好友管理域动作
|
|
@@ -195,93 +307,6 @@ no_cache: z.boolean().optional() }),
|
|
|
195
307
|
})
|
|
196
308
|
];
|
|
197
309
|
}
|
|
198
|
-
// src/onebot11/helper/message-unique.ts
|
|
199
|
-
/** OB11 message_id 上限(int32 max = 0x7FFF_FFFF)。 */
|
|
200
|
-
const INT32_MAX = 2147483647;
|
|
201
|
-
/** int32 下限。 */
|
|
202
|
-
const INT32_MIN = 1;
|
|
203
|
-
var MessageUnique = class {
|
|
204
|
-
/** NT msgId → OB11 message_id。 */
|
|
205
|
-
msgIdToInt = /* @__PURE__ */ new Map();
|
|
206
|
-
/** OB11 message_id → NT msgId。 */
|
|
207
|
-
intToMsgId = /* @__PURE__ */ new Map();
|
|
208
|
-
/** NT msgId → Peer(delete_msg / get_msg 等只有 message_id 时反查用)。 */
|
|
209
|
-
msgIdToPeer = /* @__PURE__ */ new Map();
|
|
210
|
-
/** 递增计数器。 */
|
|
211
|
-
cursor = 1;
|
|
212
|
-
/** 已释放的槽位(可复用)。 */
|
|
213
|
-
freed = /* @__PURE__ */ new Set();
|
|
214
|
-
/**
|
|
215
|
-
* 为新 NT 消息分配 OB11 message_id(幂等:同一 msgId 返回同一 id)。
|
|
216
|
-
* peer 可选:传入则记录,供 message_id → peer 反查。
|
|
217
|
-
*/
|
|
218
|
-
alloc(msgId, peer) {
|
|
219
|
-
const existing = this.msgIdToInt.get(msgId);
|
|
220
|
-
if (existing !== void 0) {
|
|
221
|
-
if (peer !== void 0) this.msgIdToPeer.set(msgId, peer);
|
|
222
|
-
return existing;
|
|
223
|
-
}
|
|
224
|
-
const id = this.nextFreeId();
|
|
225
|
-
this.msgIdToInt.set(msgId, id);
|
|
226
|
-
this.intToMsgId.set(id, msgId);
|
|
227
|
-
if (peer !== void 0) this.msgIdToPeer.set(msgId, peer);
|
|
228
|
-
this.freed.delete(id);
|
|
229
|
-
return id;
|
|
230
|
-
}
|
|
231
|
-
/** OB11 message_id → NT msgId。 */
|
|
232
|
-
getMsgId(messageId) {
|
|
233
|
-
return this.intToMsgId.get(messageId);
|
|
234
|
-
}
|
|
235
|
-
/** NT msgId → OB11 message_id(未分配返回 undefined)。 */
|
|
236
|
-
getMessageId(msgId) {
|
|
237
|
-
return this.msgIdToInt.get(msgId);
|
|
238
|
-
}
|
|
239
|
-
/** NT msgId → Peer(alloc 时未记录返回 undefined)。 */
|
|
240
|
-
getPeer(msgId) {
|
|
241
|
-
return this.msgIdToPeer.get(msgId);
|
|
242
|
-
}
|
|
243
|
-
/** 释放 NT msgId 占用的槽位(消息过期/删除时调用,可选)。 */
|
|
244
|
-
release(msgId) {
|
|
245
|
-
const id = this.msgIdToInt.get(msgId);
|
|
246
|
-
if (id === void 0) return;
|
|
247
|
-
this.msgIdToInt.delete(msgId);
|
|
248
|
-
this.intToMsgId.delete(id);
|
|
249
|
-
this.msgIdToPeer.delete(msgId);
|
|
250
|
-
this.freed.add(id);
|
|
251
|
-
}
|
|
252
|
-
/** 取下一个可用 id:优先释放池,否则递增(溢出后线性扫描空洞)。 */
|
|
253
|
-
nextFreeId() {
|
|
254
|
-
for (const id of this.freed) return id;
|
|
255
|
-
if (this.cursor > INT32_MAX) {
|
|
256
|
-
for (let i = INT32_MIN; i <= INT32_MAX; i += 1) if (!this.intToMsgId.has(i)) {
|
|
257
|
-
this.cursor = i + 1;
|
|
258
|
-
return i;
|
|
259
|
-
}
|
|
260
|
-
throw kernelError("MessageUnique 槽位耗尽(>2^31 条消息)", "INVALID_STATE");
|
|
261
|
-
}
|
|
262
|
-
const id = this.cursor;
|
|
263
|
-
this.cursor += 1;
|
|
264
|
-
return id;
|
|
265
|
-
}
|
|
266
|
-
};
|
|
267
|
-
/**
|
|
268
|
-
* 从 OB11 message_id 反查 NT msgId + Peer。
|
|
269
|
-
* delete_msg / get_msg / set_msg_emoji_like / fetch_ptt_text / 精华消息等
|
|
270
|
-
* 只有 message_id 参数的动作共用(消息不存在抛 KernelError NOT_FOUND)。
|
|
271
|
-
*/
|
|
272
|
-
function resolveMsgIdAndPeer(messageId, unique) {
|
|
273
|
-
let shortId;
|
|
274
|
-
if (typeof messageId === "number") shortId = messageId;
|
|
275
|
-
else shortId = Number(messageId);
|
|
276
|
-
const msgId = unique.getMsgId(shortId);
|
|
277
|
-
if (msgId === void 0) throw kernelError(`消息 ${messageId} 不存在`, "NOT_FOUND");
|
|
278
|
-
const peer = unique.getPeer(msgId);
|
|
279
|
-
if (peer === void 0) throw kernelError(`消息 ${messageId} 无会话记录`, "NOT_FOUND");
|
|
280
|
-
return {
|
|
281
|
-
msgId,
|
|
282
|
-
peer
|
|
283
|
-
};
|
|
284
|
-
}
|
|
285
310
|
// src/onebot11/action/group/essence.ts
|
|
286
311
|
/**
|
|
287
312
|
* 群精华/荣誉域动作
|
|
@@ -373,98 +398,10 @@ function createGroupEssenceActions(api) {
|
|
|
373
398
|
})
|
|
374
399
|
];
|
|
375
400
|
}
|
|
376
|
-
// src/onebot11/action/group/get-group-system-msg.ts
|
|
377
|
-
/** 默认获取数量。 */
|
|
378
|
-
const DEFAULT_COUNT$1 = 50;
|
|
379
|
-
/** 收集全部涉及的 uid 批量转 uin(循环外一次请求)。 */
|
|
380
|
-
async function collectUinMap(api, notifies) {
|
|
381
|
-
const uids = [];
|
|
382
|
-
for (const notify of notifies) {
|
|
383
|
-
const { user1, user2 } = notify;
|
|
384
|
-
if (user1 !== void 0) {
|
|
385
|
-
const { uid } = user1;
|
|
386
|
-
if (uid !== "") uids.push(uid);
|
|
387
|
-
}
|
|
388
|
-
if (user2 !== void 0) {
|
|
389
|
-
const { uid } = user2;
|
|
390
|
-
if (uid !== "") uids.push(uid);
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
if (uids.length === 0) return /* @__PURE__ */ new Map();
|
|
394
|
-
return await api.uidToUin(uids);
|
|
395
|
-
}
|
|
396
|
-
/** GroupNotify → OB11 群系统消息结构(纯函数,uin 已批量转换)。 */
|
|
397
|
-
function toMessageInfo(notify, uinMap) {
|
|
398
|
-
const { seq, status, postscript, user1, user2, group } = notify;
|
|
399
|
-
let user1Uid = "";
|
|
400
|
-
if (user1 !== void 0) {
|
|
401
|
-
const { uid } = user1;
|
|
402
|
-
user1Uid = uid;
|
|
403
|
-
}
|
|
404
|
-
let user2Uid = "";
|
|
405
|
-
if (user2 !== void 0) {
|
|
406
|
-
const { uid } = user2;
|
|
407
|
-
user2Uid = uid;
|
|
408
|
-
}
|
|
409
|
-
let groupCode = 0;
|
|
410
|
-
let groupName = "";
|
|
411
|
-
if (group !== void 0) {
|
|
412
|
-
const { groupCode: code, groupName: name } = group;
|
|
413
|
-
groupCode = Number(code);
|
|
414
|
-
groupName = name;
|
|
415
|
-
}
|
|
416
|
-
let invitorUin = Number(user1Uid);
|
|
417
|
-
const mapped1 = uinMap.get(user1Uid);
|
|
418
|
-
if (mapped1 !== void 0) invitorUin = Number(mapped1);
|
|
419
|
-
let actor = Number(user2Uid);
|
|
420
|
-
const mapped2 = uinMap.get(user2Uid);
|
|
421
|
-
if (mapped2 !== void 0) actor = Number(mapped2);
|
|
422
|
-
let invitorNick = "";
|
|
423
|
-
if (user1 !== void 0) {
|
|
424
|
-
const { nickName } = user1;
|
|
425
|
-
invitorNick = nickName;
|
|
426
|
-
}
|
|
427
|
-
return {
|
|
428
|
-
request_id: Number(seq),
|
|
429
|
-
invitor_uin: invitorUin,
|
|
430
|
-
invitor_nick: invitorNick,
|
|
431
|
-
group_id: groupCode,
|
|
432
|
-
message: postscript ?? "",
|
|
433
|
-
group_name: groupName,
|
|
434
|
-
checked: status !== 1,
|
|
435
|
-
actor,
|
|
436
|
-
requester_nick: invitorNick
|
|
437
|
-
};
|
|
438
|
-
}
|
|
439
|
-
/** 群系统消息动作工厂(get_group_system_msg)。 */
|
|
440
|
-
function createGroupSystemMsgActions(api) {
|
|
441
|
-
return [defineOb11Action({
|
|
442
|
-
name: "get_group_system_msg",
|
|
443
|
-
schema: z.object({ count: z.number().optional() }),
|
|
444
|
-
handle: async (payload) => {
|
|
445
|
-
const count = payload.count ?? DEFAULT_COUNT$1;
|
|
446
|
-
const notifies = await api.groupNotifyApi.getSingleScreenNotifies(false, count);
|
|
447
|
-
const uinMap = await collectUinMap(api, notifies);
|
|
448
|
-
const invited = [];
|
|
449
|
-
const joined = [];
|
|
450
|
-
for (const notify of notifies) {
|
|
451
|
-
const info = toMessageInfo(notify, uinMap);
|
|
452
|
-
if (notify.type === GroupNotifyMsgType.INVITED_BY_MEMBER) invited.push(info);
|
|
453
|
-
else if (notify.type === GroupNotifyMsgType.REQUEST_JOIN_NEED_ADMINI_STRATOR_PASS) joined.push(info);
|
|
454
|
-
}
|
|
455
|
-
const result = {
|
|
456
|
-
invited_requests: invited,
|
|
457
|
-
join_requests: joined
|
|
458
|
-
};
|
|
459
|
-
result["InvitedRequest"] = invited;
|
|
460
|
-
return result;
|
|
461
|
-
}
|
|
462
|
-
})];
|
|
463
|
-
}
|
|
464
401
|
// src/onebot11/action/limits.ts
|
|
465
402
|
/** 批量翻译的词条上限(translate_en2zh)。 */
|
|
466
403
|
const MAX_TRANSLATE_WORDS = 2e3;
|
|
467
|
-
// src/onebot11/action/group/
|
|
404
|
+
// src/onebot11/action/group/files-op.ts
|
|
468
405
|
/**
|
|
469
406
|
* 群文件操作动作:create_group_file_folder / delete_group_file /
|
|
470
407
|
* delete_group_folder / rename_group_file / move_group_file / trans_group_file
|
|
@@ -547,7 +484,7 @@ function createGroupFileOpActions(api) {
|
|
|
547
484
|
})
|
|
548
485
|
];
|
|
549
486
|
}
|
|
550
|
-
// src/onebot11/action/group/
|
|
487
|
+
// src/onebot11/action/group/files-query.ts
|
|
551
488
|
/** 默认文件数量。 */
|
|
552
489
|
const DEFAULT_FILE_COUNT = 50;
|
|
553
490
|
/** 列表拆分 files/folders(fileInfo/folderInfo 取其一,纯函数)。 */
|
|
@@ -581,7 +518,7 @@ function toGroupFileInfo(file) {
|
|
|
581
518
|
if (file.modifyTime !== void 0) out.modify_time = file.modifyTime;
|
|
582
519
|
return out;
|
|
583
520
|
}
|
|
584
|
-
/**
|
|
521
|
+
/** GroupFolderInfo → OB11 文件夹结构(纯函数)。 */
|
|
585
522
|
function toGroupFolderInfo(folder) {
|
|
586
523
|
return {
|
|
587
524
|
folder_id: folder.folderId,
|
|
@@ -756,7 +693,7 @@ function createGroupManageActions(api) {
|
|
|
756
693
|
*/
|
|
757
694
|
const getGroupAddRequestSchema = z.object({ count: z.number().optional() });
|
|
758
695
|
/** 默认获取数量。 */
|
|
759
|
-
const DEFAULT_COUNT = 100;
|
|
696
|
+
const DEFAULT_COUNT$1 = 100;
|
|
760
697
|
/** GroupNotify → OB11 群请求项(纯函数)。 */
|
|
761
698
|
function toGroupAddRequestItem(notify) {
|
|
762
699
|
const { seq, type, status, postscript, user1, group } = notify;
|
|
@@ -799,14 +736,14 @@ function createGroupNotifyActions(api) {
|
|
|
799
736
|
name: "get_group_add_request",
|
|
800
737
|
schema: getGroupAddRequestSchema,
|
|
801
738
|
handle: async (payload) => {
|
|
802
|
-
return (await api.groupNotifyApi.getSingleScreenNotifies(false, payload.count ?? DEFAULT_COUNT)).map(toGroupAddRequestItem);
|
|
739
|
+
return (await api.groupNotifyApi.getSingleScreenNotifies(false, payload.count ?? DEFAULT_COUNT$1)).map(toGroupAddRequestItem);
|
|
803
740
|
}
|
|
804
741
|
}),
|
|
805
742
|
defineOb11Action({
|
|
806
743
|
name: "get_group_ignored_notifies",
|
|
807
744
|
schema: getGroupAddRequestSchema,
|
|
808
745
|
handle: async (payload) => {
|
|
809
|
-
return (await api.groupNotifyApi.getSingleScreenNotifies(true, payload.count ?? DEFAULT_COUNT)).map(toGroupAddRequestItem);
|
|
746
|
+
return (await api.groupNotifyApi.getSingleScreenNotifies(true, payload.count ?? DEFAULT_COUNT$1)).map(toGroupAddRequestItem);
|
|
810
747
|
}
|
|
811
748
|
}),
|
|
812
749
|
defineOb11Action({
|
|
@@ -818,7 +755,7 @@ function createGroupNotifyActions(api) {
|
|
|
818
755
|
count: z.number().optional()
|
|
819
756
|
}),
|
|
820
757
|
handle: async (payload) => {
|
|
821
|
-
const count = payload.count ?? DEFAULT_COUNT;
|
|
758
|
+
const count = payload.count ?? DEFAULT_COUNT$1;
|
|
822
759
|
const notify = await findGroupNotify(api.groupNotifyApi, payload.flag, count);
|
|
823
760
|
if (notify === null) throw kernelError("未找到对应的群请求(flag 无效或已过期)", "NOT_FOUND");
|
|
824
761
|
let operateType = NTGroupRequestOperateTypes.KREFUSE;
|
|
@@ -982,6 +919,94 @@ no_cache: z.boolean().optional() }),
|
|
|
982
919
|
})
|
|
983
920
|
];
|
|
984
921
|
}
|
|
922
|
+
// src/onebot11/action/group/system-msg.ts
|
|
923
|
+
/** 默认获取数量。 */
|
|
924
|
+
const DEFAULT_COUNT = 50;
|
|
925
|
+
/** 收集全部涉及的 uid 批量转 uin(循环外一次请求)。 */
|
|
926
|
+
async function collectUinMap(api, notifies) {
|
|
927
|
+
const uids = [];
|
|
928
|
+
for (const notify of notifies) {
|
|
929
|
+
const { user1, user2 } = notify;
|
|
930
|
+
if (user1 !== void 0) {
|
|
931
|
+
const { uid } = user1;
|
|
932
|
+
if (uid !== "") uids.push(uid);
|
|
933
|
+
}
|
|
934
|
+
if (user2 !== void 0) {
|
|
935
|
+
const { uid } = user2;
|
|
936
|
+
if (uid !== "") uids.push(uid);
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
if (uids.length === 0) return /* @__PURE__ */ new Map();
|
|
940
|
+
return await api.uidToUin(uids);
|
|
941
|
+
}
|
|
942
|
+
/** GroupNotify → OB11 群系统消息结构(纯函数,uin 已批量转换)。 */
|
|
943
|
+
function toMessageInfo(notify, uinMap) {
|
|
944
|
+
const { seq, status, postscript, user1, user2, group } = notify;
|
|
945
|
+
let user1Uid = "";
|
|
946
|
+
if (user1 !== void 0) {
|
|
947
|
+
const { uid } = user1;
|
|
948
|
+
user1Uid = uid;
|
|
949
|
+
}
|
|
950
|
+
let user2Uid = "";
|
|
951
|
+
if (user2 !== void 0) {
|
|
952
|
+
const { uid } = user2;
|
|
953
|
+
user2Uid = uid;
|
|
954
|
+
}
|
|
955
|
+
let groupCode = 0;
|
|
956
|
+
let groupName = "";
|
|
957
|
+
if (group !== void 0) {
|
|
958
|
+
const { groupCode: code, groupName: name } = group;
|
|
959
|
+
groupCode = Number(code);
|
|
960
|
+
groupName = name;
|
|
961
|
+
}
|
|
962
|
+
let invitorUin = Number(user1Uid);
|
|
963
|
+
const mapped1 = uinMap.get(user1Uid);
|
|
964
|
+
if (mapped1 !== void 0) invitorUin = Number(mapped1);
|
|
965
|
+
let actor = Number(user2Uid);
|
|
966
|
+
const mapped2 = uinMap.get(user2Uid);
|
|
967
|
+
if (mapped2 !== void 0) actor = Number(mapped2);
|
|
968
|
+
let invitorNick = "";
|
|
969
|
+
if (user1 !== void 0) {
|
|
970
|
+
const { nickName } = user1;
|
|
971
|
+
invitorNick = nickName;
|
|
972
|
+
}
|
|
973
|
+
return {
|
|
974
|
+
request_id: Number(seq),
|
|
975
|
+
invitor_uin: invitorUin,
|
|
976
|
+
invitor_nick: invitorNick,
|
|
977
|
+
group_id: groupCode,
|
|
978
|
+
message: postscript ?? "",
|
|
979
|
+
group_name: groupName,
|
|
980
|
+
checked: status !== 1,
|
|
981
|
+
actor,
|
|
982
|
+
requester_nick: invitorNick
|
|
983
|
+
};
|
|
984
|
+
}
|
|
985
|
+
/** 群系统消息动作工厂(get_group_system_msg)。 */
|
|
986
|
+
function createGroupSystemMsgActions(api) {
|
|
987
|
+
return [defineOb11Action({
|
|
988
|
+
name: "get_group_system_msg",
|
|
989
|
+
schema: z.object({ count: z.number().optional() }),
|
|
990
|
+
handle: async (payload) => {
|
|
991
|
+
const count = payload.count ?? DEFAULT_COUNT;
|
|
992
|
+
const notifies = await api.groupNotifyApi.getSingleScreenNotifies(false, count);
|
|
993
|
+
const uinMap = await collectUinMap(api, notifies);
|
|
994
|
+
const invited = [];
|
|
995
|
+
const joined = [];
|
|
996
|
+
for (const notify of notifies) {
|
|
997
|
+
const info = toMessageInfo(notify, uinMap);
|
|
998
|
+
if (notify.type === GroupNotifyMsgType.INVITED_BY_MEMBER) invited.push(info);
|
|
999
|
+
else if (notify.type === GroupNotifyMsgType.REQUEST_JOIN_NEED_ADMINI_STRATOR_PASS) joined.push(info);
|
|
1000
|
+
}
|
|
1001
|
+
const result = {
|
|
1002
|
+
invited_requests: invited,
|
|
1003
|
+
join_requests: joined
|
|
1004
|
+
};
|
|
1005
|
+
result["InvitedRequest"] = invited;
|
|
1006
|
+
return result;
|
|
1007
|
+
}
|
|
1008
|
+
})];
|
|
1009
|
+
}
|
|
985
1010
|
// src/onebot11/helper/codec/cqcode.ts
|
|
986
1011
|
/**
|
|
987
1012
|
* CQ 码编解码(OneBot 11 消息段序列化格式)
|
|
@@ -1753,42 +1778,6 @@ function toOb11FriendRequestEvent(req, ctx) {
|
|
|
1753
1778
|
flag: req.reqTime
|
|
1754
1779
|
};
|
|
1755
1780
|
}
|
|
1756
|
-
// src/onebot11/action/message/resolve-peer.ts
|
|
1757
|
-
/**
|
|
1758
|
-
* OB11 目标 Peer 解析 / 单条消息拉取(多个动作共用)
|
|
1759
|
-
*
|
|
1760
|
-
* group_id 直通(群消息 peerUid = 群号);user_id 经 uin→uid 解析。
|
|
1761
|
-
*/
|
|
1762
|
-
/** 解析目标 Peer(group_id 直通;user_id 经 uin→uid)。 */
|
|
1763
|
-
async function resolveTargetPeer(payload, deps, missingHint) {
|
|
1764
|
-
if (payload.group_id !== void 0) return {
|
|
1765
|
-
chatType: ChatType.GROUP,
|
|
1766
|
-
peerUid: String(payload.group_id)
|
|
1767
|
-
};
|
|
1768
|
-
if (payload.user_id !== void 0) {
|
|
1769
|
-
const uid = (await deps.uinToUid([String(payload.user_id)])).get(String(payload.user_id));
|
|
1770
|
-
if (uid === void 0) throw kernelError(`用户 ${payload.user_id} 的 uid 解析失败`, "INVALID_PARAM");
|
|
1771
|
-
return {
|
|
1772
|
-
chatType: ChatType.C2C,
|
|
1773
|
-
peerUid: uid
|
|
1774
|
-
};
|
|
1775
|
-
}
|
|
1776
|
-
throw kernelError(missingHint, "INVALID_PARAM");
|
|
1777
|
-
}
|
|
1778
|
-
/**
|
|
1779
|
-
* 按 message_id(OB11 int32 或 NT msgId)拉取单条消息。
|
|
1780
|
-
* 消息不存在/已被撤回 → 抛 KernelError NOT_FOUND。
|
|
1781
|
-
*/
|
|
1782
|
-
async function fetchMsgById(messageId, messageUnique, msgApi) {
|
|
1783
|
-
const { msgId, peer } = resolveMsgIdAndPeer(messageId, messageUnique);
|
|
1784
|
-
const [msg] = await msgApi.fetchMsgsByMsgId(peer, [msgId]);
|
|
1785
|
-
if (msg === void 0) throw kernelError(`消息 ${messageId} 不存在或已被撤回`, "NOT_FOUND");
|
|
1786
|
-
return {
|
|
1787
|
-
msg,
|
|
1788
|
-
peer,
|
|
1789
|
-
msgId
|
|
1790
|
-
};
|
|
1791
|
-
}
|
|
1792
1781
|
// src/onebot11/action/message/forward.ts
|
|
1793
1782
|
/**
|
|
1794
1783
|
* 消息转发域动作
|
|
@@ -1955,7 +1944,7 @@ async function fetchAndTranslateHistory(peer, messageSeq, count, deps) {
|
|
|
1955
1944
|
} catch (err) {
|
|
1956
1945
|
deps.logger?.warn({
|
|
1957
1946
|
count: atUids.size,
|
|
1958
|
-
error:
|
|
1947
|
+
error: errorMessage(err)
|
|
1959
1948
|
}, "ob11: 历史消息 at uid→uin 失败,at 原样");
|
|
1960
1949
|
}
|
|
1961
1950
|
const ctx = {
|
|
@@ -1995,7 +1984,7 @@ function createHistoryActions(api) {
|
|
|
1995
1984
|
} catch (err) {
|
|
1996
1985
|
api.logger?.warn({
|
|
1997
1986
|
count: atUids.length,
|
|
1998
|
-
error:
|
|
1987
|
+
error: errorMessage(err)
|
|
1999
1988
|
}, "ob11: get_msg at uid→uin 失败,at 原样");
|
|
2000
1989
|
}
|
|
2001
1990
|
const senderRole = msg.chatType === ChatType.GROUP ? await api.groupMemberRole(msg.peerUid, msg.senderUid) : void 0;
|
|
@@ -2071,7 +2060,6 @@ async function downloadImageToCache(url, deps) {
|
|
|
2071
2060
|
const cacheDir = deps.cacheDir;
|
|
2072
2061
|
if (cacheDir === void 0 || cacheDir === "") return null;
|
|
2073
2062
|
const mediaDir = join(cacheDir, "media");
|
|
2074
|
-
const { mkdir } = await import("node:fs/promises");
|
|
2075
2063
|
await mkdir(mediaDir, { recursive: true });
|
|
2076
2064
|
const dest = join(mediaDir, `${randomUUID()}${inferExtension(null, url)}`);
|
|
2077
2065
|
try {
|
|
@@ -2080,7 +2068,7 @@ async function downloadImageToCache(url, deps) {
|
|
|
2080
2068
|
} catch (err) {
|
|
2081
2069
|
deps.logger?.warn({
|
|
2082
2070
|
url,
|
|
2083
|
-
error:
|
|
2071
|
+
error: errorMessage(err)
|
|
2084
2072
|
}, "ob11: 图片主动下载失败,get_image 退原始 url");
|
|
2085
2073
|
return null;
|
|
2086
2074
|
}
|
|
@@ -2136,7 +2124,7 @@ async function downloadPttFallback(msgId, peer, id, deps) {
|
|
|
2136
2124
|
} catch (err) {
|
|
2137
2125
|
deps.logger?.warn({
|
|
2138
2126
|
message_id: id,
|
|
2139
|
-
error:
|
|
2127
|
+
error: errorMessage(err)
|
|
2140
2128
|
}, "ob11: 语音原生下载失败,get_record 回退原始路径");
|
|
2141
2129
|
}
|
|
2142
2130
|
return null;
|
|
@@ -2347,7 +2335,7 @@ async function sendOb11Message(payload, deps) {
|
|
|
2347
2335
|
} catch (err) {
|
|
2348
2336
|
deps.logger?.warn({
|
|
2349
2337
|
count: atUins.length,
|
|
2350
|
-
error:
|
|
2338
|
+
error: errorMessage(err)
|
|
2351
2339
|
}, "ob11: at uin→uid 失败,at 段原样发送");
|
|
2352
2340
|
}
|
|
2353
2341
|
canonical = applySendContext(canonical, {
|
|
@@ -2444,11 +2432,7 @@ async function downloadAvatarToCache(url, cacheDir) {
|
|
|
2444
2432
|
if (cacheDir === void 0 || cacheDir === "") throw kernelError("set_qq_avatar 处理 URL 需要缓存目录(装配方未注入)", "INVALID_STATE");
|
|
2445
2433
|
const safeName = basename(new URL(url).pathname) || "avatar.bin";
|
|
2446
2434
|
const filePath = join(cacheDir, `avatar-${Date.now()}-${safeName}`);
|
|
2447
|
-
|
|
2448
|
-
if (!res.ok) throw new Error(`头像下载失败: ${res.status} ${res.statusText}`);
|
|
2449
|
-
const buf = new Uint8Array(await res.arrayBuffer());
|
|
2450
|
-
writeFileSync(filePath, buf);
|
|
2451
|
-
return filePath;
|
|
2435
|
+
return await downloadBufferToFile(url, filePath, void 0, "头像下载失败");
|
|
2452
2436
|
}
|
|
2453
2437
|
/**
|
|
2454
2438
|
* 账号票据与资料域动作工厂(cookies / clientkey / csrf_token / credentials /
|
|
@@ -2550,8 +2534,6 @@ function createSystemAccountActions(api) {
|
|
|
2550
2534
|
* 输入只接受本地路径与 `file://` URI:远程 `http(s)://` / `base64://` 需要下载缓存与媒体
|
|
2551
2535
|
* 依赖,当前未接(明确报错,不静默失败)。
|
|
2552
2536
|
*/
|
|
2553
|
-
/** file:// 前缀(fileURLToPath 失败时的裸剥离兜底)。 */
|
|
2554
|
-
const FILE_URI_PREFIX_RE = /^file:\/\//;
|
|
2555
2537
|
/** 路径分隔符(取文件名用)。 */
|
|
2556
2538
|
const PATH_SEPARATORS = /[\\/]/;
|
|
2557
2539
|
const downloadFileSchema = z.object({
|
|
@@ -2574,11 +2556,7 @@ const uploadPrivateFileSchema = z.object({
|
|
|
2574
2556
|
/** 本地路径 / file:// 展开;远程 URI 明确拒绝(未接下载缓存)。 */
|
|
2575
2557
|
function resolveLocalFile(file) {
|
|
2576
2558
|
if (file.startsWith("http://") || file.startsWith("https://") || file.startsWith("base64://")) throw kernelError("upload_group_file/upload_private_file 目前只支持本地路径与 file:// URI(远程 URI 需要下载缓存,未接入)", "INVALID_PARAM");
|
|
2577
|
-
if (file.startsWith("file://"))
|
|
2578
|
-
return fileURLToPath(file);
|
|
2579
|
-
} catch {
|
|
2580
|
-
return file.replace(FILE_URI_PREFIX_RE, "");
|
|
2581
|
-
}
|
|
2559
|
+
if (file.startsWith("file://")) return fileUriToPath(file);
|
|
2582
2560
|
return file;
|
|
2583
2561
|
}
|
|
2584
2562
|
/** 取路径末段作为缺省文件集名(卡片标题)。 */
|
|
@@ -2598,13 +2576,9 @@ function createSystemFileActions(api) {
|
|
|
2598
2576
|
if (cacheDir === void 0 || cacheDir === "") throw kernelError("download_file 未配置缓存目录(装配方未注入)", "INVALID_STATE");
|
|
2599
2577
|
const safeName = basename(new URL(payload.url).pathname) || "download.bin";
|
|
2600
2578
|
const filePath = join(cacheDir, `download-${Date.now()}-${safeName}`);
|
|
2601
|
-
mkdirSync(cacheDir, { recursive: true });
|
|
2602
2579
|
const init = {};
|
|
2603
2580
|
if (payload.headers !== void 0) init.headers = payload.headers;
|
|
2604
|
-
|
|
2605
|
-
if (!res.ok) throw new Error(`下载失败: ${res.status} ${res.statusText}`);
|
|
2606
|
-
const buf = new Uint8Array(await res.arrayBuffer());
|
|
2607
|
-
writeFileSync(filePath, buf);
|
|
2581
|
+
await downloadBufferToFile(payload.url, filePath, init);
|
|
2608
2582
|
return { file: filePath };
|
|
2609
2583
|
}
|
|
2610
2584
|
}),
|
|
@@ -2847,7 +2821,7 @@ function createOb11ActionRegistry(deps) {
|
|
|
2847
2821
|
for (const factory of ACTION_FACTORIES) for (const action of factory(deps.api)) registry.register(action);
|
|
2848
2822
|
return registry;
|
|
2849
2823
|
}
|
|
2850
|
-
// src/onebot11/api/
|
|
2824
|
+
// src/onebot11/api/onebot-api.ts
|
|
2851
2825
|
/**
|
|
2852
2826
|
* OneBot 11 动作统一依赖聚合。
|
|
2853
2827
|
* 各动作经 `Pick<OneBotApi, ...>` 取所需成员;注册处只构造一次本对象。
|
|
@@ -2944,7 +2918,7 @@ var OneBotApi = class {
|
|
|
2944
2918
|
this.logger?.warn({
|
|
2945
2919
|
group: groupCode,
|
|
2946
2920
|
uid,
|
|
2947
|
-
error:
|
|
2921
|
+
error: errorMessage(err)
|
|
2948
2922
|
}, "ob11: 群成员缓存读取失败,sender.role 回退 member");
|
|
2949
2923
|
return;
|
|
2950
2924
|
}
|
|
@@ -2962,7 +2936,7 @@ var OneBotApi = class {
|
|
|
2962
2936
|
} catch (err) {
|
|
2963
2937
|
this.logger?.warn({
|
|
2964
2938
|
group: groupCode,
|
|
2965
|
-
error:
|
|
2939
|
+
error: errorMessage(err)
|
|
2966
2940
|
}, "ob11: 群成员表缓存读取失败,历史 role 回退 member");
|
|
2967
2941
|
return;
|
|
2968
2942
|
}
|
|
@@ -2993,7 +2967,7 @@ var Ob11Enrichment = class {
|
|
|
2993
2967
|
} catch (err) {
|
|
2994
2968
|
this.calibLogger?.warn({
|
|
2995
2969
|
count: uids.length,
|
|
2996
|
-
error:
|
|
2970
|
+
error: errorMessage(err)
|
|
2997
2971
|
}, "ob11: 请求 uid→uin 批量转换失败,退用 uid");
|
|
2998
2972
|
map = /* @__PURE__ */ new Map();
|
|
2999
2973
|
}
|
|
@@ -3011,7 +2985,7 @@ var Ob11Enrichment = class {
|
|
|
3011
2985
|
const uin = await this.api.profileApi.getUinByUid(uid);
|
|
3012
2986
|
if (uin !== null) map.set(uid, uin);
|
|
3013
2987
|
} catch (err) {
|
|
3014
|
-
this.calibLogger?.debug({ error:
|
|
2988
|
+
this.calibLogger?.debug({ error: errorMessage(err) }, "ob11: uid→uin 资料兜底失败(该 uid 退 0)");
|
|
3015
2989
|
}
|
|
3016
2990
|
if (missing.length > MAX_PROFILE_LOOKUPS) this.calibLogger?.debug({
|
|
3017
2991
|
missing: missing.length,
|
|
@@ -3039,7 +3013,7 @@ var Ob11Enrichment = class {
|
|
|
3039
3013
|
} catch (err) {
|
|
3040
3014
|
this.calibLogger?.warn({
|
|
3041
3015
|
count: atUids.length,
|
|
3042
|
-
error:
|
|
3016
|
+
error: errorMessage(err)
|
|
3043
3017
|
}, "ob11: 消息 at uid→uin 失败,at 原样");
|
|
3044
3018
|
}
|
|
3045
3019
|
const senderRole = msg.chatType === ChatType.GROUP ? await this.api.groupMemberRole(msg.peerUid, msg.senderUid) : void 0;
|
|
@@ -3062,7 +3036,7 @@ var Ob11Enrichment = class {
|
|
|
3062
3036
|
msgType: env.msgType,
|
|
3063
3037
|
subType: env.subType,
|
|
3064
3038
|
count: uids.length,
|
|
3065
|
-
error:
|
|
3039
|
+
error: errorMessage(err)
|
|
3066
3040
|
}, "ob11: sysmsg uid→uin 失败,实体 uin 恒 0");
|
|
3067
3041
|
return () => 0;
|
|
3068
3042
|
}
|
|
@@ -3080,7 +3054,7 @@ var Ob11Enrichment = class {
|
|
|
3080
3054
|
const hit = (await this.api.msgApi.fetchMessages(peer, { count: 60 }).catch((err) => {
|
|
3081
3055
|
this.calibLogger?.debug({
|
|
3082
3056
|
group: groupCode,
|
|
3083
|
-
error:
|
|
3057
|
+
error: errorMessage(err)
|
|
3084
3058
|
}, "ob11: 精华反查近段历史拉取失败");
|
|
3085
3059
|
return [];
|
|
3086
3060
|
})).find((m) => Number(m.msgSeq) === seq);
|
|
@@ -3351,7 +3325,7 @@ var Ob11InboundMessage = class {
|
|
|
3351
3325
|
handleRawMessage(msg) {
|
|
3352
3326
|
if (hasGrayTip(msg)) {
|
|
3353
3327
|
this.broadcastNotice(msg).catch((err) => {
|
|
3354
|
-
this.deps.logger?.debug({ err:
|
|
3328
|
+
this.deps.logger?.debug({ err: errorMessage(err) }, "ob11: notice 翻译失败(整个事件丢弃)");
|
|
3355
3329
|
});
|
|
3356
3330
|
return;
|
|
3357
3331
|
}
|
|
@@ -3453,14 +3427,12 @@ function collectGroupNotifyUids(notifies) {
|
|
|
3453
3427
|
* 本模块只保留 OB11 侧内容:
|
|
3454
3428
|
* - SysMsgNoticeKind:sysmsg 可映射的 OB11 notice 种类(event/notice.ts 既有类型)
|
|
3455
3429
|
* - KIND_TABLE:(msgType, subType) → 规则(键 = 原生分发键)
|
|
3456
|
-
* -
|
|
3430
|
+
* - OBSERVED_UNNAMED_SYSMSG_KEYS:已观测但未命名的键(不广播,防校准日志噪音)
|
|
3457
3431
|
* - recognizeSysMsg:绑定 OB11 表的识别入口
|
|
3458
3432
|
*
|
|
3459
3433
|
* 解码原语(decodeProtoTree / extractSysMsgEnvelope / narrowSysMsgBlobs 等)
|
|
3460
3434
|
* 从 `shared/sysmsg.js` 导入使用。
|
|
3461
3435
|
*/
|
|
3462
|
-
/** 群号判别(strings[0] 必须是数字串)。 */
|
|
3463
|
-
const NUMERIC_RE = /^\d+$/;
|
|
3464
3436
|
/**
|
|
3465
3437
|
* (msgType, subType) → 规则表(键 = 原生分发键,design.md §7.1)。
|
|
3466
3438
|
*
|
|
@@ -3489,15 +3461,9 @@ const KIND_TABLE = /* @__PURE__ */ new Map([["732:21", {
|
|
|
3489
3461
|
};
|
|
3490
3462
|
}
|
|
3491
3463
|
}]]);
|
|
3492
|
-
/** 已观测但未命名的 (msgType, subType)(语义未知,不广播)。 */
|
|
3493
|
-
const OBSERVED_UNNAMED = /* @__PURE__ */ new Set([
|
|
3494
|
-
"528:382",
|
|
3495
|
-
"528:349",
|
|
3496
|
-
"528:381"
|
|
3497
|
-
]);
|
|
3498
3464
|
/** (msgType, subType) → 识别结果(绑定 OB11 表;table 参数供单测注入合成规则)。 */
|
|
3499
3465
|
function recognizeOb11SysMsg(msgType, subType, table = KIND_TABLE) {
|
|
3500
|
-
return recognizeSysMsg(msgType, subType, table,
|
|
3466
|
+
return recognizeSysMsg(msgType, subType, table, OBSERVED_UNNAMED_SYSMSG_KEYS);
|
|
3501
3467
|
}
|
|
3502
3468
|
// src/onebot11/inbound/sysmsg.ts
|
|
3503
3469
|
/**
|
|
@@ -3549,6 +3515,10 @@ var Ob11InboundSysMsg = class {
|
|
|
3549
3515
|
}
|
|
3550
3516
|
};
|
|
3551
3517
|
// src/onebot11/event-pipeline.ts
|
|
3518
|
+
/**
|
|
3519
|
+
* OB11 收链路订阅接线板:管理 unsubscribes 与 kernel 频道 → 领域处理器路由;
|
|
3520
|
+
* 域处理在 inbound/,异步回填在 enrichment.ts。
|
|
3521
|
+
*/
|
|
3552
3522
|
var Ob11EventPipeline = class {
|
|
3553
3523
|
deps;
|
|
3554
3524
|
essence;
|