mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-05 23:19:37 +00:00
Refactored all Satori action classes to use TypeBox schemas for payload validation and unified action naming via a new router. Added schema-based parameter checking to the SatoriAction base class. Introduced new actions for guild and member approval, and login retrieval. Centralized action name constants and types in a new router module. Enhanced event and message APIs with more structured event types and parsing logic. Added helper utilities for XML parsing. Updated exports and registration logic to support the new structure.
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
import { Static, Type } from '@sinclair/typebox';
|
|
import { SatoriAction } from '../SatoriAction';
|
|
import { SatoriActionName } from '../router';
|
|
import { GroupNotifyMsgType, NTGroupRequestOperateTypes } from 'napcat-core';
|
|
|
|
const SchemaData = Type.Object({
|
|
message_id: Type.String(), // 入群请求的 seq
|
|
approve: Type.Boolean(),
|
|
comment: Type.Optional(Type.String()),
|
|
});
|
|
|
|
type Payload = Static<typeof SchemaData>;
|
|
|
|
export class GuildMemberApproveAction extends SatoriAction<Payload, void> {
|
|
actionName = SatoriActionName.GuildMemberApprove;
|
|
override payloadSchema = SchemaData;
|
|
|
|
protected async _handle (payload: Payload): Promise<void> {
|
|
const { message_id, approve, comment } = payload;
|
|
|
|
// message_id 是入群请求的 seq
|
|
const notifies = await this.core.apis.GroupApi.getSingleScreenNotifies(true, 100);
|
|
const notify = notifies.find(
|
|
(e) =>
|
|
e.seq === message_id &&
|
|
e.type === GroupNotifyMsgType.REQUEST_JOIN_NEED_ADMINI_STRATOR_PASS
|
|
);
|
|
|
|
if (!notify) {
|
|
throw new Error(`未找到入群请求: ${message_id}`);
|
|
}
|
|
|
|
const operateType = approve
|
|
? NTGroupRequestOperateTypes.KAGREE
|
|
: NTGroupRequestOperateTypes.KREFUSE;
|
|
|
|
await this.core.apis.GroupApi.handleGroupRequest(false, notify, operateType, comment);
|
|
}
|
|
}
|