NapCatQQ/packages/napcat-onebot/action/go-cqhttp/GoCQHTTPGetModelShow.ts
手瓜一十雪 1fa0980709 Refactor action examples structure and imports
Moved action example files into a new 'example' directory and updated all imports accordingly. Removed the monolithic 'examples.ts' and redefined ActionExamples in OneBotAction.ts to only include common error codes. This improves code organization and maintainability.
2026-01-27 16:45:44 +08:00

43 lines
1.7 KiB
TypeScript

import { OneBotAction } from '@/napcat-onebot/action/OneBotAction';
import { ActionName } from '@/napcat-onebot/action/router';
import { Static, Type } from '@sinclair/typebox';
import { GoCQHTTPActionsExamples } from '../example/GoCQHTTPActionsExamples';
export const GoCQHTTPGetModelShowPayloadSchema = Type.Object({
model: Type.Optional(Type.String({ description: '模型名称' })),
});
export type GoCQHTTPGetModelShowPayload = Static<typeof GoCQHTTPGetModelShowPayloadSchema>;
export const GoCQHTTPGetModelShowReturnSchema = Type.Array(Type.Object({
variants: Type.Object({
model_show: Type.String({ description: '显示名称' }),
need_pay: Type.Boolean({ description: '是否需要付费' }),
}),
}), { description: '机型显示列表' });
export type GoCQHTTPGetModelShowReturn = Static<typeof GoCQHTTPGetModelShowReturnSchema>;
export class GoCQHTTPGetModelShow extends OneBotAction<GoCQHTTPGetModelShowPayload, GoCQHTTPGetModelShowReturn> {
override actionName = ActionName.GoCQHTTP_GetModelShow;
override payloadSchema = GoCQHTTPGetModelShowPayloadSchema;
override returnSchema = GoCQHTTPGetModelShowReturnSchema;
override actionSummary = '获取机型显示';
override actionDescription = '获取当前账号可用的设备机型显示名称列表';
override actionTags = ['Go-CQHTTP'];
override payloadExample = GoCQHTTPActionsExamples.GoCQHTTPGetModelShow.payload;
override returnExample = GoCQHTTPActionsExamples.GoCQHTTPGetModelShow.response;
async _handle (payload: GoCQHTTPGetModelShowPayload) {
if (!payload.model) {
payload.model = 'napcat';
}
return [{
variants: {
model_show: 'napcat',
need_pay: false,
},
}];
}
}