mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-04 14:41:14 +00:00
Introduced explicit payloadSchema and returnSchema definitions for all OneBotAction classes using @sinclair/typebox. This improves type safety, API documentation, and validation for action payloads and return values. Also refactored method signatures and types for consistency across the codebase.
57 lines
2.3 KiB
TypeScript
57 lines
2.3 KiB
TypeScript
import { GroupNotifyMsgStatus } from 'napcat-core';
|
|
import { OneBotAction } from '@/napcat-onebot/action/OneBotAction';
|
|
import { ActionName } from '@/napcat-onebot/action/router';
|
|
import { Type, Static } from '@sinclair/typebox';
|
|
|
|
const ReturnSchema = Type.Array(
|
|
Type.Object({
|
|
request_id: Type.Number({ description: '请求ID' }),
|
|
invitor_uin: Type.Number({ description: '邀请者QQ' }),
|
|
invitor_nick: Type.Optional(Type.String({ description: '邀请者昵称' })),
|
|
group_id: Type.Number({ description: '群号' }),
|
|
message: Type.Optional(Type.String({ description: '验证信息' })),
|
|
group_name: Type.Optional(Type.String({ description: '群名称' })),
|
|
checked: Type.Boolean({ description: '是否已处理' }),
|
|
actor: Type.Number({ description: '处理者QQ' }),
|
|
requester_nick: Type.Optional(Type.String({ description: '请求者昵称' })),
|
|
}),
|
|
{ description: '群通知列表' }
|
|
);
|
|
|
|
type ReturnType = Static<typeof ReturnSchema>;
|
|
|
|
export default class GetGroupAddRequest extends OneBotAction<void, ReturnType> {
|
|
override actionName = ActionName.GetGroupIgnoreAddRequest;
|
|
override payloadSchema = Type.Void();
|
|
override returnSchema = ReturnSchema;
|
|
|
|
async _handle (): Promise<ReturnType> {
|
|
const NTQQUserApi = this.core.apis.UserApi;
|
|
const NTQQGroupApi = this.core.apis.GroupApi;
|
|
const ignoredNotifies = await NTQQGroupApi.getSingleScreenNotifies(true, 10);
|
|
const retData: any[] = [];
|
|
|
|
const notifyPromises = ignoredNotifies
|
|
.filter(notify => notify.type === 7)
|
|
.map(async SSNotify => {
|
|
const invitorUin = SSNotify.user1?.uid ? +await NTQQUserApi.getUinByUidV2(SSNotify.user1.uid) : 0;
|
|
const actorUin = SSNotify.user2?.uid ? +await NTQQUserApi.getUinByUidV2(SSNotify.user2.uid) : 0;
|
|
retData.push({
|
|
request_id: +SSNotify.seq,
|
|
invitor_uin: invitorUin,
|
|
invitor_nick: SSNotify.user1?.nickName,
|
|
group_id: +SSNotify.group?.groupCode,
|
|
message: SSNotify?.postscript,
|
|
group_name: SSNotify.group?.groupName,
|
|
checked: SSNotify.status !== GroupNotifyMsgStatus.KUNHANDLE,
|
|
actor: actorUin,
|
|
requester_nick: SSNotify.user1?.nickName,
|
|
});
|
|
});
|
|
|
|
await Promise.all(notifyPromises);
|
|
|
|
return retData;
|
|
}
|
|
}
|