@napuketto/adapter 0.13.0 → 0.13.2
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-DgDKwUWD.mjs → core-CMqpb5-m.mjs} +24 -2
- package/dist/core-CMqpb5-m.mjs.map +1 -0
- package/dist/{essence-DsSHdIZQ.mjs → essence-DzYnP60o.mjs} +2 -2
- package/dist/{essence-DsSHdIZQ.mjs.map → essence-DzYnP60o.mjs.map} +1 -1
- package/dist/{index-B5uhdmil.d.mts → index-DDPMbC_c.d.mts} +17 -2
- package/dist/index-DDPMbC_c.d.mts.map +1 -0
- package/dist/kurobot/index.d.mts +1 -1
- package/dist/kurobot/index.mjs +2 -2
- package/dist/milky/index.d.mts +1 -1
- package/dist/milky/index.mjs +13 -13
- package/dist/milky/index.mjs.map +1 -1
- package/dist/onebot11/index.d.mts +1 -1
- package/dist/onebot11/index.mjs +31 -27
- package/dist/onebot11/index.mjs.map +1 -1
- package/dist/raw-message-D2vA27kj.mjs +31 -0
- package/dist/raw-message-D2vA27kj.mjs.map +1 -0
- package/dist/satori/index.d.mts +1 -1
- package/dist/satori/index.mjs +4 -4
- package/dist/satori/index.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/core-DgDKwUWD.mjs.map +0 -1
- package/dist/index-B5uhdmil.d.mts.map +0 -1
- package/dist/raw-message-C1E7jbjl.mjs +0 -18
- package/dist/raw-message-C1E7jbjl.mjs.map +0 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* OneBot 11 协议适配器(当前主战场)
|
|
3
3
|
* 公共面:类型 + 动作注册表 + 配置 schema + 翻译层(adapter.ts 于 P2 打通 kernel 事件后接入)。
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { A as ErrorCodeMap, D as ActionRegistry, S as BaseProtocolAdapter, w as ProtocolConfig } from "../index-DDPMbC_c.mjs";
|
|
6
6
|
import "../gray-tip-CcpfI1Og.mjs";
|
|
7
7
|
import { BuddyCacheEventChannel, BuddyEventChannel, CanonicalElement, FriendApi, GroupApi, GroupCache, GroupEventChannel, GroupNotifyApi, MsgApi, MsgEventChannel, Peer, ProfileApi, ProfileLikeApi, RichMediaApi, TicketApi, WebApi } from "@napuketto/kernel";
|
|
8
8
|
import { z } from "zod";
|
package/dist/onebot11/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { n as
|
|
1
|
+
import { S as ActionRegistry, _ as prepareVideoElements, a as extractSysMsgEnvelope, b as BaseAction, c as narrowSysMsgBlobs, f as toHex, g as ensureSilk, r as decodeProtoTree, t as toUnixSeconds, u as recognizeSysMsg, y as BaseProtocolAdapter } from "../core-CMqpb5-m.mjs";
|
|
2
|
+
import { n as senderNickname, r as subscribeRawMessages } from "../raw-message-D2vA27kj.mjs";
|
|
3
|
+
import { a as MS_TO_SEC$3, i as narrowBuddyReqs, n as extractEssenceSetSysMsg, o as resolveUin, r as narrowEssenceGroupArg, t as diffEssenceList } from "../essence-DzYnP60o.mjs";
|
|
4
4
|
import { n as firstUntranslatedGrayTip, t as collectGrayTipUids } from "../gray-tip-ByF-MKeV.mjs";
|
|
5
5
|
import { n as createWsServerSchema, t as createHttpServerSchema } from "../transport-schema-BEzr06W3.mjs";
|
|
6
6
|
import { ChatType, GrayTipSubType, GroupApi, GroupNotifyMsgStatus, GroupNotifyMsgType, NTGroupMemberRole, NTGroupRequestOperateTypes, TicketApi, TipGroupElementType, WebHonorType, kernelError, toCanonicalElements } from "@napuketto/kernel";
|
|
@@ -1838,8 +1838,6 @@ function cqMessageToCanonical(text) {
|
|
|
1838
1838
|
return segmentsToCanonical(cqMessageToSegments(text));
|
|
1839
1839
|
}
|
|
1840
1840
|
// src/onebot11/helper/message-info.ts
|
|
1841
|
-
/** 毫秒 → 秒(Unix 时间戳)。 */
|
|
1842
|
-
const MS_TO_SEC$4 = 1e3;
|
|
1843
1841
|
/** RawMessage → OB11 消息信息(message_id 经 MessageUnique 映射)。
|
|
1844
1842
|
* ctx(可选):接收方向 ID 转换上下文(at uid→uin、reply NT msgId→OB11 id,P2-19)。 */
|
|
1845
1843
|
function toOb11MessageInfo(msg, unique, ctx = {}) {
|
|
@@ -1854,9 +1852,9 @@ function toOb11MessageInfo(msg, unique, ctx = {}) {
|
|
|
1854
1852
|
message_type: messageType,
|
|
1855
1853
|
sender: {
|
|
1856
1854
|
user_id: Number(msg.senderUin),
|
|
1857
|
-
nickname: msg
|
|
1855
|
+
nickname: senderNickname(msg)
|
|
1858
1856
|
},
|
|
1859
|
-
time:
|
|
1857
|
+
time: toUnixSeconds(msg.msgTime),
|
|
1860
1858
|
message: canonicalToSegments(elements),
|
|
1861
1859
|
raw_message: canonicalToCqMessage(elements)
|
|
1862
1860
|
};
|
|
@@ -1870,16 +1868,24 @@ function toOb11MessageInfo(msg, unique, ctx = {}) {
|
|
|
1870
1868
|
}
|
|
1871
1869
|
// src/onebot11/helper/notice.ts
|
|
1872
1870
|
/** 毫秒 → 秒(Unix 时间戳)。 */
|
|
1873
|
-
const MS_TO_SEC$
|
|
1871
|
+
const MS_TO_SEC$2 = 1e3;
|
|
1874
1872
|
/** 群文件业务类型(group_upload 的 file.busid,与 kernel 群文件系列同源语义)。 */
|
|
1875
1873
|
const GROUP_FILE_BUS_ID = 102;
|
|
1876
|
-
/**
|
|
1874
|
+
/**
|
|
1875
|
+
* 检查消息是否含文件元素(group_upload 开关分支判定)。
|
|
1876
|
+
*
|
|
1877
|
+
* ⚠️ 用空值判定(`!= null`)而非 `!== undefined`(2026-11-10,Linux 原生宿主):
|
|
1878
|
+
* Windows 原生对象省略未命中的元素变体字段,Linux 3.2.x 原生对象则把**全部**
|
|
1879
|
+
* 变体字段显式置 `null`(`"grayTipElement":null` 等)。用 `!== undefined`
|
|
1880
|
+
* 会把每条普通消息都判成「含该元素」——OB11 入站消息因此全部被误路由到
|
|
1881
|
+
* grayTip notice 分支并静默丢弃(真机复现)。
|
|
1882
|
+
*/
|
|
1877
1883
|
function hasFileElement(msg) {
|
|
1878
|
-
return msg.elements.some((el) => el.fileElement
|
|
1884
|
+
return msg.elements.some((el) => el.fileElement != null);
|
|
1879
1885
|
}
|
|
1880
|
-
/** 检查消息是否含可翻译的 grayTip
|
|
1886
|
+
/** 检查消息是否含可翻译的 grayTip 元素(空值判定同 hasFileElement)。 */
|
|
1881
1887
|
function hasGrayTip(msg) {
|
|
1882
|
-
return msg.elements.some((el) => el.grayTipElement
|
|
1888
|
+
return msg.elements.some((el) => el.grayTipElement != null);
|
|
1883
1889
|
}
|
|
1884
1890
|
/** uid → uin(上下文映射缺省退化为 uid)。 */
|
|
1885
1891
|
function toUin$1(uid, ctx) {
|
|
@@ -1889,7 +1895,7 @@ function toUin$1(uid, ctx) {
|
|
|
1889
1895
|
/** 基础字段(time/self_id/post_type)。 */
|
|
1890
1896
|
function base(msg, ctx) {
|
|
1891
1897
|
return {
|
|
1892
|
-
time:
|
|
1898
|
+
time: toUnixSeconds(msg.msgTime),
|
|
1893
1899
|
self_id: Number(ctx.selfUin),
|
|
1894
1900
|
post_type: "notice",
|
|
1895
1901
|
group_id: Number(msg.peerUid)
|
|
@@ -1900,7 +1906,7 @@ function toRecall(msg, g, ctx) {
|
|
|
1900
1906
|
if (g?.revokeElement === void 0) return null;
|
|
1901
1907
|
const revoke = g.revokeElement;
|
|
1902
1908
|
if (msg.chatType === ChatType.C2C) return {
|
|
1903
|
-
time:
|
|
1909
|
+
time: toUnixSeconds(msg.msgTime),
|
|
1904
1910
|
self_id: Number(ctx.selfUin),
|
|
1905
1911
|
post_type: "notice",
|
|
1906
1912
|
notice_type: "friend_recall",
|
|
@@ -1928,7 +1934,7 @@ function toPoke(msg, g, ctx) {
|
|
|
1928
1934
|
ctx.logger?.warn({ raw: JSON.stringify(g)?.slice(0, 2e3) }, "ob11: poke grayTip raw(待真实事件校准)");
|
|
1929
1935
|
const isGroup = msg.chatType === ChatType.GROUP;
|
|
1930
1936
|
return {
|
|
1931
|
-
time:
|
|
1937
|
+
time: toUnixSeconds(msg.msgTime),
|
|
1932
1938
|
self_id: Number(ctx.selfUin),
|
|
1933
1939
|
post_type: "notice",
|
|
1934
1940
|
notice_type: "notify",
|
|
@@ -1953,7 +1959,7 @@ function toGroupChange(msg, g, ctx) {
|
|
|
1953
1959
|
const builder = GROUP_CHANGE_BUILDERS[grp.type];
|
|
1954
1960
|
if (builder === void 0) return null;
|
|
1955
1961
|
return builder({
|
|
1956
|
-
time:
|
|
1962
|
+
time: toUnixSeconds(msg.msgTime),
|
|
1957
1963
|
selfId: Number(ctx.selfUin),
|
|
1958
1964
|
groupId: Number(msg.peerUid),
|
|
1959
1965
|
memberUid: grp.memberUid ?? "",
|
|
@@ -2025,7 +2031,7 @@ function toBan(common, grp, ctx) {
|
|
|
2025
2031
|
function toFriendAdd(entry, selfUin) {
|
|
2026
2032
|
const uin = entry.coreInfo?.uin ?? entry.uin ?? "";
|
|
2027
2033
|
return {
|
|
2028
|
-
time: Math.floor(Date.now() / MS_TO_SEC$
|
|
2034
|
+
time: Math.floor(Date.now() / MS_TO_SEC$2),
|
|
2029
2035
|
self_id: Number(selfUin),
|
|
2030
2036
|
post_type: "notice",
|
|
2031
2037
|
notice_type: "friend_add",
|
|
@@ -2039,10 +2045,10 @@ function toFriendAdd(entry, selfUin) {
|
|
|
2039
2045
|
* busid 固定 102(群文件业务类型,与 kernel GROUP_FILE_BIZ_TYPE 同源语义)。
|
|
2040
2046
|
*/
|
|
2041
2047
|
function toGroupUpload(msg, selfUin) {
|
|
2042
|
-
const file = msg.elements.find((e) => e.fileElement
|
|
2048
|
+
const file = msg.elements.find((e) => e.fileElement != null)?.fileElement;
|
|
2043
2049
|
if (file === void 0) return null;
|
|
2044
2050
|
return {
|
|
2045
|
-
time:
|
|
2051
|
+
time: toUnixSeconds(msg.msgTime),
|
|
2046
2052
|
self_id: Number(selfUin),
|
|
2047
2053
|
post_type: "notice",
|
|
2048
2054
|
notice_type: "group_upload",
|
|
@@ -2061,7 +2067,7 @@ function translateGrayTip(msg, g, ctx) {
|
|
|
2061
2067
|
const subType = g.subElementType;
|
|
2062
2068
|
if (subType === GrayTipSubType.REVOKE) return toRecall(msg, g, ctx);
|
|
2063
2069
|
if (subType === GrayTipSubType.GROUP) return toGroupChange(msg, g, ctx);
|
|
2064
|
-
if (g.aioOpGrayTipElement
|
|
2070
|
+
if (g.aioOpGrayTipElement != null) return toPoke(msg, g, ctx);
|
|
2065
2071
|
logUntranslatedGrayTip(msg, ctx);
|
|
2066
2072
|
return null;
|
|
2067
2073
|
}
|
|
@@ -2124,7 +2130,7 @@ function toOb11GroupRequestEvent(notify, ctx) {
|
|
|
2124
2130
|
default: return null;
|
|
2125
2131
|
}
|
|
2126
2132
|
return {
|
|
2127
|
-
time: Math.floor(Date.now() / MS_TO_SEC$
|
|
2133
|
+
time: Math.floor(Date.now() / MS_TO_SEC$3),
|
|
2128
2134
|
self_id: Number(ctx.selfUin),
|
|
2129
2135
|
post_type: "request",
|
|
2130
2136
|
request_type: "group",
|
|
@@ -2142,7 +2148,7 @@ function toOb11GroupRequestEvent(notify, ctx) {
|
|
|
2142
2148
|
function toOb11FriendRequestEvent(req, ctx) {
|
|
2143
2149
|
const words = req["words"];
|
|
2144
2150
|
return {
|
|
2145
|
-
time: Math.floor(Date.now() / MS_TO_SEC$
|
|
2151
|
+
time: Math.floor(Date.now() / MS_TO_SEC$3),
|
|
2146
2152
|
self_id: Number(ctx.selfUin),
|
|
2147
2153
|
post_type: "request",
|
|
2148
2154
|
request_type: "friend",
|
|
@@ -3528,15 +3534,13 @@ var OneBotApi = class {
|
|
|
3528
3534
|
}
|
|
3529
3535
|
};
|
|
3530
3536
|
// src/onebot11/helper/message-event.ts
|
|
3531
|
-
/** 毫秒 → 秒(Unix 时间戳)。 */
|
|
3532
|
-
const MS_TO_SEC$2 = 1e3;
|
|
3533
3537
|
/** RawMessage → OB11 消息事件(message_id 经 MessageUnique 映射并记录 peer)。
|
|
3534
3538
|
* messageFormat 决定 message 字段格式:array = 消息段数组(标准),string = CQ 码字符串。
|
|
3535
3539
|
* ctx(可选):接收方向 ID 转换上下文(at uid→uin、reply NT msgId→OB11 id,P2-19)。 */
|
|
3536
3540
|
function toOb11MessageEvent(msg, selfUin, unique, messageFormat = "array", ctx = {}) {
|
|
3537
3541
|
const elements = applyReceiveContext(toCanonicalElements(msg), ctx);
|
|
3538
3542
|
const segments = canonicalToSegments(elements);
|
|
3539
|
-
const time =
|
|
3543
|
+
const time = toUnixSeconds(msg.msgTime);
|
|
3540
3544
|
const selfId = Number(selfUin);
|
|
3541
3545
|
const userId = Number(msg.senderUin);
|
|
3542
3546
|
const base = {
|
|
@@ -3554,7 +3558,7 @@ function toOb11MessageEvent(msg, selfUin, unique, messageFormat = "array", ctx =
|
|
|
3554
3558
|
if (msg.chatType === ChatType.GROUP) {
|
|
3555
3559
|
const sender = {
|
|
3556
3560
|
user_id: userId,
|
|
3557
|
-
nickname: msg
|
|
3561
|
+
nickname: senderNickname(msg),
|
|
3558
3562
|
role: ctx.senderRole ?? "member"
|
|
3559
3563
|
};
|
|
3560
3564
|
if (msg.sendMemberName !== void 0) sender.card = msg.sendMemberName;
|
|
@@ -3571,7 +3575,7 @@ function toOb11MessageEvent(msg, selfUin, unique, messageFormat = "array", ctx =
|
|
|
3571
3575
|
if (msg.chatType === ChatType.C2C_TEMP) subType = "group";
|
|
3572
3576
|
const sender = {
|
|
3573
3577
|
user_id: userId,
|
|
3574
|
-
nickname: msg
|
|
3578
|
+
nickname: senderNickname(msg)
|
|
3575
3579
|
};
|
|
3576
3580
|
return {
|
|
3577
3581
|
...base,
|