fix: get file way 01 get by msg & seq id

This commit is contained in:
Wesley F. Young 2024-08-31 20:30:42 +08:00
parent 3f24461612
commit f1643ac549
2 changed files with 5 additions and 21 deletions

View File

@ -259,7 +259,7 @@ export class NTQQFileApi {
return sourcePath;
}
}
await this.core.eventWrapper.callNormalEventV2(
const [, completeRetData] = await this.core.eventWrapper.callNormalEventV2(
'NodeIKernelMsgService/downloadRichMedia',
'NodeIKernelMsgListener/onRichMediaDownloadComplete',
[{
@ -279,24 +279,7 @@ export class NTQQFileApi {
1,
timeout,
);
const mixElement = (await this.core.apis.MsgApi.getMsgsByMsgId({
guildId: '',
chatType: chatType,
peerUid: peerUid,
}, [msgId])).msgList
.find((msg) => msg.msgId === msgId)
?.elements.find((e) => e.elementId === elementId);
const mixElementInner = mixElement?.videoElement
?? mixElement?.fileElement
?? mixElement?.pttElement
?? mixElement?.picElement;
let realPath = mixElementInner?.filePath;
if (!realPath) {
const picThumbPath: Map<number, string> = (mixElementInner as any)?.picThumbPath;
const picThumbPathList = Array.from(picThumbPath.values());
if (picThumbPathList.length > 0) realPath = picThumbPathList[0];
}
return realPath;
return completeRetData.filePath;
}
async getImageSize(filePath: string): Promise<ISizeCalculationResult> {

View File

@ -106,12 +106,13 @@ export class OneBotMsgApi {
peerUid: msg.peerUid,
guildId: '',
};
const encodedFileId = FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId);
return {
type: OB11MessageDataType.image,
data: {
file: element.fileName,
file: encodedFileId,
sub_type: element.picSubType,
file_id: FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId),
file_id: encodedFileId,
url: await this.core.apis.FileApi.getImageUrl(element),
file_size: element.fileSize,
},