This commit is contained in:
手瓜一十雪 2024-08-01 19:43:29 +08:00
parent 773cdc5877
commit 3cc2f1dcad
2 changed files with 6 additions and 7 deletions

View File

@ -12,11 +12,10 @@ import {
SignMusicWrapper
} from '@/core';
import { getGroupMember } from '@/core/data';
import { logDebug, logError, logWarn } from '@/common/utils/log';
import { logError, logWarn } from '@/common/utils/log';
import { uri2local } from '@/common/utils/file';
import { ob11Config } from '@/onebot11/config';
import { RequestUtil } from '@/common/utils/request';
import fs from 'node:fs';
import { MessageUnique } from '@/common/utils/MessageUnique';
export type MessageContext = {
@ -25,12 +24,11 @@ export type MessageContext = {
}
async function handleOb11FileLikeMessage(
{ data: { file, name: payloadFileName } }: OB11MessageFileBase,
{ data: inputdata }: OB11MessageFileBase,
{ deleteAfterSentFiles }: MessageContext
) {
const uri = file;
const { path, isLocal, fileName, errMsg } = (await uri2local(uri));
//有的奇怪的框架将url作为参数 而不是file 此时优先url
let { path, isLocal, fileName, errMsg } = (await uri2local(inputdata?.url || inputdata.file));
if (errMsg) {
logError('文件下载失败', errMsg);
@ -41,7 +39,7 @@ async function handleOb11FileLikeMessage(
deleteAfterSentFiles.push(path);
}
return { path, fileName: payloadFileName || fileName };
return { path, fileName: inputdata.name || fileName };
}
const _handlers: {

View File

@ -174,6 +174,7 @@ export class OB11Constructor {
// message_data["data"]["file"] = element.picElement.sourcePath
message_data['data']['file'] = element.picElement.fileName;
message_data['data']['subType'] = element.picElement.picSubType;
message_data['data']['file_id'] = UUIDConverter.encode(msg.peerUin, msg.msgId);
// message_data["data"]["path"] = element.picElement.sourcePath
try {