From 9672f67a230031dd57f8399dbae250a5bb363de2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?=
 <nanaeonn@outlook.com>
Date: Wed, 15 May 2024 21:12:10 +0800
Subject: [PATCH] feat: new Api GetGroupEssence&GetGroupHonorInfo

---
 src/onebot11/action/group/GetGroupEssence.ts  | 20 +++++++++++++++++
 .../action/group/GetGroupHonorInfo.ts         | 22 +++++++++++++++++++
 src/onebot11/action/index.ts                  |  4 ++++
 src/onebot11/action/types.ts                  |  2 ++
 4 files changed, 48 insertions(+)
 create mode 100644 src/onebot11/action/group/GetGroupEssence.ts
 create mode 100644 src/onebot11/action/group/GetGroupHonorInfo.ts

diff --git a/src/onebot11/action/group/GetGroupEssence.ts b/src/onebot11/action/group/GetGroupEssence.ts
new file mode 100644
index 0000000..739eee5
--- /dev/null
+++ b/src/onebot11/action/group/GetGroupEssence.ts
@@ -0,0 +1,20 @@
+import { GroupEssenceMsgRet, WebApi } from "@/ntqqapi/api";
+import BaseAction from "../BaseAction";
+import { ActionName } from "../types";
+
+interface PayloadType {
+  group_id: number;
+  pages: number;
+}
+
+export class GetGroupEssence extends BaseAction<PayloadType, GroupEssenceMsgRet> {
+  actionName = ActionName.GoCQHTTP_GetEssenceMsg;
+
+  protected async _handle(payload: PayloadType) {
+    const ret = await WebApi.getGroupEssenceMsg(payload.group_id.toString(), payload.pages.toString());
+    if (!ret) {
+      throw new Error('获取失败');
+    }
+    return ret;
+  }
+}
diff --git a/src/onebot11/action/group/GetGroupHonorInfo.ts b/src/onebot11/action/group/GetGroupHonorInfo.ts
new file mode 100644
index 0000000..9e72ecd
--- /dev/null
+++ b/src/onebot11/action/group/GetGroupHonorInfo.ts
@@ -0,0 +1,22 @@
+import { WebApi, WebHonorType } from "@/ntqqapi/api";
+import { ActionName } from "../types";
+import BaseAction from "../BaseAction";
+
+interface Payload {
+  group_id: number,
+  type?: WebHonorType
+}
+export class GetGroupHonorInfo extends BaseAction<Payload, Array<any>> {
+  actionName = ActionName.GetGroupHonorInfo;
+
+  protected async _handle(payload: Payload) {
+    // console.log(await NTQQUserApi.getRobotUinRange());
+    if (!payload.group_id) {
+      throw '缺少参数group_id';
+    }
+    if (!payload.type) {
+      payload.type = WebHonorType.ALL;
+    }
+    return await WebApi.getGroupHonorInfo(payload.group_id.toString(), payload.type);
+  }
+}
diff --git a/src/onebot11/action/index.ts b/src/onebot11/action/index.ts
index a5a4539..adc8edc 100644
--- a/src/onebot11/action/index.ts
+++ b/src/onebot11/action/index.ts
@@ -47,6 +47,8 @@ import { GoCQHTTGetForwardMsgAction } from './go-cqhttp/GetForwardMsg'
 import { GetCookies } from './user/GetCookie'
 import { SetMsgEmojiLike } from './msg/SetMsgEmojiLike'
 import { ForwardFriendSingleMsg, ForwardSingleGroupMsg } from './msg/ForwardSingleMsg'
+import { GetGroupEssence } from './group/GetGroupEssence'
+import { GetGroupHonorInfo } from './group/GetGroupHonorInfo'
 
 export const actionHandlers = [
   new GetFile(),
@@ -89,6 +91,8 @@ export const actionHandlers = [
   new ForwardFriendSingleMsg(),
   new ForwardSingleGroupMsg(),
   //以下为go-cqhttp api
+  new GetGroupEssence(),
+  new GetGroupHonorInfo(),
   new GoCQHTTPSendForwardMsg(),
   new GoCQHTTPSendGroupForwardMsg(),
   new GoCQHTTPSendPrivateForwardMsg(),
diff --git a/src/onebot11/action/types.ts b/src/onebot11/action/types.ts
index 039aa15..5d15705 100644
--- a/src/onebot11/action/types.ts
+++ b/src/onebot11/action/types.ts
@@ -66,4 +66,6 @@ export enum ActionName {
   GoCQHTTP_DownloadFile = 'download_file',
   GoCQHTTP_GetGroupMsgHistory = 'get_group_msg_history',
   GoCQHTTP_GetForwardMsg = 'get_forward_msg',
+  GoCQHTTP_GetEssenceMsg = "get_essence_msg_list",
+  GetGroupHonorInfo = "get_group_honor_info",
 }