From 8ca30de760c072d72969eefdc67b7c6771088955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Thu, 22 Aug 2024 14:26:49 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E5=85=BC=E5=AE=B9=E6=80=A7=E6=8F=90?= =?UTF-8?q?=E9=AB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/onebot/action/msg/SendMsg/create-send-elements.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/onebot/action/msg/SendMsg/create-send-elements.ts b/src/onebot/action/msg/SendMsg/create-send-elements.ts index 2c9667f0..9398c640 100644 --- a/src/onebot/action/msg/SendMsg/create-send-elements.ts +++ b/src/onebot/action/msg/SendMsg/create-send-elements.ts @@ -17,14 +17,21 @@ async function handleOb11FileLikeMessage( { data: inputdata }: OB11MessageFileBase, { 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 { path, isLocal, fileName, errMsg, success, - } = (await uri2local(coreContext.NapCatTempPath, inputdata?.url || inputdata.file)); + } = (await uri2local(coreContext.NapCatTempPath, fileOrUrl)); if (!success) { coreContext.context.logger.logError('文件下载失败', errMsg);