chore: 兼容性提高

This commit is contained in:
手瓜一十雪
2024-08-22 14:26:49 +08:00
parent 8a10b81bd9
commit 8ca30de760

View File

@@ -17,14 +17,21 @@ async function handleOb11FileLikeMessage(
{ data: inputdata }: OB11MessageFileBase, { data: inputdata }: OB11MessageFileBase,
{ deleteAfterSentFiles }: MessageContext, { deleteAfterSentFiles }: MessageContext,
) { ) {
//有的奇怪的框架将url作为参数 而不是file 此时优先url 同时注意可能传入的是非file://开头的目录 By Mlikiowa //inputdata?.url || inputdata.file
const isBlankUrl = !inputdata.url || inputdata.url === '';
const isBlankFile = !inputdata.file || inputdata.file === '';
if (isBlankUrl && isBlankFile) {
coreContext.context.logger.logError('文件消息缺少参数', inputdata);
throw Error('文件消息缺少参数');
}
const fileOrUrl = (isBlankUrl ? inputdata.file : inputdata.url) || "";
const { const {
path, path,
isLocal, isLocal,
fileName, fileName,
errMsg, errMsg,
success, success,
} = (await uri2local(coreContext.NapCatTempPath, inputdata?.url || inputdata.file)); } = (await uri2local(coreContext.NapCatTempPath, fileOrUrl));
if (!success) { if (!success) {
coreContext.context.logger.logError('文件下载失败', errMsg); coreContext.context.logger.logError('文件下载失败', errMsg);