NapCatQQ/packages/napcat-onebot/action/system/GetCSRF.ts
手瓜一十雪 335c83a3d5 Refactor action example imports and add example files
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.
2026-01-25 17:55:07 +08:00

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),
};
}
}