mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
feat: support node id in fake forward (with auto download richMedia in reference message)
This commit is contained in:
parent
0be6effc32
commit
9f07b07c82
@ -6,6 +6,7 @@ import {
|
||||
Peer,
|
||||
PicElement,
|
||||
PicType,
|
||||
RawMessage,
|
||||
SendFileElement,
|
||||
SendPicElement,
|
||||
SendPttElement,
|
||||
@ -267,6 +268,29 @@ export class NTQQFileApi {
|
||||
return fileTransNotifyInfo.filePath;
|
||||
}
|
||||
|
||||
async downloadRawMsgMedia(msg: RawMessage[]) {
|
||||
const res = await Promise.all(msg.map(m =>
|
||||
this.downloadMedia(m.msgId, m.chatType, m.peerUid, m.elements[0].elementId, '', '', 1000 * 60 * 2, true)
|
||||
));
|
||||
msg.forEach((m, index) => {
|
||||
const element = m.elements[0];
|
||||
switch (element.elementType) {
|
||||
case ElementType.PIC:
|
||||
element.picElement!.sourcePath = res[index];
|
||||
break;
|
||||
case ElementType.VIDEO:
|
||||
element.videoElement!.filePath = res[index];
|
||||
break;
|
||||
case ElementType.PTT:
|
||||
element.pttElement!.filePath = res[index];
|
||||
break;
|
||||
case ElementType.FILE:
|
||||
element.fileElement!.filePath = res[index];
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async downloadMedia(msgId: string, chatType: ChatType, peerUid: string, elementId: string, thumbPath: string, sourcePath: string, timeout = 1000 * 60 * 2, force: boolean = false) {
|
||||
// 用于下载收到的消息中的图片等
|
||||
if (sourcePath && fs.existsSync(sourcePath)) {
|
||||
|
@ -203,6 +203,7 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
||||
}
|
||||
const msg = (await this.core.apis.MsgApi.getMsgsByMsgId(nodeMsg.Peer, [nodeMsg.MsgId])).msgList[0];
|
||||
logger.logDebug(`handleForwardedNodesPacket[PureRaw] 开始转换 ${JSON.stringify(msg)}`);
|
||||
await this.core.apis.FileApi.downloadRawMsgMedia([msg]);
|
||||
const transformedMsg = this.core.apis.PacketApi.packetSession?.packer.packetConverter.rawMsgToPacketMsg(msg);
|
||||
logger.logDebug(`handleForwardedNodesPacket[PureRaw] 转换为 ${JSON.stringify(transformedMsg)}`);
|
||||
packetMsg.push(transformedMsg!);
|
||||
|
Loading…
x
Reference in New Issue
Block a user