From 919705966c01c8e38aeaa77d640d1dba16f75124 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: Mon, 9 Sep 2024 09:19:23 +0800 Subject: [PATCH] build: 2.4.1 --- manifest.json | 2 +- package.json | 2 +- src/common/version.ts | 2 +- src/core/apis/group.ts | 8 ++--- src/onebot/api/group.ts | 4 ++- src/onebot/api/msg.ts | 33 ++++++++++++------- .../notice/OB11GroupUploadNoticeEvent.ts | 1 + src/onebot/types/message.ts | 1 + src/webui/ui/NapCat.ts | 2 +- static/assets/renderer.js | 2 +- 10 files changed, 35 insertions(+), 22 deletions(-) diff --git a/manifest.json b/manifest.json index a44cf36e..f7b01876 100644 --- a/manifest.json +++ b/manifest.json @@ -4,7 +4,7 @@ "name": "NapCatQQ", "slug": "NapCat.Framework", "description": "高性能的 OneBot 11 协议实现", - "version": "2.4.0", + "version": "2.4.1", "icon": "./logo.png", "authors": [ { diff --git a/package.json b/package.json index 02d1b36e..22045061 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "napcat", "private": true, "type": "module", - "version": "2.4.0", + "version": "2.4.1", "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 0e9301de..fb5716b7 100644 --- a/src/common/version.ts +++ b/src/common/version.ts @@ -1 +1 @@ -export const napCatVersion = '2.4.0'; +export const napCatVersion = '2.4.1'; diff --git a/src/core/apis/group.ts b/src/core/apis/group.ts index 9dd48271..00ec0098 100644 --- a/src/core/apis/group.ts +++ b/src/core/apis/group.ts @@ -32,10 +32,10 @@ export class NTQQGroupApi { for (const group of this.groups) { this.groupCache.set(group.groupCode, group); } - let text = await this.context.session.getMsgService().sendSsoCmdReqByContend( - 'LightAppSvc.mini_app_share.AdaptShareInfo', - JSON.stringify({ data: 'test' })); - console.log(text); + // let text = await this.context.session.getMsgService().sendSsoCmdReqByContend( + // 'LightAppSvc.mini_app_share.AdaptShareInfo', + // JSON.stringify({ data: 'test' })); + // console.log(text); this.context.logger.logDebug(`加载${this.groups.length}个群组缓存完成`); } diff --git a/src/onebot/api/group.ts b/src/onebot/api/group.ts index 07d31c60..500ba0a8 100644 --- a/src/onebot/api/group.ts +++ b/src/onebot/api/group.ts @@ -19,6 +19,7 @@ import { OB11GroupPokeEvent } from '@/onebot/event/notice/OB11PokeEvent'; import { OB11GroupEssenceEvent } from '@/onebot/event/notice/OB11GroupEssenceEvent'; import { OB11GroupTitleEvent } from '@/onebot/event/notice/OB11GroupTitleEvent'; import { FileNapCatOneBotUUID } from '@/common/helper'; +import { pathToFileURL } from 'node:url'; export class OneBotGroupApi { obContext: NapCatOneBot11Adapter; @@ -77,7 +78,8 @@ export class OneBotGroupApi { id: FileNapCatOneBotUUID.encode({ chatType: ChatType.KCHATTYPEGROUP, peerUid: msg.peerUid, - }, msg.msgId, element.elementId, element.fileElement.fileName), + }, msg.msgId, element.elementId, "."+element.fileElement.fileName), + url: pathToFileURL(element.fileElement.filePath), name: element.fileElement.fileName, size: parseInt(element.fileElement.fileSize), busid: element.fileElement.fileBizId || 0, diff --git a/src/onebot/api/msg.ts b/src/onebot/api/msg.ts index a5691719..e819d821 100644 --- a/src/onebot/api/msg.ts +++ b/src/onebot/api/msg.ts @@ -1,5 +1,6 @@ import { FileNapCatOneBotUUID } from '@/common/helper'; import { MessageUnique } from '@/common/message-unique'; +import { pathToFileURL } from 'node:url'; import { AtType, ChatType, @@ -106,7 +107,7 @@ export class OneBotMsgApi { peerUid: msg.peerUid, guildId: '', }; - const encodedFileId = FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId, element.fileName); + const encodedFileId = FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId, "."+element.fileName); return { type: OB11MessageDataType.image, data: { @@ -114,6 +115,7 @@ export class OneBotMsgApi { sub_type: element.picSubType, file_id: encodedFileId, url: await this.core.apis.FileApi.getImageUrl(element), + path: element.filePath, file_size: element.fileSize, file_unique: element.fileName }, @@ -135,8 +137,8 @@ export class OneBotMsgApi { data: { file: element.fileName, path: element.filePath, - url: element.filePath, - file_id: FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId, element.fileName), + url: pathToFileURL(element.filePath), + file_id: FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId, "."+element.fileName), file_size: element.fileSize, file_unique: element.fileName, }, @@ -175,13 +177,16 @@ export class OneBotMsgApi { peerUid: msg.peerUid, guildId: '', }; + const { emojiId } = _; + const dir = emojiId.substring(0, 2); + const url = `https://gxh.vip.qq.com/club/item/parcel/item/${dir}/${emojiId}/raw300.gif` return { type: OB11MessageDataType.image, data: { file: 'marketface', - file_id: FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId, ".jpg"), + file_id: FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId, "."+_.key+".jpg"), path: elementWrapper.elementId, - url: elementWrapper.elementId, + url: url, file_unique: _.key }, }; @@ -257,14 +262,14 @@ export class OneBotMsgApi { if (!videoDownUrl) { videoDownUrl = element.filePath; } - + const fileCode = FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId, "."+element.fileName) return { type: OB11MessageDataType.video, data: { - file: element.fileName, + file: fileCode, path: videoDownUrl, - url: videoDownUrl, - file_id: FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId, element.fileName), + url: videoDownUrl ?? pathToFileURL(element.filePath), + file_id: fileCode, file_size: element.fileSize, file_unique: element.fileName, }, @@ -277,14 +282,16 @@ export class OneBotMsgApi { peerUid: msg.peerUid, guildId: '', }; - const fileCode = FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId, element.fileName); + const fileCode = FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId, "."+element.fileName); return { type: OB11MessageDataType.voice, data: { file: fileCode, path: element.filePath, + url: pathToFileURL(element.filePath), file_id: fileCode, file_size: element.fileSize, + file_unique: element.fileName }, }; }, @@ -793,18 +800,20 @@ export class OneBotMsgApi { ) { const isBlankUrl = !inputdata.url || inputdata.url === ''; const isBlankFile = !inputdata.file || inputdata.file === ''; + const isBlankPath = !inputdata.path || inputdata.path === ''; if (isBlankUrl && isBlankFile) { this.core.context.logger.logError('文件消息缺少参数', inputdata); throw Error('文件消息缺少参数'); } - const fileOrUrl = (isBlankUrl ? inputdata.file : inputdata.url) ?? ''; + //path->url->file + const realUri = (!isBlankUrl ? inputdata.url :(!isBlankPath ? inputdata.path:inputdata.file ))??''; const { path, isLocal, fileName, errMsg, success, - } = (await uri2local(this.core.NapCatTempPath, fileOrUrl)); + } = (await uri2local(this.core.NapCatTempPath, realUri)); if (!success) { this.core.context.logger.logError('文件下载失败', errMsg); diff --git a/src/onebot/event/notice/OB11GroupUploadNoticeEvent.ts b/src/onebot/event/notice/OB11GroupUploadNoticeEvent.ts index ba433292..524cc483 100644 --- a/src/onebot/event/notice/OB11GroupUploadNoticeEvent.ts +++ b/src/onebot/event/notice/OB11GroupUploadNoticeEvent.ts @@ -6,6 +6,7 @@ export interface GroupUploadFile { name: string, size: number, busid: number, + url:string; } export class OB11GroupUploadNoticeEvent extends OB11GroupNoticeEvent { diff --git a/src/onebot/types/message.ts b/src/onebot/types/message.ts index 3ed30119..5bc63fc7 100644 --- a/src/onebot/types/message.ts +++ b/src/onebot/types/message.ts @@ -84,6 +84,7 @@ export interface OB11MessageText { export interface OB11MessageFileBase { data: { + path?: string; thumb?: string; name?: string; file: string, diff --git a/src/webui/ui/NapCat.ts b/src/webui/ui/NapCat.ts index 27133501..bde043d4 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.4.0', 'napcat-update-button', 'secondary'), + SettingButton('V2.4.1', 'napcat-update-button', 'secondary'), ), ]), SettingList([ diff --git a/static/assets/renderer.js b/static/assets/renderer.js index 03650c03..da1e243f 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.4.0", "napcat-update-button", "secondary") + SettingButton("V2.4.1", "napcat-update-button", "secondary") ) ]), SettingList([