From c95682a0c7f5a8e5d3802d0ebc56edb8b19739dc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 14 Mar 2025 09:11:21 +0000 Subject: [PATCH] :balloon: auto fixes by pre-commit hooks --- .../core/platform/sources/gewechat/client.py | 119 +++++++++--------- 1 file changed, 59 insertions(+), 60 deletions(-) diff --git a/astrbot/core/platform/sources/gewechat/client.py b/astrbot/core/platform/sources/gewechat/client.py index 985185b1..abaf1a87 100644 --- a/astrbot/core/platform/sources/gewechat/client.py +++ b/astrbot/core/platform/sources/gewechat/client.py @@ -24,12 +24,12 @@ class SimpleGewechatClient: """ def __init__( - self, - base_url: str, - nickname: str, - host: str, - port: int, - event_queue: asyncio.Queue, + self, + base_url: str, + nickname: str, + host: str, + port: int, + event_queue: asyncio.Queue, ): self.base_url = base_url if self.base_url.endswith("/"): @@ -139,8 +139,8 @@ class SimpleGewechatClient: # at msg_source = d["MsgSource"] if ( - f"" in msg_source - or f"" in msg_source + f"" in msg_source + or f"" in msg_source ): at_me = True if "在群聊中@了你" in d.get("PushContent", ""): @@ -157,8 +157,8 @@ class SimpleGewechatClient: user_real_name = "unknown" if abm.group_id: if ( - abm.group_id not in self.userrealnames - or user_id not in self.userrealnames[abm.group_id] + abm.group_id not in self.userrealnames + or user_id not in self.userrealnames[abm.group_id] ): # 获取群成员列表,并且缓存 if abm.group_id not in self.userrealnames: @@ -252,9 +252,9 @@ class SimpleGewechatClient: await asyncio.sleep(3) async with aiohttp.ClientSession() as session: async with session.post( - f"{self.base_url}/tools/setCallback", - headers=self.headers, - json={"token": self.token, "callbackUrl": self.callback_url}, + f"{self.base_url}/tools/setCallback", + headers=self.headers, + json={"token": self.token, "callbackUrl": self.callback_url}, ) as resp: json_blob = await resp.json() logger.info(f"设置回调结果: {json_blob}") @@ -282,9 +282,9 @@ class SimpleGewechatClient: # /login/checkOnline async with aiohttp.ClientSession() as session: async with session.post( - f"{self.base_url}/login/checkOnline", - headers=self.headers, - json={"appId": appid}, + f"{self.base_url}/login/checkOnline", + headers=self.headers, + json={"appId": appid}, ) as resp: json_blob = await resp.json() return json_blob["data"] @@ -295,9 +295,9 @@ class SimpleGewechatClient: if online: async with aiohttp.ClientSession() as session: async with session.post( - f"{self.base_url}/login/logout", - headers=self.headers, - json={"appId": self.appid}, + f"{self.base_url}/login/logout", + headers=self.headers, + json={"appId": self.appid}, ) as resp: json_blob = await resp.json() logger.info(f"登出结果: {json_blob}") @@ -329,9 +329,9 @@ class SimpleGewechatClient: try: async with aiohttp.ClientSession() as session: async with session.post( - f"{self.base_url}/login/getLoginQrCode", - headers=self.headers, - json=payload, + f"{self.base_url}/login/getLoginQrCode", + headers=self.headers, + json=payload, ) as resp: json_blob = await resp.json() if json_blob["ret"] != 200: @@ -380,9 +380,9 @@ class SimpleGewechatClient: async with aiohttp.ClientSession() as session: async with session.post( - f"{self.base_url}/login/checkLogin", - headers=self.headers, - json=payload, + f"{self.base_url}/login/checkLogin", + headers=self.headers, + json=payload, ) as resp: json_blob = await resp.json() logger.info(f"检查登录状态: {json_blob}") @@ -421,9 +421,9 @@ class SimpleGewechatClient: async with aiohttp.ClientSession() as session: async with session.post( - f"{self.base_url}/group/getChatroomMemberList", - headers=self.headers, - json=payload, + f"{self.base_url}/group/getChatroomMemberList", + headers=self.headers, + json=payload, ) as resp: json_blob = await resp.json() return json_blob["data"] @@ -439,7 +439,7 @@ class SimpleGewechatClient: async with aiohttp.ClientSession() as session: async with session.post( - f"{self.base_url}/message/postText", headers=self.headers, json=payload + f"{self.base_url}/message/postText", headers=self.headers, json=payload ) as resp: json_blob = await resp.json() logger.debug(f"发送消息结果: {json_blob}") @@ -453,7 +453,7 @@ class SimpleGewechatClient: async with aiohttp.ClientSession() as session: async with session.post( - f"{self.base_url}/message/postImage", headers=self.headers, json=payload + f"{self.base_url}/message/postImage", headers=self.headers, json=payload ) as resp: json_blob = await resp.json() logger.debug(f"发送图片结果: {json_blob}") @@ -470,7 +470,7 @@ class SimpleGewechatClient: async with aiohttp.ClientSession() as session: async with session.post( - f"{self.base_url}/message/postVoice", headers=self.headers, json=payload + f"{self.base_url}/message/postVoice", headers=self.headers, json=payload ) as resp: json_blob = await resp.json() logger.debug(f"发送语音结果: {json_blob}") @@ -485,7 +485,7 @@ class SimpleGewechatClient: async with aiohttp.ClientSession() as session: async with session.post( - f"{self.base_url}/message/postFile", headers=self.headers, json=payload + f"{self.base_url}/message/postFile", headers=self.headers, json=payload ) as resp: json_blob = await resp.json() logger.debug(f"发送文件结果: {json_blob}") @@ -503,9 +503,9 @@ class SimpleGewechatClient: async with aiohttp.ClientSession() as session: async with session.post( - f"{self.base_url}/contacts/addContacts", - headers=self.headers, - json=payload, + f"{self.base_url}/contacts/addContacts", + headers=self.headers, + json=payload, ) as resp: json_blob = await resp.json() logger.debug(f"申请添加好友结果: {json_blob}") @@ -519,9 +519,9 @@ class SimpleGewechatClient: async with aiohttp.ClientSession() as session: async with session.post( - f"{self.base_url}/group/getChatroomInfo", - headers=self.headers, - json=payload, + f"{self.base_url}/group/getChatroomInfo", + headers=self.headers, + json=payload, ) as resp: json_blob = await resp.json() logger.debug(f"获取群信息结果: {json_blob}") @@ -535,9 +535,9 @@ class SimpleGewechatClient: async with aiohttp.ClientSession() as session: async with session.post( - f"{self.base_url}/group/getChatroomMemberList", - headers=self.headers, - json=payload, + f"{self.base_url}/group/getChatroomMemberList", + headers=self.headers, + json=payload, ) as resp: json_blob = await resp.json() logger.debug(f"获取群信息结果: {json_blob}") @@ -545,34 +545,33 @@ class SimpleGewechatClient: async def accept_group_invite(self, url: str): """同意进群""" - payload = { - "appId": self.appid, - "url": url - } + payload = {"appId": self.appid, "url": url} async with aiohttp.ClientSession() as session: async with session.post( - f"{self.base_url}/group/agreeJoinRoom", - headers=self.headers, - json=payload, + f"{self.base_url}/group/agreeJoinRoom", + 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): + 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 + "memberWxid": to_wxid, } async with aiohttp.ClientSession() as session: async with session.post( - f"{self.base_url}/group/addGroupMemberAsFriend", - headers=self.headers, - json=payload, + f"{self.base_url}/group/addGroupMemberAsFriend", + headers=self.headers, + json=payload, ) as resp: json_blob = await resp.json() logger.debug(f"获取群信息结果: {json_blob}") @@ -580,23 +579,23 @@ class SimpleGewechatClient: async def get_user_or_group_info(self, *ids): """ - 获取用户或群组信息。 + 获取用户或群组信息。 - :param ids: 可变数量的 wxid 参数 - """ + :param ids: 可变数量的 wxid 参数 + """ wxids_str = list(ids) payload = { "appId": self.appid, - "wxids": wxids_str # 使用逗号分隔的字符串 + "wxids": wxids_str, # 使用逗号分隔的字符串 } async with aiohttp.ClientSession() as session: async with session.post( - f"{self.base_url}/contacts/getDetailInfo", - headers=self.headers, - json=payload, + f"{self.base_url}/contacts/getDetailInfo", + headers=self.headers, + json=payload, ) as resp: json_blob = await resp.json() logger.debug(f"获取群信息结果: {json_blob}")