@napuketto/adapter 0.0.21 → 0.1.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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as ProtocolConfig, n as BaseProtocolAdapter, s as ActionRegistry, u as ErrorCodeMap } from "../index-CDKj-jus.mjs";
|
|
2
2
|
import "../gray-tip-CcpfI1Og.mjs";
|
|
3
|
-
import { BuddyEventChannel, CanonicalElement, ChatType, FriendApi, GroupApi, GroupCache, GroupEventChannel, GroupNotifyApi, MsgApi, MsgEventChannel, Peer, ProfileApi, ProfileLikeApi, RichMediaApi, TicketApi, WebApi } from "@napuketto/kernel";
|
|
3
|
+
import { BuddyCacheEventChannel, BuddyEventChannel, CanonicalElement, ChatType, FriendApi, GroupApi, GroupCache, GroupEventChannel, GroupNotifyApi, MsgApi, MsgEventChannel, Peer, ProfileApi, ProfileLikeApi, RichMediaApi, TicketApi, WebApi } from "@napuketto/kernel";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { EventBroadcaster, TransportAdapter } from "@napuketto/network";
|
|
6
6
|
//#region src/onebot11/helper/message-unique.d.ts
|
|
@@ -182,6 +182,11 @@ type OB11MessageSegment = {
|
|
|
182
182
|
file: string;
|
|
183
183
|
url?: string;
|
|
184
184
|
};
|
|
185
|
+
} | {
|
|
186
|
+
type: "file";
|
|
187
|
+
data: {
|
|
188
|
+
file: string;
|
|
189
|
+
};
|
|
185
190
|
} | {
|
|
186
191
|
type: "reply";
|
|
187
192
|
data: {
|
|
@@ -650,6 +655,7 @@ declare const ob11ConfigSchema: z.ZodObject<{
|
|
|
650
655
|
array: "array";
|
|
651
656
|
string: "string";
|
|
652
657
|
}>>;
|
|
658
|
+
groupUploadAsNotice: z.ZodDefault<z.ZodBoolean>;
|
|
653
659
|
httpServers: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
654
660
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
655
661
|
host: z.ZodDefault<z.ZodString>;
|
|
@@ -712,6 +718,8 @@ interface OneBot11AdapterOptions extends OneBotApiOptions {
|
|
|
712
718
|
groupChannel?: GroupEventChannel;
|
|
713
719
|
/** kernel 好友事件通道(可选:Buddy/onBuddyReqChange → OB11 request 源)。 */
|
|
714
720
|
friendChannel?: BuddyEventChannel;
|
|
721
|
+
/** 好友缓存 diff 通道(可选:BuddyCache/onBuddyAdded → OB11 friend_add 源,B2)。 */
|
|
722
|
+
buddyCacheEvents?: BuddyCacheEventChannel;
|
|
715
723
|
/** 校准日志(可选:未知事件形状 raw JSON;IPC 模式传 loader pino 实例)。 */
|
|
716
724
|
logger?: AdapterLoggerLike;
|
|
717
725
|
}
|
|
@@ -721,6 +729,7 @@ declare class NapukettoOneBot11Adapter extends BaseProtocolAdapter<OB11Config> {
|
|
|
721
729
|
private readonly msgChannel;
|
|
722
730
|
private readonly groupChannel;
|
|
723
731
|
private readonly friendChannel;
|
|
732
|
+
private readonly buddyCacheEvents;
|
|
724
733
|
private readonly calibLogger;
|
|
725
734
|
private readonly selfUin;
|
|
726
735
|
private readonly oneBotApi;
|
|
@@ -731,6 +740,8 @@ declare class NapukettoOneBot11Adapter extends BaseProtocolAdapter<OB11Config> {
|
|
|
731
740
|
private heartbeatTimer;
|
|
732
741
|
private reportSelfMessage;
|
|
733
742
|
private messageFormat;
|
|
743
|
+
/** 群文件报形式(B4):true = fileElement 群消息报 group_upload notice 替代 message。 */
|
|
744
|
+
private groupUploadAsNotice;
|
|
734
745
|
/** IPC 桥模式标记(subscribeOnly 启动;reload 时跳过传输重建)。 */
|
|
735
746
|
private subscribedOnly;
|
|
736
747
|
constructor(opts: OneBot11AdapterOptions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/onebot11/helper/message-unique.ts","../../src/onebot11/api/one-bot-api.ts","../../src/onebot11/action/error-map.ts","../../src/onebot11/action/group/get-group-at-all-remain.ts","../../src/onebot11/types/index.ts","../../src/onebot11/event/base.ts","../../src/onebot11/event/message.ts","../../src/onebot11/event/meta.ts","../../src/onebot11/event/notice.ts","../../src/onebot11/event/request.ts","../../src/onebot11/event/index.ts","../../src/onebot11/action/index.ts","../../src/onebot11/helper/codec/cqcode.ts","../../src/onebot11/helper/codec/segment.ts","../../src/onebot11/helper/config.ts","../../src/onebot11/helper/data.ts","../../src/onebot11/adapter.ts","../../src/onebot11/transport.ts"],"mappings":";;;;;;cAkBa;;mBAEQ;;mBAEA;;mBAEA;;UAET;;mBAES;;;;;EAMjB,MAAM,eAAe,OAAO;;EAmB5B,SAAS;;EAKT,aAAa;;EAKb,QAAQ,gBAAgB;;EAKxB,QAAQ;;UAYA;;;;;UCvDK;;EAEb;;EAEA,mBAAmB;;EAEnB;;EAEA;;EAEA,aAAa;;EAEb,gBAAgB;;;UAIH;EACb,QAAQ;EACR,UAAU;EACV,gBAAgB;EAChB,WAAW;EACX,WAAW;EACX,cAAc;EACd,YAAY;EACZ,gBAAgB;EAChB,QAAQ;;EAER;IAAQ;IAAa;;;EAErB,QAAQ;;EAER,aAAa;;;;;;cAOJ;;WAEA,QAAQ;;WAER,UAAU;;WAEV,gBAAgB;;WAEhB,WAAW;;WAEX,WAAW;;WAEX,cAAc;;WAEd,YAAY;;WAEZ,gBAAgB;;WAEhB,QAAQ;;WAER,YAAY;;WAEZ,eAAe;;WAEf;IAAQ;IAAa;;;WAErB;;WAEA;;WAEA,mBAAmB;;WAEnB;;WAEA;;WAEA,aAAa;;WAEb,gBAAgB;EAEzB,YAAY,MAAM;;EAuBlB,SAAS,iBAAiB,QAAQ;;EAKlC,SAAS,iBAAiB,QAAQ;;;;;cCzHzB,kBAAkB;;;;UCMd;EACb;EACA;EACA;;;;;;;;;UCba,WAAW;EACxB;EACA;EACA,MAAM;EACN;EACA;;;KAIQ;EACJ;EAAc;IAAQ;;;EACtB;EAAY;IAAQ;IAAY;;;EAChC;EAAc;IAAQ;;;EACtB;EAAe;IAAQ;IAAc;;;EACrC;EAAgB;IAAQ;IAAc;;;EACtC;EAAe;IAAQ;IAAc;;;EACrC;EAAe;IAAQ;;;EACvB;EAAiB;IAAQ;;;EACzB;EAAc;IAAQ;;;EACtB;EAAa;IAAQ;;;EACrB;EAAgB;IAAQ;;;;KAGpB,uBAAuB;;UAGlB;EACb;EACA;EACA;EACA;;;UAIa;EACb;EACA;EACA;EACA;;;UAIa;EACb;EACA;;;UAIa;EACb;EACA;EACA;EACA;IACI;IACA;IACA;IACA;;EAEJ;EACA,SAAS;EACT;EACA;EACA;;;KAIQ;;UAGK;EACb;EACA;EACA;EACA;EACA,MAAM;EACN;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;;;UAIa;EACb;EACA;EACA;;;UAIa;EACb;EACA;EACA,MAAM;EACN;;EAEA;EACA;EACA;EACA;;;UAIa;EACb;EACA;EACA;EACA;EACA;;;UAIa;EACb;EACA;EACA;;;UAIa;EACb;EACA,oBAAoB;EACpB,gBAAgB;EAChB,gBAAgB;EAChB,aAAa;EACb,oBAAoB;EACpB,cAAc;;;UAID;EACb;EACA;EACA;;EAEA;EACA;EACA;EACA,eAAe;EACf,gBAAgB;EAChB;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/onebot11/helper/message-unique.ts","../../src/onebot11/api/one-bot-api.ts","../../src/onebot11/action/error-map.ts","../../src/onebot11/action/group/get-group-at-all-remain.ts","../../src/onebot11/types/index.ts","../../src/onebot11/event/base.ts","../../src/onebot11/event/message.ts","../../src/onebot11/event/meta.ts","../../src/onebot11/event/notice.ts","../../src/onebot11/event/request.ts","../../src/onebot11/event/index.ts","../../src/onebot11/action/index.ts","../../src/onebot11/helper/codec/cqcode.ts","../../src/onebot11/helper/codec/segment.ts","../../src/onebot11/helper/config.ts","../../src/onebot11/helper/data.ts","../../src/onebot11/adapter.ts","../../src/onebot11/transport.ts"],"mappings":";;;;;;cAkBa;;mBAEQ;;mBAEA;;mBAEA;;UAET;;mBAES;;;;;EAMjB,MAAM,eAAe,OAAO;;EAmB5B,SAAS;;EAKT,aAAa;;EAKb,QAAQ,gBAAgB;;EAKxB,QAAQ;;UAYA;;;;;UCvDK;;EAEb;;EAEA,mBAAmB;;EAEnB;;EAEA;;EAEA,aAAa;;EAEb,gBAAgB;;;UAIH;EACb,QAAQ;EACR,UAAU;EACV,gBAAgB;EAChB,WAAW;EACX,WAAW;EACX,cAAc;EACd,YAAY;EACZ,gBAAgB;EAChB,QAAQ;;EAER;IAAQ;IAAa;;;EAErB,QAAQ;;EAER,aAAa;;;;;;cAOJ;;WAEA,QAAQ;;WAER,UAAU;;WAEV,gBAAgB;;WAEhB,WAAW;;WAEX,WAAW;;WAEX,cAAc;;WAEd,YAAY;;WAEZ,gBAAgB;;WAEhB,QAAQ;;WAER,YAAY;;WAEZ,eAAe;;WAEf;IAAQ;IAAa;;;WAErB;;WAEA;;WAEA,mBAAmB;;WAEnB;;WAEA;;WAEA,aAAa;;WAEb,gBAAgB;EAEzB,YAAY,MAAM;;EAuBlB,SAAS,iBAAiB,QAAQ;;EAKlC,SAAS,iBAAiB,QAAQ;;;;;cCzHzB,kBAAkB;;;;UCMd;EACb;EACA;EACA;;;;;;;;;UCba,WAAW;EACxB;EACA;EACA,MAAM;EACN;EACA;;;KAIQ;EACJ;EAAc;IAAQ;;;EACtB;EAAY;IAAQ;IAAY;;;EAChC;EAAc;IAAQ;;;EACtB;EAAe;IAAQ;IAAc;;;EACrC;EAAgB;IAAQ;IAAc;;;EACtC;EAAe;IAAQ;IAAc;;;EACrC;EAAc;IAAQ;;;EACtB;EAAe;IAAQ;;;EACvB;EAAiB;IAAQ;;;EACzB;EAAc;IAAQ;;;EACtB;EAAa;IAAQ;;;EACrB;EAAgB;IAAQ;;;;KAGpB,uBAAuB;;UAGlB;EACb;EACA;EACA;EACA;;;UAIa;EACb;EACA;EACA;EACA;;;UAIa;EACb;EACA;;;UAIa;EACb;EACA;EACA;EACA;IACI;IACA;IACA;IACA;;EAEJ;EACA,SAAS;EACT;EACA;EACA;;;KAIQ;;UAGK;EACb;EACA;EACA;EACA;EACA,MAAM;EACN;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;;;UAIa;EACb;EACA;EACA;;;UAIa;EACb;EACA;EACA,MAAM;EACN;;EAEA;EACA;EACA;EACA;;;UAIa;EACb;EACA;EACA;EACA;EACA;;;UAIa;EACb;EACA;EACA;;;UAIa;EACb;EACA,oBAAoB;EACpB,gBAAgB;EAChB,gBAAgB;EAChB,aAAa;EACb,oBAAoB;EACpB,cAAc;;;UAID;EACb;EACA;EACA;;EAEA;EACA;EACA;EACA,eAAe;EACf,gBAAgB;EAChB;;;;;;;;;;;;KCtJQ;;UAGK;;EAEb;;EAEA;;EAEA,WAAW;;;;;UCPE;EACb;EACA;EACA;;;UAIa,oBAAoB;EACjC;EACA;;;UAIa,8BAA8B;EAC3C;EACA;;EAEA;EACA;EACA;EACA;EACA,SAAS;EACT;EACA;EACA,QAAQ;EACR,YAAY;;;UAIC,gCAAgC;EAC7C;EACA;;EAEA;EACA;EACA;EACA,SAAS;EACT;EACA;EACA,QAAQ;;EAER;;;KAIQ,mBAAmB,wBAAwB;;;;UC9CtC;EACb;EACA;GACC;;;UAIY,+BAA+B;EAC5C;EACA;EACA;;;UAIa,+BAA+B;EAC5C;EACA;;EAEA;EACA,QAAQ;;;KAIA,gBAAgB,yBAAyB;;;;UCvBpC;EACb;EACA;EACA;EACA;;;UAIa;EACb;EACA;EACA;;;UAIa;EACb;EACA;EACA;;;UAIa,mCAAmC;EAChD;EACA;EACA;EACA;EACA,MAAM;;;UAIO,kCAAkC;EAC/C;EACA;EACA;EACA;EACA;;;UAIa,qCAAqC;EAClD;EACA;EACA;EACA;EACA;EACA;;;UAIa,qCAAqC;EAClD;EACA;EACA;EACA;EACA;EACA;;;UAIa,gCAAgC;EAC7C;EACA;EACA;EACA;EACA;EACA;;EAEA;;;UAIa,iCAAiC;EAC9C;EACA;EACA;;;UAIa,mCAAmC;EAChD;EACA;EACA;EACA;EACA;EACA;;;UAIa,oCAAoC;EACjD;EACA;EACA;EACA;;;UAIa,iCAAiC;EAC9C;EACA;EACA;EACA;EACA;EACA;;;UAIa,oCAAoC;EACjD;EACA;EACA;EACA;EACA;EACA;EACA;;;UAIa,8BAA8B;EAC3C;EACA;EACA;EACA;EACA;EACA;;EAEA;;;UAIa,mCAAmC;EAChD;EACA;EACA;EACA,MAAM;;;UAIO,iCAAiC;EAC9C;EACA;EACA;EACA;;;UAIa,oCAAoC;EACjD;EACA;EACA;EACA;EACA;EACA,OAAO;;;UAIM,kCAAkC;EAC/C;EACA;EACA;EACA;EACA;;;KAIQ,kBACN,6BACA,4BACA,+BACA,+BACA,0BACA,2BACA,6BACA,8BACA,2BACA,8BACA,wBACA,6BACA,2BACA,8BACA;;;;UCpLW,+BAA+B;EAC5C;EACA;EACA;;EAEA;;EAEA;;;UAIa,8BAA8B;EAC3C;EACA;;EAEA;EACA;EACA;EACA;EACA;;;KAIQ,mBAAmB,yBAAyB;;;;KCiB5C,YAAY,mBAAoB,kBAAmB,mBAAoB;;;;UCyDlE;;EAEb,KAAK;;;iBAIO,yBAAyB,MAAM,iBAAiB;;;;;;;;;;;;;;UC9E/C;EACb;EACA,QAAQ;;;iBAII,aAAa;;iBAKb,cAAc;;iBAKd,eAAe;;iBASf,aACZ,cACA,QAAQ;;iBAeI,eAAe,eAAe,eAAe;;iBAkB7C,iBAAiB,OAAO,eAAe;;;;iBCsHvC,oBAAoB,UAAU;;;;cCxJjC,kBAAgB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuB3B,EAAA,KAAA;;KAGU,aAAa,EAAE,aAAa;;;;iBC/DxB,oBAAoB,UAAU,qBAAqB;;iBAYnD,oBAAoB,UAAU,uBAAuB;;iBAoIrD,oBAAoB,eAAe;;iBAkBnC,qBAAqB,UAAU;;iBAK/B,qBAAqB,eAAe;;;;UCvInC;EACb,KAAK,cAAc;EACnB,KAAK,cAAc;;;UAIN,+BAA+B;;EAE5C,QAAQ,eAAe;;EAEvB,aAAa;;EAEb,YAAY;;EAEZ,eAAe;;EAEf,gBAAgB;;EAEhB,mBAAmB;;EAEnB,SAAS;;;cAIA,iCAAiC,oBAAoB;WACrD;mBAEQ;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;;WAER,UAAU;UACX;UACA;UACA;UACA;UACA;;UAEA;;UAEA;EAER,YAAY,MAAM;;;;;UAwBJ;;UAYA;;UAyCN;;UAiBM;;UAaN;;;;;;EAoIF,iBAAiB;;EAUvB;;;;;;UAUc;;UA2BA;;UAiBA;;UA4BA;;UAiBN;;;;;EAWF,cAAc,cAAc,UAAU,wBAAwB;;;;;UC9YvD;;EAEb,SAAS;;EAET,YAAY;;EAEZ,aAAa;;;UAIA;;EAEb,QAAQ;;EAER,aAAa;;EAEb,gBAAgB,cAAc,UAAU;;EAExC;;;iBAiBY,uBAAuB,MAAM,gCAAgC"}
|
package/dist/onebot11/index.mjs
CHANGED
|
@@ -1536,6 +1536,10 @@ const CANONICAL_TO_SEGMENT = {
|
|
|
1536
1536
|
type: "video",
|
|
1537
1537
|
data: mediaData(el.path, el.url)
|
|
1538
1538
|
}),
|
|
1539
|
+
file: (el) => ({
|
|
1540
|
+
type: "file",
|
|
1541
|
+
data: { file: el.name ?? el.path }
|
|
1542
|
+
}),
|
|
1539
1543
|
reply: (el) => ({
|
|
1540
1544
|
type: "reply",
|
|
1541
1545
|
data: { id: el.messageId }
|
|
@@ -1626,6 +1630,10 @@ const CQ_SEGMENT_BUILDERS = {
|
|
|
1626
1630
|
type: "video",
|
|
1627
1631
|
data: mediaData(params["file"] ?? "", params["url"])
|
|
1628
1632
|
}),
|
|
1633
|
+
file: (params) => ({
|
|
1634
|
+
type: "file",
|
|
1635
|
+
data: { file: params["file"] ?? "" }
|
|
1636
|
+
}),
|
|
1629
1637
|
reply: (params) => ({
|
|
1630
1638
|
type: "reply",
|
|
1631
1639
|
data: { id: params["id"] ?? "" }
|
|
@@ -1721,6 +1729,12 @@ const ob11ConfigSchema = z.object({
|
|
|
1721
1729
|
reportSelfMessage: z.boolean().default(false),
|
|
1722
1730
|
/** 消息内容格式:array = 消息段数组(标准),string = CQ 码字符串。 */
|
|
1723
1731
|
messagePostFormat: z.enum(MESSAGE_FORMATS).default("array"),
|
|
1732
|
+
/**
|
|
1733
|
+
* 群文件报形式(B4,2026-09-08):false(缺省)= message 事件 + file 段
|
|
1734
|
+
* (go-cqhttp 兼容;此前 file 元素被静默丢弃,本版本起透出);true = 含
|
|
1735
|
+
* fileElement 的群消息改报 group_upload notice 事件(替代 message 事件)。
|
|
1736
|
+
*/
|
|
1737
|
+
groupUploadAsNotice: z.boolean().default(false),
|
|
1724
1738
|
/** HTTP 反向服务器列表。 */
|
|
1725
1739
|
httpServers: z.array(httpServerSchema).default([]),
|
|
1726
1740
|
/** HTTP 正向上报列表。 */
|
|
@@ -1855,7 +1869,7 @@ function cqMessageToCanonical(text) {
|
|
|
1855
1869
|
//#endregion
|
|
1856
1870
|
//#region src/onebot11/helper/message-info.ts
|
|
1857
1871
|
/** 毫秒 → 秒(Unix 时间戳)。 */
|
|
1858
|
-
const MS_TO_SEC$
|
|
1872
|
+
const MS_TO_SEC$5 = 1e3;
|
|
1859
1873
|
/** RawMessage → OB11 消息信息(message_id 经 MessageUnique 映射)。
|
|
1860
1874
|
* ctx(可选):接收方向 ID 转换上下文(at uid→uin、reply NT msgId→OB11 id,P2-19)。 */
|
|
1861
1875
|
function toOb11MessageInfo(msg, unique, ctx = {}) {
|
|
@@ -1872,7 +1886,7 @@ function toOb11MessageInfo(msg, unique, ctx = {}) {
|
|
|
1872
1886
|
user_id: Number(msg.senderUin),
|
|
1873
1887
|
nickname: msg.sendNickName
|
|
1874
1888
|
},
|
|
1875
|
-
time: Math.floor(Number(msg.msgTime) / MS_TO_SEC$
|
|
1889
|
+
time: Math.floor(Number(msg.msgTime) / MS_TO_SEC$5),
|
|
1876
1890
|
message: canonicalToSegments(elements),
|
|
1877
1891
|
raw_message: canonicalToCqMessage(elements)
|
|
1878
1892
|
};
|
|
@@ -1886,27 +1900,14 @@ function toOb11MessageInfo(msg, unique, ctx = {}) {
|
|
|
1886
1900
|
}
|
|
1887
1901
|
//#endregion
|
|
1888
1902
|
//#region src/onebot11/helper/notice.ts
|
|
1889
|
-
/**
|
|
1890
|
-
* OB11 notice 事件翻译(P2-7,2026-08-05;2026-09-08 T4 补全)
|
|
1891
|
-
*
|
|
1892
|
-
* NT QQ 中群成员变动/撤回等系统事件通过**消息的灰色提示元素(grayTip)**广播。
|
|
1893
|
-
* 本模块把 RawMessage 里的 grayTip 翻译为 OB11 notice 事件(纯函数,ADR-008)。
|
|
1894
|
-
*
|
|
1895
|
-
* 支持:
|
|
1896
|
-
* - group_recall(群撤回,grayTip.subElementType=REVOKE + chatType=GROUP)
|
|
1897
|
-
* - friend_recall(好友撤回,REVOKE + chatType=C2C,2026-09-08)
|
|
1898
|
-
* - group_increase / group_decrease(群成员变动,subElementType=GROUP + TipGroupElement.type)
|
|
1899
|
-
* - group_admin(管理员变更,TipGroupElement.type=BLOCK/UNBLOCK 的 role 语义)
|
|
1900
|
-
* - group_ban(禁言,TipGroupElement.type=SHUT_UP)
|
|
1901
|
-
* - notify.poke(戳一戳,aioOpGrayTipElement;⚠️ 待真实 poke 事件验证,2026-09-08)
|
|
1902
|
-
*
|
|
1903
|
-
* 未知/未翻译的 grayTip 子类型(JSON/BUDDY/ESSENCE/GROUP_NOTIFY 等)打 raw JSON
|
|
1904
|
-
* 日志(ctx.logger 可选)——为后续真实事件校准积累数据。
|
|
1905
|
-
*
|
|
1906
|
-
* user_id/operator_id 都是 uin:接收 uidToUin Map(调用方批量转换后传入,保持纯函数)。
|
|
1907
|
-
*/
|
|
1908
1903
|
/** 毫秒 → 秒(Unix 时间戳)。 */
|
|
1909
|
-
const MS_TO_SEC$
|
|
1904
|
+
const MS_TO_SEC$4 = 1e3;
|
|
1905
|
+
/** 群文件业务类型(group_upload 的 file.busid,与 kernel 群文件系列同源语义)。 */
|
|
1906
|
+
const GROUP_FILE_BUS_ID = 102;
|
|
1907
|
+
/** 检查消息是否含文件元素(group_upload 开关分支判定)。 */
|
|
1908
|
+
function hasFileElement(msg) {
|
|
1909
|
+
return msg.elements.some((el) => el.fileElement !== void 0);
|
|
1910
|
+
}
|
|
1910
1911
|
/** 检查消息是否含可翻译的 grayTip 元素。 */
|
|
1911
1912
|
function hasGrayTip(msg) {
|
|
1912
1913
|
return msg.elements.some((el) => el.grayTipElement !== void 0);
|
|
@@ -1919,7 +1920,7 @@ function toUin$1(uid, ctx) {
|
|
|
1919
1920
|
/** 基础字段(time/self_id/post_type)。 */
|
|
1920
1921
|
function base(msg, ctx) {
|
|
1921
1922
|
return {
|
|
1922
|
-
time: Math.floor(Number(msg.msgTime) / MS_TO_SEC$
|
|
1923
|
+
time: Math.floor(Number(msg.msgTime) / MS_TO_SEC$4),
|
|
1923
1924
|
self_id: Number(ctx.selfUin),
|
|
1924
1925
|
post_type: "notice",
|
|
1925
1926
|
group_id: Number(msg.peerUid)
|
|
@@ -1930,7 +1931,7 @@ function toRecall(msg, g, ctx) {
|
|
|
1930
1931
|
if (g?.revokeElement === void 0) return null;
|
|
1931
1932
|
const revoke = g.revokeElement;
|
|
1932
1933
|
if (msg.chatType === ChatType.C2C) return {
|
|
1933
|
-
time: Math.floor(Number(msg.msgTime) / MS_TO_SEC$
|
|
1934
|
+
time: Math.floor(Number(msg.msgTime) / MS_TO_SEC$4),
|
|
1934
1935
|
self_id: Number(ctx.selfUin),
|
|
1935
1936
|
post_type: "notice",
|
|
1936
1937
|
notice_type: "friend_recall",
|
|
@@ -1958,7 +1959,7 @@ function toPoke(msg, g, ctx) {
|
|
|
1958
1959
|
ctx.logger?.warn({ raw: JSON.stringify(g)?.slice(0, 2e3) }, "ob11: poke grayTip raw(待真实事件校准)");
|
|
1959
1960
|
const isGroup = msg.chatType === ChatType.GROUP;
|
|
1960
1961
|
return {
|
|
1961
|
-
time: Math.floor(Number(msg.msgTime) / MS_TO_SEC$
|
|
1962
|
+
time: Math.floor(Number(msg.msgTime) / MS_TO_SEC$4),
|
|
1962
1963
|
self_id: Number(ctx.selfUin),
|
|
1963
1964
|
post_type: "notice",
|
|
1964
1965
|
notice_type: "notify",
|
|
@@ -1973,7 +1974,7 @@ function toGroupChange(msg, g, ctx) {
|
|
|
1973
1974
|
const grp = g?.groupElement;
|
|
1974
1975
|
if (grp === void 0 || grp.type === void 0) return null;
|
|
1975
1976
|
const common = {
|
|
1976
|
-
time: Math.floor(Number(msg.msgTime) / MS_TO_SEC$
|
|
1977
|
+
time: Math.floor(Number(msg.msgTime) / MS_TO_SEC$4),
|
|
1977
1978
|
selfId: Number(ctx.selfUin),
|
|
1978
1979
|
groupId: Number(msg.peerUid),
|
|
1979
1980
|
memberUid: grp.memberUid ?? "",
|
|
@@ -2045,6 +2046,45 @@ function toBan(common, grp, ctx) {
|
|
|
2045
2046
|
duration: Number(shutUp?.duration ?? 0)
|
|
2046
2047
|
};
|
|
2047
2048
|
}
|
|
2049
|
+
/**
|
|
2050
|
+
* 好友添加(friend_add,B2,2026-09-08)。
|
|
2051
|
+
* 数据源 = kernel BuddyCache 快照 diff(Buddy/onBuddyListChange 全量快照对比,
|
|
2052
|
+
* 首帧 baseline 不发)——非 grayTip 路径。user_id 取 coreInfo.uin(顶层 uin 兜底)。
|
|
2053
|
+
*/
|
|
2054
|
+
function toFriendAdd(entry, selfUin) {
|
|
2055
|
+
const uin = entry.coreInfo?.uin ?? entry.uin ?? "";
|
|
2056
|
+
return {
|
|
2057
|
+
time: Math.floor(Date.now() / MS_TO_SEC$4),
|
|
2058
|
+
self_id: Number(selfUin),
|
|
2059
|
+
post_type: "notice",
|
|
2060
|
+
notice_type: "friend_add",
|
|
2061
|
+
user_id: Number(uin)
|
|
2062
|
+
};
|
|
2063
|
+
}
|
|
2064
|
+
/**
|
|
2065
|
+
* 群文件上传(group_upload,B4,2026-09-08)。
|
|
2066
|
+
* 数据源 = 含 fileElement 的群消息(开关 groupUploadAsNotice=true 时替代
|
|
2067
|
+
* message 事件报出)。file.id 取 fileUuid(缺省文件名)、size 取 fileSize、
|
|
2068
|
+
* busid 固定 102(群文件业务类型,与 kernel GROUP_FILE_BIZ_TYPE 同源语义)。
|
|
2069
|
+
*/
|
|
2070
|
+
function toGroupUpload(msg, selfUin) {
|
|
2071
|
+
const file = msg.elements.find((e) => e.fileElement !== void 0)?.fileElement;
|
|
2072
|
+
if (file === void 0) return null;
|
|
2073
|
+
return {
|
|
2074
|
+
time: Math.floor(Number(msg.msgTime) / MS_TO_SEC$4),
|
|
2075
|
+
self_id: Number(selfUin),
|
|
2076
|
+
post_type: "notice",
|
|
2077
|
+
notice_type: "group_upload",
|
|
2078
|
+
group_id: Number(msg.peerUid),
|
|
2079
|
+
user_id: Number(msg.senderUin),
|
|
2080
|
+
file: {
|
|
2081
|
+
id: file.fileUuid ?? file.fileName ?? "",
|
|
2082
|
+
name: file.fileName ?? "",
|
|
2083
|
+
size: Number(file.fileSize ?? 0),
|
|
2084
|
+
busid: GROUP_FILE_BUS_ID
|
|
2085
|
+
}
|
|
2086
|
+
};
|
|
2087
|
+
}
|
|
2048
2088
|
/** 单个 grayTip 元素 → notice 事件(null = 不可翻译;未知子类型打 raw 日志)。 */
|
|
2049
2089
|
function translateGrayTip(msg, g, ctx) {
|
|
2050
2090
|
const subType = g.subElementType;
|
|
@@ -2086,7 +2126,7 @@ function toOb11NoticeEvent(msg, ctx) {
|
|
|
2086
2126
|
* narrowBuddyReqs 防御性收窄,未知形状返回 null 由调用方打 raw 日志积累校准数据。
|
|
2087
2127
|
*/
|
|
2088
2128
|
/** 毫秒 → 秒(Unix 时间戳)。 */
|
|
2089
|
-
const MS_TO_SEC$
|
|
2129
|
+
const MS_TO_SEC$3 = 1e3;
|
|
2090
2130
|
/** uid → uin(上下文映射缺省时:数字 uid 直取数值,非数字 uid 返回 0 表示未知)。 */
|
|
2091
2131
|
function toUin(uid, ctx) {
|
|
2092
2132
|
if (uid === void 0 || uid === "") return 0;
|
|
@@ -2116,7 +2156,7 @@ function toOb11GroupRequestEvent(notify, ctx) {
|
|
|
2116
2156
|
default: return null;
|
|
2117
2157
|
}
|
|
2118
2158
|
return {
|
|
2119
|
-
time: Math.floor(Date.now() / MS_TO_SEC$
|
|
2159
|
+
time: Math.floor(Date.now() / MS_TO_SEC$3),
|
|
2120
2160
|
self_id: Number(ctx.selfUin),
|
|
2121
2161
|
post_type: "request",
|
|
2122
2162
|
request_type: "group",
|
|
@@ -2152,7 +2192,7 @@ function narrowBuddyReqs(arg) {
|
|
|
2152
2192
|
function toOb11FriendRequestEvent(req, ctx) {
|
|
2153
2193
|
const words = req["words"];
|
|
2154
2194
|
return {
|
|
2155
|
-
time: Math.floor(Date.now() / MS_TO_SEC$
|
|
2195
|
+
time: Math.floor(Date.now() / MS_TO_SEC$3),
|
|
2156
2196
|
self_id: Number(ctx.selfUin),
|
|
2157
2197
|
post_type: "request",
|
|
2158
2198
|
request_type: "friend",
|
|
@@ -2293,16 +2333,17 @@ var GetGroupMsgHistoryAction = class extends BaseAction {
|
|
|
2293
2333
|
//#endregion
|
|
2294
2334
|
//#region src/onebot11/action/message/get-media.ts
|
|
2295
2335
|
/**
|
|
2296
|
-
* get_image / get_record 动作:获取图片/语音文件(P2-14;2026-09-08 T5
|
|
2336
|
+
* get_image / get_record 动作:获取图片/语音文件(P2-14;2026-09-08 T5 接主动下载;
|
|
2337
|
+
* 2026-09-08 B1 语音接原生 downloadRichMedia)
|
|
2297
2338
|
*
|
|
2298
2339
|
* message_id 反查 → fetchMsgsByMsgId → 找 PIC/PTT 元素:
|
|
2299
2340
|
* - 本地文件解析:NT 相对路径(sourcePath/filePath)按 mediaBaseDir(QQ NT
|
|
2300
2341
|
* global 目录)解析为绝对路径,命中磁盘即返回 file
|
|
2301
2342
|
* - 图片主动下载:本地未命中且有 picUrl → @napuketto/media downloadUrl 落
|
|
2302
2343
|
* cacheDir/media/,返回 file(绝对路径)+ url + file_size/file_name
|
|
2303
|
-
* -
|
|
2304
|
-
*
|
|
2305
|
-
*
|
|
2344
|
+
* - 语音主动下载(B1):本地未命中 → kernel MsgApi.downloadPtt(原生
|
|
2345
|
+
* downloadRichMedia + 轮询元素回查)→ filePath 落盘后返回绝对路径;
|
|
2346
|
+
* 失败回退原始 filePath(NT 相对/绝对)+ 元数据,不抛错
|
|
2306
2347
|
*/
|
|
2307
2348
|
const getMediaSchema = z.object({
|
|
2308
2349
|
/** CQ 码 file 字段或 message_id(简化:message_id 反查)。 */
|
|
@@ -2390,7 +2431,7 @@ var GetImageAction = class extends BaseAction {
|
|
|
2390
2431
|
return base;
|
|
2391
2432
|
}
|
|
2392
2433
|
};
|
|
2393
|
-
/**
|
|
2434
|
+
/** 获取语音信息(本地优先;未命中走原生 downloadRichMedia,失败回退原始路径)。 */
|
|
2394
2435
|
var GetRecordAction = class extends BaseAction {
|
|
2395
2436
|
name = "get_record";
|
|
2396
2437
|
schema = getMediaSchema;
|
|
@@ -2401,15 +2442,37 @@ var GetRecordAction = class extends BaseAction {
|
|
|
2401
2442
|
this.deps = deps;
|
|
2402
2443
|
}
|
|
2403
2444
|
async _handle(payload) {
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2445
|
+
const id = takeId(payload, "get_record");
|
|
2446
|
+
const { msgId, peer } = resolveMsgIdAndPeer(id, this.deps.messageUnique);
|
|
2447
|
+
const [first] = await this.deps.msgApi.fetchMsgsByMsgId(peer, [msgId]);
|
|
2448
|
+
if (first === void 0) throw kernelError(`消息 ${id} 不存在或已被撤回`, "NOT_FOUND");
|
|
2449
|
+
const ptt = first.elements.find((e) => e.pttElement !== void 0)?.pttElement;
|
|
2450
|
+
if (ptt === void 0 || ptt.filePath === void 0) throw kernelError(`消息 ${id} 不包含语音`, "NOT_FOUND");
|
|
2451
|
+
const meta = () => ({
|
|
2452
|
+
...ptt.fileSize !== void 0 ? { file_size: ptt.fileSize } : {},
|
|
2453
|
+
...ptt.fileName !== void 0 ? { file_name: ptt.fileName } : {}
|
|
2412
2454
|
});
|
|
2455
|
+
const local = resolveLocalMediaFile(ptt.filePath, this.deps);
|
|
2456
|
+
if (local !== null) return {
|
|
2457
|
+
...meta(),
|
|
2458
|
+
file: local
|
|
2459
|
+
};
|
|
2460
|
+
try {
|
|
2461
|
+
const downloaded = await this.deps.msgApi.downloadPtt(msgId, peer);
|
|
2462
|
+
const rel = downloaded.filePath;
|
|
2463
|
+
if (rel !== void 0 && rel !== "") {
|
|
2464
|
+
const localAfter = resolveLocalMediaFile(rel, this.deps);
|
|
2465
|
+
if (localAfter !== null) return {
|
|
2466
|
+
...downloaded.fileSize !== void 0 ? { file_size: downloaded.fileSize } : {},
|
|
2467
|
+
...downloaded.fileName !== void 0 ? { file_name: downloaded.fileName } : {},
|
|
2468
|
+
file: localAfter
|
|
2469
|
+
};
|
|
2470
|
+
}
|
|
2471
|
+
} catch {}
|
|
2472
|
+
return {
|
|
2473
|
+
...meta(),
|
|
2474
|
+
file: ptt.filePath
|
|
2475
|
+
};
|
|
2413
2476
|
}
|
|
2414
2477
|
};
|
|
2415
2478
|
//#endregion
|
|
@@ -3504,14 +3567,14 @@ var OneBotApi = class {
|
|
|
3504
3567
|
//#endregion
|
|
3505
3568
|
//#region src/onebot11/helper/message-event.ts
|
|
3506
3569
|
/** 毫秒 → 秒(Unix 时间戳)。 */
|
|
3507
|
-
const MS_TO_SEC$
|
|
3570
|
+
const MS_TO_SEC$2 = 1e3;
|
|
3508
3571
|
/** RawMessage → OB11 消息事件(message_id 经 MessageUnique 映射并记录 peer)。
|
|
3509
3572
|
* messageFormat 决定 message 字段格式:array = 消息段数组(标准),string = CQ 码字符串。
|
|
3510
3573
|
* ctx(可选):接收方向 ID 转换上下文(at uid→uin、reply NT msgId→OB11 id,P2-19)。 */
|
|
3511
3574
|
function toOb11MessageEvent(msg, selfUin, unique, messageFormat = "array", ctx = {}) {
|
|
3512
3575
|
const elements = applyReceiveContext(toCanonicalElements(msg), ctx);
|
|
3513
3576
|
const segments = canonicalToSegments(elements);
|
|
3514
|
-
const time = Math.floor(Number(msg.msgTime) / MS_TO_SEC$
|
|
3577
|
+
const time = Math.floor(Number(msg.msgTime) / MS_TO_SEC$2);
|
|
3515
3578
|
const selfId = Number(selfUin);
|
|
3516
3579
|
const userId = Number(msg.senderUin);
|
|
3517
3580
|
const base = {
|
|
@@ -3557,6 +3620,80 @@ function toOb11MessageEvent(msg, selfUin, unique, messageFormat = "array", ctx =
|
|
|
3557
3620
|
};
|
|
3558
3621
|
}
|
|
3559
3622
|
//#endregion
|
|
3623
|
+
//#region src/onebot11/helper/notice-extra.ts
|
|
3624
|
+
/** 毫秒 → 秒(Unix 时间戳)。 */
|
|
3625
|
+
const MS_TO_SEC$1 = 1e3;
|
|
3626
|
+
/** 候选 uin 字段(按优先级取第一个数字串;uid 串不硬转——待校准)。 */
|
|
3627
|
+
function pickUin(item) {
|
|
3628
|
+
for (const key of [
|
|
3629
|
+
"senderUin",
|
|
3630
|
+
"fromUin",
|
|
3631
|
+
"peerUin"
|
|
3632
|
+
]) {
|
|
3633
|
+
const v = item[key];
|
|
3634
|
+
if (typeof v === "string" && v !== "" && Number.isFinite(Number(v))) return v;
|
|
3635
|
+
}
|
|
3636
|
+
return "0";
|
|
3637
|
+
}
|
|
3638
|
+
/** 候选 url 字段(fileUrl / url;未知为空串)。 */
|
|
3639
|
+
function pickUrl(item) {
|
|
3640
|
+
for (const key of ["fileUrl", "url"]) {
|
|
3641
|
+
const v = item[key];
|
|
3642
|
+
if (typeof v === "string" && v !== "") return v;
|
|
3643
|
+
}
|
|
3644
|
+
return "";
|
|
3645
|
+
}
|
|
3646
|
+
/** 单个候选对象 → 归一化项(不可识别返回 null)。接受两类形状:
|
|
3647
|
+
* ① RawMessage 型(elements[].fileElement——离线文件以消息推送到达的假设,
|
|
3648
|
+
* 与 onRecvOfflineFileMsg 挂在 MsgService、UpdateC2CFileMsg 字符串一致)
|
|
3649
|
+
* ② 专用实体型(顶层 fileName 或 fileInfo.fileName——getNewOfflineFileList 族) */
|
|
3650
|
+
function narrowItem(item) {
|
|
3651
|
+
if (typeof item !== "object" || item === null) return null;
|
|
3652
|
+
const obj = item;
|
|
3653
|
+
if (Array.isArray(obj["elements"])) {
|
|
3654
|
+
const file = obj["elements"].find((e) => typeof e === "object" && e !== null && "fileElement" in e)?.fileElement;
|
|
3655
|
+
if (file === void 0) return null;
|
|
3656
|
+
return {
|
|
3657
|
+
senderUin: pickUin(obj),
|
|
3658
|
+
name: typeof file["fileName"] === "string" ? file["fileName"] : "",
|
|
3659
|
+
size: Number(file["fileSize"] ?? 0),
|
|
3660
|
+
url: pickUrl(file)
|
|
3661
|
+
};
|
|
3662
|
+
}
|
|
3663
|
+
const file = obj["fileInfo"] ?? obj;
|
|
3664
|
+
if (typeof file["fileName"] !== "string") return null;
|
|
3665
|
+
return {
|
|
3666
|
+
senderUin: pickUin(obj),
|
|
3667
|
+
name: file["fileName"],
|
|
3668
|
+
size: Number(file["fileSize"] ?? 0),
|
|
3669
|
+
url: pickUrl(file)
|
|
3670
|
+
};
|
|
3671
|
+
}
|
|
3672
|
+
/**
|
|
3673
|
+
* onRecvOfflineFileMsg 参数 → 归一化项列表(防御性收窄)。
|
|
3674
|
+
* 接受数组 / 单对象;全部不可识别返回 null(调用方打 raw 日志)。
|
|
3675
|
+
* 空数组同样返回 null(无文件可翻译,与未知形状同走日志路径无害)。
|
|
3676
|
+
*/
|
|
3677
|
+
function narrowOfflineFiles(arg) {
|
|
3678
|
+
const narrowed = (Array.isArray(arg) ? arg : [arg]).map(narrowItem).filter((v) => v !== null);
|
|
3679
|
+
return narrowed.length > 0 ? narrowed : null;
|
|
3680
|
+
}
|
|
3681
|
+
/** 归一化项 → OB11 offline_file notice(time 取当前时刻,friend_add 同款)。 */
|
|
3682
|
+
function toOfflineFileNotice(item, selfUin) {
|
|
3683
|
+
return {
|
|
3684
|
+
time: Math.floor(Date.now() / MS_TO_SEC$1),
|
|
3685
|
+
self_id: Number(selfUin),
|
|
3686
|
+
post_type: "notice",
|
|
3687
|
+
notice_type: "offline_file",
|
|
3688
|
+
user_id: Number(item.senderUin),
|
|
3689
|
+
file: {
|
|
3690
|
+
name: item.name,
|
|
3691
|
+
size: item.size,
|
|
3692
|
+
url: item.url
|
|
3693
|
+
}
|
|
3694
|
+
};
|
|
3695
|
+
}
|
|
3696
|
+
//#endregion
|
|
3560
3697
|
//#region src/onebot11/transport.ts
|
|
3561
3698
|
/**
|
|
3562
3699
|
* OB11 传输装配(P2-5,2026-08-05)
|
|
@@ -3711,6 +3848,7 @@ var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
|
|
|
3711
3848
|
msgChannel;
|
|
3712
3849
|
groupChannel;
|
|
3713
3850
|
friendChannel;
|
|
3851
|
+
buddyCacheEvents;
|
|
3714
3852
|
calibLogger;
|
|
3715
3853
|
selfUin;
|
|
3716
3854
|
oneBotApi;
|
|
@@ -3721,6 +3859,8 @@ var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
|
|
|
3721
3859
|
heartbeatTimer = null;
|
|
3722
3860
|
reportSelfMessage = false;
|
|
3723
3861
|
messageFormat = "array";
|
|
3862
|
+
/** 群文件报形式(B4):true = fileElement 群消息报 group_upload notice 替代 message。 */
|
|
3863
|
+
groupUploadAsNotice = false;
|
|
3724
3864
|
/** IPC 桥模式标记(subscribeOnly 启动;reload 时跳过传输重建)。 */
|
|
3725
3865
|
subscribedOnly = false;
|
|
3726
3866
|
constructor(opts) {
|
|
@@ -3736,6 +3876,7 @@ var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
|
|
|
3736
3876
|
this.msgChannel = opts.msgChannel;
|
|
3737
3877
|
this.groupChannel = opts.groupChannel;
|
|
3738
3878
|
this.friendChannel = opts.friendChannel;
|
|
3879
|
+
this.buddyCacheEvents = opts.buddyCacheEvents;
|
|
3739
3880
|
this.calibLogger = opts.logger;
|
|
3740
3881
|
this.selfUin = opts.self.uin;
|
|
3741
3882
|
this.oneBotApi = new OneBotApi(opts);
|
|
@@ -3749,6 +3890,7 @@ var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
|
|
|
3749
3890
|
if (this.subscribedOnly) {
|
|
3750
3891
|
this.reportSelfMessage = config.reportSelfMessage;
|
|
3751
3892
|
this.messageFormat = config.messagePostFormat;
|
|
3893
|
+
this.groupUploadAsNotice = config.groupUploadAsNotice;
|
|
3752
3894
|
return;
|
|
3753
3895
|
}
|
|
3754
3896
|
await this.stopAll();
|
|
@@ -3759,6 +3901,7 @@ var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
|
|
|
3759
3901
|
this.subscribedOnly = false;
|
|
3760
3902
|
this.reportSelfMessage = config.reportSelfMessage;
|
|
3761
3903
|
this.messageFormat = config.messagePostFormat;
|
|
3904
|
+
this.groupUploadAsNotice = config.groupUploadAsNotice;
|
|
3762
3905
|
const broadcaster = this.getBroadcaster();
|
|
3763
3906
|
if (broadcaster !== void 0) {
|
|
3764
3907
|
this.transports = assembleOb11Transports({
|
|
@@ -3830,13 +3973,36 @@ var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
|
|
|
3830
3973
|
return;
|
|
3831
3974
|
}
|
|
3832
3975
|
if (!this.reportSelfMessage && String(msg.senderUin) === this.selfUin) return;
|
|
3976
|
+
if (this.groupUploadAsNotice && msg.chatType === ChatType.GROUP && hasFileElement(msg)) {
|
|
3977
|
+
const notice = toGroupUpload(msg, this.selfUin);
|
|
3978
|
+
if (notice !== null) {
|
|
3979
|
+
this.broadcastEvent(notice);
|
|
3980
|
+
return;
|
|
3981
|
+
}
|
|
3982
|
+
}
|
|
3833
3983
|
this.broadcastMessageEvent(msg);
|
|
3834
3984
|
});
|
|
3835
3985
|
}));
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3986
|
+
this.unsubscribes.push(this.msgChannel.on("Msg/onRecvOfflineFileMsg", (arg) => {
|
|
3987
|
+
const items = narrowOfflineFiles(arg);
|
|
3988
|
+
if (items === null) {
|
|
3989
|
+
this.calibLogger?.warn({ raw: JSON.stringify(arg)?.slice(0, 2e3) }, "ob11: onRecvOfflineFileMsg 未知参数形状");
|
|
3990
|
+
return;
|
|
3991
|
+
}
|
|
3992
|
+
for (const item of items) this.broadcastEvent(toOfflineFileNotice(item, this.selfUin));
|
|
3993
|
+
}));
|
|
3994
|
+
for (const evt of ["Msg/onRecvSysMsg", "Msg/onRecvOnlineFileMsg"]) this.unsubscribes.push(this.msgChannel.on(evt, (arg) => {
|
|
3995
|
+
this.calibLogger?.info({ raw: JSON.stringify(arg)?.slice(0, 2e3) }, `ob11: ${evt} raw(sys msg 校准数据)`);
|
|
3839
3996
|
}));
|
|
3997
|
+
if (this.groupChannel !== void 0) {
|
|
3998
|
+
this.unsubscribes.push(this.groupChannel.on("Group/onGroupNotifiesUpdated", (doubt, notifies) => {
|
|
3999
|
+
if (doubt || !Array.isArray(notifies)) return;
|
|
4000
|
+
this.broadcastGroupRequests(notifies);
|
|
4001
|
+
}));
|
|
4002
|
+
this.unsubscribes.push(this.groupChannel.on("Group/onGroupEssenceListChange", (arg) => {
|
|
4003
|
+
this.calibLogger?.info({ raw: JSON.stringify(arg)?.slice(0, 2e3) }, "ob11: onGroupEssenceListChange raw(group_essence 校准数据)");
|
|
4004
|
+
}));
|
|
4005
|
+
}
|
|
3840
4006
|
if (this.friendChannel !== void 0) {
|
|
3841
4007
|
this.unsubscribes.push(this.friendChannel.on("Buddy/onBuddyReqChange", (arg) => {
|
|
3842
4008
|
const reqs = narrowBuddyReqs(arg);
|
|
@@ -3850,6 +4016,9 @@ var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
|
|
|
3850
4016
|
this.calibLogger?.info({ raw: JSON.stringify(arg)?.slice(0, 2e3) }, `ob11: ${evt} raw(friend_add 校准数据)`);
|
|
3851
4017
|
}));
|
|
3852
4018
|
}
|
|
4019
|
+
if (this.buddyCacheEvents !== void 0) this.unsubscribes.push(this.buddyCacheEvents.on("BuddyCache/onBuddyAdded", (entry) => {
|
|
4020
|
+
this.broadcastEvent(toFriendAdd(entry, this.selfUin));
|
|
4021
|
+
}));
|
|
3853
4022
|
}
|
|
3854
4023
|
/**
|
|
3855
4024
|
* 仅启动接收链路(IPC 桥模式,2026-08-27):订阅消息通道维护 messageUnique +
|
|
@@ -3860,6 +4029,7 @@ var NapukettoOneBot11Adapter = class extends BaseProtocolAdapter {
|
|
|
3860
4029
|
const config = await this.config.load();
|
|
3861
4030
|
this.reportSelfMessage = config.reportSelfMessage;
|
|
3862
4031
|
this.messageFormat = config.messagePostFormat;
|
|
4032
|
+
this.groupUploadAsNotice = config.groupUploadAsNotice;
|
|
3863
4033
|
this.subscribedOnly = true;
|
|
3864
4034
|
this.subscribe();
|
|
3865
4035
|
}
|