@napuketto/adapter 0.17.0 → 0.17.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/{buddy-req-BvAxJo6d.mjs → buddy-req-BtlTJhYX.mjs} +2 -2
- package/dist/{buddy-req-BvAxJo6d.mjs.map → buddy-req-BtlTJhYX.mjs.map} +1 -1
- package/dist/{index-DBD-IZKn.d.mts → index-B2Hf9yzT.d.mts} +18 -6
- package/dist/{index-DBD-IZKn.d.mts.map → index-B2Hf9yzT.d.mts.map} +1 -1
- package/dist/{index-CepyMhuM.d.mts → index-d_RSpWyb.d.mts} +17 -6
- package/dist/index-d_RSpWyb.d.mts.map +1 -0
- package/dist/index-dsurF2t_.d.mts.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +4 -4
- package/dist/kurobot/index.mjs +1 -1
- package/dist/{kurobot-cMBAVX3L.mjs → kurobot-qVM9AdYt.mjs} +2 -2
- package/dist/{kurobot-cMBAVX3L.mjs.map → kurobot-qVM9AdYt.mjs.map} +1 -1
- package/dist/milky/index.d.mts +1 -1
- package/dist/milky/index.mjs +1 -1
- package/dist/{milky-CYAOJLv_.mjs → milky-g7xcz0B5.mjs} +207 -121
- package/dist/milky-g7xcz0B5.mjs.map +1 -0
- package/dist/onebot11/index.d.mts +1 -1
- package/dist/onebot11/index.mjs +1 -1
- package/dist/{onebot11-BikYDo3k.mjs → onebot11-C_yEFxou.mjs} +189 -101
- package/dist/onebot11-C_yEFxou.mjs.map +1 -0
- package/dist/{raw-message-D5nMIebz.mjs → raw-message-Cs4vDKUU.mjs} +11 -3
- package/dist/raw-message-Cs4vDKUU.mjs.map +1 -0
- package/dist/satori/index.mjs +1 -1
- package/dist/{satori-Cb2uM3PY.mjs → satori-D9t3K5J5.mjs} +18 -7
- package/dist/{satori-Cb2uM3PY.mjs.map → satori-D9t3K5J5.mjs.map} +1 -1
- package/package.json +2 -2
- package/dist/index-CepyMhuM.d.mts.map +0 -1
- package/dist/milky-CYAOJLv_.mjs.map +0 -1
- package/dist/onebot11-BikYDo3k.mjs.map +0 -1
- package/dist/raw-message-D5nMIebz.mjs.map +0 -1
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* OneBot 11 协议适配器(当前主战场)
|
|
3
3
|
* 公共面:类型 + 动作注册表 + 配置 schema + 翻译层(adapter.ts 于 打通 kernel 事件后接入)。
|
|
4
4
|
*/
|
|
5
|
-
import { $ as OB11Return, A as Ob11ActionDeps, B as cqMessageToCanonical, C as CqCode, D as parseCqMessage, E as escapeCqText, F as OneBotApiOptions, G as GroupHonorInfo, H as segmentsToCanonical, I as OneBotSystemOptions, J as HonorMember, K as GroupInfo, L as MessageUnique, M as AtAllRemainInfo, N as ob11ErrorCodeMap, O as serializeCqParts, P as OneBotApi, Q as OB11MessageSegment, R as canonicalToCqMessage, S as segmentsToCqMessage, T as escapeCqParam, U as CurrentTalkative, V as cqMessageToSegments, W as FriendInfo, X as OB11Message, Y as LoginInfo, Z as OB11MessageInfo, _ as OB11PrivateMessageEvent, a as OneBot11AdapterOptions, b as OB11Config, c as OB11GroupRequestEvent, d as OB11HeartbeatMetaEvent, et as Sender, f as OB11LifecycleMetaEvent, g as OB11MessageEvent, h as OB11GroupMessageEvent, i as NapukettoOneBot11Adapter, j as createOb11ActionRegistry, k as unescapeCqText, l as OB11RequestEvent, m as OB11Status, n as Ob11TransportSet, nt as StrangerInfo, o as OB11Event, p as OB11MetaEvent, q as GroupMemberInfo, r as assembleOb11Transports, rt as VersionInfo, s as OB11FriendRequestEvent, t as AssembleOb11TransportsOptions, tt as Sex, u as OB11NoticeEvent, v as OB11BaseEvent, w as encodeCqCode, x as ob11ConfigSchema, y as OB11PostType, z as canonicalToSegments } from "../index-
|
|
5
|
+
import { $ as OB11Return, A as Ob11ActionDeps, B as cqMessageToCanonical, C as CqCode, D as parseCqMessage, E as escapeCqText, F as OneBotApiOptions, G as GroupHonorInfo, H as segmentsToCanonical, I as OneBotSystemOptions, J as HonorMember, K as GroupInfo, L as MessageUnique, M as AtAllRemainInfo, N as ob11ErrorCodeMap, O as serializeCqParts, P as OneBotApi, Q as OB11MessageSegment, R as canonicalToCqMessage, S as segmentsToCqMessage, T as escapeCqParam, U as CurrentTalkative, V as cqMessageToSegments, W as FriendInfo, X as OB11Message, Y as LoginInfo, Z as OB11MessageInfo, _ as OB11PrivateMessageEvent, a as OneBot11AdapterOptions, b as OB11Config, c as OB11GroupRequestEvent, d as OB11HeartbeatMetaEvent, et as Sender, f as OB11LifecycleMetaEvent, g as OB11MessageEvent, h as OB11GroupMessageEvent, i as NapukettoOneBot11Adapter, j as createOb11ActionRegistry, k as unescapeCqText, l as OB11RequestEvent, m as OB11Status, n as Ob11TransportSet, nt as StrangerInfo, o as OB11Event, p as OB11MetaEvent, q as GroupMemberInfo, r as assembleOb11Transports, rt as VersionInfo, s as OB11FriendRequestEvent, t as AssembleOb11TransportsOptions, tt as Sex, u as OB11NoticeEvent, v as OB11BaseEvent, w as encodeCqCode, x as ob11ConfigSchema, y as OB11PostType, z as canonicalToSegments } from "../index-B2Hf9yzT.mjs";
|
|
6
6
|
export { type AssembleOb11TransportsOptions, type AtAllRemainInfo, type CqCode, type CurrentTalkative, type FriendInfo, type GroupHonorInfo, type GroupInfo, type GroupMemberInfo, type HonorMember, type LoginInfo, MessageUnique, NapukettoOneBot11Adapter, type OB11BaseEvent, type OB11Config, type OB11Event, type OB11FriendRequestEvent, type OB11GroupMessageEvent, type OB11GroupRequestEvent, type OB11HeartbeatMetaEvent, type OB11LifecycleMetaEvent, type OB11Message, type OB11MessageEvent, type OB11MessageInfo, type OB11MessageSegment, type OB11MetaEvent, type OB11NoticeEvent, type OB11PostType, type OB11PrivateMessageEvent, type OB11RequestEvent, type OB11Return, type OB11Status, type Ob11ActionDeps, type Ob11TransportSet, type OneBot11AdapterOptions, OneBotApi, type OneBotApiOptions, type OneBotSystemOptions, type Sender, type Sex, type StrangerInfo, type VersionInfo, assembleOb11Transports, canonicalToCqMessage, canonicalToSegments, cqMessageToCanonical, cqMessageToSegments, createOb11ActionRegistry, encodeCqCode, escapeCqParam, escapeCqText, ob11ConfigSchema, ob11ErrorCodeMap, parseCqMessage, segmentsToCanonical, segmentsToCqMessage, serializeCqParts, unescapeCqText };
|
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-C_yEFxou.mjs";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { a as resolveProtocolConfig, i as BaseProtocolAdapter, o as ActionRegistry, r as createServerSchema, s as runAction } from "./core-D8sq68iP.mjs";
|
|
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-
|
|
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-
|
|
5
|
-
import { ChatType, GrayTipSubType, GroupApi, GroupNotifyMsgStatus, GroupNotifyMsgType, NTGroupMemberRole, NTGroupRequestOperateTypes, TicketApi, TipGroupElementType, WebHonorType, errorMessage, kernelError, toCanonicalElements } from "@napuketto/kernel";
|
|
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-BtlTJhYX.mjs";
|
|
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";
|
|
8
8
|
import { randomUUID } from "node:crypto";
|
|
@@ -1083,6 +1083,8 @@ function serializeCqParts(parts) {
|
|
|
1083
1083
|
return out;
|
|
1084
1084
|
}
|
|
1085
1085
|
// src/onebot11/helper/codec/segment.ts
|
|
1086
|
+
/** 校验失败统一文案(协议入站边界,ADR-009)。 */
|
|
1087
|
+
const INVALID_SEGMENT_MESSAGE = "OneBot11 消息段格式不合法";
|
|
1086
1088
|
/** OB11 媒体段 data(image/record/video 共用,url 可选)。 */
|
|
1087
1089
|
function mediaData(file, url) {
|
|
1088
1090
|
const data = { file };
|
|
@@ -1104,113 +1106,199 @@ function canonicalAt(target, display) {
|
|
|
1104
1106
|
if (display !== void 0) el.display = display;
|
|
1105
1107
|
return el;
|
|
1106
1108
|
}
|
|
1107
|
-
/** canonical 媒体元素(image/voice/video,url
|
|
1109
|
+
/** canonical 媒体元素(image/voice/video,url 可选;分支内收窄,无需断言)。 */
|
|
1108
1110
|
function canonicalMedia(type, path, url) {
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1111
|
+
switch (type) {
|
|
1112
|
+
case "image": return url === void 0 ? {
|
|
1113
|
+
type: "image",
|
|
1114
|
+
path
|
|
1115
|
+
} : {
|
|
1116
|
+
type: "image",
|
|
1117
|
+
path,
|
|
1118
|
+
url
|
|
1119
|
+
};
|
|
1120
|
+
case "voice": return url === void 0 ? {
|
|
1121
|
+
type: "voice",
|
|
1122
|
+
path
|
|
1123
|
+
} : {
|
|
1124
|
+
type: "voice",
|
|
1125
|
+
path,
|
|
1126
|
+
url
|
|
1127
|
+
};
|
|
1128
|
+
case "video": return url === void 0 ? {
|
|
1129
|
+
type: "video",
|
|
1130
|
+
path
|
|
1131
|
+
} : {
|
|
1132
|
+
type: "video",
|
|
1133
|
+
path,
|
|
1134
|
+
url
|
|
1135
|
+
};
|
|
1136
|
+
}
|
|
1115
1137
|
}
|
|
1116
1138
|
/** canonical json/xml 的 raw → OB11 data 字符串(字符串原样,对象序列化)。 */
|
|
1117
1139
|
function rawToString(raw) {
|
|
1118
1140
|
if (typeof raw === "string") return raw;
|
|
1119
1141
|
return JSON.stringify(raw);
|
|
1120
1142
|
}
|
|
1121
|
-
/**
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1143
|
+
/** 字段是否为 string | number(OB11 数值型 id 的容忍形态)。 */
|
|
1144
|
+
function isStringOrNumber(val) {
|
|
1145
|
+
return typeof val === "string" || typeof val === "number";
|
|
1146
|
+
}
|
|
1147
|
+
/** 可选字符串字段(缺省合法,出现时必须是 string)。 */
|
|
1148
|
+
function isOptionalString(data, key) {
|
|
1149
|
+
return data[key] === void 0 || typeof data[key] === "string";
|
|
1150
|
+
}
|
|
1151
|
+
/** 文本 / at / face 类型的 data 校验。 */
|
|
1152
|
+
function isTextLikeSegmentData(type, data) {
|
|
1153
|
+
switch (type) {
|
|
1154
|
+
case "text":
|
|
1155
|
+
case "string": return hasStringProp(data, "text");
|
|
1156
|
+
case "at": return isStringOrNumber(data["qq"]) && isOptionalString(data, "name");
|
|
1157
|
+
case "face": return isStringOrNumber(data["id"]);
|
|
1158
|
+
default: return false;
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
/** image / record / video / file 类型的 data 校验。 */
|
|
1162
|
+
function isMediaSegmentData(type, data) {
|
|
1163
|
+
switch (type) {
|
|
1164
|
+
case "image":
|
|
1165
|
+
case "record":
|
|
1166
|
+
case "video": return hasStringProp(data, "file") && isOptionalString(data, "url");
|
|
1167
|
+
case "file": return hasStringProp(data, "file");
|
|
1168
|
+
default: return false;
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
/** reply / forward / json / xml 类型的 data 校验。 */
|
|
1172
|
+
function isPayloadSegmentData(type, data) {
|
|
1173
|
+
switch (type) {
|
|
1174
|
+
case "reply":
|
|
1175
|
+
case "forward": return isStringOrNumber(data["id"]);
|
|
1176
|
+
case "json":
|
|
1177
|
+
case "xml": return typeof data["data"] === "string" || isRecord(data["data"]);
|
|
1178
|
+
default: return false;
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
/**
|
|
1182
|
+
* OB11 消息段形状守卫:`type` 为 string,`data` 为对象,且**已知类型的必填字段**
|
|
1183
|
+
* 类型正确。未知 `type` 一律判非法(发送入口显式拒绝,不静默丢段)。
|
|
1184
|
+
*
|
|
1185
|
+
* 按 data 校验形态拆成三组小函数(文本类 / 媒体类 / 载荷类),主函数只做短路组合。
|
|
1186
|
+
*/
|
|
1187
|
+
function isOB11MessageSegment(val) {
|
|
1188
|
+
if (!isRecord(val) || !hasStringProp(val, "type")) return false;
|
|
1189
|
+
const data = val["data"];
|
|
1190
|
+
if (!isRecord(data)) return false;
|
|
1191
|
+
const type = val["type"];
|
|
1192
|
+
return isTextLikeSegmentData(type, data) || isMediaSegmentData(type, data) || isPayloadSegmentData(type, data);
|
|
1193
|
+
}
|
|
1194
|
+
/**
|
|
1195
|
+
* 校验并收窄入站 segment 数组(HTTP 动作载荷 → OB11MessageSegment[])。
|
|
1196
|
+
* 任一项不合法即抛 INVALID_PARAM(ADR-009 外部边界统一错误语义)。
|
|
1197
|
+
*/
|
|
1198
|
+
function parseOB11MessageSegments(raw) {
|
|
1199
|
+
const out = [];
|
|
1200
|
+
for (const item of raw) {
|
|
1201
|
+
if (!isOB11MessageSegment(item)) throw kernelError(INVALID_SEGMENT_MESSAGE, "INVALID_PARAM");
|
|
1202
|
+
out.push(item);
|
|
1203
|
+
}
|
|
1204
|
+
return out;
|
|
1205
|
+
}
|
|
1168
1206
|
/** canonical 元素 → OB11 segment(null = OB11 无法表达,跳过)。 */
|
|
1169
1207
|
function canonicalToSegment(el) {
|
|
1170
|
-
|
|
1171
|
-
|
|
1208
|
+
switch (el.type) {
|
|
1209
|
+
case "text": return {
|
|
1210
|
+
type: "text",
|
|
1211
|
+
data: { text: el.text }
|
|
1212
|
+
};
|
|
1213
|
+
case "at": return {
|
|
1214
|
+
type: "at",
|
|
1215
|
+
data: atData(el.target, el.display)
|
|
1216
|
+
};
|
|
1217
|
+
case "image": return {
|
|
1218
|
+
type: "image",
|
|
1219
|
+
data: mediaData(el.path, el.url)
|
|
1220
|
+
};
|
|
1221
|
+
case "face": return {
|
|
1222
|
+
type: "face",
|
|
1223
|
+
data: { id: el.id }
|
|
1224
|
+
};
|
|
1225
|
+
case "voice": return {
|
|
1226
|
+
type: "record",
|
|
1227
|
+
data: mediaData(el.path, el.url)
|
|
1228
|
+
};
|
|
1229
|
+
case "video": return {
|
|
1230
|
+
type: "video",
|
|
1231
|
+
data: mediaData(el.path, el.url)
|
|
1232
|
+
};
|
|
1233
|
+
case "file": return {
|
|
1234
|
+
type: "file",
|
|
1235
|
+
data: { file: el.name ?? el.path }
|
|
1236
|
+
};
|
|
1237
|
+
case "reply": return {
|
|
1238
|
+
type: "reply",
|
|
1239
|
+
data: { id: el.messageId }
|
|
1240
|
+
};
|
|
1241
|
+
case "forward": return {
|
|
1242
|
+
type: "forward",
|
|
1243
|
+
data: { id: el.messageIds[0] ?? "" }
|
|
1244
|
+
};
|
|
1245
|
+
case "json": return {
|
|
1246
|
+
type: "json",
|
|
1247
|
+
data: { data: rawToString(el.raw) }
|
|
1248
|
+
};
|
|
1249
|
+
case "xml": return {
|
|
1250
|
+
type: "xml",
|
|
1251
|
+
data: { data: rawToString(el.raw) }
|
|
1252
|
+
};
|
|
1253
|
+
case "unknown": return null;
|
|
1254
|
+
default: return null;
|
|
1255
|
+
}
|
|
1172
1256
|
}
|
|
1173
|
-
/**
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
}),
|
|
1179
|
-
string: (seg) => ({
|
|
1180
|
-
type: "text",
|
|
1181
|
-
text: seg.data.text
|
|
1182
|
-
}),
|
|
1183
|
-
at: (seg) => canonicalAt(seg.data.qq, seg.data.name),
|
|
1184
|
-
face: (seg) => ({
|
|
1185
|
-
type: "face",
|
|
1186
|
-
id: seg.data.id
|
|
1187
|
-
}),
|
|
1188
|
-
image: (seg) => canonicalMedia("image", seg.data.file, seg.data.url),
|
|
1189
|
-
record: (seg) => canonicalMedia("voice", seg.data.file, seg.data.url),
|
|
1190
|
-
video: (seg) => canonicalMedia("video", seg.data.file, seg.data.url),
|
|
1191
|
-
reply: (seg) => ({
|
|
1192
|
-
type: "reply",
|
|
1193
|
-
messageId: seg.data.id
|
|
1194
|
-
}),
|
|
1195
|
-
forward: (seg) => ({
|
|
1196
|
-
type: "forward",
|
|
1197
|
-
messageIds: [seg.data.id]
|
|
1198
|
-
}),
|
|
1199
|
-
json: (seg) => ({
|
|
1200
|
-
type: "json",
|
|
1201
|
-
raw: seg.data.data
|
|
1202
|
-
}),
|
|
1203
|
-
xml: (seg) => ({
|
|
1204
|
-
type: "xml",
|
|
1205
|
-
raw: seg.data.data
|
|
1206
|
-
})
|
|
1207
|
-
};
|
|
1208
|
-
/** OB11 segment → canonical 元素(未知 type 兜底按 xml 处理,保持既有行为)。 */
|
|
1257
|
+
/**
|
|
1258
|
+
* OB11 segment → canonical 元素(未知 type 兜底按 xml 处理,保持既有行为)。
|
|
1259
|
+
* 入参已由 isOB11MessageSegment 收窄;类型侧调用(内部 CQ 码生成 / 接收方向翻译)
|
|
1260
|
+
* 直接传 OB11MessageSegment,default 分支仅在运行时出现意外 type 时命中。
|
|
1261
|
+
*/
|
|
1209
1262
|
function segmentToCanonical(seg) {
|
|
1210
|
-
const
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1263
|
+
const rawSegment = seg;
|
|
1264
|
+
switch (seg.type) {
|
|
1265
|
+
case "text":
|
|
1266
|
+
case "string": return {
|
|
1267
|
+
type: "text",
|
|
1268
|
+
text: seg.data.text
|
|
1269
|
+
};
|
|
1270
|
+
case "at": return canonicalAt(String(seg.data.qq), seg.data.name);
|
|
1271
|
+
case "face": return {
|
|
1272
|
+
type: "face",
|
|
1273
|
+
id: String(seg.data.id)
|
|
1274
|
+
};
|
|
1275
|
+
case "image": return canonicalMedia("image", seg.data.file, seg.data.url);
|
|
1276
|
+
case "record": return canonicalMedia("voice", seg.data.file, seg.data.url);
|
|
1277
|
+
case "video": return canonicalMedia("video", seg.data.file, seg.data.url);
|
|
1278
|
+
case "reply": return {
|
|
1279
|
+
type: "reply",
|
|
1280
|
+
messageId: String(seg.data.id)
|
|
1281
|
+
};
|
|
1282
|
+
case "forward": return {
|
|
1283
|
+
type: "forward",
|
|
1284
|
+
messageIds: [String(seg.data.id)]
|
|
1285
|
+
};
|
|
1286
|
+
case "json": return {
|
|
1287
|
+
type: "json",
|
|
1288
|
+
raw: seg.data.data
|
|
1289
|
+
};
|
|
1290
|
+
case "xml": return {
|
|
1291
|
+
type: "xml",
|
|
1292
|
+
raw: seg.data.data
|
|
1293
|
+
};
|
|
1294
|
+
default: {
|
|
1295
|
+
const data = isRecord(rawSegment) ? rawSegment["data"] : void 0;
|
|
1296
|
+
return {
|
|
1297
|
+
type: "xml",
|
|
1298
|
+
raw: isRecord(data) ? data["data"] : void 0
|
|
1299
|
+
};
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1214
1302
|
}
|
|
1215
1303
|
/** 已知 CQ 类型 → segment 构造器。 */
|
|
1216
1304
|
const CQ_SEGMENT_BUILDERS = {
|
|
@@ -2325,7 +2413,7 @@ const sendGroupMsgSchema = z.object({
|
|
|
2325
2413
|
async function sendOb11Message(payload, deps) {
|
|
2326
2414
|
const peer = await resolveTargetPeer(payload, deps, "send_msg 需要 group_id 或 user_id");
|
|
2327
2415
|
let canonical;
|
|
2328
|
-
if (Array.isArray(payload.message)) canonical = segmentsToCanonical(payload.message);
|
|
2416
|
+
if (Array.isArray(payload.message)) canonical = segmentsToCanonical(parseOB11MessageSegments(payload.message));
|
|
2329
2417
|
else canonical = cqMessageToCanonical(payload.message);
|
|
2330
2418
|
const atUins = [];
|
|
2331
2419
|
for (const el of canonical) if (el.type === "at" && el.target !== "all") atUins.push(el.target);
|
|
@@ -3897,4 +3985,4 @@ function echoFieldOf(req) {
|
|
|
3897
3985
|
}
|
|
3898
3986
|
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 };
|
|
3899
3987
|
|
|
3900
|
-
//# sourceMappingURL=onebot11-
|
|
3988
|
+
//# sourceMappingURL=onebot11-C_yEFxou.mjs.map
|