测试入群提醒。
This commit is contained in:
@@ -119,12 +119,61 @@ class GroupMemberChangePlugin(MessagePluginInterface):
|
|||||||
wxid = member["wxid"]
|
wxid = member["wxid"]
|
||||||
nickname = member["nickname"]
|
nickname = member["nickname"]
|
||||||
|
|
||||||
# now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||||
member_wxids = [wxid]
|
member_wxids = [wxid]
|
||||||
|
|
||||||
await bot.send_at_message(roomid, f"👏欢迎 {nickname} 加入群聊!🎉", member_wxids)
|
await bot.send_at_message(roomid, f"👏欢迎 {nickname} 加入群聊!🎉", member_wxids)
|
||||||
# members = await bot.get_contract_detail(member_wxids, roomid)
|
members = await bot.get_chatroom_member_detail(wxid, roomid)
|
||||||
|
head_url = members.get("SmallHeadImgUrl") or members.get("BigHeadImgUrl") or ""
|
||||||
|
|
||||||
|
xml_content = f"""
|
||||||
|
<appmsg appid="" sdkver="1">
|
||||||
|
<title>👏欢迎 {nickname} 加入群聊!🎉</title>
|
||||||
|
<des>⌚时间:{now}</des>
|
||||||
|
<action>view</action>
|
||||||
|
<type>5</type>
|
||||||
|
<showtype>0</showtype>
|
||||||
|
<content />
|
||||||
|
<url>https://hot.imsyy.top/#/</url>
|
||||||
|
<dataurl />
|
||||||
|
<lowurl />
|
||||||
|
<lowdataurl />
|
||||||
|
<recorditem />
|
||||||
|
<thumburl>{head_url}</thumburl>
|
||||||
|
<messageaction />
|
||||||
|
<laninfo />
|
||||||
|
<extinfo />
|
||||||
|
<sourceusername />
|
||||||
|
<sourcedisplayname />
|
||||||
|
<commenturl />
|
||||||
|
<appattach>
|
||||||
|
<totallen>0</totallen>
|
||||||
|
<attachid />
|
||||||
|
<emoticonmd5 />
|
||||||
|
<fileext />
|
||||||
|
<aeskey />
|
||||||
|
</appattach>
|
||||||
|
<webviewshared>
|
||||||
|
<publisherId />
|
||||||
|
<publisherReqId>0</publisherReqId>
|
||||||
|
</webviewshared>
|
||||||
|
<weappinfo>
|
||||||
|
<pagepath />
|
||||||
|
<username />
|
||||||
|
<appid />
|
||||||
|
<appservicetype>0</appservicetype>
|
||||||
|
</weappinfo>
|
||||||
|
<websearch />
|
||||||
|
</appmsg>
|
||||||
|
<fromusername>Jyunere</fromusername>
|
||||||
|
<scene>0</scene>
|
||||||
|
<appinfo>
|
||||||
|
<version>1</version>
|
||||||
|
<appname></appname>
|
||||||
|
</appinfo>
|
||||||
|
<commenturl></commenturl>
|
||||||
|
"""
|
||||||
|
await bot.send_link_xml_message(xml_content, roomid)
|
||||||
# if members:
|
# if members:
|
||||||
# gewe_client.client.post_link(gewe_client.client.app_id, sender,
|
# gewe_client.client.post_link(gewe_client.client.app_id, sender,
|
||||||
# title=f"👏欢迎 {nickname} 加入群聊!🎉",
|
# title=f"👏欢迎 {nickname} 加入群聊!🎉",
|
||||||
|
|||||||
@@ -44,7 +44,8 @@ class ChatroomMixin(WechatAPIClientBase):
|
|||||||
|
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
json_param = {"Wxid": self.wxid, "QID": chatroom}
|
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()
|
json_resp = await response.json()
|
||||||
|
|
||||||
if json_resp.get("Success"):
|
if json_resp.get("Success"):
|
||||||
@@ -90,7 +91,8 @@ class ChatroomMixin(WechatAPIClientBase):
|
|||||||
|
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
json_param = {"Wxid": self.wxid, "QID": chatroom}
|
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()
|
json_resp = await response.json()
|
||||||
|
|
||||||
if json_resp.get("Success"):
|
if json_resp.get("Success"):
|
||||||
@@ -181,3 +183,21 @@ class ChatroomMixin(WechatAPIClientBase):
|
|||||||
if not found:
|
if not found:
|
||||||
result.append("") # 如果没找到对应的成员,添加空字符串
|
result.append("") # 如果没找到对应的成员,添加空字符串
|
||||||
return result
|
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