From d9ec43469993052dd416a2fbce00bccf254749a8 Mon Sep 17 00:00:00 2001 From: Moyuyanli <572490972@qq.com> Date: Tue, 11 Mar 2025 17:08:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:gewe=E7=9A=84client=E6=B7=BB=E5=8A=A0=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=A5=BD=E5=8F=8B=E6=8E=A5=E5=8F=A3=20feat:g?= =?UTF-8?q?ewe=E7=9A=84client=E6=B7=BB=E5=8A=A0=20=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E7=BE=A4=E4=BF=A1=E6=81=AF/=E7=BE=A4=E6=88=90=E5=91=98?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=20feat:gewe=E7=9A=84client=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=20=E6=B7=BB=E5=8A=A0=E7=BE=A4=E6=88=90=E5=91=98=E4=B8=BA?= =?UTF-8?q?=E5=A5=BD=E5=8F=8B=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/platform/sources/gewechat/client.py | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/astrbot/core/platform/sources/gewechat/client.py b/astrbot/core/platform/sources/gewechat/client.py index 7268efded..de7762b2d 100644 --- a/astrbot/core/platform/sources/gewechat/client.py +++ b/astrbot/core/platform/sources/gewechat/client.py @@ -487,3 +487,75 @@ class SimpleGewechatClient: ) as resp: json_blob = await resp.json() logger.debug(f"发送文件结果: {json_blob}") + + async def add_friend(self, v3: str, v4: str, content: str): + """申请添加好友""" + payload = { + "appId": self.appid, + "scene": 3, + "content": content, + "v4": v4, + "v3": v3, + "option": 2, + } + + async with aiohttp.ClientSession() as session: + async with session.post( + f"{self.base_url}/contacts/addContacts", + headers=self.headers, + json=payload, + ) as resp: + json_blob = await resp.json() + logger.debug(f"申请添加好友结果: {json_blob}") + return json_blob + + async def get_group(self, group_id: str): + payload = { + "appId": self.appid, + "chatroomId": group_id, + } + + async with aiohttp.ClientSession() as session: + async with session.post( + f"{self.base_url}/group/getChatroomInfo", + headers=self.headers, + json=payload, + ) as resp: + json_blob = await resp.json() + logger.debug(f"获取群信息结果: {json_blob}") + return json_blob + + async def get_group_member(self, group_id: str): + payload = { + "appId": self.appid, + "chatroomId": group_id, + } + + async with aiohttp.ClientSession() as session: + async with session.post( + f"{self.base_url}/group/getChatroomMemberList", + headers=self.headers, + json=payload, + ) as resp: + json_blob = await resp.json() + logger.debug(f"获取群信息结果: {json_blob}") + return json_blob + + + async def add_group_member_to_friend(self, group_id: str,to_wxid: str,content: str): + payload = { + "appId": self.appid, + "chatroomId": group_id, + "content": content, + "memberWxid": to_wxid + } + + async with aiohttp.ClientSession() as session: + async with session.post( + f"{self.base_url}/group/addGroupMemberAsFriend", + headers=self.headers, + json=payload, + ) as resp: + json_blob = await resp.json() + logger.debug(f"获取群信息结果: {json_blob}") + return json_blob \ No newline at end of file