From d36ea93e63e531ebc8be396e596a817d4f3fafe1 Mon Sep 17 00:00:00 2001 From: idranme Date: Sun, 1 Sep 2024 15:26:34 +0800 Subject: [PATCH] refactor --- .../action/go-cqhttp/CreateGroupFileFolder.ts | 2 +- .../action/go-cqhttp/DelEssenceMsg.ts | 2 +- src/onebot11/action/go-cqhttp/DelGroupFile.ts | 2 +- .../action/go-cqhttp/DelGroupFolder.ts | 2 +- src/onebot11/action/go-cqhttp/DownloadFile.ts | 2 +- .../action/go-cqhttp/GetForwardMsg.ts | 2 +- .../action/go-cqhttp/GetGroupMsgHistory.ts | 2 +- .../action/go-cqhttp/GetGroupSystemMsg.ts | 2 +- .../action/go-cqhttp/GetStrangerInfo.ts | 2 +- .../{msg => go-cqhttp}/MarkMsgAsRead.ts | 2 +- .../action/go-cqhttp/QuickOperation.ts | 2 +- .../action/go-cqhttp/SendForwardMsg.ts | 6 +- .../action/go-cqhttp/SetEssenceMsg.ts | 2 +- src/onebot11/action/go-cqhttp/UploadFile.ts | 4 +- src/onebot11/action/index.ts | 68 ++++++++++--------- 15 files changed, 52 insertions(+), 50 deletions(-) rename src/onebot11/action/{msg => go-cqhttp}/MarkMsgAsRead.ts (76%) diff --git a/src/onebot11/action/go-cqhttp/CreateGroupFileFolder.ts b/src/onebot11/action/go-cqhttp/CreateGroupFileFolder.ts index 4fdafdd..ef81d33 100644 --- a/src/onebot11/action/go-cqhttp/CreateGroupFileFolder.ts +++ b/src/onebot11/action/go-cqhttp/CreateGroupFileFolder.ts @@ -7,7 +7,7 @@ interface Payload { parent_id?: '/' } -export class GoCQHTTPCreateGroupFileFolder extends BaseAction { +export class CreateGroupFileFolder extends BaseAction { actionName = ActionName.GoCQHTTP_CreateGroupFileFolder async _handle(payload: Payload) { diff --git a/src/onebot11/action/go-cqhttp/DelEssenceMsg.ts b/src/onebot11/action/go-cqhttp/DelEssenceMsg.ts index 7c7a1f3..db5e7da 100644 --- a/src/onebot11/action/go-cqhttp/DelEssenceMsg.ts +++ b/src/onebot11/action/go-cqhttp/DelEssenceMsg.ts @@ -6,7 +6,7 @@ interface Payload { message_id: number | string } -export default class GoCQHTTPDelEssenceMsg extends BaseAction { +export class DelEssenceMsg extends BaseAction { actionName = ActionName.GoCQHTTP_DelEssenceMsg; protected async _handle(payload: Payload): Promise { diff --git a/src/onebot11/action/go-cqhttp/DelGroupFile.ts b/src/onebot11/action/go-cqhttp/DelGroupFile.ts index 8a0355a..e883390 100644 --- a/src/onebot11/action/go-cqhttp/DelGroupFile.ts +++ b/src/onebot11/action/go-cqhttp/DelGroupFile.ts @@ -7,7 +7,7 @@ interface Payload { busid?: 102 } -export class GoCQHTTPDelGroupFile extends BaseAction { +export class DelGroupFile extends BaseAction { actionName = ActionName.GoCQHTTP_DelGroupFile async _handle(payload: Payload) { diff --git a/src/onebot11/action/go-cqhttp/DelGroupFolder.ts b/src/onebot11/action/go-cqhttp/DelGroupFolder.ts index 2e4a692..2cb3984 100644 --- a/src/onebot11/action/go-cqhttp/DelGroupFolder.ts +++ b/src/onebot11/action/go-cqhttp/DelGroupFolder.ts @@ -6,7 +6,7 @@ interface Payload { folder_id: string } -export class GoCQHTTPDelGroupFolder extends BaseAction { +export class DelGroupFolder extends BaseAction { actionName = ActionName.GoCQHTTP_DelGroupFolder async _handle(payload: Payload) { diff --git a/src/onebot11/action/go-cqhttp/DownloadFile.ts b/src/onebot11/action/go-cqhttp/DownloadFile.ts index 808b841..2f25aa0 100644 --- a/src/onebot11/action/go-cqhttp/DownloadFile.ts +++ b/src/onebot11/action/go-cqhttp/DownloadFile.ts @@ -19,7 +19,7 @@ interface FileResponse { file: string } -export default class GoCQHTTPDownloadFile extends BaseAction { +export class DownloadFile extends BaseAction { actionName = ActionName.GoCQHTTP_DownloadFile protected async _handle(payload: Payload): Promise { diff --git a/src/onebot11/action/go-cqhttp/GetForwardMsg.ts b/src/onebot11/action/go-cqhttp/GetForwardMsg.ts index a2a29ef..d8a728c 100644 --- a/src/onebot11/action/go-cqhttp/GetForwardMsg.ts +++ b/src/onebot11/action/go-cqhttp/GetForwardMsg.ts @@ -13,7 +13,7 @@ interface Response { messages: (OB11Message & { content: OB11MessageData })[] } -export class GoCQHTTGetForwardMsgAction extends BaseAction { +export class GetForwardMsg extends BaseAction { actionName = ActionName.GoCQHTTP_GetForwardMsg protected async _handle(payload: Payload): Promise { const msgId = payload.id || payload.message_id diff --git a/src/onebot11/action/go-cqhttp/GetGroupMsgHistory.ts b/src/onebot11/action/go-cqhttp/GetGroupMsgHistory.ts index aed1a06..a429dcb 100644 --- a/src/onebot11/action/go-cqhttp/GetGroupMsgHistory.ts +++ b/src/onebot11/action/go-cqhttp/GetGroupMsgHistory.ts @@ -17,7 +17,7 @@ interface Response { messages: OB11Message[] } -export default class GoCQHTTPGetGroupMsgHistory extends BaseAction { +export class GetGroupMsgHistory extends BaseAction { actionName = ActionName.GoCQHTTP_GetGroupMsgHistory protected async _handle(payload: Payload): Promise { diff --git a/src/onebot11/action/go-cqhttp/GetGroupSystemMsg.ts b/src/onebot11/action/go-cqhttp/GetGroupSystemMsg.ts index bbaba57..7b6de96 100644 --- a/src/onebot11/action/go-cqhttp/GetGroupSystemMsg.ts +++ b/src/onebot11/action/go-cqhttp/GetGroupSystemMsg.ts @@ -24,7 +24,7 @@ interface Response { }[] } -export class GoCQHTTPGetGroupSystemMsg extends BaseAction { +export class GetGroupSystemMsg extends BaseAction { actionName = ActionName.GoCQHTTP_GetGroupSystemMsg async _handle(payload: void) { diff --git a/src/onebot11/action/go-cqhttp/GetStrangerInfo.ts b/src/onebot11/action/go-cqhttp/GetStrangerInfo.ts index dbe1946..03f9c34 100644 --- a/src/onebot11/action/go-cqhttp/GetStrangerInfo.ts +++ b/src/onebot11/action/go-cqhttp/GetStrangerInfo.ts @@ -10,7 +10,7 @@ interface Payload { user_id: number | string } -export default class GoCQHTTPGetStrangerInfo extends BaseAction { +export class GetStrangerInfo extends BaseAction { actionName = ActionName.GoCQHTTP_GetStrangerInfo protected async _handle(payload: Payload): Promise { diff --git a/src/onebot11/action/msg/MarkMsgAsRead.ts b/src/onebot11/action/go-cqhttp/MarkMsgAsRead.ts similarity index 76% rename from src/onebot11/action/msg/MarkMsgAsRead.ts rename to src/onebot11/action/go-cqhttp/MarkMsgAsRead.ts index f3796f5..ba8f3d6 100644 --- a/src/onebot11/action/msg/MarkMsgAsRead.ts +++ b/src/onebot11/action/go-cqhttp/MarkMsgAsRead.ts @@ -5,7 +5,7 @@ interface Payload { message_id: number } -export default class GoCQHTTPMarkMsgAsRead extends BaseAction { +export class MarkMsgAsRead extends BaseAction { actionName = ActionName.GoCQHTTP_MarkMsgAsRead protected async _handle(payload: Payload): Promise { diff --git a/src/onebot11/action/go-cqhttp/QuickOperation.ts b/src/onebot11/action/go-cqhttp/QuickOperation.ts index 6e1d9ac..a416444 100644 --- a/src/onebot11/action/go-cqhttp/QuickOperation.ts +++ b/src/onebot11/action/go-cqhttp/QuickOperation.ts @@ -7,7 +7,7 @@ interface Payload { operation: QuickOperation } -export class GoCQHTTHandleQuickOperation extends BaseAction { +export class HandleQuickOperation extends BaseAction { actionName = ActionName.GoCQHTTP_HandleQuickOperation protected async _handle(payload: Payload): Promise { handleQuickOperation(this.ctx, payload.context, payload.operation).catch(e => this.ctx.logger.error(e)) diff --git a/src/onebot11/action/go-cqhttp/SendForwardMsg.ts b/src/onebot11/action/go-cqhttp/SendForwardMsg.ts index aa75905..4e7b73d 100644 --- a/src/onebot11/action/go-cqhttp/SendForwardMsg.ts +++ b/src/onebot11/action/go-cqhttp/SendForwardMsg.ts @@ -3,7 +3,7 @@ import { OB11PostSendMsg } from '../../types' import { ActionName } from '../types' import { convertMessage2List } from '../../helper/createMessage' -export class GoCQHTTPSendForwardMsg extends SendMsg { +export class SendForwardMsg extends SendMsg { actionName = ActionName.GoCQHTTP_SendForwardMsg protected async check(payload: OB11PostSendMsg) { @@ -12,10 +12,10 @@ export class GoCQHTTPSendForwardMsg extends SendMsg { } } -export class GoCQHTTPSendPrivateForwardMsg extends GoCQHTTPSendForwardMsg { +export class SendPrivateForwardMsg extends SendForwardMsg { actionName = ActionName.GoCQHTTP_SendPrivateForwardMsg } -export class GoCQHTTPSendGroupForwardMsg extends GoCQHTTPSendForwardMsg { +export class SendGroupForwardMsg extends SendForwardMsg { actionName = ActionName.GoCQHTTP_SendGroupForwardMsg } diff --git a/src/onebot11/action/go-cqhttp/SetEssenceMsg.ts b/src/onebot11/action/go-cqhttp/SetEssenceMsg.ts index 827b200..d3c1fef 100644 --- a/src/onebot11/action/go-cqhttp/SetEssenceMsg.ts +++ b/src/onebot11/action/go-cqhttp/SetEssenceMsg.ts @@ -6,7 +6,7 @@ interface Payload { message_id: number | string } -export default class GoCQHTTPSetEssenceMsg extends BaseAction { +export class SetEssenceMsg extends BaseAction { actionName = ActionName.GoCQHTTP_SetEssenceMsg; protected async _handle(payload: Payload): Promise { diff --git a/src/onebot11/action/go-cqhttp/UploadFile.ts b/src/onebot11/action/go-cqhttp/UploadFile.ts index 41d67fb..e40ecd4 100644 --- a/src/onebot11/action/go-cqhttp/UploadFile.ts +++ b/src/onebot11/action/go-cqhttp/UploadFile.ts @@ -16,7 +16,7 @@ interface Payload { folder_id?: string } -export class GoCQHTTPUploadGroupFile extends BaseAction { +export class UploadGroupFile extends BaseAction { actionName = ActionName.GoCQHTTP_UploadGroupFile protected async _handle(payload: Payload): Promise { @@ -37,7 +37,7 @@ export class GoCQHTTPUploadGroupFile extends BaseAction { } } -export class GoCQHTTPUploadPrivateFile extends BaseAction { +export class UploadPrivateFile extends BaseAction { actionName = ActionName.GoCQHTTP_UploadPrivateFile async getPeer(payload: Payload): Promise { diff --git a/src/onebot11/action/index.ts b/src/onebot11/action/index.ts index d37de37..44990ca 100644 --- a/src/onebot11/action/index.ts +++ b/src/onebot11/action/index.ts @@ -16,11 +16,11 @@ import CanSendRecord from './system/CanSendRecord' import CanSendImage from './system/CanSendImage' import GetStatus from './system/GetStatus' import { - GoCQHTTPSendForwardMsg, - GoCQHTTPSendGroupForwardMsg, - GoCQHTTPSendPrivateForwardMsg, + SendForwardMsg, + SendGroupForwardMsg, + SendPrivateForwardMsg, } from './go-cqhttp/SendForwardMsg' -import GoCQHTTPGetStrangerInfo from './go-cqhttp/GetStrangerInfo' +import { GetStrangerInfo } from './go-cqhttp/GetStrangerInfo' import SendLike from './user/SendLike' import SetGroupAddRequest from './group/SetGroupAddRequest' import SetGroupLeave from './group/SetGroupLeave' @@ -35,29 +35,30 @@ import SetGroupAdmin from './group/SetGroupAdmin' import SetGroupCard from './group/SetGroupCard' import GetImage from './file/GetImage' import GetRecord from './file/GetRecord' -import GoCQHTTPMarkMsgAsRead from './msg/MarkMsgAsRead' +import { MarkMsgAsRead } from './go-cqhttp/MarkMsgAsRead' import CleanCache from './system/CleanCache' -import { GoCQHTTPUploadGroupFile, GoCQHTTPUploadPrivateFile } from './go-cqhttp/UploadFile' +import { UploadGroupFile, UploadPrivateFile } from './go-cqhttp/UploadFile' import { GetConfigAction, SetConfigAction } from './llonebot/Config' import GetGroupAddRequest from './llonebot/GetGroupAddRequest' import SetQQAvatar from './llonebot/SetQQAvatar' -import GoCQHTTPDownloadFile from './go-cqhttp/DownloadFile' -import GoCQHTTPGetGroupMsgHistory from './go-cqhttp/GetGroupMsgHistory' +import { DownloadFile } from './go-cqhttp/DownloadFile' +import { GetGroupMsgHistory } from './go-cqhttp/GetGroupMsgHistory' import GetFile from './file/GetFile' -import { GoCQHTTGetForwardMsgAction } from './go-cqhttp/GetForwardMsg' +import { GetForwardMsg } from './go-cqhttp/GetForwardMsg' import { GetCookies } from './user/GetCookie' import { SetMsgEmojiLike } from './msg/SetMsgEmojiLike' import { ForwardFriendSingleMsg, ForwardGroupSingleMsg } from './msg/ForwardSingleMsg' import { GetGroupEssence } from './group/GetGroupEssence' import { GetGroupHonorInfo } from './group/GetGroupHonorInfo' -import { GoCQHTTHandleQuickOperation } from './go-cqhttp/QuickOperation' -import GoCQHTTPSetEssenceMsg from './go-cqhttp/SetEssenceMsg' -import GoCQHTTPDelEssenceMsg from './go-cqhttp/DelEssenceMsg' +import { HandleQuickOperation } from './go-cqhttp/QuickOperation' +import { SetEssenceMsg } from './go-cqhttp/SetEssenceMsg' +import { DelEssenceMsg } from './go-cqhttp/DelEssenceMsg' import GetEvent from './llonebot/GetEvent' -import { GoCQHTTPDelGroupFile } from './go-cqhttp/DelGroupFile' -import { GoCQHTTPGetGroupSystemMsg } from './go-cqhttp/GetGroupSystemMsg' -import { GoCQHTTPCreateGroupFileFolder } from './go-cqhttp/CreateGroupFileFolder' -import { GoCQHTTPDelGroupFolder } from './go-cqhttp/DelGroupFolder' +import { DelGroupFile } from './go-cqhttp/DelGroupFile' +import { GetGroupSystemMsg } from './go-cqhttp/GetGroupSystemMsg' +import { CreateGroupFileFolder } from './go-cqhttp/CreateGroupFileFolder' +import { DelGroupFolder } from './go-cqhttp/DelGroupFolder' +import { GetGroupAtAllRemain } from './go-cqhttp/GetGroupAtAllRemain' export function initActionMap(adapter: Adapter) { const actionHandlers = [ @@ -105,24 +106,25 @@ export function initActionMap(adapter: Adapter) { //以下为go-cqhttp api new GetGroupEssence(adapter), new GetGroupHonorInfo(adapter), - new GoCQHTTPSendForwardMsg(adapter), - new GoCQHTTPSendGroupForwardMsg(adapter), - new GoCQHTTPSendPrivateForwardMsg(adapter), - new GoCQHTTPGetStrangerInfo(adapter), - new GoCQHTTPDownloadFile(adapter), + new SendForwardMsg(adapter), + new SendGroupForwardMsg(adapter), + new SendPrivateForwardMsg(adapter), + new GetStrangerInfo(adapter), + new DownloadFile(adapter), new GetGuildList(adapter), - new GoCQHTTPMarkMsgAsRead(adapter), - new GoCQHTTPUploadGroupFile(adapter), - new GoCQHTTPUploadPrivateFile(adapter), - new GoCQHTTPGetGroupMsgHistory(adapter), - new GoCQHTTGetForwardMsgAction(adapter), - new GoCQHTTHandleQuickOperation(adapter), - new GoCQHTTPSetEssenceMsg(adapter), - new GoCQHTTPDelEssenceMsg(adapter), - new GoCQHTTPDelGroupFile(adapter), - new GoCQHTTPGetGroupSystemMsg(adapter), - new GoCQHTTPCreateGroupFileFolder(adapter), - new GoCQHTTPDelGroupFolder(adapter) + new MarkMsgAsRead(adapter), + new UploadGroupFile(adapter), + new UploadPrivateFile(adapter), + new GetGroupMsgHistory(adapter), + new GetForwardMsg(adapter), + new HandleQuickOperation(adapter), + new SetEssenceMsg(adapter), + new DelEssenceMsg(adapter), + new DelGroupFile(adapter), + new GetGroupSystemMsg(adapter), + new CreateGroupFileFolder(adapter), + new DelGroupFolder(adapter), + new GetGroupAtAllRemain(adapter) ] const actionMap = new Map>() for (const action of actionHandlers) {