This commit is contained in:
pk5ls20 committed 2025-02-05 08:07:58 +08:00
1 parent eb1140d7ba
commit b758a06ceb
13 files changed
+508 -105

No files matched your search

+16 -2
View File
@@ -1,8 +1,8 @@
import {
Peer,
ChatType,
ElementType,
MessageElement,
Peer,
RawMessage,
SendArkElement,
SendFaceElement,
@@ -31,7 +31,9 @@ import {
PacketMsgVideoElement,
PacketMultiMsgElement
} from '@/core/packet/message/element';
import { PacketMsg, PacketSendMsgElement } from '@/core/packet/message/message';
import {PacketMsg, PacketSendMsgElement} from '@/core/packet/message/message';
import {NapProtoDecodeStructType} from '@napneko/nap-proto-core';
import {Elem} from '@/core/packet/transformer/proto';
const SupportedElementTypes = [
ElementType.TEXT,
@@ -154,4 +156,16 @@ export class PacketMsgConverter {
}).filter((e) => e !== null)
};
}
packetMsgToRaw(msg: NapProtoDecodeStructType<typeof Elem>[]): [MessageElement, NapProtoDecodeStructType<typeof Elem> | null][] {
const converters = [PacketMsgTextElement.parseElement,
PacketMsgAtElement.parseElement, PacketMsgReplyElement.parseElement, PacketMsgPicElement.parseElement];
return msg.map((element) => {
for (const converter of converters) {
const result = converter(element);
if (result) return result;
}
return null;
}).filter((e) => e !== null);
}
}