mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-05 15:11:15 +00:00
Moved action example data to dedicated 'examples.ts' files for each action category (extends, file, go-cqhttp, group, msg, system, user). Updated all action classes to import and use the new example modules, improving code organization and maintainability. Also added missing actionTags and actionDescription where appropriate.
30 lines
1002 B
TypeScript
30 lines
1002 B
TypeScript
import { OneBotAction } from '@/napcat-onebot/action/OneBotAction';
|
|
import { ActionName } from '@/napcat-onebot/action/router';
|
|
import { Type, Static } from '@sinclair/typebox';
|
|
import { SystemActionsExamples } from './examples';
|
|
|
|
export const GetCSRFReturnSchema = Type.Object({
|
|
token: Type.Number({ description: 'CSRF Token' }),
|
|
});
|
|
|
|
export type GetCSRFReturnType = Static<typeof GetCSRFReturnSchema>;
|
|
|
|
export class GetCSRF extends OneBotAction<void, GetCSRFReturnType> {
|
|
override actionName = ActionName.GetCSRF;
|
|
override payloadSchema = Type.Object({});
|
|
override returnSchema = GetCSRFReturnSchema;
|
|
override actionDescription = '获取 CSRF Token';
|
|
override actionTags = ['系统接口'];
|
|
override payloadExample = SystemActionsExamples.GetCSRF.payload;
|
|
|
|
async _handle () {
|
|
const sKey = await this.core.apis.UserApi.getSKey();
|
|
if (!sKey) {
|
|
throw new Error('SKey is undefined');
|
|
}
|
|
return {
|
|
token: +this.core.apis.WebApi.getBknFromSKey(sKey),
|
|
};
|
|
}
|
|
}
|