@napuketto/adapter 0.12.4 → 0.13.1
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-BNOfqnV-.mjs → core-CMqpb5-m.mjs} +94 -8
- package/dist/core-CMqpb5-m.mjs.map +1 -0
- package/dist/{essence-BRbsj_Vv.mjs → essence-DzYnP60o.mjs} +2 -2
- package/dist/{essence-BRbsj_Vv.mjs.map → essence-DzYnP60o.mjs.map} +1 -1
- package/dist/{index-DNvM3A-1.d.mts → index-DDPMbC_c.d.mts} +41 -3
- package/dist/index-DDPMbC_c.d.mts.map +1 -0
- package/dist/kurobot/index.d.mts +1 -1
- package/dist/kurobot/index.mjs +1 -1
- package/dist/milky/index.d.mts +1 -1
- package/dist/milky/index.mjs +3 -3
- package/dist/onebot11/index.d.mts +1 -1
- package/dist/onebot11/index.mjs +35 -26
- package/dist/onebot11/index.mjs.map +1 -1
- 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 +1 -1
- package/dist/core-BNOfqnV-.mjs.map +0 -1
- package/dist/index-DNvM3A-1.d.mts.map +0 -1
package/dist/onebot11/index.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { _ as
|
|
2
|
-
import { a as MS_TO_SEC$
|
|
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 { 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";
|
|
3
3
|
import { n as subscribeRawMessages } from "../raw-message-C1E7jbjl.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";
|
|
7
|
+
import { basename, join } from "node:path";
|
|
7
8
|
import { downloadUrl, inferExtension } from "@napuketto/media";
|
|
8
9
|
import { z } from "zod";
|
|
9
10
|
import { randomUUID } from "node:crypto";
|
|
10
11
|
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
11
|
-
import { basename, join } from "node:path";
|
|
12
12
|
import { HttpClient, HttpServer, WsClient, WsServer } from "@napuketto/network";
|
|
13
13
|
// src/onebot11/action/error-map.ts
|
|
14
14
|
/** OB11 错误码映射表(send_msg 等所有 OB11 动作共用)。 */
|
|
@@ -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 = {}) {
|
|
@@ -1856,7 +1854,7 @@ function toOb11MessageInfo(msg, unique, ctx = {}) {
|
|
|
1856
1854
|
user_id: Number(msg.senderUin),
|
|
1857
1855
|
nickname: msg.sendNickName
|
|
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",
|
|
@@ -2668,8 +2674,13 @@ async function sendOb11Message(payload, deps) {
|
|
|
2668
2674
|
return el;
|
|
2669
2675
|
});
|
|
2670
2676
|
canonical = await ensureVoiceSilk(canonical);
|
|
2671
|
-
const
|
|
2672
|
-
|
|
2677
|
+
const prepared = await prepareVideoElements(canonical);
|
|
2678
|
+
try {
|
|
2679
|
+
const { msgId } = await deps.msgApi.sendMessage(peer, prepared.elements);
|
|
2680
|
+
return { message_id: deps.messageUnique.alloc(msgId, peer) };
|
|
2681
|
+
} finally {
|
|
2682
|
+
await prepared.cleanup();
|
|
2683
|
+
}
|
|
2673
2684
|
}
|
|
2674
2685
|
/** 发送消息(P2-3 接 kernel apis/msg,返回真实 message_id)。 */
|
|
2675
2686
|
var SendMsgAction = class extends BaseAction {
|
|
@@ -3523,15 +3534,13 @@ var OneBotApi = class {
|
|
|
3523
3534
|
}
|
|
3524
3535
|
};
|
|
3525
3536
|
// src/onebot11/helper/message-event.ts
|
|
3526
|
-
/** 毫秒 → 秒(Unix 时间戳)。 */
|
|
3527
|
-
const MS_TO_SEC$2 = 1e3;
|
|
3528
3537
|
/** RawMessage → OB11 消息事件(message_id 经 MessageUnique 映射并记录 peer)。
|
|
3529
3538
|
* messageFormat 决定 message 字段格式:array = 消息段数组(标准),string = CQ 码字符串。
|
|
3530
3539
|
* ctx(可选):接收方向 ID 转换上下文(at uid→uin、reply NT msgId→OB11 id,P2-19)。 */
|
|
3531
3540
|
function toOb11MessageEvent(msg, selfUin, unique, messageFormat = "array", ctx = {}) {
|
|
3532
3541
|
const elements = applyReceiveContext(toCanonicalElements(msg), ctx);
|
|
3533
3542
|
const segments = canonicalToSegments(elements);
|
|
3534
|
-
const time =
|
|
3543
|
+
const time = toUnixSeconds(msg.msgTime);
|
|
3535
3544
|
const selfId = Number(selfUin);
|
|
3536
3545
|
const userId = Number(msg.senderUin);
|
|
3537
3546
|
const base = {
|