Selaa lähdekoodia

调整托管

develop
H Vs 2 kuukautta sitten
vanhempi
commit
f8a2777025
1 muutettua tiedostoa jossa 24 lisäystä ja 25 poistoa
  1. +24
    -25
      resources/messages_resource.py

+ 24
- 25
resources/messages_resource.py Näytä tiedosto

@@ -32,7 +32,12 @@ class MessagesResource(Resource):
if token_id=="":
logger.warning('找不到登录信息,不处理')
return jsonify({"message": "收到微信回调消息"})

wx_config = gewe_chat.wxchat.get_wxchat_config_from_cache(wxid)
if not bool(wx_config.get("agentEnabled",False)):
logger.info('智能体未启用,不处理')
return jsonify({"message": "收到微信回调消息"})
if type_name=='AddMsg':
wxid = msg.get("Wxid")
msg_data = msg.get("Data")
@@ -41,33 +46,27 @@ class MessagesResource(Resource):
to_wxid = msg_data["ToUserName"]["string"]
msg_push_content=msg_data.get("PushContent") #群发

wx_config = gewe_chat.wxchat.get_wxchat_config_from_cache(wxid)
if not bool(wx_config.get("agentEnabled",False)):
logger.warning(f'{wxid} 智能体已关闭')
handlers = {
#wx_config = gewe_chat.wxchat.get_wxchat_config_from_cache(wxid)
handlers = {
1: handle_text,
3: handle_image,
34: handle_voice,
49: handle_xml,
37: handle_add_friend_notice,
37: handle_add_friend_notice,
10002: handle_10002_msg
}
else:
handlers = {
1: handle_text,
3: handle_image,
34: handle_voice,
49: handle_xml,
37: handle_add_friend_notice,
10002: handle_10002_msg
}
# (扫码进群情况)判断受否是群聊,并添加到通信录
if check_chatroom(from_wxid) or check_chatroom(to_wxid):
logger.info('群信息')
chatroom_id=from_wxid
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_groups_info_to_cache(token_id,app_id,wxid,chatroom_id)
handlers[1]=handle_text_group
handlers[3]=handle_image_group
handlers[34]=handle_voice_group
# (扫码进群情况)判断受否是群聊,并添加到通信录
if check_chatroom(from_wxid) or check_chatroom(to_wxid):
logger.info('群信息')
chatroom_id=from_wxid
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_groups_info_to_cache(token_id,app_id,wxid,chatroom_id)
handlers[1]=handle_text_group
handlers[3]=handle_image_group
handlers[34]=handle_voice_group

handler = handlers.get(msg_type)
if handler:


Loading…
Peruuta
Tallenna