fix: 网络视频后缀识别

fix: 网络文件下载失败的错误提示
This commit is contained in:
linyuchen
2024-03-07 18:43:47 +08:00
parent 7bfb3f2003
commit 501031b39b
4 changed files with 15 additions and 6 deletions

View File

@@ -1,10 +1,10 @@
{ {
"manifest_version": 4, "manifest_version": 4,
"type": "extension", "type": "extension",
"name": "LLOneBot v3.13.6", "name": "LLOneBot v3.13.7",
"slug": "LLOneBot", "slug": "LLOneBot",
"description": "LiteLoaderQQNT的OneBotApi", "description": "LiteLoaderQQNT的OneBotApi",
"version": "3.13.6", "version": "3.13.7",
"thumbnail": "./icon.png", "thumbnail": "./icon.png",
"authors": [ "authors": [
{ {

View File

@@ -330,7 +330,10 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
const file = sendMsg.data?.file const file = sendMsg.data?.file
const payloadFileName = sendMsg.data?.name const payloadFileName = sendMsg.data?.name
if (file) { if (file) {
const {path, isLocal, fileName} = (await uri2local(file)) const {path, isLocal, fileName, errMsg} = (await uri2local(file))
if (errMsg){
throw errMsg
}
if (path) { if (path) {
if (!isLocal) { // 只删除http和base64转过来的文件 if (!isLocal) { // 只删除http和base64转过来的文件
deleteAfterSentFiles.push(path) deleteAfterSentFiles.push(path)

View File

@@ -33,7 +33,13 @@ export async function uri2local(uri: string, fileName: string = null) {
} }
} else if (url.protocol == "http:" || url.protocol == "https:") { } 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) { if (!fetchRes.ok) {
res.errMsg = `${url}下载失败,` + fetchRes.statusText res.errMsg = `${url}下载失败,` + fetchRes.statusText
return res return res
@@ -46,7 +52,7 @@ export async function uri2local(uri: string, fileName: string = null) {
fileName = pathInfo.name fileName = pathInfo.name
if (pathInfo.ext){ if (pathInfo.ext){
fileName += pathInfo.ext fileName += pathInfo.ext
res.ext = pathInfo.ext // res.ext = pathInfo.ext
} }
} }
res.fileName = fileName res.fileName = fileName

View File

@@ -1 +1 @@
export const version = "3.13.6" export const version = "3.13.7"