855 协议版本-调整完毕内容
This commit is contained in:
@@ -43,8 +43,8 @@ class ChatroomMixin(WechatAPIClientBase):
|
||||
raise UserLoggedOut("请先登录")
|
||||
|
||||
async with aiohttp.ClientSession() as session:
|
||||
json_param = {"Wxid": self.wxid, "Chatroom": chatroom}
|
||||
response = await session.post(f'http://{self.ip}:{self.port}/GetChatroomInfo', json=json_param)
|
||||
json_param = {"Wxid": self.wxid, "QID": chatroom}
|
||||
response = await session.post(f'http://{self.ip}:{self.port}/api/Group/GetChatRoomInfoDetail', json=json_param)
|
||||
json_resp = await response.json()
|
||||
|
||||
if json_resp.get("Success"):
|
||||
@@ -67,8 +67,8 @@ class ChatroomMixin(WechatAPIClientBase):
|
||||
raise UserLoggedOut("请先登录")
|
||||
|
||||
async with aiohttp.ClientSession() as session:
|
||||
json_param = {"Wxid": self.wxid, "Chatroom": chatroom}
|
||||
response = await session.post(f'http://{self.ip}:{self.port}/GetChatroomInfoNoAnnounce', json=json_param)
|
||||
json_param = {"Wxid": self.wxid, "QID": chatroom}
|
||||
response = await session.post(f'http://{self.ip}:{self.port}/api/Group/GetChatRoomInfo', json=json_param)
|
||||
json_resp = await response.json()
|
||||
|
||||
if json_resp.get("Success"):
|
||||
@@ -89,8 +89,8 @@ class ChatroomMixin(WechatAPIClientBase):
|
||||
raise UserLoggedOut("请先登录")
|
||||
|
||||
async with aiohttp.ClientSession() as session:
|
||||
json_param = {"Wxid": self.wxid, "Chatroom": chatroom}
|
||||
response = await session.post(f'http://{self.ip}:{self.port}/GetChatroomMemberDetail', json=json_param)
|
||||
json_param = {"Wxid": self.wxid, "QID": chatroom}
|
||||
response = await session.post(f'http://{self.ip}:{self.port}/api/Group/GetChatRoomMemberDetail', json=json_param)
|
||||
json_resp = await response.json()
|
||||
|
||||
if json_resp.get("Success"):
|
||||
@@ -138,11 +138,46 @@ class ChatroomMixin(WechatAPIClientBase):
|
||||
wxid = ",".join(wxid)
|
||||
|
||||
async with aiohttp.ClientSession() as session:
|
||||
json_param = {"Wxid": self.wxid, "Chatroom": chatroom, "InviteWxids": wxid}
|
||||
response = await session.post(f'http://{self.ip}:{self.port}/InviteChatroomMember', json=json_param)
|
||||
json_param = {"Wxid": self.wxid, "ChatRoomName": chatroom, "ToWxids": wxid}
|
||||
response = await session.post(f'http://{self.ip}:{self.port}/api/Group/InviteChatRoomMember',
|
||||
json=json_param)
|
||||
json_resp = await response.json()
|
||||
|
||||
if json_resp.get("Success"):
|
||||
return True
|
||||
else:
|
||||
self.error_handler(json_resp)
|
||||
|
||||
async def get_chatroom_nickname(self, wxid: Union[str, list[str]], chatroom: str) -> Union[str, list[str]]:
|
||||
"""获取用户昵称
|
||||
|
||||
Args:
|
||||
wxid: 用户wxid,可以是单个wxid或最多20个wxid的列表
|
||||
chatroom: 群聊id
|
||||
|
||||
Returns:
|
||||
Union[str, list[str]]: 如果输入单个wxid返回str,如果输入wxid列表则返回对应的昵称列表
|
||||
"""
|
||||
data = await self.get_chatroom_member_list(chatroom)
|
||||
|
||||
if isinstance(wxid, str):
|
||||
# 单个wxid的情况
|
||||
for member in data:
|
||||
if member.get("UserName") == wxid:
|
||||
# 优先返回DisplayName,如果不存在则返回NickName
|
||||
return member.get("DisplayName") or member.get("NickName") or ""
|
||||
return "" # 如果没找到对应的成员,返回空字符串
|
||||
else:
|
||||
# wxid列表的情况
|
||||
result = []
|
||||
for single_wxid in wxid:
|
||||
found = False
|
||||
for member in data:
|
||||
if member.get("UserName") == single_wxid:
|
||||
# 优先返回DisplayName,如果不存在则返回NickName
|
||||
result.append(member.get("DisplayName") or member.get("NickName") or "")
|
||||
found = True
|
||||
break
|
||||
if not found:
|
||||
result.append("") # 如果没找到对应的成员,添加空字符串
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user