测试入群提醒。
This commit is contained in:
@@ -44,7 +44,8 @@ class ChatroomMixin(WechatAPIClientBase):
|
||||
|
||||
async with aiohttp.ClientSession() as session:
|
||||
json_param = {"Wxid": self.wxid, "QID": chatroom}
|
||||
response = await session.post(f'http://{self.ip}:{self.port}/api/Group/GetChatRoomInfoDetail', json=json_param)
|
||||
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"):
|
||||
@@ -90,7 +91,8 @@ class ChatroomMixin(WechatAPIClientBase):
|
||||
|
||||
async with aiohttp.ClientSession() as session:
|
||||
json_param = {"Wxid": self.wxid, "QID": chatroom}
|
||||
response = await session.post(f'http://{self.ip}:{self.port}/api/Group/GetChatRoomMemberDetail', json=json_param)
|
||||
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"):
|
||||
@@ -159,7 +161,7 @@ class ChatroomMixin(WechatAPIClientBase):
|
||||
Union[str, list[str]]: 如果输入单个wxid返回str,如果输入wxid列表则返回对应的昵称列表
|
||||
"""
|
||||
data = await self.get_chatroom_member_list(chatroom)
|
||||
|
||||
|
||||
if isinstance(wxid, str):
|
||||
# 单个wxid的情况
|
||||
for member in data:
|
||||
@@ -181,3 +183,21 @@ class ChatroomMixin(WechatAPIClientBase):
|
||||
if not found:
|
||||
result.append("") # 如果没找到对应的成员,添加空字符串
|
||||
return result
|
||||
|
||||
async def get_chatroom_member_detail(self, wxid: str, chatroom: str) -> dict:
|
||||
"""获取用户昵称
|
||||
|
||||
Args:
|
||||
wxid: 用户wxid,可以是单个wxid或最多20个wxid的列表
|
||||
chatroom: 群聊id
|
||||
|
||||
Returns:
|
||||
Union[str, list[str]]: 如果输入单个wxid返回str,如果输入wxid列表则返回对应的昵称列表
|
||||
"""
|
||||
data = await self.get_chatroom_member_list(chatroom)
|
||||
|
||||
for member in data:
|
||||
if member.get("UserName") == wxid:
|
||||
# 优先返回DisplayName,如果不存在则返回NickName
|
||||
return member
|
||||
return {} # 如果没找到对应的成员,返回空字符串
|
||||
|
||||
Reference in New Issue
Block a user