mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-06 13:05:09 +00:00
refactor: Action
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName } from '../types';
|
||||
|
||||
const SchemaData = {
|
||||
@@ -13,7 +13,7 @@ const SchemaData = {
|
||||
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
|
||||
export class CreateGroupFileFolder extends BaseAction<Payload, any> {
|
||||
export class CreateGroupFileFolder extends OneBotAction<Payload, any> {
|
||||
actionName = ActionName.GoCQHTTP_CreateGroupFileFolder;
|
||||
payloadSchema = SchemaData;
|
||||
async _handle(payload: Payload) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName } from '../types';
|
||||
import { FileNapCatOneBotUUID } from '@/common/helper';
|
||||
|
||||
@@ -14,7 +14,7 @@ const SchemaData = {
|
||||
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
|
||||
export class DeleteGroupFile extends BaseAction<Payload, any> {
|
||||
export class DeleteGroupFile extends OneBotAction<Payload, any> {
|
||||
actionName = ActionName.GOCQHTTP_DeleteGroupFile;
|
||||
payloadSchema = SchemaData;
|
||||
async _handle(payload: Payload) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
import { ActionName } from '../types';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
|
||||
const SchemaData = {
|
||||
type: 'object',
|
||||
@@ -14,7 +14,7 @@ const SchemaData = {
|
||||
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
|
||||
export class DeleteGroupFileFolder extends BaseAction<Payload, any> {
|
||||
export class DeleteGroupFileFolder extends OneBotAction<Payload, any> {
|
||||
actionName = ActionName.GoCQHTTP_DeleteGroupFileFolder;
|
||||
payloadSchema = SchemaData;
|
||||
async _handle(payload: Payload) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName } from '../types';
|
||||
import fs from 'fs';
|
||||
import { join as joinPath } from 'node:path';
|
||||
@@ -28,7 +28,7 @@ const SchemaData = {
|
||||
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
|
||||
export default class GoCQHTTPDownloadFile extends BaseAction<Payload, FileResponse> {
|
||||
export default class GoCQHTTPDownloadFile extends OneBotAction<Payload, FileResponse> {
|
||||
actionName = ActionName.GoCQHTTP_DownloadFile;
|
||||
payloadSchema = SchemaData;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { OB11Message, OB11MessageData, OB11MessageDataType, OB11MessageForward, OB11MessageNodePlain as OB11MessageNode } from '@/onebot';
|
||||
import { ActionName } from '../types';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
@@ -16,7 +16,7 @@ const SchemaData = {
|
||||
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
|
||||
export class GoCQHTTPGetForwardMsgAction extends BaseAction<Payload, any> {
|
||||
export class GoCQHTTPGetForwardMsgAction extends OneBotAction<Payload, any> {
|
||||
actionName = ActionName.GoCQHTTP_GetForwardMsg;
|
||||
payloadSchema = SchemaData;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { OB11Message } from '@/onebot';
|
||||
import { ActionName } from '../types';
|
||||
import { ChatType } from '@/core/entities';
|
||||
@@ -23,7 +23,7 @@ const SchemaData = {
|
||||
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
|
||||
export default class GetFriendMsgHistory extends BaseAction<Payload, Response> {
|
||||
export default class GetFriendMsgHistory extends OneBotAction<Payload, Response> {
|
||||
actionName = ActionName.GetFriendMsgHistory;
|
||||
payloadSchema = SchemaData;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName } from '../types';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
|
||||
@@ -11,7 +11,7 @@ const SchemaData = {
|
||||
} as const satisfies JSONSchema;
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
|
||||
export class GoCQHTTPGetGroupAtAllRemain extends BaseAction<Payload, any> {
|
||||
export class GoCQHTTPGetGroupAtAllRemain extends OneBotAction<Payload, any> {
|
||||
actionName = ActionName.GoCQHTTP_GetGroupAtAllRemain;
|
||||
payloadSchema = SchemaData;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName } from '../types';
|
||||
|
||||
const SchemaData = {
|
||||
@@ -12,7 +12,7 @@ const SchemaData = {
|
||||
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
|
||||
export class GetGroupFileSystemInfo extends BaseAction<Payload, {
|
||||
export class GetGroupFileSystemInfo extends OneBotAction<Payload, {
|
||||
file_count: number,
|
||||
limit_count: number, // unimplemented
|
||||
used_space: number, // TODO:unimplemented, but can be implemented later
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName } from '../types';
|
||||
import { OB11Entities } from '@/onebot/entities';
|
||||
|
||||
@@ -16,7 +16,7 @@ const SchemaData = {
|
||||
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
|
||||
export class GetGroupFilesByFolder extends BaseAction<any, any> {
|
||||
export class GetGroupFilesByFolder extends OneBotAction<any, any> {
|
||||
actionName = ActionName.GoCQHTTP_GetGroupFilesByFolder;
|
||||
payloadSchema = SchemaData;
|
||||
async _handle(payload: Payload) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName } from '../types';
|
||||
import { WebHonorType } from '@/core/entities';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
@@ -14,7 +14,7 @@ const SchemaData = {
|
||||
// enum是不是有点抽象
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
|
||||
export class GetGroupHonorInfo extends BaseAction<Payload, Array<any>> {
|
||||
export class GetGroupHonorInfo extends OneBotAction<Payload, Array<any>> {
|
||||
actionName = ActionName.GetGroupHonorInfo;
|
||||
payloadSchema = SchemaData;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { OB11Message } from '@/onebot';
|
||||
import { ActionName } from '../types';
|
||||
import { ChatType, Peer } from '@/core/entities';
|
||||
@@ -23,7 +23,7 @@ const SchemaData = {
|
||||
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
|
||||
export default class GoCQHTTPGetGroupMsgHistory extends BaseAction<Payload, Response> {
|
||||
export default class GoCQHTTPGetGroupMsgHistory extends OneBotAction<Payload, Response> {
|
||||
actionName = ActionName.GoCQHTTP_GetGroupMsgHistory;
|
||||
payloadSchema = SchemaData;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName } from '../types';
|
||||
import { OB11GroupFile, OB11GroupFileFolder } from '@/onebot';
|
||||
import { OB11Entities } from '@/onebot/entities';
|
||||
@@ -15,7 +15,7 @@ const SchemaData = {
|
||||
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
|
||||
export class GetGroupRootFiles extends BaseAction<Payload, {
|
||||
export class GetGroupRootFiles extends OneBotAction<Payload, {
|
||||
files: OB11GroupFile[],
|
||||
folders: OB11GroupFileFolder[],
|
||||
}> {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName } from '../types';
|
||||
import { JSONSchema } from 'json-schema-to-ts';
|
||||
import { sleep } from '@/common/helper';
|
||||
@@ -10,7 +10,7 @@ const SchemaData = {
|
||||
},
|
||||
} as const satisfies JSONSchema;
|
||||
|
||||
export class GetOnlineClient extends BaseAction<void, Array<any>> {
|
||||
export class GetOnlineClient extends OneBotAction<void, Array<any>> {
|
||||
actionName = ActionName.GetOnlineClient;
|
||||
|
||||
async _handle(payload: void) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { OB11User, OB11UserSex } from '@/onebot';
|
||||
import { OB11Entities } from '@/onebot/entities';
|
||||
import { ActionName } from '../types';
|
||||
@@ -15,7 +15,7 @@ const SchemaData = {
|
||||
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
|
||||
export default class GoCQHTTPGetStrangerInfo extends BaseAction<Payload, OB11User> {
|
||||
export default class GoCQHTTPGetStrangerInfo extends OneBotAction<Payload, OB11User> {
|
||||
actionName = ActionName.GoCQHTTP_GetStrangerInfo;
|
||||
|
||||
async _handle(payload: Payload): Promise<OB11User> {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName } from '../types';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
|
||||
@@ -11,7 +11,7 @@ const SchemaData = {
|
||||
} as const satisfies JSONSchema;
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
|
||||
export class GoCQHTTPCheckUrlSafely extends BaseAction<Payload, any> {
|
||||
export class GoCQHTTPCheckUrlSafely extends OneBotAction<Payload, any> {
|
||||
actionName = ActionName.GoCQHTTP_CheckUrlSafely;
|
||||
payloadSchema = SchemaData;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName } from '../types';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
|
||||
@@ -18,7 +18,7 @@ const SchemaData = {
|
||||
} as const satisfies JSONSchema;
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
|
||||
export class GoCQHTTPDeleteFriend extends BaseAction<Payload, any> {
|
||||
export class GoCQHTTPDeleteFriend extends OneBotAction<Payload, any> {
|
||||
actionName = ActionName.GoCQHTTP_DeleteFriend;
|
||||
payloadSchema = SchemaData;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName } from '../types';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
|
||||
@@ -10,7 +10,7 @@ const SchemaData = {
|
||||
} as const satisfies JSONSchema;
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
|
||||
export class GoCQHTTPGetModelShow extends BaseAction<Payload, any> {
|
||||
export class GoCQHTTPGetModelShow extends OneBotAction<Payload, any> {
|
||||
actionName = ActionName.GoCQHTTP_GetModelShow;
|
||||
payloadSchema = SchemaData;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName } from '../types';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
|
||||
@@ -9,7 +9,7 @@ const SchemaData = {
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
|
||||
//兼容性代码
|
||||
export class GoCQHTTPSetModelShow extends BaseAction<Payload, any> {
|
||||
export class GoCQHTTPSetModelShow extends OneBotAction<Payload, any> {
|
||||
actionName = ActionName.GoCQHTTP_SetModelShow;
|
||||
payloadSchema = SchemaData;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName } from '../types';
|
||||
import { QuickAction, QuickActionEvent } from '@/onebot/types';
|
||||
|
||||
@@ -7,7 +7,7 @@ interface Payload {
|
||||
operation: QuickAction
|
||||
}
|
||||
|
||||
export class GoCQHTTPHandleQuickAction extends BaseAction<Payload, null> {
|
||||
export class GoCQHTTPHandleQuickAction extends OneBotAction<Payload, null> {
|
||||
actionName = ActionName.GoCQHTTP_HandleQuickAction;
|
||||
|
||||
async _handle(payload: Payload): Promise<null> {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { checkFileReceived, uri2local } from '@/common/file';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName } from '../types';
|
||||
import { unlink } from 'node:fs';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
@@ -21,7 +21,7 @@ const SchemaData = {
|
||||
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
|
||||
export class SendGroupNotice extends BaseAction<Payload, null> {
|
||||
export class SendGroupNotice extends OneBotAction<Payload, null> {
|
||||
actionName = ActionName.GoCQHTTP_SendGroupNotice;
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName, BaseCheckResult } from '../types';
|
||||
import * as fs from 'node:fs';
|
||||
import { checkFileReceived, uri2local } from '@/common/file';
|
||||
@@ -8,7 +8,7 @@ interface Payload {
|
||||
group_id: number
|
||||
}
|
||||
|
||||
export default class SetGroupPortrait extends BaseAction<Payload, any> {
|
||||
export default class SetGroupPortrait extends OneBotAction<Payload, any> {
|
||||
actionName = ActionName.SetGroupPortrait;
|
||||
|
||||
// 用不着复杂检测
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName } from '../types';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
|
||||
@@ -14,7 +14,7 @@ const SchemaData = {
|
||||
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
|
||||
export class SetQQProfile extends BaseAction<Payload, any> {
|
||||
export class SetQQProfile extends OneBotAction<Payload, any> {
|
||||
actionName = ActionName.SetQQProfile;
|
||||
payloadSchema = SchemaData;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName } from '../types';
|
||||
import { ChatType, Peer } from '@/core/entities';
|
||||
import fs from 'fs';
|
||||
@@ -20,7 +20,7 @@ const SchemaData = {
|
||||
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
|
||||
export default class GoCQHTTPUploadGroupFile extends BaseAction<Payload, null> {
|
||||
export default class GoCQHTTPUploadGroupFile extends OneBotAction<Payload, null> {
|
||||
actionName = ActionName.GoCQHTTP_UploadGroupFile;
|
||||
payloadSchema = SchemaData;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName } from '../types';
|
||||
import { ChatType, Peer, SendFileElement } from '@/core/entities';
|
||||
import fs from 'fs';
|
||||
@@ -19,7 +19,7 @@ const SchemaData = {
|
||||
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
|
||||
export default class GoCQHTTPUploadPrivateFile extends BaseAction<Payload, null> {
|
||||
export default class GoCQHTTPUploadPrivateFile extends OneBotAction<Payload, null> {
|
||||
actionName = ActionName.GOCQHTTP_UploadPrivateFile;
|
||||
payloadSchema = SchemaData;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user