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.
29 lines
835 B
TypeScript
29 lines
835 B
TypeScript
import { Static, Type } from '@sinclair/typebox';
|
|
import { SatoriAction } from '../SatoriAction';
|
|
import { SatoriActionName } from '../router';
|
|
import { SatoriUser } from '../../types';
|
|
|
|
const SchemaData = Type.Object({
|
|
user_id: Type.String(),
|
|
});
|
|
|
|
type Payload = Static<typeof SchemaData>;
|
|
|
|
export class UserGetAction extends SatoriAction<Payload, SatoriUser> {
|
|
actionName = SatoriActionName.UserGet;
|
|
override payloadSchema = SchemaData;
|
|
|
|
protected async _handle (payload: Payload): Promise<SatoriUser> {
|
|
const { user_id } = payload;
|
|
|
|
const uid = await this.core.apis.UserApi.getUidByUinV2(user_id);
|
|
const userInfo = await this.core.apis.UserApi.getUserDetailInfo(uid, false);
|
|
|
|
return {
|
|
id: user_id,
|
|
name: userInfo.nick,
|
|
avatar: `https://q1.qlogo.cn/g?b=qq&nk=${user_id}&s=640`,
|
|
};
|
|
}
|
|
}
|