From a5ce424a40f450422bd576de831079c48596ef5b 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: Sun, 1 Sep 2024 18:44:23 +0800 Subject: [PATCH] release: 2.2.36 --- manifest.json | 2 +- package.json | 2 +- src/common/version.ts | 2 +- src/onebot/action/file/GetFile.ts | 20 ++++++++++++++++---- src/webui/ui/NapCat.ts | 2 +- static/assets/renderer.js | 2 +- 6 files changed, 21 insertions(+), 9 deletions(-) diff --git a/manifest.json b/manifest.json index e47d5feb..f36eafe9 100644 --- a/manifest.json +++ b/manifest.json @@ -4,7 +4,7 @@ "name": "NapCatQQ", "slug": "NapCat.Framework", "description": "高性能的 OneBot 11 协议实现", - "version": "2.2.35", + "version": "2.2.36", "icon": "./logo.png", "authors": [ { diff --git a/package.json b/package.json index cd7744a0..8efd4560 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "napcat", "private": true, "type": "module", - "version": "2.2.35", + "version": "2.2.36", "scripts": { "build:framework": "vite build --mode framework", "build:shell": "vite build --mode shell", diff --git a/src/common/version.ts b/src/common/version.ts index 4a47e3d8..2eb6713b 100644 --- a/src/common/version.ts +++ b/src/common/version.ts @@ -1 +1 @@ -export const napCatVersion = '2.2.35'; +export const napCatVersion = '2.2.36'; diff --git a/src/onebot/action/file/GetFile.ts b/src/onebot/action/file/GetFile.ts index 5da768fe..77790b45 100644 --- a/src/onebot/action/file/GetFile.ts +++ b/src/onebot/action/file/GetFile.ts @@ -3,6 +3,7 @@ import fs from 'fs/promises'; import { FileNapCatOneBotUUID } from '@/common/helper'; import { ActionName } from '../types'; import { FromSchema, JSONSchema } from 'json-schema-to-ts'; +import { OB11MessageImage, OB11MessageVideo } from '@/onebot/types'; export interface GetFilePayload { file: string; // 文件名或者fileUuid @@ -33,16 +34,27 @@ export class GetFileBase extends BaseAction { if (contextMsgFile) { const { peer, msgId, elementId } = contextMsgFile; const downloadPath = await this.core.apis.FileApi.downloadMedia(msgId, peer.chatType, peer.peerUid, elementId, '', ''); - const mixElement = (await this.core.apis.MsgApi.getMsgsByMsgId(peer, [msgId]))?.msgList - .find(msg => msg.msgId === msgId)?.elements.find(e => e.elementId === elementId); + const rawMessage = (await this.core.apis.MsgApi.getMsgsByMsgId(peer, [msgId]))?.msgList + .find(msg => msg.msgId === msgId); + const mixElement = rawMessage?.elements.find(e => e.elementId === elementId); const mixElementInner = mixElement?.videoElement ?? mixElement?.fileElement ?? mixElement?.pttElement ?? mixElement?.picElement; if (!mixElementInner) throw new Error('element not found'); const fileSize = mixElementInner.fileSize?.toString() ?? ''; const fileName = mixElementInner.fileName ?? ''; - + let url = ''; + if (mixElement?.picElement && rawMessage) { + let tempData = + await this.obContext.apis.MsgApi.rawToOb11Converters.picElement?.(mixElement?.picElement, rawMessage, mixElement) as OB11MessageImage | undefined; + url = tempData?.data.url ?? ''; + } + if (mixElement?.videoElement && rawMessage) { + let tempData = + await this.obContext.apis.MsgApi.rawToOb11Converters.videoElement?.(mixElement?.videoElement, rawMessage, mixElement) as OB11MessageVideo | undefined; + url = tempData?.data.url ?? ''; + } const res: GetFileResponse = { file: downloadPath, - url: downloadPath, + url: url !== '' ? url : downloadPath, file_size: fileSize, file_name: fileName, }; diff --git a/src/webui/ui/NapCat.ts b/src/webui/ui/NapCat.ts index d87c12e0..54f1be35 100644 --- a/src/webui/ui/NapCat.ts +++ b/src/webui/ui/NapCat.ts @@ -30,7 +30,7 @@ async function onSettingWindowCreated(view: Element) { SettingItem( 'Napcat', undefined, - SettingButton('V2.2.35', 'napcat-update-button', 'secondary'), + SettingButton('V2.2.36', 'napcat-update-button', 'secondary'), ), ]), SettingList([ diff --git a/static/assets/renderer.js b/static/assets/renderer.js index d4ee95f7..d9884b07 100644 --- a/static/assets/renderer.js +++ b/static/assets/renderer.js @@ -164,7 +164,7 @@ async function onSettingWindowCreated(view) { SettingItem( 'Napcat', void 0, - SettingButton("V2.2.35", "napcat-update-button", "secondary") + SettingButton("V2.2.36", "napcat-update-button", "secondary") ) ]), SettingList([