mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-05 15:11:15 +00:00
Standardized type usage and improved type safety across multiple OneBot action files. Updated payload schemas to use string types for IDs and flags, refined return types, and enhanced message content typing. Added error handling for missing parameters in SetGroupTodo.
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: ReturnType = [];
|
|
|
|
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;
|
|
}
|
|
}
|