From 275c4ce22615684c7227e66763d7c30f7a10552c Mon Sep 17 00:00:00 2001 From: "Wesley F. Young" Date: Thu, 29 Aug 2024 17:08:36 +0800 Subject: [PATCH] feat: GetGroupIgnoredNotifies --- src/core/apis/group.ts | 4 +- src/core/services/NodeIKernelGroupService.ts | 3 +- .../action/group/GetGroupIgnoredNotifies.ts | 39 +++++++++++++++ src/onebot/action/group/GetGroupSystemMsg.ts | 50 ------------------- src/onebot/action/index.ts | 4 +- src/onebot/action/types.ts | 2 +- 6 files changed, 45 insertions(+), 57 deletions(-) create mode 100644 src/onebot/action/group/GetGroupIgnoredNotifies.ts delete mode 100644 src/onebot/action/group/GetGroupSystemMsg.ts diff --git a/src/core/apis/group.ts b/src/core/apis/group.ts index 7f3a16c5..4145cd31 100644 --- a/src/core/apis/group.ts +++ b/src/core/apis/group.ts @@ -309,12 +309,12 @@ export class NTQQGroupApi { return this.context.session.getGroupService().removeGroupEssence(param); } - async getSingleScreenNotifies(num: number) { + async getSingleScreenNotifies(doubt: boolean, num: number) { const [, , , notifies] = await this.core.eventWrapper.callNormalEventV2( 'NodeIKernelGroupService/getSingleScreenNotifies', 'NodeIKernelGroupListener/onGroupSingleScreenNotifies', [ - false, + doubt, '', num, ], diff --git a/src/core/services/NodeIKernelGroupService.ts b/src/core/services/NodeIKernelGroupService.ts index 788b088c..7d54c099 100644 --- a/src/core/services/NodeIKernelGroupService.ts +++ b/src/core/services/NodeIKernelGroupService.ts @@ -182,8 +182,7 @@ export interface NodeIKernelGroupService { destroyGroup(groupCode: string): void; - //获取单屏群通知列表 - getSingleScreenNotifies(force: boolean, start_seq: string, num: number): Promise; + getSingleScreenNotifies(doubted: boolean, start_seq: string, num: number): Promise; clearGroupNotifies(groupCode: string): void; diff --git a/src/onebot/action/group/GetGroupIgnoredNotifies.ts b/src/onebot/action/group/GetGroupIgnoredNotifies.ts new file mode 100644 index 00000000..4b74e672 --- /dev/null +++ b/src/onebot/action/group/GetGroupIgnoredNotifies.ts @@ -0,0 +1,39 @@ +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 GetGroupIgnoredNotifies extends BaseAction { + actionName = ActionName.GetGroupIgnoredNotifies; + + async _handle(payload: void) { + const NTQQUserApi = this.core.apis.UserApi; + const NTQQGroupApi = this.core.apis.GroupApi; + const ignoredNotifies = await NTQQGroupApi.getSingleScreenNotifies(true, 10); + const retData: any = { + join_requests: await Promise.all( + ignoredNotifies + .filter(notify => notify.type === 7) + .map(async SSNotify => ({ + 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, + actor: await NTQQUserApi.getUinByUidV2(SSNotify.user2?.uid) || 0, + }))), + }; + + return retData; + } +} diff --git a/src/onebot/action/group/GetGroupSystemMsg.ts b/src/onebot/action/group/GetGroupSystemMsg.ts deleted file mode 100644 index 222eb410..00000000 --- a/src/onebot/action/group/GetGroupSystemMsg.ts +++ /dev/null @@ -1,50 +0,0 @@ -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(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; - } -} diff --git a/src/onebot/action/index.ts b/src/onebot/action/index.ts index 7859d765..4f32c38e 100644 --- a/src/onebot/action/index.ts +++ b/src/onebot/action/index.ts @@ -52,7 +52,7 @@ import { GetFriendWithCategory } from './extends/GetFriendWithCategory'; import { SendGroupNotice } from './go-cqhttp/SendGroupNotice'; import { GetGroupHonorInfo } from './go-cqhttp/GetGroupHonorInfo'; import { GoCQHTTPHandleQuickAction } from './go-cqhttp/QuickAction'; -import { GetGroupSystemMsg } from './group/GetGroupSystemMsg'; +import { GetGroupIgnoredNotifies } from './group/GetGroupIgnoredNotifies'; import { GetOnlineClient } from './go-cqhttp/GetOnlineClient'; import { IOCRImage, OCRImage } from './extends/OCRImage'; import { GetGroupFileCount } from './file/GetGroupFileCount'; @@ -159,7 +159,7 @@ export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCo new GoCQHTTPGetForwardMsgAction(obContext, core), new GetFriendMsgHistory(obContext, core), new GoCQHTTPHandleQuickAction(obContext, core), - new GetGroupSystemMsg(obContext, core), + new GetGroupIgnoredNotifies(obContext, core), new DelEssenceMsg(obContext, core), new SetEssenceMsg(obContext, core), new GetRecentContact(obContext, core), diff --git a/src/onebot/action/types.ts b/src/onebot/action/types.ts index 053d80dc..ea08c883 100644 --- a/src/onebot/action/types.ts +++ b/src/onebot/action/types.ts @@ -87,7 +87,7 @@ export enum ActionName { GoCQHTTP_GetGroupMsgHistory = 'get_group_msg_history', GoCQHTTP_GetForwardMsg = 'get_forward_msg', GetFriendMsgHistory = 'get_friend_msg_history', - GetGroupSystemMsg = 'get_group_system_msg', + GetGroupIgnoredNotifies = 'get_group_ignored_notifies', GetOnlineClient = 'get_online_clients', OCRImage = 'ocr_image', IOCRImage = '.ocr_image',