refactor: simplify the PacketClient availability check process & add action nc_get_packet_status

This commit is contained in:
pk5ls20
2024-10-19 04:41:32 +08:00
parent 83bced82b1
commit 7a4a255a89
7 changed files with 38 additions and 31 deletions

View File

@@ -1,23 +1,11 @@
import BaseAction from '../BaseAction';
import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
// no_cache get时传字符串
const SchemaData = {
type: 'object',
properties: {
},
} as const satisfies JSONSchema;
import { GetPacketStatusDepends } from "@/onebot/action/packet/GetPacketStatus";
type Payload = FromSchema<typeof SchemaData>;
export class GetRkey extends BaseAction<Payload, Array<any>> {
export class GetRkey extends GetPacketStatusDepends<null, Array<any>> {
actionName = ActionName.GetRkey;
payloadSchema = SchemaData;
async _handle(payload: Payload) {
if (!this.core.apis.PacketApi.available) {
throw new Error('PacketClient is not init');
}
async _handle() {
return await this.core.apis.PacketApi.sendRkeyPacket();
}
}