mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-12-26 19:01:28 +08:00
37 lines
1.3 KiB
TypeScript
37 lines
1.3 KiB
TypeScript
import BaseAction from '../BaseAction';
|
||
import { ActionName } from '../types';
|
||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||
|
||
const SchemaData = {
|
||
type: 'object',
|
||
properties: {
|
||
nickname: { type: 'string' },
|
||
personal_note: { type: 'string' },
|
||
sex: { type: ['number', 'string'] },//传Sex值?建议传0
|
||
},
|
||
required: ['nickname'],
|
||
} as const satisfies JSONSchema;
|
||
|
||
type Payload = FromSchema<typeof SchemaData>;
|
||
|
||
export class SetQQProfile extends BaseAction<Payload, any> {
|
||
actionName = ActionName.SetQQProfile;
|
||
payloadSchema = SchemaData;
|
||
|
||
async _handle(payload: Payload) {
|
||
const self = this.core.selfInfo;
|
||
const OldProfile = await this.core.apis.UserApi.getUserDetailInfo(self.uid);
|
||
return await this.core.apis.UserApi.modifySelfProfile({
|
||
nick: payload.nickname,
|
||
longNick: (payload?.personal_note ?? OldProfile?.longNick) || '',
|
||
sex: parseInt(payload?.sex ? payload?.sex.toString() : OldProfile?.sex!.toString()),
|
||
birthday: {
|
||
birthday_year: OldProfile?.birthday_year!.toString(),
|
||
birthday_month: OldProfile?.birthday_month!.toString(),
|
||
birthday_day: OldProfile?.birthday_day!.toString(),
|
||
},
|
||
location: undefined,
|
||
});
|
||
}
|
||
}
|