From 501031b39bc2f605f7a2c5493b4b086485a1cfe4 Mon Sep 17 00:00:00 2001 From: linyuchen Date: Thu, 7 Mar 2024 18:43:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=BD=91=E7=BB=9C=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E5=90=8E=E7=BC=80=E8=AF=86=E5=88=AB=20fix:=20=E7=BD=91?= =?UTF-8?q?=E7=BB=9C=E6=96=87=E4=BB=B6=E4=B8=8B=E8=BD=BD=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E7=9A=84=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manifest.json | 4 ++-- src/onebot11/action/SendMsg.ts | 5 ++++- src/onebot11/utils.ts | 10 ++++++++-- src/version.ts | 2 +- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/manifest.json b/manifest.json index f23606c..b05719c 100644 --- a/manifest.json +++ b/manifest.json @@ -1,10 +1,10 @@ { "manifest_version": 4, "type": "extension", - "name": "LLOneBot v3.13.6", + "name": "LLOneBot v3.13.7", "slug": "LLOneBot", "description": "LiteLoaderQQNT的OneBotApi", - "version": "3.13.6", + "version": "3.13.7", "thumbnail": "./icon.png", "authors": [ { diff --git a/src/onebot11/action/SendMsg.ts b/src/onebot11/action/SendMsg.ts index ecb1324..81c4ea5 100644 --- a/src/onebot11/action/SendMsg.ts +++ b/src/onebot11/action/SendMsg.ts @@ -330,7 +330,10 @@ export class SendMsg extends BaseAction { const file = sendMsg.data?.file const payloadFileName = sendMsg.data?.name if (file) { - const {path, isLocal, fileName} = (await uri2local(file)) + const {path, isLocal, fileName, errMsg} = (await uri2local(file)) + if (errMsg){ + throw errMsg + } if (path) { if (!isLocal) { // 只删除http和base64转过来的文件 deleteAfterSentFiles.push(path) diff --git a/src/onebot11/utils.ts b/src/onebot11/utils.ts index d74c254..812e891 100644 --- a/src/onebot11/utils.ts +++ b/src/onebot11/utils.ts @@ -33,7 +33,13 @@ export async function uri2local(uri: string, fileName: string = null) { } } else if (url.protocol == "http:" || url.protocol == "https:") { // 下载文件 - let fetchRes = await fetch(url) + let fetchRes: Response; + try{ + fetchRes = await fetch(url) + }catch (e) { + res.errMsg = `${url}下载失败` + return res + } if (!fetchRes.ok) { res.errMsg = `${url}下载失败,` + fetchRes.statusText return res @@ -46,7 +52,7 @@ export async function uri2local(uri: string, fileName: string = null) { fileName = pathInfo.name if (pathInfo.ext){ fileName += pathInfo.ext - res.ext = pathInfo.ext + // res.ext = pathInfo.ext } } res.fileName = fileName diff --git a/src/version.ts b/src/version.ts index 5633f79..63485bf 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const version = "3.13.6" \ No newline at end of file +export const version = "3.13.7" \ No newline at end of file