mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
feat: support node id in fake forward (with auto download richMedia in reference message)
This commit is contained in:
@@ -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)) {
|
||||
|
Reference in New Issue
Block a user