tanebi
Version:
NTQQ Node.js Protocol Implementation
1,094 lines (1,043 loc) • 315 kB
JavaScript
// src/entity/BotEntity.ts
var BotEntity = class {
constructor(bot, data) {
this.bot = bot;
this.data = data;
}
updateBinding(data) {
this.data = data;
}
};
// src/entity/BotContact.ts
var BotContact = class extends BotEntity {
constructor(bot, data) {
super(bot, data);
}
get uin() {
return this.data.uin;
}
};
// src/internal/message/index.ts
var MessageType = /* @__PURE__ */ ((MessageType2) => {
MessageType2[MessageType2["PrivateMessage"] = 1] = "PrivateMessage";
MessageType2[MessageType2["GroupMessage"] = 2] = "GroupMessage";
return MessageType2;
})(MessageType || {});
// src/internal/packet/message/PushMsg.ts
import { ProtoField as ProtoField8, ProtoMessage as ProtoMessage8, ScalarType as ScalarType8 } from "@tanebijs/protobuf";
// src/internal/packet/common/NTSysEvent.ts
import { ProtoField, ProtoMessage, ScalarType } from "@tanebijs/protobuf";
var NTSysEvent = ProtoMessage.of({
ip: ProtoField(1, ScalarType.STRING),
sid: ProtoField(2, ScalarType.INT64),
sub: ProtoField(3, () => ({
state: ProtoField(2, ScalarType.INT64),
field3: ProtoField(3, ScalarType.INT32),
field4: ProtoField(4, ScalarType.INT64),
uin: ProtoField(5, ScalarType.INT64),
flag: ProtoField(6, ScalarType.INT32),
on: ProtoField(7, ScalarType.INT32),
groupUin: ProtoField(8, ScalarType.UINT32)
}))
});
// src/internal/packet/message/MessageContentHead.ts
import { ProtoField as ProtoField2, ProtoMessage as ProtoMessage2, ScalarType as ScalarType2 } from "@tanebijs/protobuf";
var MessageContentHead = ProtoMessage2.of({
type: ProtoField2(1, ScalarType2.UINT32),
// message type
subType: ProtoField2(2, ScalarType2.UINT32, true),
// message subtype (0x211/0x2dc/0x210 and other system message subtypes, same as c2c_cmd)
c2cCmd: ProtoField2(3, ScalarType2.UINT32, true),
// c2c message subtype
random: ProtoField2(4, ScalarType2.UINT32, true),
sequence: ProtoField2(5, ScalarType2.UINT32, true),
timestamp: ProtoField2(6, ScalarType2.UINT32),
pkgNum: ProtoField2(7, ScalarType2.INT64, true),
// number of packages, not 1 when the message needs to be sent in packages
pkgIndex: ProtoField2(8, ScalarType2.UINT32, true),
// current package index, starting from 0
divSeq: ProtoField2(9, ScalarType2.UINT32, true),
// message package seq, the div_seq of the same message is the same
autoReply: ProtoField2(10, ScalarType2.UINT32),
ntMsgSeq: ProtoField2(11, ScalarType2.UINT32, true),
// unique incremental seq of c2c messages between two uins
msgUid: ProtoField2(12, ScalarType2.UINT64, true),
forward: ProtoField2(15, () => ({
field1: ProtoField2(1, ScalarType2.UINT32, true),
// 0
field2: ProtoField2(2, ScalarType2.UINT32, true),
// 0
field3: ProtoField2(3, ScalarType2.UINT32, true),
// for friend: 2, for group: null
unknownBase64: ProtoField2(4, ScalarType2.STRING, true),
avatar: ProtoField2(5, ScalarType2.STRING, true)
}), true)
});
// src/internal/packet/message/MessageBody.ts
import { ProtoField as ProtoField7, ProtoMessage as ProtoMessage7, ScalarType as ScalarType7 } from "@tanebijs/protobuf";
// src/internal/packet/message/RichText.ts
import { ProtoField as ProtoField6, ProtoMessage as ProtoMessage6, ScalarType as ScalarType6 } from "@tanebijs/protobuf";
// src/internal/packet/message/Attribute.ts
import { ProtoField as ProtoField3, ProtoMessage as ProtoMessage3, ScalarType as ScalarType3 } from "@tanebijs/protobuf";
var Attribute = ProtoMessage3.of({
codePage: ProtoField3(1, ScalarType3.INT32, false, false),
time: ProtoField3(2, ScalarType3.INT32, false, false),
random: ProtoField3(3, ScalarType3.INT32, false, false),
color: ProtoField3(4, ScalarType3.INT32, false, false),
size: ProtoField3(5, ScalarType3.INT32, false, false),
effect: ProtoField3(6, ScalarType3.INT32, false, false),
charSet: ProtoField3(7, ScalarType3.INT32, false, false),
pitchAndFamily: ProtoField3(8, ScalarType3.INT32, false, false),
fontName: ProtoField3(9, ScalarType3.STRING, true, false),
reserveData: ProtoField3(10, ScalarType3.BYTES, true, false)
});
// src/internal/packet/message/NotOnlineFile.ts
import { ProtoField as ProtoField4, ProtoMessage as ProtoMessage4, ScalarType as ScalarType4 } from "@tanebijs/protobuf";
var NotOnlineFile = ProtoMessage4.of({
fileType: ProtoField4(1, ScalarType4.INT32, true, false),
sig: ProtoField4(2, ScalarType4.BYTES, true, false),
fileUuid: ProtoField4(3, ScalarType4.STRING, true, false),
fileMd5: ProtoField4(4, ScalarType4.BYTES, true, false),
fileName: ProtoField4(5, ScalarType4.STRING, true, false),
fileSize: ProtoField4(6, ScalarType4.INT64, true, false),
note: ProtoField4(7, ScalarType4.BYTES, true, false),
reserved: ProtoField4(8, ScalarType4.INT32, true, false),
subcmd: ProtoField4(9, ScalarType4.INT32, true, false),
microCloud: ProtoField4(10, ScalarType4.INT32, true, false),
bytesFileUrls: ProtoField4(11, ScalarType4.BYTES, false, true),
downloadFlag: ProtoField4(12, ScalarType4.INT32, true, false),
dangerEvel: ProtoField4(50, ScalarType4.INT32, true, false),
lifeTime: ProtoField4(51, ScalarType4.INT32, true, false),
uploadTime: ProtoField4(52, ScalarType4.INT32, true, false),
absFileType: ProtoField4(53, ScalarType4.INT32, true, false),
clientType: ProtoField4(54, ScalarType4.INT32, true, false),
expireTime: ProtoField4(55, ScalarType4.INT32, true, false),
pbReserve: ProtoField4(56, ScalarType4.BYTES, true, false),
fileHash: ProtoField4(57, ScalarType4.STRING, true, false)
});
// src/internal/packet/message/Ptt.ts
import { ProtoField as ProtoField5, ProtoMessage as ProtoMessage5, ScalarType as ScalarType5 } from "@tanebijs/protobuf";
var Ptt = ProtoMessage5.of({
fileType: ProtoField5(1, ScalarType5.INT32, false, false),
srcUin: ProtoField5(2, ScalarType5.INT64, false, false),
fileUuid: ProtoField5(3, ScalarType5.STRING, true, false),
fileMd5: ProtoField5(4, ScalarType5.BYTES, true, false),
fileName: ProtoField5(5, ScalarType5.STRING, true, false),
fileSize: ProtoField5(6, ScalarType5.INT32, false, false),
reserve: ProtoField5(7, ScalarType5.BYTES, true, false),
fileId: ProtoField5(8, ScalarType5.INT32, false, false),
serverIp: ProtoField5(9, ScalarType5.INT32, false, false),
serverPort: ProtoField5(10, ScalarType5.INT32, false, false),
boolValid: ProtoField5(11, ScalarType5.BOOL, false, false),
signature: ProtoField5(12, ScalarType5.BYTES, true, false),
shortcut: ProtoField5(13, ScalarType5.BYTES, true, false),
fileKey: ProtoField5(14, ScalarType5.BYTES, true, false),
magicPttIndex: ProtoField5(15, ScalarType5.INT32, false, false),
voiceSwitch: ProtoField5(16, ScalarType5.INT32, false, false),
pttUrl: ProtoField5(17, ScalarType5.BYTES, true, false),
groupFileKey: ProtoField5(18, ScalarType5.STRING, true, false),
time: ProtoField5(19, ScalarType5.INT32, false, false),
downPara: ProtoField5(20, ScalarType5.BYTES, true, false),
format: ProtoField5(29, ScalarType5.INT32, false, false),
pbReserve: ProtoField5(30, ScalarType5.BYTES, true, false),
bytesPttUrls: ProtoField5(31, ScalarType5.BYTES, false, true),
downloadFlag: ProtoField5(32, ScalarType5.INT32, false, false)
});
// src/internal/packet/message/RichText.ts
var RichText = ProtoMessage6.of({
attribute: ProtoField6(1, () => Attribute.fields, true),
elements: ProtoField6(2, ScalarType6.BYTES, false, true),
notOnlineFile: ProtoField6(3, () => NotOnlineFile.fields, true),
ptt: ProtoField6(4, () => Ptt.fields, true)
});
// src/internal/packet/message/MessageBody.ts
var MessageBody = ProtoMessage7.of({
richText: ProtoField7(1, () => RichText.fields, true),
msgContent: ProtoField7(2, ScalarType7.BYTES, true),
msgEncryptContent: ProtoField7(3, ScalarType7.BYTES, true)
});
// src/internal/packet/message/PushMsg.ts
var PushMsg = ProtoMessage8.of({
message: ProtoField8(1, ScalarType8.BYTES),
status: ProtoField8(3, ScalarType8.INT32, true),
ntEvent: ProtoField8(4, () => NTSysEvent.fields, true),
pingFlag: ProtoField8(5, ScalarType8.INT32, true),
generalFlag: ProtoField8(9, ScalarType8.INT32, true)
});
var PushMsgBody = ProtoMessage8.of({
responseHead: ProtoField8(1, () => ({
fromUin: ProtoField8(1, ScalarType8.UINT32),
fromUid: ProtoField8(2, ScalarType8.STRING, true),
type: ProtoField8(3, ScalarType8.UINT32),
sigMap: ProtoField8(4, ScalarType8.UINT32),
toUin: ProtoField8(5, ScalarType8.UINT32),
toUid: ProtoField8(6, ScalarType8.STRING, true),
friendExt: ProtoField8(7, () => ({
friendName: ProtoField8(6, ScalarType8.STRING, true)
}), true),
groupExt: ProtoField8(8, () => ({
groupUin: ProtoField8(1, ScalarType8.UINT32),
memberName: ProtoField8(4, ScalarType8.STRING),
unknown5: ProtoField8(5, ScalarType8.UINT32),
groupName: ProtoField8(7, ScalarType8.STRING)
}), true)
})),
contentHead: ProtoField8(2, () => MessageContentHead.fields),
body: ProtoField8(3, () => MessageBody.fields, true)
});
// src/internal/message/incoming/segment-base.ts
function defineIncoming(acceptsField, segmentType, tryParse) {
return { acceptsField, segmentType, tryParse };
}
var IncomingSegmentCollection = class {
constructor(parsers) {
this.parsers = parsers;
}
parse(element) {
for (const parser of this.parsers) {
const value = element[parser.acceptsField];
if (value) {
const segment = parser.tryParse(value);
if (segment) {
return { type: parser.segmentType, ...segment };
}
}
}
}
};
// src/internal/packet/oidb/media/ExtBizInfo.ts
import { ProtoField as ProtoField9, ProtoMessage as ProtoMessage9, ScalarType as ScalarType9 } from "@tanebijs/protobuf";
var ExtBizInfo = ProtoMessage9.of({
pic: ProtoField9(1, () => PicExtBizInfo.fields, true, false),
video: ProtoField9(2, () => VideoExtBizInfo.fields, true, false),
ptt: ProtoField9(3, () => PttExtBizInfo.fields, true, false),
busiType: ProtoField9(10, ScalarType9.UINT32, false, false)
});
var PicExtBizInfo = ProtoMessage9.of({
bizType: ProtoField9(1, ScalarType9.UINT32, false, false),
textSummary: ProtoField9(2, ScalarType9.STRING, true, false),
bytesPbReserveC2C: ProtoField9(11, ScalarType9.BYTES, true, false),
bytesPbReserveTroop: ProtoField9(12, ScalarType9.BYTES, true, false),
fromScene: ProtoField9(1001, ScalarType9.UINT32, false, false),
toScene: ProtoField9(1002, ScalarType9.UINT32, false, false),
oldFileId: ProtoField9(1003, ScalarType9.UINT32, false, false)
});
var VideoExtBizInfo = ProtoMessage9.of({
fromScene: ProtoField9(1, ScalarType9.UINT32, false, false),
toScene: ProtoField9(2, ScalarType9.UINT32, false, false),
bytesPbReserve: ProtoField9(3, ScalarType9.BYTES, true, false)
});
var PttExtBizInfo = ProtoMessage9.of({
srcUin: ProtoField9(1, ScalarType9.UINT64, false, false),
pttScene: ProtoField9(2, ScalarType9.UINT32, false, false),
pttType: ProtoField9(3, ScalarType9.UINT32, false, false),
changeVoice: ProtoField9(4, ScalarType9.UINT32, false, false),
waveform: ProtoField9(5, ScalarType9.BYTES, true, false),
autoConvertText: ProtoField9(6, ScalarType9.UINT32, false, false),
bytesReserve: ProtoField9(11, ScalarType9.BYTES, true, false),
bytesPbReserve: ProtoField9(12, ScalarType9.BYTES, true, false),
bytesGeneralFlags: ProtoField9(13, ScalarType9.BYTES, true, false)
});
// src/internal/packet/oidb/media/FileInfo.ts
import { ProtoField as ProtoField10, ProtoMessage as ProtoMessage10, ScalarType as ScalarType10 } from "@tanebijs/protobuf";
var FileInfo = ProtoMessage10.of({
fileSize: ProtoField10(1, ScalarType10.UINT32, false, false),
fileHash: ProtoField10(2, ScalarType10.STRING, true, false),
fileSha1: ProtoField10(3, ScalarType10.STRING, true, false),
fileName: ProtoField10(4, ScalarType10.STRING, true, false),
type: ProtoField10(5, () => ({
type: ProtoField10(1, ScalarType10.UINT32, false, false),
picFormat: ProtoField10(2, ScalarType10.UINT32, false, false),
videoFormat: ProtoField10(3, ScalarType10.UINT32, false, false),
voiceFormat: ProtoField10(4, ScalarType10.UINT32, false, false)
}), true, false),
width: ProtoField10(6, ScalarType10.UINT32, false, false),
height: ProtoField10(7, ScalarType10.UINT32, false, false),
time: ProtoField10(8, ScalarType10.UINT32, false, false),
original: ProtoField10(9, ScalarType10.UINT32, false, false)
});
// src/internal/packet/oidb/media/IndexNode.ts
import { ProtoField as ProtoField11, ProtoMessage as ProtoMessage11, ScalarType as ScalarType11 } from "@tanebijs/protobuf";
var IndexNode = ProtoMessage11.of({
info: ProtoField11(1, () => FileInfo.fields, true, false),
fileUuid: ProtoField11(2, ScalarType11.STRING, true, false),
storeId: ProtoField11(3, ScalarType11.UINT32, false, false),
uploadTime: ProtoField11(4, ScalarType11.UINT32, false, false),
ttl: ProtoField11(5, ScalarType11.UINT32, false, false),
subType: ProtoField11(6, ScalarType11.UINT32, false, false)
});
// src/internal/packet/oidb/media/MsgInfo.ts
import { ProtoField as ProtoField12, ProtoMessage as ProtoMessage12, ScalarType as ScalarType12 } from "@tanebijs/protobuf";
var MsgInfo = ProtoMessage12.of({
msgInfoBody: ProtoField12(1, () => MsgInfoBody.fields, false, true),
extBizInfo: ProtoField12(2, () => ExtBizInfo.fields, true, false)
});
var MsgInfoBody = ProtoMessage12.of({
index: ProtoField12(1, () => IndexNode.fields, true, false),
picture: ProtoField12(2, () => PictureInfo.fields, true, false),
video: ProtoField12(3, () => VideoInfo.fields, true, false),
audio: ProtoField12(4, () => AudioInfo.fields, true, false),
fileExist: ProtoField12(5, ScalarType12.BOOL, false, false),
hashSum: ProtoField12(6, () => HashSum.fields, true, false)
});
var PictureInfo = ProtoMessage12.of({
urlPath: ProtoField12(1, ScalarType12.STRING, true, false),
ext: ProtoField12(2, () => PicUrlExtInfo.fields, true, false),
domain: ProtoField12(3, ScalarType12.STRING, true, false)
});
var PicUrlExtInfo = ProtoMessage12.of({
originalParameter: ProtoField12(1, ScalarType12.STRING, true, false),
bigParameter: ProtoField12(2, ScalarType12.STRING, true, false),
thumbParameter: ProtoField12(3, ScalarType12.STRING, true, false)
});
var VideoInfo = ProtoMessage12.of({});
var VideoExtInfo = ProtoMessage12.of({
videoCodecFormat: ProtoField12(1, ScalarType12.UINT32, false, false)
});
var AudioInfo = ProtoMessage12.of({});
var HashSum = ProtoMessage12.of({});
// src/internal/message/incoming/segment/image.ts
var ntImageUrlBase = "https://multimedia.nt.qq.com.cn";
var legacyImageUrlBase = "http://gchat.qpic.cn";
var ImageSubType = /* @__PURE__ */ ((ImageSubType3) => {
ImageSubType3[ImageSubType3["Picture"] = 0] = "Picture";
ImageSubType3[ImageSubType3["Face"] = 1] = "Face";
return ImageSubType3;
})(ImageSubType || {});
var imageCommonParser = defineIncoming(
"common",
"image",
(element) => {
if (element.serviceType === 48 && (element.businessType === 20 || element.businessType === 10) && element.pbElement) {
const msgInfo = MsgInfo.decode(element.pbElement);
if (msgInfo.msgInfoBody.length > 0) {
const msgInfoBody = msgInfo.msgInfoBody[0];
return {
indexNode: msgInfoBody.index,
width: msgInfoBody.index?.info?.width ?? 0,
height: msgInfoBody.index?.info?.height ?? 0,
subType: msgInfo.extBizInfo?.pic?.bizType ?? 0 /* Picture */,
summary: msgInfo.extBizInfo?.pic?.textSummary || "[\u56FE\u7247]"
};
}
}
}
);
var imageNotOnlineParser = defineIncoming(
"notOnlineImage",
"image",
(element) => {
if (element.origUrl) {
if (element.origUrl.includes("&fileid=")) {
return {
url: `${ntImageUrlBase}${element.origUrl}`,
width: element.picWidth,
height: element.picHeight,
subType: element.pbRes?.subType ?? 0 /* Picture */,
summary: element.pbRes?.summary || "[\u56FE\u7247]"
};
} else {
return {
url: `${legacyImageUrlBase}${element.origUrl}`,
width: element.picWidth,
height: element.picHeight,
subType: element.pbRes?.subType ?? 0 /* Picture */,
summary: element.pbRes?.summary || "[\u56FE\u7247]"
};
}
}
}
);
var imageCustomFaceParser = defineIncoming(
"customFace",
"image",
(element) => {
if (element.origUrl) {
if (element.origUrl.includes("&fileid=")) {
return {
url: `${ntImageUrlBase}${element.origUrl}`,
width: element.width,
height: element.height,
subType: element.pbReserve?.subType ?? parseSubTypeFromOldData(element.oldData),
summary: element.pbReserve?.summary || "[\u52A8\u753B\u8868\u60C5]"
};
} else {
return {
url: `${legacyImageUrlBase}${element.origUrl}`,
width: element.width,
height: element.height,
subType: element.pbReserve?.subType ?? parseSubTypeFromOldData(element.oldData),
summary: element.pbReserve?.summary || "[\u52A8\u753B\u8868\u60C5]"
};
}
}
}
);
function parseSubTypeFromOldData(element) {
if (!element || element.length < 5) {
return 0 /* Picture */;
}
return element[4] === 54 ? 1 /* Face */ : 0 /* Picture */;
}
// src/internal/message/incoming/segment/mention.ts
var mentionParser = defineIncoming(
"text",
"mention",
(element) => {
if (element.attr6Buf?.length && element.attr6Buf.length >= 11) {
return {
name: element.str,
uin: element.attr6Buf.readUInt32BE(7)
};
}
}
);
// src/internal/message/incoming/segment/text.ts
var textParser = defineIncoming(
"text",
"text",
(element) => {
if (!element.attr6Buf?.length) {
return { content: element.str };
}
}
);
// src/internal/message/incoming/segment/light-app.ts
import { inflateSync } from "zlib";
import { z } from "zod";
var lightAppSchema = z.object({
app: z.string()
}).passthrough();
var lightAppParser = defineIncoming(
"lightApp",
"lightApp",
(element) => {
const payloadRaw = inflateSync(element.data.subarray(1)).toString("utf-8");
const payload = lightAppSchema.safeParse(JSON.parse(payloadRaw));
if (!payload.success) {
return void 0;
}
return {
app: payload.data.app,
payload: payload.data
};
}
);
// src/internal/message/incoming/segment/record.ts
var recordParser = defineIncoming(
"common",
"record",
(element) => {
if (element.serviceType === 48 && (element.businessType === 22 || element.businessType === 12) && element.pbElement) {
const msgInfo = MsgInfo.decode(element.pbElement);
if (msgInfo.msgInfoBody.length > 0) {
return {
indexNode: msgInfo.msgInfoBody[0].index
};
}
}
}
);
// src/internal/message/incoming/segment/video.ts
var videoParser = defineIncoming(
"common",
"video",
(element) => {
if (element.serviceType === 48 && (element.businessType === 21 || element.businessType === 11) && element.pbElement) {
const msgInfo = MsgInfo.decode(element.pbElement);
if (msgInfo.msgInfoBody.length > 0) {
return {
indexNode: msgInfo.msgInfoBody[0].index
};
}
}
}
);
// src/internal/packet/message/face/LargeFaceInfo.ts
import { ProtoField as ProtoField13, ProtoMessage as ProtoMessage13, ScalarType as ScalarType13 } from "@tanebijs/protobuf";
var LargeFaceInfo = ProtoMessage13.of({
aniStickerPackId: ProtoField13(1, ScalarType13.STRING),
aniStickerId: ProtoField13(2, ScalarType13.STRING),
faceId: ProtoField13(3, ScalarType13.INT32),
field4: ProtoField13(4, ScalarType13.INT32),
aniStickerType: ProtoField13(5, ScalarType13.INT32),
field6: ProtoField13(6, ScalarType13.STRING),
preview: ProtoField13(7, ScalarType13.STRING),
field9: ProtoField13(9, ScalarType13.INT32)
});
// src/internal/packet/message/face/SmallExtraFaceInfo.ts
import { ProtoField as ProtoField14, ProtoMessage as ProtoMessage14, ScalarType as ScalarType14 } from "@tanebijs/protobuf";
var SmallExtraFaceInfo = ProtoMessage14.of({
faceId: ProtoField14(1, ScalarType14.UINT32),
text1: ProtoField14(2, ScalarType14.STRING, true),
text2: ProtoField14(3, ScalarType14.STRING, true)
});
// src/internal/message/incoming/segment/face.ts
var faceOldFaceParser = defineIncoming(
"face",
"face",
(element) => {
if (element.old) return {
faceId: element.index ?? 0,
isInLargeCategory: false
};
}
);
var faceCommonParser = defineIncoming(
"common",
"face",
(element) => {
if (element.pbElement) {
if (element.serviceType === 37) {
const largeFaceInfo = LargeFaceInfo.decode(element.pbElement);
return {
faceId: largeFaceInfo.faceId,
summary: largeFaceInfo.preview,
isInLargeCategory: true
};
} else if (element.serviceType === 33) {
const smallExtraFaceInfo = SmallExtraFaceInfo.decode(element.pbElement);
return {
faceId: smallExtraFaceInfo.faceId,
summary: smallExtraFaceInfo.text1 ?? smallExtraFaceInfo.text2,
isInLargeCategory: false
};
}
}
}
);
// src/internal/message/incoming/segment/forward.ts
import { XMLParser } from "fast-xml-parser";
import { inflateSync as inflateSync2 } from "zlib";
import { z as z2 } from "zod";
var forwardXmlParser = new XMLParser({
ignoreAttributes: false,
attributeNamePrefix: "@"
});
var forwardXmlSchema = z2.object({
msg: z2.object({
"@m_resid": z2.string(),
"@tSum": z2.string(),
item: z2.object({
title: z2.array(z2.object({
"@color": z2.string(),
"#text": z2.string()
}))
})
})
});
var forwardParser = defineIncoming(
"richMsg",
"forward",
(element) => {
if (element.serviceId === 35 && element.template1 !== void 0) {
const xml = inflateSync2(element.template1.subarray(1)).toString("utf-8");
const parsed = forwardXmlSchema.parse(forwardXmlParser.parse(xml)).msg;
return {
resId: parsed["@m_resid"],
recursiveCount: parseInt(parsed["@tSum"]),
preview: parsed.item.title.filter((title) => title["@color"] === "#777777").map((title) => title["#text"])
};
}
}
);
// src/internal/packet/message/MessageElement.ts
import { ProtoField as ProtoField34, ProtoMessage as ProtoMessage34 } from "@tanebijs/protobuf";
// src/internal/packet/message/element/TextElement.ts
import { ProtoField as ProtoField15, ProtoMessage as ProtoMessage15, ScalarType as ScalarType15 } from "@tanebijs/protobuf";
var TextElement = ProtoMessage15.of({
str: ProtoField15(1, ScalarType15.STRING, true, false),
link: ProtoField15(2, ScalarType15.STRING, true, false),
attr6Buf: ProtoField15(3, ScalarType15.BYTES, true, false),
attr7Buf: ProtoField15(4, ScalarType15.BYTES, true, false),
buf: ProtoField15(11, ScalarType15.BYTES, true, false),
pbReserve: ProtoField15(12, ScalarType15.BYTES, true, false)
});
var MentionExtra = ProtoMessage15.of({
type: ProtoField15(3, ScalarType15.UINT32),
uin: ProtoField15(4, ScalarType15.UINT32, true, false),
field5: ProtoField15(5, ScalarType15.UINT32, true, false),
uid: ProtoField15(9, ScalarType15.STRING)
});
// src/internal/packet/message/element/FaceElement.ts
import { ProtoField as ProtoField16, ProtoMessage as ProtoMessage16, ScalarType as ScalarType16 } from "@tanebijs/protobuf";
var FaceElement = ProtoMessage16.of({
index: ProtoField16(1, ScalarType16.INT32, true, false),
old: ProtoField16(2, ScalarType16.BYTES, true, false),
buf: ProtoField16(11, ScalarType16.BYTES, true, false)
});
// src/internal/packet/message/element/OnlineImageElement.ts
import { ProtoField as ProtoField17, ProtoMessage as ProtoMessage17, ScalarType as ScalarType17 } from "@tanebijs/protobuf";
var OnlineImageElement = ProtoMessage17.of({
guid: ProtoField17(1, ScalarType17.BYTES, true, false),
filePath: ProtoField17(2, ScalarType17.BYTES, true, false),
oldVerSendFile: ProtoField17(3, ScalarType17.BYTES, true, false)
});
// src/internal/packet/message/element/NotOnlineImageElement.ts
import { ProtoField as ProtoField18, ProtoMessage as ProtoMessage18, ScalarType as ScalarType18 } from "@tanebijs/protobuf";
var NotOnlineImageElement = ProtoMessage18.of({
filePath: ProtoField18(1, ScalarType18.STRING, true, false),
fileLen: ProtoField18(2, ScalarType18.UINT32, false, false),
downloadPath: ProtoField18(3, ScalarType18.STRING, true, false),
oldVerSendFile: ProtoField18(4, ScalarType18.BYTES, true, false),
imgType: ProtoField18(5, ScalarType18.INT32, false, false),
previewsImage: ProtoField18(6, ScalarType18.BYTES, true, false),
picMd5: ProtoField18(7, ScalarType18.BYTES, true, false),
picHeight: ProtoField18(8, ScalarType18.UINT32, false, false),
picWidth: ProtoField18(9, ScalarType18.UINT32, false, false),
resId: ProtoField18(10, ScalarType18.STRING, true, false),
flag: ProtoField18(11, ScalarType18.BYTES, true, false),
thumbUrl: ProtoField18(12, ScalarType18.STRING, true, false),
original: ProtoField18(13, ScalarType18.INT32, false, false),
bigUrl: ProtoField18(14, ScalarType18.STRING, true, false),
origUrl: ProtoField18(15, ScalarType18.STRING, true, false),
bizType: ProtoField18(16, ScalarType18.INT32, false, false),
result: ProtoField18(17, ScalarType18.INT32, false, false),
index: ProtoField18(18, ScalarType18.INT32, false, false),
opFaceBuf: ProtoField18(19, ScalarType18.BYTES, true, false),
oldPicMd5: ProtoField18(20, ScalarType18.BOOL, false, false),
thumbWidth: ProtoField18(21, ScalarType18.INT32, false, false),
thumbHeight: ProtoField18(22, ScalarType18.INT32, false, false),
fileId: ProtoField18(23, ScalarType18.INT32, false, false),
showLen: ProtoField18(24, ScalarType18.UINT32, false, false),
downloadLen: ProtoField18(25, ScalarType18.UINT32, false, false),
x400Url: ProtoField18(26, ScalarType18.STRING, true, false),
x400Width: ProtoField18(27, ScalarType18.UINT32, false, false),
x400Height: ProtoField18(28, ScalarType18.UINT32, false, false),
pbRes: ProtoField18(29, () => ({
subType: ProtoField18(1, ScalarType18.INT32, false, false),
field3: ProtoField18(3, ScalarType18.INT32, false, false),
field4: ProtoField18(4, ScalarType18.INT32, false, false),
summary: ProtoField18(8, ScalarType18.STRING, true, false),
field10: ProtoField18(10, ScalarType18.INT32, false, false),
pbRes: ProtoField18(20, ScalarType18.BYTES, true, false),
url: ProtoField18(30, ScalarType18.STRING, true, false),
md5Str: ProtoField18(31, ScalarType18.STRING, true, false)
}), true, false)
});
// src/internal/packet/message/element/TransElement.ts
import { ProtoField as ProtoField19, ProtoMessage as ProtoMessage19, ScalarType as ScalarType19 } from "@tanebijs/protobuf";
var TransElement = ProtoMessage19.of({
elemType: ProtoField19(1, ScalarType19.INT32, false, false),
elemValue: ProtoField19(2, ScalarType19.BYTES, true, false)
});
// src/internal/packet/message/element/MarketFaceElement.ts
import { ProtoField as ProtoField20, ProtoMessage as ProtoMessage20, ScalarType as ScalarType20 } from "@tanebijs/protobuf";
var MarketFaceElement = ProtoMessage20.of({
summary: ProtoField20(1, ScalarType20.STRING, true, false),
itemType: ProtoField20(2, ScalarType20.INT32, false, false),
info: ProtoField20(3, ScalarType20.INT32, false, false),
faceId: ProtoField20(4, ScalarType20.BYTES, true, false),
tabId: ProtoField20(5, ScalarType20.INT32, false, false),
subType: ProtoField20(6, ScalarType20.INT32, false, false),
key: ProtoField20(7, ScalarType20.STRING, true, false),
width: ProtoField20(10, ScalarType20.INT32, false, false),
height: ProtoField20(11, ScalarType20.INT32, false, false),
pbReserve: ProtoField20(13, () => MarketfaceReserve.fields, true, false)
});
var MarketfaceReserve = ProtoMessage20.of({
field8: ProtoField20(8, ScalarType20.INT32, false, false)
});
// src/internal/packet/message/element/CustomFaceElement.ts
import { ProtoField as ProtoField21, ProtoMessage as ProtoMessage21, ScalarType as ScalarType21 } from "@tanebijs/protobuf";
var CustomFaceElement = ProtoMessage21.of({
guid: ProtoField21(1, ScalarType21.BYTES, true, false),
filePath: ProtoField21(2, ScalarType21.STRING, true, false),
shortcut: ProtoField21(3, ScalarType21.STRING, true, false),
buffer: ProtoField21(4, ScalarType21.BYTES, true, false),
flag: ProtoField21(5, ScalarType21.BYTES, true, false),
oldData: ProtoField21(6, ScalarType21.BYTES, true, false),
fileId: ProtoField21(7, ScalarType21.UINT32, false, false),
serverIp: ProtoField21(8, ScalarType21.INT32, true, false),
serverPort: ProtoField21(9, ScalarType21.INT32, true, false),
fileType: ProtoField21(10, ScalarType21.INT32, false, false),
signature: ProtoField21(11, ScalarType21.BYTES, true, false),
useful: ProtoField21(12, ScalarType21.INT32, false, false),
md5: ProtoField21(13, ScalarType21.BYTES, true, false),
thumbUrl: ProtoField21(14, ScalarType21.STRING, true, false),
bigUrl: ProtoField21(15, ScalarType21.STRING, true, false),
origUrl: ProtoField21(16, ScalarType21.STRING, true, false),
bizType: ProtoField21(17, ScalarType21.INT32, false, false),
repeatIndex: ProtoField21(18, ScalarType21.INT32, false, false),
repeatImage: ProtoField21(19, ScalarType21.INT32, false, false),
imageType: ProtoField21(20, ScalarType21.INT32, false, false),
index: ProtoField21(21, ScalarType21.INT32, false, false),
width: ProtoField21(22, ScalarType21.INT32, false, false),
height: ProtoField21(23, ScalarType21.INT32, false, false),
source: ProtoField21(24, ScalarType21.INT32, false, false),
size: ProtoField21(25, ScalarType21.UINT32, false, false),
origin: ProtoField21(26, ScalarType21.INT32, false, false),
thumbWidth: ProtoField21(27, ScalarType21.INT32, true, false),
thumbHeight: ProtoField21(28, ScalarType21.INT32, true, false),
showLen: ProtoField21(29, ScalarType21.INT32, false, false),
downloadLen: ProtoField21(30, ScalarType21.INT32, false, false),
x400Url: ProtoField21(31, ScalarType21.STRING, true, false),
x400Width: ProtoField21(32, ScalarType21.INT32, false, false),
x400Height: ProtoField21(33, ScalarType21.INT32, false, false),
pbReserve: ProtoField21(34, () => ({
subType: ProtoField21(1, ScalarType21.INT32, false, false),
field3: ProtoField21(3, ScalarType21.INT32, false, false),
field4: ProtoField21(4, ScalarType21.INT32, false, false),
summary: ProtoField21(9, ScalarType21.STRING, true, false),
field10: ProtoField21(10, ScalarType21.INT32, false, false),
pbRes: ProtoField21(21, ScalarType21.BYTES, true, false)
}), true, false)
});
// src/internal/packet/message/element/ElementFlags2.ts
import { ProtoField as ProtoField22, ProtoMessage as ProtoMessage22, ScalarType as ScalarType22 } from "@tanebijs/protobuf";
var ElementFlags2 = ProtoMessage22.of({
colorTextId: ProtoField22(1, ScalarType22.UINT32, false, false),
msgId: ProtoField22(2, ScalarType22.UINT64, false, false),
whisperSessionId: ProtoField22(3, ScalarType22.UINT32, false, false),
pttChangeBit: ProtoField22(4, ScalarType22.UINT32, false, false),
vipStatus: ProtoField22(5, ScalarType22.UINT32, false, false),
compatibleId: ProtoField22(6, ScalarType22.UINT32, false, false),
insts: ProtoField22(7, () => Instance.fields, false, true),
msgRptCnt: ProtoField22(8, ScalarType22.UINT32, false, false),
srcInst: ProtoField22(9, () => Instance.fields, true, false),
longtitude: ProtoField22(10, ScalarType22.UINT32, false, false),
latitude: ProtoField22(11, ScalarType22.UINT32, false, false),
customFont: ProtoField22(12, ScalarType22.UINT32, false, false),
pcSupportDef: ProtoField22(13, () => PcSupportDef.fields, true, false),
crmFlags: ProtoField22(14, ScalarType22.UINT32, true, false)
});
var Instance = ProtoMessage22.of({
appId: ProtoField22(1, ScalarType22.UINT32, false, false),
instId: ProtoField22(2, ScalarType22.UINT32, false, false)
});
var PcSupportDef = ProtoMessage22.of({
pcPtlBegin: ProtoField22(1, ScalarType22.UINT32, false, false),
pcPtlEnd: ProtoField22(2, ScalarType22.UINT32, false, false),
macPtlBegin: ProtoField22(3, ScalarType22.UINT32, false, false),
macPtlEnd: ProtoField22(4, ScalarType22.UINT32, false, false),
ptlsSupport: ProtoField22(5, ScalarType22.UINT32, false, true),
ptlsNotSupport: ProtoField22(6, ScalarType22.UINT32, false, true)
});
// src/internal/packet/message/element/RichMsgElement.ts
import { ProtoField as ProtoField23, ProtoMessage as ProtoMessage23, ScalarType as ScalarType23 } from "@tanebijs/protobuf";
var RichMsgElement = ProtoMessage23.of({
template1: ProtoField23(1, ScalarType23.BYTES, true, false),
serviceId: ProtoField23(2, ScalarType23.INT32, true, false),
msgResId: ProtoField23(3, ScalarType23.BYTES, true, false),
rand: ProtoField23(4, ScalarType23.INT32, true, false),
seq: ProtoField23(5, ScalarType23.INT32, true, false)
});
// src/internal/packet/message/element/GroupFileElement.ts
import { ProtoField as ProtoField24, ProtoMessage as ProtoMessage24, ScalarType as ScalarType24 } from "@tanebijs/protobuf";
var GroupFileElement = ProtoMessage24.of({
filename: ProtoField24(1, ScalarType24.STRING, true, false),
fileSize: ProtoField24(2, ScalarType24.INT64, false, false),
fileId: ProtoField24(3, ScalarType24.BYTES, true, false),
batchId: ProtoField24(4, ScalarType24.BYTES, true, false),
fileKey: ProtoField24(5, ScalarType24.BYTES, true, false),
mark: ProtoField24(6, ScalarType24.BYTES, true, false),
sequence: ProtoField24(7, ScalarType24.INT64, false, false),
batchItemId: ProtoField24(8, ScalarType24.BYTES, true, false),
feedMsgTime: ProtoField24(9, ScalarType24.INT32, false, false),
pbReserve: ProtoField24(10, ScalarType24.BYTES, true, false)
});
// src/internal/packet/message/element/ExtraInfoElement.ts
import { ProtoField as ProtoField25, ProtoMessage as ProtoMessage25, ScalarType as ScalarType25 } from "@tanebijs/protobuf";
var ExtraInfoElement = ProtoMessage25.of({
nick: ProtoField25(1, ScalarType25.STRING, true, false),
groupCard: ProtoField25(2, ScalarType25.STRING, true, false),
level: ProtoField25(3, ScalarType25.INT32, false, false),
flags: ProtoField25(4, ScalarType25.INT32, false, false),
groupMask: ProtoField25(5, ScalarType25.INT32, false, false),
msgTailId: ProtoField25(6, ScalarType25.INT32, false, false),
senderTitle: ProtoField25(7, ScalarType25.STRING, true, false),
apnsTips: ProtoField25(8, ScalarType25.BYTES, true, false),
uin: ProtoField25(9, ScalarType25.UINT64, false, false),
msgStateFlag: ProtoField25(10, ScalarType25.INT32, false, false),
apnsSoundType: ProtoField25(11, ScalarType25.INT32, false, false),
newGroupFlag: ProtoField25(12, ScalarType25.INT32, false, false)
});
// src/internal/packet/message/element/VideoFileElement.ts
import { ProtoField as ProtoField26, ProtoMessage as ProtoMessage26, ScalarType as ScalarType26 } from "@tanebijs/protobuf";
var VideoFileElement = ProtoMessage26.of({
fileUuid: ProtoField26(1, ScalarType26.STRING, true, false),
fileMd5: ProtoField26(2, ScalarType26.BYTES, true, false),
fileName: ProtoField26(3, ScalarType26.STRING, true, false),
fileFormat: ProtoField26(4, ScalarType26.INT32, false, false),
fileTime: ProtoField26(5, ScalarType26.INT32, false, false),
fileSize: ProtoField26(6, ScalarType26.INT32, false, false),
thumbWidth: ProtoField26(7, ScalarType26.INT32, false, false),
thumbHeight: ProtoField26(8, ScalarType26.INT32, false, false),
thumbFileMd5: ProtoField26(9, ScalarType26.BYTES, true, false),
source: ProtoField26(10, ScalarType26.BYTES, true, false),
thumbFileSize: ProtoField26(11, ScalarType26.INT32, false, false),
busiType: ProtoField26(12, ScalarType26.INT32, false, false),
fromChatType: ProtoField26(13, ScalarType26.INT32, false, false),
toChatType: ProtoField26(14, ScalarType26.INT32, false, false),
boolSupportProgressive: ProtoField26(15, ScalarType26.BOOL, false, false),
fileWidth: ProtoField26(16, ScalarType26.INT32, false, false),
fileHeight: ProtoField26(17, ScalarType26.INT32, false, false),
subBusiType: ProtoField26(18, ScalarType26.INT32, false, false),
videoAttr: ProtoField26(19, ScalarType26.INT32, false, false),
bytesThumbFileUrls: ProtoField26(20, ScalarType26.BYTES, false, true),
bytesVideoFileUrls: ProtoField26(21, ScalarType26.BYTES, false, true),
thumbDownloadFlag: ProtoField26(22, ScalarType26.INT32, false, false),
videoDownloadFlag: ProtoField26(23, ScalarType26.INT32, false, false),
pbReserve: ProtoField26(24, ScalarType26.BYTES, true, false)
});
// src/internal/packet/message/element/AnonymousGroupMessageElement.ts
import { ProtoField as ProtoField27, ProtoMessage as ProtoMessage27, ScalarType as ScalarType27 } from "@tanebijs/protobuf";
var AnonymousGroupMessageElement = ProtoMessage27.of({
flags: ProtoField27(1, ScalarType27.INT32, false, false),
anonId: ProtoField27(2, ScalarType27.BYTES, true, false),
anonNick: ProtoField27(3, ScalarType27.STRING, true, false),
headPortrait: ProtoField27(4, ScalarType27.INT32, false, false),
expireTime: ProtoField27(5, ScalarType27.INT32, false, false),
bubbleId: ProtoField27(6, ScalarType27.INT32, false, false),
rankColor: ProtoField27(7, ScalarType27.BYTES, true, false)
});
// src/internal/packet/message/element/QQWalletMsgElement.ts
import { ProtoField as ProtoField28, ProtoMessage as ProtoMessage28, ScalarType as ScalarType28 } from "@tanebijs/protobuf";
var QQWalletMsgElement = ProtoMessage28.of({
type: ProtoField28(1, () => ({
sendUin: ProtoField28(1, ScalarType28.UINT64, false, false),
sender: ProtoField28(2, () => QQWalletAioElem.fields, true, false),
receiver: ProtoField28(3, () => QQWalletAioElem.fields, true, false),
channelId: ProtoField28(4, ScalarType28.INT32, false, false),
templateId: ProtoField28(5, ScalarType28.INT32, false, false),
resend: ProtoField28(6, ScalarType28.UINT32, false, false),
msgPriority: ProtoField28(7, ScalarType28.UINT32, false, false),
redType: ProtoField28(8, ScalarType28.INT32, false, false),
billNo: ProtoField28(9, ScalarType28.BYTES, true, false),
authKey: ProtoField28(10, ScalarType28.BYTES, true, false),
sessionType: ProtoField28(11, ScalarType28.INT32, false, false),
msgType: ProtoField28(12, ScalarType28.INT32, false, false),
envelOpeId: ProtoField28(13, ScalarType28.INT32, false, false),
name: ProtoField28(14, ScalarType28.BYTES, true, false),
confType: ProtoField28(15, ScalarType28.INT32, false, false),
msgFrom: ProtoField28(16, ScalarType28.INT32, false, false),
pcBody: ProtoField28(17, ScalarType28.BYTES, true, false),
index: ProtoField28(18, ScalarType28.BYTES, true, false),
redChannel: ProtoField28(19, ScalarType28.UINT32, false, false),
grapUin: ProtoField28(20, ScalarType28.UINT64, false, true),
pbReserve: ProtoField28(21, ScalarType28.BYTES, true, false)
}), true, false)
});
var QQWalletAioElem = ProtoMessage28.of({
background: ProtoField28(1, ScalarType28.UINT32, false, false),
icon: ProtoField28(2, ScalarType28.UINT32, false, false),
title: ProtoField28(3, ScalarType28.STRING, true, false),
subtitle: ProtoField28(4, ScalarType28.STRING, true, false),
content: ProtoField28(5, ScalarType28.STRING, true, false),
linkUrl: ProtoField28(6, ScalarType28.BYTES, true, false),
blackStripe: ProtoField28(7, ScalarType28.BYTES, true, false),
notice: ProtoField28(8, ScalarType28.BYTES, true, false),
titleColor: ProtoField28(9, ScalarType28.UINT32, false, false),
subtitleColor: ProtoField28(10, ScalarType28.UINT32, false, false),
actionsPriority: ProtoField28(11, ScalarType28.BYTES, true, false),
jumpUrl: ProtoField28(12, ScalarType28.BYTES, true, false),
nativeIos: ProtoField28(13, ScalarType28.BYTES, true, false),
nativeAndroid: ProtoField28(14, ScalarType28.BYTES, true, false),
iconUrl: ProtoField28(15, ScalarType28.BYTES, true, false),
contentColor: ProtoField28(16, ScalarType28.UINT32, false, false),
contentBgColor: ProtoField28(17, ScalarType28.UINT32, false, false),
aioImageLeft: ProtoField28(18, ScalarType28.BYTES, true, false),
aioImageRight: ProtoField28(19, ScalarType28.BYTES, true, false),
cftImage: ProtoField28(20, ScalarType28.BYTES, true, false),
pbReserve: ProtoField28(21, ScalarType28.BYTES, true, false)
});
// src/internal/packet/message/element/CustomElement.ts
import { ProtoField as ProtoField29, ProtoMessage as ProtoMessage29, ScalarType as ScalarType29 } from "@tanebijs/protobuf";
var CustomElement = ProtoMessage29.of({
desc: ProtoField29(1, ScalarType29.BYTES, true, false),
data: ProtoField29(2, ScalarType29.BYTES, true, false),
enumType: ProtoField29(3, ScalarType29.INT32, false, false),
ext: ProtoField29(4, ScalarType29.BYTES, true, false),
sound: ProtoField29(5, ScalarType29.BYTES, true, false)
});
// src/internal/packet/message/element/GeneralFlagsElement.ts
import { ProtoField as ProtoField30, ProtoMessage as ProtoMessage30, ScalarType as ScalarType30 } from "@tanebijs/protobuf";
var GeneralFlagsElement = ProtoMessage30.of({
bubbleDiyTextId: ProtoField30(1, ScalarType30.INT32, false, false),
groupFlagNew: ProtoField30(2, ScalarType30.INT32, false, false),
uin: ProtoField30(3, ScalarType30.UINT64, false, false),
rpId: ProtoField30(4, ScalarType30.BYTES, true, false),
prpFold: ProtoField30(5, ScalarType30.INT32, false, false),
longTextFlag: ProtoField30(6, ScalarType30.INT32, false, false),
longTextResId: ProtoField30(7, ScalarType30.STRING, true, false),
groupType: ProtoField30(8, ScalarType30.INT32, false, false),
toUinFlag: ProtoField30(9, ScalarType30.INT32, false, false),
glamourLevel: ProtoField30(10, ScalarType30.INT32, false, false),
memberLevel: ProtoField30(11, ScalarType30.INT32, false, false),
groupRankSeq: ProtoField30(12, ScalarType30.INT64, false, false),
olympicTorch: ProtoField30(13, ScalarType30.INT32, false, false),
babyqGuideMsgCookie: ProtoField30(14, ScalarType30.BYTES, true, false),
uin32ExpertFlag: ProtoField30(15, ScalarType30.INT32, false, false),
bubbleSubId: ProtoField30(16, ScalarType30.INT32, false, false),
pendantId: ProtoField30(17, ScalarType30.INT64, false, false),
rpIndex: ProtoField30(18, ScalarType30.BYTES, true, false),
pbReserve: ProtoField30(19, ScalarType30.BYTES, true, false)
});
// src/internal/packet/message/element/SrcMsgElement.ts
import { ProtoField as ProtoField31, ProtoMessage as ProtoMessage31, ScalarType as ScalarType31 } from "@tanebijs/protobuf";
var SrcMsgElement = ProtoMessage31.of({
origSeqs: ProtoField31(1, ScalarType31.UINT32, false, true),
senderUin: ProtoField31(2, ScalarType31.UINT32, false, false),
time: ProtoField31(3, ScalarType31.INT32, true, false),
flag: ProtoField31(4, ScalarType31.INT32, true, false),
elems: ProtoField31(5, ScalarType31.BYTES, false, true),
type: ProtoField31(6, ScalarType31.INT32, true, false),
richMsg: ProtoField31(7, ScalarType31.BYTES, true, false),
pbReserve: ProtoField31(8, () => ({
messageId: ProtoField31(3, ScalarType31.UINT64),
senderUid: ProtoField31(6, ScalarType31.STRING, true),
receiverUid: ProtoField31(7, ScalarType31.STRING, true),
friendSequence: ProtoField31(8, ScalarType31.UINT32, true)
}), true, false),
sourceMsg: ProtoField31(9, ScalarType31.BYTES, true, false),
toUin: ProtoField31(10, ScalarType31.UINT32, true, false),
troopName: ProtoField31(11, ScalarType31.BYTES, true, false)
});
// src/internal/packet/message/element/LightAppElement.ts
import { ProtoField as ProtoField32, ProtoMessage as ProtoMessage32, ScalarType as ScalarType32 } from "@tanebijs/protobuf";
var LightAppElement = ProtoMessage32.of({
data: ProtoField32(1, ScalarType32.BYTES, true, false),
msgResid: ProtoField32(2, ScalarType32.BYTES, true, false)
});
// src/internal/packet/message/element/CommonElement.ts
import { ProtoField as ProtoField33, ProtoMessage as ProtoMessage33, ScalarType as ScalarType33 } from "@tanebijs/protobuf";
var CommonElement = ProtoMessage33.of({
serviceType: ProtoField33(1, ScalarType33.INT32, false, false),
pbElement: ProtoField33(2, ScalarType33.BYTES, true, false),
businessType: ProtoField33(3, ScalarType33.UINT32, false, false)
});
// src/internal/packet/message/MessageElement.ts
var MessageElement = ProtoMessage34.of({
text: ProtoField34(1, () => TextElement.fields, true, false),
face: ProtoField34(2, () => FaceElement.fields, true, false),
onlineImage: ProtoField34(3, () => OnlineImageElement.fields, true, false),
notOnlineImage: ProtoField34(4, () => NotOnlineImageElement.fields, true, false),
trans: ProtoField34(5, () => TransElement.fields, true, false),
marketFace: ProtoField34(6, () => MarketFaceElement.fields, true, false),
customFace: ProtoField34(8, () => CustomFaceElement.fields, true, false),
flags2: ProtoField34(9, () => ElementFlags2.fields, true, false),
richMsg: ProtoField34(12, () => RichMsgElement.fields, true, false),
groupFile: ProtoField34(13, () => GroupFileElement.fields, true, false),
extraInfo: ProtoField34(16, () => ExtraInfoElement.fields, true, false),
videoFile: ProtoField34(19, () => VideoFileElement.fields, true, false),
anonGroupMsg: ProtoField34(21, () => AnonymousGroupMessageElement.fields, true, false),
qqWalletMsg: ProtoField34(24, () => QQWalletMsgElement.fields, true, false),
custom: ProtoField34(31, () => CustomElement.fields, true, false),
generalFlags: ProtoField34(37, () => GeneralFlagsElement.fields, true, false),
srcMsg: ProtoField34(45, () => SrcMsgElement.fields, true, false),
lightApp: ProtoField34(51, () => LightAppElement.fields, true, false),
common: ProtoField34(53, () => CommonElement.fields, true, false)
});
// src/internal/message/incoming/index.ts
var incomingSegments = new IncomingSegmentCollection([
textParser,
mentionParser,
faceOldFaceParser,
faceCommonParser,
imageCommonParser,
recordParser,
videoParser,
forwardParser,
imageNotOnlineParser,
imageCustomFaceParser,
lightAppParser
]);
var blob = Symbol("Raw PushMsgBody");
var rawElems = Symbol("Raw elements");
var msgUid = Symbol("Message UID");
function parsePushMsgBody(raw) {
const pushMsgBody = PushMsgBody.decode(raw);
const result = parseMetadata(pushMsgBody, raw);
if (pushMsgBody.body?.richText?.elements) {
const elementsDecoded = pushMsgBody.body.richText.elements.map((element) => MessageElement.decode(element));
for (const element of elementsDecoded) {
const previous = result.segments.length === 0 ? void 0 : result.segments[result.segments.length - 1];
if (!result.repliedSequence && element.srcMsg) {
result.repliedSequence = element.srcMsg.pbReserve?.friendSequence ?? element.srcMsg.origSeqs?.[0];
continue;
}
if (element.extraInfo && result.type === 2 /* GroupMessage */) {
result.senderDataBindingUpdate = {
nickname: element.extraInfo.nick,
card: element.extraInfo.groupCard,
level: element.extraInfo.level,
specialTitle: element.extraInfo.senderTitle
};
}
const parsed = incomingSegments.parse(element);
if (parsed) {
if (previous?.type === "face" && parsed.type === "text" && previous.isInLargeCategory) continue;
result.segments.push(parsed);
}
}
}
if (result.repliedSequence && result.type === 2 /* GroupMessage */ && result.segments[0]?.type === "mention" && result.segments[1]?.type === "text") {
result.segments = result.segments.slice(2);
}
return result;
}
function parseMetadata(pushMsg, raw) {
if (!pushMsg.responseHead.groupExt) {
return {
type: 1 /* PrivateMessage */,
time: pushMsg.contentHead.timestamp,
senderUin: pushMsg.responseHead.fromUin,
targetUin: pushMsg.responseHead.toUin,
senderUid: pushMsg.responseHead.fromUid,
targetUid: pushMsg.responseHead.toUid,
senderName: pushMsg.responseHead.friendExt?.friendName ?? "",
sequence: pushMsg.contentHead.ntMsgSeq ?? 0,
segments: [],
forwardAvatarUrl: pushMsg.contentHead.forward?.avatar,
[blob]: raw,
[rawElems]: pushMsg.body?.richText?.elements ?? [],
[msgUid]: pushMsg.contentHead.msgUid,
clientSequence: pushMsg.contentHead.sequence ?? 0,
random: pushMsg.contentHead.random ?? 0,
isTemporary: pushMsg.contentHead.type === 141 /* TempMessage */
};
} else {
return {
type: 2 /* GroupMessage */,
time: pushMsg.contentHead.timestamp,
groupUin: pushMsg.responseHead.groupExt.groupUin,
senderUin: pushMsg.responseHead.fromUin,
targetUin: pushMsg.responseHead.toUin,
senderUid: pushMsg.responseHead.fromUid,
senderName: pushMsg.responseHead.groupExt.memberName,
sequence: pushMsg.contentHead.sequence ?? 0,
segments: [],
forwardAvatarUrl: pushMsg.contentHead.forward?.avatar,
[blob]: raw,
[rawElems]: pushMsg.body?.richText?.elements ?? [],
[msgUid]: pushMsg.contentHead.msgUid
};
}
}
// src/message/MessageDispatcher.ts
import { EventEmitter } from "events";
var rawMessage = Symbol("Raw message");
var MessageDispatcher = class {
constructor(bot) {
this.bot = bot;
}
global = new EventEmitter();
async emit(incoming) {
const contact = await this.resolveContact(incoming);
if (!contact) {
return;
}
if (incoming.segments.length === 0) {
return;
}
const message = await this.create(incoming, contact);
if (!message) {
return;
}
await this.dispatch(message, incoming, contact);
}
async create(incoming, contact) {
const segments = incoming.segments;
const firstSegment = segments[0];
if (segments.length === 1) {
if (firstSegment.type === "image"