@napuketto/adapter 0.17.1 → 0.18.0
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/{buddy-req-BtlTJhYX.mjs → buddy-req-CN7gzJpq.mjs} +50 -13
- package/dist/buddy-req-CN7gzJpq.mjs.map +1 -0
- package/dist/core/index.mjs +1 -1
- package/dist/{core-D8sq68iP.mjs → core-C7Nnl45P.mjs} +3 -3
- package/dist/core-C7Nnl45P.mjs.map +1 -0
- package/dist/index-B-HpCes-.d.mts.map +1 -1
- package/dist/index-B2Hf9yzT.d.mts.map +1 -1
- package/dist/index-DBjlR2dn.d.mts.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/kurobot/index.mjs +1 -1
- package/dist/{kurobot-qVM9AdYt.mjs → kurobot-B3por6f4.mjs} +18 -18
- package/dist/kurobot-B3por6f4.mjs.map +1 -0
- package/dist/milky/index.mjs +1 -1
- package/dist/{milky-g7xcz0B5.mjs → milky-Dpk2r5RV.mjs} +56 -26
- package/dist/milky-Dpk2r5RV.mjs.map +1 -0
- package/dist/onebot11/index.mjs +1 -1
- package/dist/{onebot11-C_yEFxou.mjs → onebot11-D_JlAsjy.mjs} +67 -51
- package/dist/onebot11-D_JlAsjy.mjs.map +1 -0
- package/dist/satori/index.mjs +1 -1
- package/dist/{satori-D9t3K5J5.mjs → satori-Deamai7y.mjs} +30 -16
- package/dist/satori-Deamai7y.mjs.map +1 -0
- package/package.json +4 -4
- package/dist/buddy-req-BtlTJhYX.mjs.map +0 -1
- package/dist/core-D8sq68iP.mjs.map +0 -1
- package/dist/kurobot-qVM9AdYt.mjs.map +0 -1
- package/dist/milky-g7xcz0B5.mjs.map +0 -1
- package/dist/onebot11-C_yEFxou.mjs.map +0 -1
- package/dist/satori-D9t3K5J5.mjs.map +0 -1
package/dist/onebot11/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { y as MessageUnique, t as NapukettoOneBot11Adapter, r as OneBotApi, n as assembleOb11Transports, a as canonicalToCqMessage, o as canonicalToSegments, s as cqMessageToCanonical, c as cqMessageToSegments, i as createOb11ActionRegistry, f as encodeCqCode, p as escapeCqParam, m as escapeCqText, u as ob11ConfigSchema, v as ob11ErrorCodeMap, h as parseCqMessage, l as segmentsToCanonical, d as segmentsToCqMessage, g as serializeCqParts, _ as unescapeCqText } from "../onebot11-
|
|
1
|
+
export { y as MessageUnique, t as NapukettoOneBot11Adapter, r as OneBotApi, n as assembleOb11Transports, a as canonicalToCqMessage, o as canonicalToSegments, s as cqMessageToCanonical, c as cqMessageToSegments, i as createOb11ActionRegistry, f as encodeCqCode, p as escapeCqParam, m as escapeCqText, u as ob11ConfigSchema, v as ob11ErrorCodeMap, h as parseCqMessage, l as segmentsToCanonical, d as segmentsToCqMessage, g as serializeCqParts, _ as unescapeCqText } from "../onebot11-D_JlAsjy.mjs";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as resolveProtocolConfig, i as BaseProtocolAdapter, o as ActionRegistry, r as createServerSchema, s as runAction } from "./core-
|
|
1
|
+
import { a as resolveProtocolConfig, i as BaseProtocolAdapter, o as ActionRegistry, r as createServerSchema, s as runAction } from "./core-C7Nnl45P.mjs";
|
|
2
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-Cs4vDKUU.mjs";
|
|
3
3
|
import { a as logEventFailure, c as downloadBufferToFile, d as prepareVideoElements, i as hasGrayTip, l as ensureSilk, o as sliceRaw, r as firstUntranslatedGrayTip, s as truncRaw, t as collectGrayTipUids, u as fileUriToPath } from "./gray-tip-DmZmdtjP.mjs";
|
|
4
|
-
import { a as EssenceListSync, c as OBSERVED_UNNAMED_SYSMSG_KEYS, d as processSysMsgBlob, f as recognizeSysMsg, i as narrowBuddyReqs, l as narrowSysMsgBlobs, n as batchUnreadNums, o as extractEssenceSetSysMsg, r as filterBuddyReqs, s as narrowEssenceGroupArg, t as BuddyReqDedup } from "./buddy-req-
|
|
4
|
+
import { a as EssenceListSync, c as OBSERVED_UNNAMED_SYSMSG_KEYS, d as processSysMsgBlob, f as recognizeSysMsg, i as narrowBuddyReqs, l as narrowSysMsgBlobs, n as batchUnreadNums, o as extractEssenceSetSysMsg, r as filterBuddyReqs, s as narrowEssenceGroupArg, t as BuddyReqDedup } from "./buddy-req-CN7gzJpq.mjs";
|
|
5
5
|
import { ChatType, GrayTipSubType, GroupApi, GroupNotifyMsgStatus, GroupNotifyMsgType, NTGroupMemberRole, NTGroupRequestOperateTypes, TicketApi, TipGroupElementType, WebHonorType, errorMessage, hasStringProp, isRecord, kernelError, toCanonicalElements } from "@napuketto/kernel";
|
|
6
6
|
import { HttpClient, HttpServer, WsClient, WsServer } from "@napuketto/network";
|
|
7
7
|
import { z } from "zod";
|
|
@@ -374,13 +374,13 @@ function createGroupEssenceActions(api) {
|
|
|
374
374
|
if (seg !== null) content.push(seg);
|
|
375
375
|
}
|
|
376
376
|
out.push({
|
|
377
|
-
msg_seq: item.msg_seq,
|
|
378
|
-
msg_random: item.msg_random,
|
|
377
|
+
msg_seq: item.msg_seq ?? 0,
|
|
378
|
+
msg_random: item.msg_random ?? 0,
|
|
379
379
|
sender_id: Number(item.sender_uin),
|
|
380
|
-
sender_nick: item.sender_nick,
|
|
380
|
+
sender_nick: item.sender_nick ?? "",
|
|
381
381
|
operator_id: Number(item.add_digest_uin),
|
|
382
|
-
operator_nick: item.add_digest_nick,
|
|
383
|
-
operator_time: item.add_digest_time,
|
|
382
|
+
operator_nick: item.add_digest_nick ?? "",
|
|
383
|
+
operator_time: item.add_digest_time ?? 0,
|
|
384
384
|
message_id: 0,
|
|
385
385
|
content
|
|
386
386
|
});
|
|
@@ -775,8 +775,8 @@ function createGroupNotifyActions(api) {
|
|
|
775
775
|
const out = [];
|
|
776
776
|
for (const member of members) out.push({
|
|
777
777
|
user_id: Number(uinMap.get(member.uid) ?? member.uin ?? member.uid),
|
|
778
|
-
nickname: member.nick,
|
|
779
|
-
shut_up_time: member.shutUpTime
|
|
778
|
+
nickname: member.nick ?? "",
|
|
779
|
+
shut_up_time: member.shutUpTime ?? 0
|
|
780
780
|
});
|
|
781
781
|
return out;
|
|
782
782
|
}
|
|
@@ -812,6 +812,22 @@ function toOb11GroupInfoDetail(detail) {
|
|
|
812
812
|
}
|
|
813
813
|
/** 禁言秒 → 毫秒(shut_up_timestamp 单位)。 */
|
|
814
814
|
const SEC_TO_MS = 1e3;
|
|
815
|
+
/** 可选成员字段补全(缺省 / 空值不写入,保持 OB11 事件精简)。 */
|
|
816
|
+
function applyMemberOptionalFields(info, member) {
|
|
817
|
+
const cardName = member.cardName ?? "";
|
|
818
|
+
if (cardName !== "") info.card = cardName;
|
|
819
|
+
if (member.memberSpecialTitle !== void 0 && member.memberSpecialTitle !== "") {
|
|
820
|
+
info.title = member.memberSpecialTitle;
|
|
821
|
+
info.special_title = member.memberSpecialTitle;
|
|
822
|
+
}
|
|
823
|
+
const shutUpTime = member.shutUpTime ?? 0;
|
|
824
|
+
if (shutUpTime > 0) info.shut_up_timestamp = shutUpTime * SEC_TO_MS;
|
|
825
|
+
const joinTime = member.joinTime ?? "";
|
|
826
|
+
if (joinTime !== "" && joinTime !== "0") info.join_time = Number(joinTime);
|
|
827
|
+
const lastSpeakTime = member.lastSpeakTime ?? "";
|
|
828
|
+
if (lastSpeakTime !== "" && lastSpeakTime !== "0") info.last_sent_time = Number(lastSpeakTime);
|
|
829
|
+
if (typeof member.age === "number") info.age = member.age;
|
|
830
|
+
}
|
|
815
831
|
/** NT GroupMember → OB11 GroupMemberInfo(uin 由 uidToUin 映射补全)。 */
|
|
816
832
|
function toOb11GroupMemberInfo(groupCode, member, uidToUin) {
|
|
817
833
|
let uinStr = member.uin;
|
|
@@ -819,18 +835,10 @@ function toOb11GroupMemberInfo(groupCode, member, uidToUin) {
|
|
|
819
835
|
const info = {
|
|
820
836
|
group_id: Number(groupCode),
|
|
821
837
|
user_id: Number(uinStr),
|
|
822
|
-
nickname: member.nick,
|
|
823
|
-
role: GroupApi.roleToString(member.role)
|
|
838
|
+
nickname: member.nick ?? "",
|
|
839
|
+
role: GroupApi.roleToString(member.role ?? NTGroupMemberRole.UNSPECIFIED)
|
|
824
840
|
};
|
|
825
|
-
|
|
826
|
-
if (member.memberSpecialTitle !== void 0 && member.memberSpecialTitle !== "") {
|
|
827
|
-
info.title = member.memberSpecialTitle;
|
|
828
|
-
info.special_title = member.memberSpecialTitle;
|
|
829
|
-
}
|
|
830
|
-
if (member.shutUpTime > 0) info.shut_up_timestamp = member.shutUpTime * SEC_TO_MS;
|
|
831
|
-
if (member.joinTime !== "" && member.joinTime !== "0") info.join_time = Number(member.joinTime);
|
|
832
|
-
if (member.lastSpeakTime !== "" && member.lastSpeakTime !== "0") info.last_sent_time = Number(member.lastSpeakTime);
|
|
833
|
-
if (typeof member.age === "number") info.age = member.age;
|
|
841
|
+
applyMemberOptionalFields(info, member);
|
|
834
842
|
return info;
|
|
835
843
|
}
|
|
836
844
|
// src/onebot11/action/group/query.ts
|
|
@@ -922,6 +930,8 @@ no_cache: z.boolean().optional() }),
|
|
|
922
930
|
// src/onebot11/action/group/system-msg.ts
|
|
923
931
|
/** 默认获取数量。 */
|
|
924
932
|
const DEFAULT_COUNT = 50;
|
|
933
|
+
/** OB11 兼容别名键(常量是为了规避 objectLiteralMember 命名规则)。 */
|
|
934
|
+
const INVITED_REQUEST_ALIAS = "InvitedRequest";
|
|
925
935
|
/** 收集全部涉及的 uid 批量转 uin(循环外一次请求)。 */
|
|
926
936
|
async function collectUinMap(api, notifies) {
|
|
927
937
|
const uids = [];
|
|
@@ -998,12 +1008,11 @@ function createGroupSystemMsgActions(api) {
|
|
|
998
1008
|
if (notify.type === GroupNotifyMsgType.INVITED_BY_MEMBER) invited.push(info);
|
|
999
1009
|
else if (notify.type === GroupNotifyMsgType.REQUEST_JOIN_NEED_ADMINI_STRATOR_PASS) joined.push(info);
|
|
1000
1010
|
}
|
|
1001
|
-
|
|
1011
|
+
return {
|
|
1002
1012
|
invited_requests: invited,
|
|
1003
|
-
join_requests: joined
|
|
1013
|
+
join_requests: joined,
|
|
1014
|
+
[INVITED_REQUEST_ALIAS]: invited
|
|
1004
1015
|
};
|
|
1005
|
-
result["InvitedRequest"] = invited;
|
|
1006
|
-
return result;
|
|
1007
1016
|
}
|
|
1008
1017
|
})];
|
|
1009
1018
|
}
|
|
@@ -1601,7 +1610,7 @@ const GROUP_FILE_BUS_ID = 102;
|
|
|
1601
1610
|
* 会把每条普通消息都判成「含该元素」——OB11 入站消息因此全部被误路由到
|
|
1602
1611
|
* grayTip notice 分支并静默丢弃(真机复现)。
|
|
1603
1612
|
*/
|
|
1604
|
-
function hasFileElement(msg) {
|
|
1613
|
+
function hasFileElement$1(msg) {
|
|
1605
1614
|
return msg.elements.some((el) => el.fileElement != null);
|
|
1606
1615
|
}
|
|
1607
1616
|
/** 基础字段(time/self_id/post_type)。 */
|
|
@@ -3001,7 +3010,7 @@ var OneBotApi = class {
|
|
|
3001
3010
|
if (this.groupCache === void 0) return;
|
|
3002
3011
|
try {
|
|
3003
3012
|
const member = await this.groupCache.getMember(groupCode, uid);
|
|
3004
|
-
return member === void 0 ? void 0 : GroupApi.roleToString(member.role);
|
|
3013
|
+
return member === void 0 ? void 0 : GroupApi.roleToString(member.role ?? NTGroupMemberRole.UNSPECIFIED);
|
|
3005
3014
|
} catch (err) {
|
|
3006
3015
|
this.logger?.warn({
|
|
3007
3016
|
group: groupCode,
|
|
@@ -3019,7 +3028,7 @@ var OneBotApi = class {
|
|
|
3019
3028
|
if (this.groupCache === void 0) return;
|
|
3020
3029
|
try {
|
|
3021
3030
|
const out = /* @__PURE__ */ new Map();
|
|
3022
|
-
for (const member of await this.groupCache.getMembers(groupCode)) out.set(member.uid, GroupApi.roleToString(member.role));
|
|
3031
|
+
for (const member of await this.groupCache.getMembers(groupCode)) out.set(member.uid, GroupApi.roleToString(member.role ?? NTGroupMemberRole.UNSPECIFIED));
|
|
3023
3032
|
return out;
|
|
3024
3033
|
} catch (err) {
|
|
3025
3034
|
this.logger?.warn({
|
|
@@ -3258,28 +3267,35 @@ function pickUrl(item) {
|
|
|
3258
3267
|
}
|
|
3259
3268
|
return "";
|
|
3260
3269
|
}
|
|
3270
|
+
/** 元素项是否携带 fileElement 记录。 */
|
|
3271
|
+
function hasFileElement(el) {
|
|
3272
|
+
return isRecord(el) && isRecord(el["fileElement"]);
|
|
3273
|
+
}
|
|
3261
3274
|
/** 单个候选对象 → 归一化项(不可识别返回 null)。接受两类形状:
|
|
3262
3275
|
* ① RawMessage 型(elements[].fileElement——离线文件以消息推送到达的假设,
|
|
3263
3276
|
* 与 onRecvOfflineFileMsg 挂在 MsgService、UpdateC2CFileMsg 字符串一致)
|
|
3264
3277
|
* ② 专用实体型(顶层 fileName 或 fileInfo.fileName——getNewOfflineFileList 族) */
|
|
3265
3278
|
function narrowItem(item) {
|
|
3266
|
-
if (
|
|
3267
|
-
const
|
|
3268
|
-
if (Array.isArray(
|
|
3269
|
-
const
|
|
3270
|
-
if (
|
|
3279
|
+
if (!isRecord(item)) return null;
|
|
3280
|
+
const elements = item["elements"];
|
|
3281
|
+
if (Array.isArray(elements)) {
|
|
3282
|
+
const el = elements.find(hasFileElement);
|
|
3283
|
+
if (el === void 0) return null;
|
|
3284
|
+
const file = el.fileElement;
|
|
3271
3285
|
return {
|
|
3272
|
-
senderUin: pickUin(
|
|
3286
|
+
senderUin: pickUin(item),
|
|
3273
3287
|
name: typeof file["fileName"] === "string" ? file["fileName"] : "",
|
|
3274
3288
|
size: Number(file["fileSize"] ?? 0),
|
|
3275
3289
|
url: pickUrl(file)
|
|
3276
3290
|
};
|
|
3277
3291
|
}
|
|
3278
|
-
const
|
|
3279
|
-
|
|
3292
|
+
const fileInfo = item["fileInfo"];
|
|
3293
|
+
const file = isRecord(fileInfo) ? fileInfo : item;
|
|
3294
|
+
const fileName = file["fileName"];
|
|
3295
|
+
if (typeof fileName !== "string") return null;
|
|
3280
3296
|
return {
|
|
3281
|
-
senderUin: pickUin(
|
|
3282
|
-
name:
|
|
3297
|
+
senderUin: pickUin(item),
|
|
3298
|
+
name: fileName,
|
|
3283
3299
|
size: Number(file["fileSize"] ?? 0),
|
|
3284
3300
|
url: pickUrl(file)
|
|
3285
3301
|
};
|
|
@@ -3418,7 +3434,7 @@ var Ob11InboundMessage = class {
|
|
|
3418
3434
|
return;
|
|
3419
3435
|
}
|
|
3420
3436
|
if (!this.reportSelfMessage && String(msg.senderUin) === this.deps.selfUin) return;
|
|
3421
|
-
if (this.groupUploadAsNotice && msg.chatType === ChatType.GROUP && hasFileElement(msg)) {
|
|
3437
|
+
if (this.groupUploadAsNotice && msg.chatType === ChatType.GROUP && hasFileElement$1(msg)) {
|
|
3422
3438
|
const notice = toGroupUpload(msg, this.deps.selfUin);
|
|
3423
3439
|
if (notice !== null) {
|
|
3424
3440
|
this.deps.broadcast(notice);
|
|
@@ -3943,12 +3959,13 @@ var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
|
|
|
3943
3959
|
}
|
|
3944
3960
|
/** 请求分发(挂到 transport 的 onRequest):{ action, params, echo } → 注册表分发。 */
|
|
3945
3961
|
async handleRequest(req, respond) {
|
|
3946
|
-
const parsed = req
|
|
3947
|
-
const
|
|
3948
|
-
const
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
if (action === "")
|
|
3962
|
+
const parsed = isRecord(req) ? req : {};
|
|
3963
|
+
const action = parsed["action"];
|
|
3964
|
+
const echo = parsed["echo"];
|
|
3965
|
+
const params = parsed["params"] ?? {};
|
|
3966
|
+
let actionName = "";
|
|
3967
|
+
if (typeof action === "string") actionName = action;
|
|
3968
|
+
if (actionName === "") {
|
|
3952
3969
|
respond({
|
|
3953
3970
|
status: "failed",
|
|
3954
3971
|
retcode: 404,
|
|
@@ -3958,13 +3975,13 @@ var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
|
|
|
3958
3975
|
});
|
|
3959
3976
|
return;
|
|
3960
3977
|
}
|
|
3961
|
-
const act = this.registry.get(
|
|
3978
|
+
const act = this.registry.get(actionName);
|
|
3962
3979
|
if (act === void 0) {
|
|
3963
3980
|
respond({
|
|
3964
3981
|
status: "failed",
|
|
3965
3982
|
retcode: 404,
|
|
3966
3983
|
data: null,
|
|
3967
|
-
message: `未知动作: ${
|
|
3984
|
+
message: `未知动作: ${actionName}`,
|
|
3968
3985
|
...echo !== void 0 ? { echo } : {}
|
|
3969
3986
|
});
|
|
3970
3987
|
return;
|
|
@@ -3977,12 +3994,11 @@ var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
|
|
|
3977
3994
|
};
|
|
3978
3995
|
/** 请求体 echo 字段提取(透传用;非对象 / 缺省 / undefined 返回空对象)。 */
|
|
3979
3996
|
function echoFieldOf(req) {
|
|
3980
|
-
if (req
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
}
|
|
3997
|
+
if (!isRecord(req)) return {};
|
|
3998
|
+
const echo = req["echo"];
|
|
3999
|
+
if (echo !== void 0) return { echo };
|
|
3984
4000
|
return {};
|
|
3985
4001
|
}
|
|
3986
4002
|
export { unescapeCqText as _, canonicalToCqMessage as a, cqMessageToSegments as c, segmentsToCqMessage as d, encodeCqCode as f, serializeCqParts as g, parseCqMessage as h, createOb11ActionRegistry as i, segmentsToCanonical as l, escapeCqText as m, assembleOb11Transports as n, canonicalToSegments as o, escapeCqParam as p, OneBotApi as r, cqMessageToCanonical as s, NapukettoOneBot11Adapter as t, ob11ConfigSchema as u, ob11ErrorCodeMap as v, MessageUnique as y };
|
|
3987
4003
|
|
|
3988
|
-
//# sourceMappingURL=onebot11-
|
|
4004
|
+
//# sourceMappingURL=onebot11-D_JlAsjy.mjs.map
|