|
@@ -635,17 +635,23 @@ def handle_xml(token_id,app_id, wxid,msg_data,from_wxid, to_wxid): |
|
|
type_value = root.find(".//appmsg/type").text |
|
|
type_value = root.find(".//appmsg/type").text |
|
|
handlers = { |
|
|
handlers = { |
|
|
57: handle_xml_reference, |
|
|
57: handle_xml_reference, |
|
|
|
|
|
5: handle_xml_invite_group |
|
|
} |
|
|
} |
|
|
handler = handlers.get(type_value) |
|
|
handler = handlers.get(type_value) |
|
|
if handler: |
|
|
if handler: |
|
|
return handler(token_id,app_id, wxid,msg_data,from_wxid, to_wxid) |
|
|
return handler(token_id,app_id, wxid,msg_data,from_wxid, to_wxid) |
|
|
elif "邀请你加入了群聊" in msg_content_xml: # 邀请加入群聊 |
|
|
|
|
|
logger.warning(f"xml消息 {type_value} 邀请你加入了群聊.todo") |
|
|
|
|
|
|
|
|
# elif "邀请你加入了群聊" in msg_content_xml: # 邀请加入群聊 |
|
|
|
|
|
# logger.warning(f"xml消息 {type_value} 邀请你加入了群聊.todo") |
|
|
else: |
|
|
else: |
|
|
print(f"xml消息 {type_value} 未解析") |
|
|
print(f"xml消息 {type_value} 未解析") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def handle_xml_reference(token_id,app_id, wxid,msg_data,from_wxid, to_wxid): |
|
|
def handle_xml_reference(token_id,app_id, wxid,msg_data,from_wxid, to_wxid): |
|
|
''' |
|
|
''' |
|
|
|
|
|
引用消息 |
|
|
判断此类消息的逻辑:$.Data.MsgType=49 并且 解析$.Data.Content.string中的xml msg.appmsg.type=57 |
|
|
判断此类消息的逻辑:$.Data.MsgType=49 并且 解析$.Data.Content.string中的xml msg.appmsg.type=57 |
|
|
''' |
|
|
''' |
|
|
callback_to_user=from_wxid |
|
|
callback_to_user=from_wxid |
|
@@ -675,6 +681,34 @@ def handle_xml_reference(token_id,app_id, wxid,msg_data,from_wxid, to_wxid): |
|
|
gewe_chat.wxchat.save_session_messages_to_cache(hash_key, {"role": "assistant", "content": reply_content}) |
|
|
gewe_chat.wxchat.save_session_messages_to_cache(hash_key, {"role": "assistant", "content": reply_content}) |
|
|
gewe_chat.wxchat.post_text(token_id,app_id,callback_to_user,reply_content) |
|
|
gewe_chat.wxchat.post_text(token_id,app_id,callback_to_user,reply_content) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def handle_xml_invite_group(token_id,app_id, wxid,msg_data,from_wxid, to_wxid): |
|
|
|
|
|
''' |
|
|
|
|
|
群聊邀请 |
|
|
|
|
|
判断此类消息的逻辑:$.Data.MsgType=49 |
|
|
|
|
|
并且 解析$.Data.Content.string中的xml msg.appmsg.title=邀请你加入群聊(根据手机设置的系统语言title会有调整,不同语言关键字不同) |
|
|
|
|
|
''' |
|
|
|
|
|
logger.info(f'{wxid} 群聊邀请') |
|
|
|
|
|
msg_content_xml=msg_data["Content"]["string"] |
|
|
|
|
|
root = ET.fromstring(msg_content_xml) |
|
|
|
|
|
title_value = root.find(".//appmsg/title").text |
|
|
|
|
|
|
|
|
|
|
|
if '邀请你加入群聊' in title_value: |
|
|
|
|
|
invite_url = root.find('.//url').text |
|
|
|
|
|
ret,msg,data=gewe_chat.wxchat.agree_join_room(token_id,app_id,invite_url) |
|
|
|
|
|
if ret==200: |
|
|
|
|
|
logger.info(f'群聊邀请,同意加入群聊 {msg} {data}') |
|
|
|
|
|
chatroom_id=data.get('ChatRoomId') |
|
|
|
|
|
ret,msg,data=gewe_chat.wxchat.save_contract_list(token_id,app_id,chatroom_id,3) |
|
|
|
|
|
logger.info(f'群聊邀请,保存到通讯录 chatroom_id {chatroom_id} {msg}') |
|
|
|
|
|
gewe_chat.wxchat.update_group_info_to_cache(token_id,app_id,wxid,chatroom_id) |
|
|
|
|
|
gewe_chat.wxchat.update_group_members_to_cache(token_id,app_id,wxid,chatroom_id) |
|
|
|
|
|
else: |
|
|
|
|
|
logger.warning(f'群聊邀请,同意加入群聊失败 {msg} {data}') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def handle_add_friend_notice(token_id,app_id, wxid,msg_data,from_wxid, to_wxid): |
|
|
def handle_add_friend_notice(token_id,app_id, wxid,msg_data,from_wxid, to_wxid): |
|
|
''' |
|
|
''' |
|
|
好友添加请求通知 |
|
|
好友添加请求通知 |
|
|