From cd50df3a56c42e38d7494c42859cf86daad0225c Mon Sep 17 00:00:00 2001 From: MisakaTAT Date: Mon, 25 Mar 2024 17:50:54 +0800 Subject: [PATCH] feat: added an gocqhttp extended api send_forward_msg --- src/onebot11/action/go-cqhttp/SendForwardMsg.ts | 16 ++++++++++------ src/onebot11/action/index.ts | 3 ++- src/onebot11/action/types.ts | 1 + 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/onebot11/action/go-cqhttp/SendForwardMsg.ts b/src/onebot11/action/go-cqhttp/SendForwardMsg.ts index 9e3c3ca..ff14537 100644 --- a/src/onebot11/action/go-cqhttp/SendForwardMsg.ts +++ b/src/onebot11/action/go-cqhttp/SendForwardMsg.ts @@ -2,17 +2,21 @@ import SendMsg, {convertMessage2List} from "../msg/SendMsg"; import {OB11PostSendMsg} from "../../types"; import {ActionName} from "../types"; -export class GoCQHTTPSendGroupForwardMsg extends SendMsg { - actionName = ActionName.GoCQHTTP_SendGroupForwardMsg; +export class GoCQHTTPSendForwardMsg extends SendMsg { + actionName = ActionName.GoCQHTTP_SendForwardMsg; protected async check(payload: OB11PostSendMsg) { - if (payload.messages){ - payload.message = convertMessage2List(payload.messages); - } + if (payload.user_id) this.actionName = ActionName.GoCQHTTP_SendPrivateForwardMsg; + if (payload.group_id) this.actionName = ActionName.GoCQHTTP_SendGroupForwardMsg; + if (payload.messages) payload.message = convertMessage2List(payload.messages); return super.check(payload); } } -export class GoCQHTTPSendPrivateForwardMsg extends GoCQHTTPSendGroupForwardMsg { +export class GoCQHTTPSendPrivateForwardMsg extends GoCQHTTPSendForwardMsg { actionName = ActionName.GoCQHTTP_SendPrivateForwardMsg; +} + +export class GoCQHTTPSendGroupForwardMsg extends GoCQHTTPSendForwardMsg { + actionName = ActionName.GoCQHTTP_SendGroupForwardMsg; } \ No newline at end of file diff --git a/src/onebot11/action/index.ts b/src/onebot11/action/index.ts index d0edfd2..bfc5530 100644 --- a/src/onebot11/action/index.ts +++ b/src/onebot11/action/index.ts @@ -14,7 +14,7 @@ import GetVersionInfo from "./system/GetVersionInfo"; import CanSendRecord from "./system/CanSendRecord"; import CanSendImage from "./system/CanSendImage"; import GetStatus from "./system/GetStatus"; -import {GoCQHTTPSendGroupForwardMsg, GoCQHTTPSendPrivateForwardMsg} from "./go-cqhttp/SendForwardMsg"; +import {GoCQHTTPSendForwardMsg, GoCQHTTPSendGroupForwardMsg, GoCQHTTPSendPrivateForwardMsg} from "./go-cqhttp/SendForwardMsg"; import GoCQHTTPGetStrangerInfo from "./go-cqhttp/GetStrangerInfo"; import SendLike from "./user/SendLike"; import SetGroupAddRequest from "./group/SetGroupAddRequest"; @@ -73,6 +73,7 @@ export const actionHandlers = [ new CleanCache(), //以下为go-cqhttp api + new GoCQHTTPSendForwardMsg(), new GoCQHTTPSendGroupForwardMsg(), new GoCQHTTPSendPrivateForwardMsg(), new GoCQHTTPGetStrangerInfo(), diff --git a/src/onebot11/action/types.ts b/src/onebot11/action/types.ts index 5985b1b..2216dc0 100644 --- a/src/onebot11/action/types.ts +++ b/src/onebot11/action/types.ts @@ -51,6 +51,7 @@ export enum ActionName { GetRecord = "get_record", CleanCache = "clean_cache", // 以下为go-cqhttp api + GoCQHTTP_SendForwardMsg = "send_forward_msg", GoCQHTTP_SendGroupForwardMsg = "send_group_forward_msg", GoCQHTTP_SendPrivateForwardMsg = "send_private_forward_msg", GoCQHTTP_GetStrangerInfo = "get_stranger_info",