This commit is contained in:
aaron 2025-03-03 08:50:05 +08:00
parent 63c16b7a6e
commit 48e1cbe608

View File

@ -114,19 +114,29 @@ async def wechat_corp_callback(
# 解析基本信息 # 解析基本信息
msg_type = msg_root.find('MsgType').text msg_type = msg_root.find('MsgType').text
print(f"msg_type: {msg_type}")
# 处理事件消息 # 处理事件消息
if msg_type == 'event': if msg_type == 'event':
event = msg_root.find('Event').text event = msg_root.find('Event').text
print(f"event: {event}")
# 处理进群事件 # 处理进群事件
if event == 'change_external_chat': if event == 'change_external_chat':
chat_id = msg_root.find('ChatId').text chat_id = msg_root.find('ChatId').text
change_type = msg_root.find('ChangeType').text change_type = msg_root.find('ChangeType').text
update_detail = msg_root.find('UpdateDetail') update_detail = msg_root.find('UpdateDetail')
print(f"chat_id: {chat_id}")
print(f"change_type: {change_type}")
print(f"update_detail: {update_detail}")
# 处理进群事件 # 处理进群事件
if update_detail == 'add_member': if update_detail == 'add_member':
userid = msg_root.find('MemChangeList')[0].find('Item').text userid = msg_root.find('MemChangeList')[0].find('Item').text
print(f"userid: {userid}")
unionid = await wecom_client.get_unionid_from_userid(userid) unionid = await wecom_client.get_unionid_from_userid(userid)
print(f"根据userid获取unionid结果: {unionid}") print(f"根据userid获取unionid结果: {unionid}")