@napuketto/adapter 0.4.2 → 0.6.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-Q7Q4bVuz.mjs +43 -0
- package/dist/buddy-req-Q7Q4bVuz.mjs.map +1 -0
- package/dist/gray-tip-LwBee5mo.mjs +33 -0
- package/dist/gray-tip-LwBee5mo.mjs.map +1 -0
- package/dist/kurobot/index.mjs +1 -1
- package/dist/milky/index.d.mts +236 -0
- package/dist/milky/index.d.mts.map +1 -0
- package/dist/milky/index.mjs +2513 -0
- package/dist/milky/index.mjs.map +1 -0
- package/dist/onebot11/index.d.mts +2 -0
- package/dist/onebot11/index.d.mts.map +1 -1
- package/dist/onebot11/index.mjs +79 -93
- package/dist/onebot11/index.mjs.map +1 -1
- package/dist/raw-message-D_ecJy4C.mjs +19 -0
- package/dist/raw-message-D_ecJy4C.mjs.map +1 -0
- package/dist/satori/index.mjs +3 -2
- package/dist/satori/index.mjs.map +1 -1
- package/dist/{gray-tip-B80z9KR4.mjs → transport-schema-CpPxyRK0.mjs} +2 -21
- package/dist/transport-schema-CpPxyRK0.mjs.map +1 -0
- package/package.json +9 -4
- package/dist/gray-tip-B80z9KR4.mjs.map +0 -1
- package/dist/raw-message-6KdlG8kR.mjs +0 -13
- package/dist/raw-message-6KdlG8kR.mjs.map +0 -1
package/dist/onebot11/index.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { i as BaseAction, o as ActionRegistry, r as BaseProtocolAdapter, t as ensureSilk } from "../core-DyXyDUcU.mjs";
|
|
2
|
-
import { n as
|
|
3
|
-
import { t as
|
|
2
|
+
import { n as createWsServerSchema, t as createHttpServerSchema } from "../transport-schema-CpPxyRK0.mjs";
|
|
3
|
+
import { n as firstUntranslatedGrayTip, t as collectGrayTipUids } from "../gray-tip-LwBee5mo.mjs";
|
|
4
|
+
import { n as MS_TO_SEC$5, r as resolveUin, t as narrowBuddyReqs } from "../buddy-req-Q7Q4bVuz.mjs";
|
|
5
|
+
import { n as subscribeRawMessages } from "../raw-message-D_ecJy4C.mjs";
|
|
4
6
|
import { ChatType, GrayTipSubType, GroupApi, GroupNotifyMsgStatus, GroupNotifyMsgType, NTGroupMemberRole, NTGroupRequestOperateTypes, TicketApi, TipGroupElementType, WebHonorType, kernelError, toCanonicalElements } from "@napuketto/kernel";
|
|
5
7
|
import { downloadUrl, inferExtension } from "@napuketto/media";
|
|
6
8
|
import { z } from "zod";
|
|
@@ -1877,7 +1879,7 @@ function cqMessageToCanonical(text) {
|
|
|
1877
1879
|
//#endregion
|
|
1878
1880
|
//#region src/onebot11/helper/message-info.ts
|
|
1879
1881
|
/** 毫秒 → 秒(Unix 时间戳)。 */
|
|
1880
|
-
const MS_TO_SEC$
|
|
1882
|
+
const MS_TO_SEC$4 = 1e3;
|
|
1881
1883
|
/** RawMessage → OB11 消息信息(message_id 经 MessageUnique 映射)。
|
|
1882
1884
|
* ctx(可选):接收方向 ID 转换上下文(at uid→uin、reply NT msgId→OB11 id,P2-19)。 */
|
|
1883
1885
|
function toOb11MessageInfo(msg, unique, ctx = {}) {
|
|
@@ -1894,7 +1896,7 @@ function toOb11MessageInfo(msg, unique, ctx = {}) {
|
|
|
1894
1896
|
user_id: Number(msg.senderUin),
|
|
1895
1897
|
nickname: msg.sendNickName
|
|
1896
1898
|
},
|
|
1897
|
-
time: Math.floor(Number(msg.msgTime) / MS_TO_SEC$
|
|
1899
|
+
time: Math.floor(Number(msg.msgTime) / MS_TO_SEC$4),
|
|
1898
1900
|
message: canonicalToSegments(elements),
|
|
1899
1901
|
raw_message: canonicalToCqMessage(elements)
|
|
1900
1902
|
};
|
|
@@ -1909,7 +1911,7 @@ function toOb11MessageInfo(msg, unique, ctx = {}) {
|
|
|
1909
1911
|
//#endregion
|
|
1910
1912
|
//#region src/onebot11/helper/notice.ts
|
|
1911
1913
|
/** 毫秒 → 秒(Unix 时间戳)。 */
|
|
1912
|
-
const MS_TO_SEC$
|
|
1914
|
+
const MS_TO_SEC$3 = 1e3;
|
|
1913
1915
|
/** 群文件业务类型(group_upload 的 file.busid,与 kernel 群文件系列同源语义)。 */
|
|
1914
1916
|
const GROUP_FILE_BUS_ID = 102;
|
|
1915
1917
|
/** 检查消息是否含文件元素(group_upload 开关分支判定)。 */
|
|
@@ -1928,7 +1930,7 @@ function toUin$1(uid, ctx) {
|
|
|
1928
1930
|
/** 基础字段(time/self_id/post_type)。 */
|
|
1929
1931
|
function base(msg, ctx) {
|
|
1930
1932
|
return {
|
|
1931
|
-
time: Math.floor(Number(msg.msgTime) / MS_TO_SEC$
|
|
1933
|
+
time: Math.floor(Number(msg.msgTime) / MS_TO_SEC$3),
|
|
1932
1934
|
self_id: Number(ctx.selfUin),
|
|
1933
1935
|
post_type: "notice",
|
|
1934
1936
|
group_id: Number(msg.peerUid)
|
|
@@ -1939,7 +1941,7 @@ function toRecall(msg, g, ctx) {
|
|
|
1939
1941
|
if (g?.revokeElement === void 0) return null;
|
|
1940
1942
|
const revoke = g.revokeElement;
|
|
1941
1943
|
if (msg.chatType === ChatType.C2C) return {
|
|
1942
|
-
time: Math.floor(Number(msg.msgTime) / MS_TO_SEC$
|
|
1944
|
+
time: Math.floor(Number(msg.msgTime) / MS_TO_SEC$3),
|
|
1943
1945
|
self_id: Number(ctx.selfUin),
|
|
1944
1946
|
post_type: "notice",
|
|
1945
1947
|
notice_type: "friend_recall",
|
|
@@ -1967,7 +1969,7 @@ function toPoke(msg, g, ctx) {
|
|
|
1967
1969
|
ctx.logger?.warn({ raw: JSON.stringify(g)?.slice(0, 2e3) }, "ob11: poke grayTip raw(待真实事件校准)");
|
|
1968
1970
|
const isGroup = msg.chatType === ChatType.GROUP;
|
|
1969
1971
|
return {
|
|
1970
|
-
time: Math.floor(Number(msg.msgTime) / MS_TO_SEC$
|
|
1972
|
+
time: Math.floor(Number(msg.msgTime) / MS_TO_SEC$3),
|
|
1971
1973
|
self_id: Number(ctx.selfUin),
|
|
1972
1974
|
post_type: "notice",
|
|
1973
1975
|
notice_type: "notify",
|
|
@@ -1977,28 +1979,30 @@ function toPoke(msg, g, ctx) {
|
|
|
1977
1979
|
target_id: toUin$1(aioOp?.peerUid ?? "", ctx)
|
|
1978
1980
|
};
|
|
1979
1981
|
}
|
|
1982
|
+
/** 群成员变动映射器表(键 = TipGroupElementType;缺项 = 不可翻译返回 null)。 */
|
|
1983
|
+
const GROUP_CHANGE_BUILDERS = {
|
|
1984
|
+
[TipGroupElementType.MEMBER_ADD]: toMemberAdd,
|
|
1985
|
+
[TipGroupElementType.QUIT]: toQuit,
|
|
1986
|
+
[TipGroupElementType.BLOCK]: toAdminChange,
|
|
1987
|
+
[TipGroupElementType.UNBLOCK]: toAdminChange,
|
|
1988
|
+
[TipGroupElementType.SHUT_UP]: toBan
|
|
1989
|
+
};
|
|
1980
1990
|
/** 群成员变动(group_increase / group_decrease / group_admin / group_ban)。 */
|
|
1981
1991
|
function toGroupChange(msg, g, ctx) {
|
|
1982
1992
|
const grp = g?.groupElement;
|
|
1983
1993
|
if (grp === void 0 || grp.type === void 0) return null;
|
|
1984
|
-
const
|
|
1985
|
-
|
|
1994
|
+
const builder = GROUP_CHANGE_BUILDERS[grp.type];
|
|
1995
|
+
if (builder === void 0) return null;
|
|
1996
|
+
return builder({
|
|
1997
|
+
time: Math.floor(Number(msg.msgTime) / MS_TO_SEC$3),
|
|
1986
1998
|
selfId: Number(ctx.selfUin),
|
|
1987
1999
|
groupId: Number(msg.peerUid),
|
|
1988
2000
|
memberUid: grp.memberUid ?? "",
|
|
1989
2001
|
adminUid: grp.adminUid ?? ""
|
|
1990
|
-
};
|
|
1991
|
-
switch (grp.type) {
|
|
1992
|
-
case TipGroupElementType.MEMBER_ADD: return toMemberAdd(common, ctx);
|
|
1993
|
-
case TipGroupElementType.QUIT: return toQuit(common, ctx);
|
|
1994
|
-
case TipGroupElementType.BLOCK:
|
|
1995
|
-
case TipGroupElementType.UNBLOCK: return toAdminChange(common, grp, ctx);
|
|
1996
|
-
case TipGroupElementType.SHUT_UP: return toBan(common, grp, ctx);
|
|
1997
|
-
default: return null;
|
|
1998
|
-
}
|
|
2002
|
+
}, grp, ctx);
|
|
1999
2003
|
}
|
|
2000
2004
|
/** 群成员增加(approve=管理员操作 / invite=普通邀请)。 */
|
|
2001
|
-
function toMemberAdd(common, ctx) {
|
|
2005
|
+
function toMemberAdd(common, _grp, ctx) {
|
|
2002
2006
|
const { time, selfId, groupId, memberUid, adminUid } = common;
|
|
2003
2007
|
return {
|
|
2004
2008
|
time,
|
|
@@ -2012,7 +2016,7 @@ function toMemberAdd(common, ctx) {
|
|
|
2012
2016
|
};
|
|
2013
2017
|
}
|
|
2014
2018
|
/** 群成员退出(leave)。 */
|
|
2015
|
-
function toQuit(common, ctx) {
|
|
2019
|
+
function toQuit(common, _grp, ctx) {
|
|
2016
2020
|
const { time, selfId, groupId, memberUid, adminUid } = common;
|
|
2017
2021
|
return {
|
|
2018
2022
|
time,
|
|
@@ -2040,18 +2044,18 @@ function toAdminChange(common, grp, ctx) {
|
|
|
2040
2044
|
}
|
|
2041
2045
|
/** 禁言(duration>0=ban / 否则 lift_ban)。 */
|
|
2042
2046
|
function toBan(common, grp, ctx) {
|
|
2043
|
-
const { time, selfId, groupId, adminUid, memberUid } = common;
|
|
2044
2047
|
const shutUp = grp.shutUp;
|
|
2048
|
+
const duration = Number(shutUp?.duration ?? 0);
|
|
2045
2049
|
return {
|
|
2046
|
-
time,
|
|
2047
|
-
self_id: selfId,
|
|
2050
|
+
time: common.time,
|
|
2051
|
+
self_id: common.selfId,
|
|
2048
2052
|
post_type: "notice",
|
|
2049
2053
|
notice_type: "group_ban",
|
|
2050
|
-
sub_type:
|
|
2051
|
-
group_id: groupId,
|
|
2052
|
-
operator_id: toUin$1(shutUp?.admin?.uid ?? adminUid, ctx),
|
|
2053
|
-
user_id: toUin$1(shutUp?.member?.uid ?? memberUid, ctx),
|
|
2054
|
-
duration
|
|
2054
|
+
sub_type: duration > 0 ? "ban" : "lift_ban",
|
|
2055
|
+
group_id: common.groupId,
|
|
2056
|
+
operator_id: toUin$1(shutUp?.admin?.uid ?? common.adminUid, ctx),
|
|
2057
|
+
user_id: toUin$1(shutUp?.member?.uid ?? common.memberUid, ctx),
|
|
2058
|
+
duration
|
|
2055
2059
|
};
|
|
2056
2060
|
}
|
|
2057
2061
|
/**
|
|
@@ -2062,7 +2066,7 @@ function toBan(common, grp, ctx) {
|
|
|
2062
2066
|
function toFriendAdd(entry, selfUin) {
|
|
2063
2067
|
const uin = entry.coreInfo?.uin ?? entry.uin ?? "";
|
|
2064
2068
|
return {
|
|
2065
|
-
time: Math.floor(Date.now() / MS_TO_SEC$
|
|
2069
|
+
time: Math.floor(Date.now() / MS_TO_SEC$3),
|
|
2066
2070
|
self_id: Number(selfUin),
|
|
2067
2071
|
post_type: "notice",
|
|
2068
2072
|
notice_type: "friend_add",
|
|
@@ -2079,7 +2083,7 @@ function toGroupUpload(msg, selfUin) {
|
|
|
2079
2083
|
const file = msg.elements.find((e) => e.fileElement !== void 0)?.fileElement;
|
|
2080
2084
|
if (file === void 0) return null;
|
|
2081
2085
|
return {
|
|
2082
|
-
time: Math.floor(Number(msg.msgTime) / MS_TO_SEC$
|
|
2086
|
+
time: Math.floor(Number(msg.msgTime) / MS_TO_SEC$3),
|
|
2083
2087
|
self_id: Number(selfUin),
|
|
2084
2088
|
post_type: "notice",
|
|
2085
2089
|
notice_type: "group_upload",
|
|
@@ -2099,12 +2103,16 @@ function translateGrayTip(msg, g, ctx) {
|
|
|
2099
2103
|
if (subType === GrayTipSubType.REVOKE) return toRecall(msg, g, ctx);
|
|
2100
2104
|
if (subType === GrayTipSubType.GROUP) return toGroupChange(msg, g, ctx);
|
|
2101
2105
|
if (g.aioOpGrayTipElement !== void 0) return toPoke(msg, g, ctx);
|
|
2102
|
-
ctx
|
|
2103
|
-
subType,
|
|
2104
|
-
raw: JSON.stringify(g)?.slice(0, 2e3)
|
|
2105
|
-
}, "ob11: 未翻译的 grayTip 子类型(raw 校准数据)");
|
|
2106
|
+
logUntranslatedGrayTip(msg, ctx);
|
|
2106
2107
|
return null;
|
|
2107
2108
|
}
|
|
2109
|
+
function logUntranslatedGrayTip(msg, ctx) {
|
|
2110
|
+
const untranslated = firstUntranslatedGrayTip(msg);
|
|
2111
|
+
if (untranslated !== void 0) ctx.logger?.warn({
|
|
2112
|
+
subType: untranslated.subElementType,
|
|
2113
|
+
raw: JSON.stringify(untranslated)?.slice(0, 2e3)
|
|
2114
|
+
}, "ob11: 未翻译的 grayTip 子类型(raw 校准数据)");
|
|
2115
|
+
}
|
|
2108
2116
|
/** RawMessage → OB11 notice 事件(无 grayTip 返回 null)。
|
|
2109
2117
|
* 未知/未翻译子类型打 raw JSON 日志(校准数据积累,2026-09-08)。 */
|
|
2110
2118
|
function toOb11NoticeEvent(msg, ctx) {
|
|
@@ -2133,15 +2141,9 @@ function toOb11NoticeEvent(msg, ctx) {
|
|
|
2133
2141
|
* ⚠️ onBuddyReqChange 回调参数形状未经真实事件校准(wrapper 字符串证据仅有方法名),
|
|
2134
2142
|
* narrowBuddyReqs 防御性收窄,未知形状返回 null 由调用方打 raw 日志积累校准数据。
|
|
2135
2143
|
*/
|
|
2136
|
-
/**
|
|
2137
|
-
const MS_TO_SEC$3 = 1e3;
|
|
2138
|
-
/** uid → uin(上下文映射缺省时:数字 uid 直取数值,非数字 uid 返回 0 表示未知)。 */
|
|
2144
|
+
/** uid → uin(core 共享解析;ctx 携带映射)。 */
|
|
2139
2145
|
function toUin(uid, ctx) {
|
|
2140
|
-
|
|
2141
|
-
const uin = ctx.uidToUin.get(uid);
|
|
2142
|
-
if (uin !== void 0) return Number(uin);
|
|
2143
|
-
const n = Number(uid);
|
|
2144
|
-
return Number.isFinite(n) ? n : 0;
|
|
2146
|
+
return resolveUin(uid, ctx.uidToUin);
|
|
2145
2147
|
}
|
|
2146
2148
|
/**
|
|
2147
2149
|
* GroupNotify → OB11 群请求事件(group_add / group_invite)。
|
|
@@ -2164,7 +2166,7 @@ function toOb11GroupRequestEvent(notify, ctx) {
|
|
|
2164
2166
|
default: return null;
|
|
2165
2167
|
}
|
|
2166
2168
|
return {
|
|
2167
|
-
time: Math.floor(Date.now() / MS_TO_SEC$
|
|
2169
|
+
time: Math.floor(Date.now() / MS_TO_SEC$5),
|
|
2168
2170
|
self_id: Number(ctx.selfUin),
|
|
2169
2171
|
post_type: "request",
|
|
2170
2172
|
request_type: "group",
|
|
@@ -2175,24 +2177,6 @@ function toOb11GroupRequestEvent(notify, ctx) {
|
|
|
2175
2177
|
flag: String(notify.seq)
|
|
2176
2178
|
};
|
|
2177
2179
|
}
|
|
2178
|
-
/** BuddyReq 防御性收窄:仅接受字段形状可用的对象(onBuddyReqChange 参数待真实事件校准)。 */
|
|
2179
|
-
function isBuddyReqLike(value) {
|
|
2180
|
-
if (typeof value !== "object" || value === null) return false;
|
|
2181
|
-
const v = value;
|
|
2182
|
-
return typeof v["reqTime"] === "string" && typeof v["friendUid"] === "string";
|
|
2183
|
-
}
|
|
2184
|
-
/**
|
|
2185
|
-
* onBuddyReqChange 回调参数 → BuddyReq 列表(防御性收窄)。
|
|
2186
|
-
* 已知候选形状:BuddyReq[] / { buddyReqs: BuddyReq[] };其余返回 null(调用方打 raw 日志)。
|
|
2187
|
-
*/
|
|
2188
|
-
function narrowBuddyReqs(arg) {
|
|
2189
|
-
if (Array.isArray(arg)) return arg.every(isBuddyReqLike) ? arg : null;
|
|
2190
|
-
if (typeof arg === "object" && arg !== null) {
|
|
2191
|
-
const reqs = arg["buddyReqs"];
|
|
2192
|
-
if (Array.isArray(reqs) && reqs.every(isBuddyReqLike)) return reqs;
|
|
2193
|
-
}
|
|
2194
|
-
return null;
|
|
2195
|
-
}
|
|
2196
2180
|
/**
|
|
2197
2181
|
* BuddyReq → OB11 好友请求事件(friend)。
|
|
2198
2182
|
* comment 取 words 字段(验证留言,形状待校准,缺省空串);flag = reqTime。
|
|
@@ -2200,7 +2184,7 @@ function narrowBuddyReqs(arg) {
|
|
|
2200
2184
|
function toOb11FriendRequestEvent(req, ctx) {
|
|
2201
2185
|
const words = req["words"];
|
|
2202
2186
|
return {
|
|
2203
|
-
time: Math.floor(Date.now() / MS_TO_SEC$
|
|
2187
|
+
time: Math.floor(Date.now() / MS_TO_SEC$5),
|
|
2204
2188
|
self_id: Number(ctx.selfUin),
|
|
2205
2189
|
post_type: "request",
|
|
2206
2190
|
request_type: "friend",
|
|
@@ -4269,22 +4253,20 @@ var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
|
|
|
4269
4253
|
/** 订阅 kernel 事件(消息 + 群通知 + 好友请求,幂等)。 */
|
|
4270
4254
|
subscribe() {
|
|
4271
4255
|
if (this.unsubscribes.length > 0) return;
|
|
4272
|
-
this.unsubscribes.push(this.msgChannel
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4256
|
+
this.unsubscribes.push(subscribeRawMessages(this.msgChannel, (msg) => {
|
|
4257
|
+
if (hasGrayTip(msg)) {
|
|
4258
|
+
this.broadcastNotice(msg).catch(() => {});
|
|
4259
|
+
return;
|
|
4260
|
+
}
|
|
4261
|
+
if (!this.reportSelfMessage && String(msg.senderUin) === this.selfUin) return;
|
|
4262
|
+
if (this.groupUploadAsNotice && msg.chatType === ChatType.GROUP && hasFileElement(msg)) {
|
|
4263
|
+
const notice = toGroupUpload(msg, this.selfUin);
|
|
4264
|
+
if (notice !== null) {
|
|
4265
|
+
this.broadcastEvent(notice);
|
|
4276
4266
|
return;
|
|
4277
4267
|
}
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
const notice = toGroupUpload(msg, this.selfUin);
|
|
4281
|
-
if (notice !== null) {
|
|
4282
|
-
this.broadcastEvent(notice);
|
|
4283
|
-
return;
|
|
4284
|
-
}
|
|
4285
|
-
}
|
|
4286
|
-
this.broadcastMessageEvent(msg);
|
|
4287
|
-
});
|
|
4268
|
+
}
|
|
4269
|
+
this.broadcastMessageEvent(msg);
|
|
4288
4270
|
}));
|
|
4289
4271
|
this.unsubscribes.push(this.msgChannel.on("Msg/onRecvOfflineFileMsg", (arg) => {
|
|
4290
4272
|
const items = narrowOfflineFiles(arg);
|
|
@@ -4415,18 +4397,9 @@ var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
|
|
|
4415
4397
|
}
|
|
4416
4398
|
/** 广播群系统通知 → OB11 group request 事件(批量 uidToUin 后翻译,纯函数)。 */
|
|
4417
4399
|
async broadcastGroupRequests(notifies) {
|
|
4418
|
-
const uids = [];
|
|
4419
|
-
for (const n of notifies) {
|
|
4420
|
-
const notify = n;
|
|
4421
|
-
for (const u of [notify.user1, notify.user2]) if (typeof u?.uid === "string" && u.uid !== "") uids.push(u.uid);
|
|
4422
|
-
}
|
|
4423
|
-
let uidToUin = /* @__PURE__ */ new Map();
|
|
4424
|
-
if (uids.length > 0) try {
|
|
4425
|
-
uidToUin = await this.oneBotApi.uidToUin(uids);
|
|
4426
|
-
} catch {}
|
|
4427
4400
|
const ctx = {
|
|
4428
4401
|
selfUin: this.selfUin,
|
|
4429
|
-
uidToUin
|
|
4402
|
+
uidToUin: await this.uidToUinMap(collectGroupNotifyUids(notifies))
|
|
4430
4403
|
};
|
|
4431
4404
|
for (const n of notifies) {
|
|
4432
4405
|
const event = toOb11GroupRequestEvent(n, ctx);
|
|
@@ -4435,17 +4408,21 @@ var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
|
|
|
4435
4408
|
}
|
|
4436
4409
|
/** 广播好友申请 → OB11 friend request 事件(批量 uidToUin 后翻译,纯函数)。 */
|
|
4437
4410
|
async broadcastFriendRequests(reqs) {
|
|
4438
|
-
const uids = reqs.map((r) => r.friendUid).filter((uid) => uid !== "");
|
|
4439
|
-
let uidToUin = /* @__PURE__ */ new Map();
|
|
4440
|
-
if (uids.length > 0) try {
|
|
4441
|
-
uidToUin = await this.oneBotApi.uidToUin(uids);
|
|
4442
|
-
} catch {}
|
|
4443
4411
|
const ctx = {
|
|
4444
4412
|
selfUin: this.selfUin,
|
|
4445
|
-
uidToUin
|
|
4413
|
+
uidToUin: await this.uidToUinMap(reqs.map((r) => r.friendUid).filter((uid) => uid !== ""))
|
|
4446
4414
|
};
|
|
4447
4415
|
for (const req of reqs) this.broadcastEvent(toOb11FriendRequestEvent(req, ctx));
|
|
4448
4416
|
}
|
|
4417
|
+
/** uid 批量 → uin(失败退空 Map:翻译层退化为 uid 数值,不阻塞请求上报)。 */
|
|
4418
|
+
async uidToUinMap(uids) {
|
|
4419
|
+
if (uids.length === 0) return /* @__PURE__ */ new Map();
|
|
4420
|
+
try {
|
|
4421
|
+
return await this.oneBotApi.uidToUin(uids);
|
|
4422
|
+
} catch {
|
|
4423
|
+
return /* @__PURE__ */ new Map();
|
|
4424
|
+
}
|
|
4425
|
+
}
|
|
4449
4426
|
/** 退订(幂等)。 */
|
|
4450
4427
|
unsubscribeAll() {
|
|
4451
4428
|
for (const off of this.unsubscribes) off();
|
|
@@ -4486,6 +4463,15 @@ var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
|
|
|
4486
4463
|
respond(result);
|
|
4487
4464
|
}
|
|
4488
4465
|
};
|
|
4466
|
+
/** 收集群系统通知涉及的 uid(user1/user2 双方,空 uid 跳过)。 */
|
|
4467
|
+
function collectGroupNotifyUids(notifies) {
|
|
4468
|
+
const uids = [];
|
|
4469
|
+
for (const n of notifies) {
|
|
4470
|
+
const notify = n;
|
|
4471
|
+
for (const u of [notify.user1, notify.user2]) if (typeof u?.uid === "string" && u.uid !== "") uids.push(u.uid);
|
|
4472
|
+
}
|
|
4473
|
+
return uids;
|
|
4474
|
+
}
|
|
4489
4475
|
//#endregion
|
|
4490
4476
|
export { MessageUnique, NapukettoOneBot11Adapter, OneBotApi, assembleOb11Transports, canonicalToCqMessage, canonicalToSegments, cqMessageToCanonical, cqMessageToSegments, createOb11ActionRegistry, encodeCqCode, escapeCqParam, escapeCqText, ob11ConfigSchema, ob11ErrorCodeMap, parseCqMessage, segmentsToCanonical, segmentsToCqMessage, serializeCqParts, unescapeCqText };
|
|
4491
4477
|
|