diff --git a/manifest.json b/manifest.json index 1f78972e..d1684cb7 100644 --- a/manifest.json +++ b/manifest.json @@ -4,7 +4,7 @@ "name": "NapCatQQ", "slug": "NapCat.Framework", "description": "高性能的 OneBot 11 协议实现", - "version": "2.4.2", + "version": "2.4.3", "icon": "./logo.png", "authors": [ { diff --git a/package.json b/package.json index 23aa76dc..201882b1 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "napcat", "private": true, "type": "module", - "version": "2.4.2", + "version": "2.4.3", "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 eddfb216..73f14927 100644 --- a/src/common/version.ts +++ b/src/common/version.ts @@ -1 +1 @@ -export const napCatVersion = '2.4.2'; +export const napCatVersion = '2.4.3'; diff --git a/src/onebot/action/index.ts b/src/onebot/action/index.ts index b9ed7a8b..c55e9b0a 100644 --- a/src/onebot/action/index.ts +++ b/src/onebot/action/index.ts @@ -83,6 +83,7 @@ import { DeleteGroupFileFolder } from '@/onebot/action/go-cqhttp/DeleteGroupFile import { GetGroupFileSystemInfo } from '@/onebot/action/go-cqhttp/GetGroupFileSystemInfo'; import { GetGroupRootFiles } from '@/onebot/action/go-cqhttp/GetGroupRootFiles'; import { GetGroupFilesByFolder } from '@/onebot/action/go-cqhttp/GetGroupFilesByFolder'; +import { GetGroupSystemMsg } from './system/GetSystemMsg'; export type ActionMap = Map>; @@ -176,6 +177,7 @@ export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCo new DeleteGroupFileFolder(obContext, core), new GetGroupFileSystemInfo(obContext, core), new GetGroupFilesByFolder(obContext, core), + new GetGroupSystemMsg(obContext, core), ]; const actionMap = new Map(); for (const action of actionHandlers) { diff --git a/src/onebot/action/system/GetSystemMsg.ts b/src/onebot/action/system/GetSystemMsg.ts new file mode 100644 index 00000000..cceb2477 --- /dev/null +++ b/src/onebot/action/system/GetSystemMsg.ts @@ -0,0 +1,50 @@ +import { GroupNotifyMsgStatus } from '@/core'; +import BaseAction from '../BaseAction'; +import { ActionName } from '../types'; +import { FromSchema, JSONSchema } from 'json-schema-to-ts'; + +const SchemaData = { + type: 'object', + properties: { + group_id: { type: ['number', 'string'] }, + }, +} as const satisfies JSONSchema; + +type Payload = FromSchema; + +export class GetGroupSystemMsg extends BaseAction { + actionName = ActionName.GetGroupSystemMsg; + + async _handle(payload: void) { + const NTQQUserApi = this.core.apis.UserApi; + const NTQQGroupApi = this.core.apis.GroupApi; + // 默认10条 该api未完整实现 包括响应数据规范化 类型规范化 + const SingleScreenNotifies = await NTQQGroupApi.getSingleScreenNotifies(false,10); + const retData: any = { InvitedRequest: [], join_requests: [] }; + for (const SSNotify of SingleScreenNotifies) { + if (SSNotify.type == 1) { + retData.InvitedRequest.push({ + request_id: SSNotify.seq, + invitor_uin: await NTQQUserApi.getUinByUidV2(SSNotify.user1?.uid), + invitor_nick: SSNotify.user1?.nickName, + group_id: SSNotify.group?.groupCode, + group_name: SSNotify.group?.groupName, + checked: SSNotify.status === GroupNotifyMsgStatus.KUNHANDLE ? false : true, + actor: await NTQQUserApi.getUinByUidV2(SSNotify.user2?.uid) || 0, + }); + } else if (SSNotify.type == 7) { + retData.join_requests.push({ + request_id: SSNotify.seq, + requester_uin: await NTQQUserApi.getUinByUidV2(SSNotify.user1?.uid), + requester_nick: SSNotify.user1?.nickName, + group_id: SSNotify.group?.groupCode, + group_name: SSNotify.group?.groupName, + checked: SSNotify.status === GroupNotifyMsgStatus.KUNHANDLE ? false : true, + actor: await NTQQUserApi.getUinByUidV2(SSNotify.user2?.uid) || 0, + }); + } + } + + return retData; + } +} \ No newline at end of file diff --git a/src/onebot/action/types.ts b/src/onebot/action/types.ts index b8ccc078..e93eb90f 100644 --- a/src/onebot/action/types.ts +++ b/src/onebot/action/types.ts @@ -116,5 +116,6 @@ export enum ActionName { SetInputStatus = 'set_input_status', GetCSRF = 'get_csrf_token', DelGroupNotice = '_del_group_notice', - GetGroupInfoEx = "get_group_info_ex" + GetGroupInfoEx = "get_group_info_ex", + GetGroupSystemMsg = 'get_group_system_msg', } diff --git a/src/onebot/api/msg.ts b/src/onebot/api/msg.ts index bf68f341..2a55cf4d 100644 --- a/src/onebot/api/msg.ts +++ b/src/onebot/api/msg.ts @@ -107,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: { @@ -138,7 +138,7 @@ export class OneBotMsgApi { file: element.fileName, path: element.filePath, url: pathToFileURL(element.filePath).href, - file_id: FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId, "."+element.fileName), + file_id: FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId, "." + element.fileName), file_size: element.fileSize, file_unique: element.fileName, }, @@ -184,7 +184,7 @@ export class OneBotMsgApi { type: OB11MessageDataType.image, data: { file: 'marketface', - file_id: FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId, "."+_.key+".jpg"), + file_id: FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId, "." + _.key + ".jpg"), path: elementWrapper.elementId, url: url, file_unique: _.key @@ -262,7 +262,7 @@ export class OneBotMsgApi { if (!videoDownUrl) { videoDownUrl = element.filePath; } - 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.video, data: { @@ -282,7 +282,7 @@ 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: { @@ -798,15 +798,11 @@ export class OneBotMsgApi { { data: inputdata }: OB11MessageFileBase, { deleteAfterSentFiles }: MessageContext, ) { - const isBlankUrl = !inputdata.url || inputdata.url === ''; - const isBlankFile = !inputdata.file || inputdata.file === ''; - const isBlankPath = !inputdata.path || inputdata.path === ''; - if (isBlankUrl && isBlankFile) { + const realUri = inputdata.url || inputdata.file || inputdata.path || ''; + if (realUri.length === 0) { this.core.context.logger.logError('文件消息缺少参数', inputdata); throw Error('文件消息缺少参数'); } - //path->url->file - const realUri = (!isBlankUrl ? inputdata.url :(!isBlankPath ? inputdata.path:inputdata.file ))??''; const { path, isLocal, diff --git a/src/webui/ui/NapCat.ts b/src/webui/ui/NapCat.ts index 0cc07c83..f6e6c02c 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.2', 'napcat-update-button', 'secondary'), + SettingButton('V2.4.3', 'napcat-update-button', 'secondary'), ), ]), SettingList([ diff --git a/static/assets/renderer.js b/static/assets/renderer.js index 2666aba9..a17485a9 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.2", "napcat-update-button", "secondary") + SettingButton("V2.4.3", "napcat-update-button", "secondary") ) ]), SettingList([