|
|
@@ -136,13 +136,42 @@ class MessagesResource(Resource): |
|
|
|
|
|
|
|
def handle_name_card(token_id,app_id, wxid,msg_data,from_wxid, to_wxid): |
|
|
|
logger.info('名片消息') |
|
|
|
msg_content_xml=msg_data["Content"]["string"] |
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
msg_content_xml=msg_data["Content"]["string"] |
|
|
|
# 解析XML字符串 |
|
|
|
root = ET.fromstring(msg_content_xml) |
|
|
|
root = ET.fromstring(msg_content_xml) |
|
|
|
|
|
|
|
# 提取alias属性 |
|
|
|
alias_value = root.get("alias") |
|
|
|
# 加好友资料 |
|
|
|
option = root.get("scene") |
|
|
|
v3 = root.get("username") |
|
|
|
v4 = root.get("antispamticket") |
|
|
|
|
|
|
|
logger.info(f"alias_value: {alias_value}, option: {option}, v3: {v3}, v4: {v4}") |
|
|
|
# 判断appid 是否已经创建3天 |
|
|
|
k, login_info = utils.get_login_info_by_wxid(wxid) |
|
|
|
creation_timestamp=int(login_info.get('create_at',time.time())) |
|
|
|
current_timestamp = time.time() |
|
|
|
three_days_seconds = 3 * 24 * 60 * 60 # 三天的秒数 |
|
|
|
diff_flag=(current_timestamp - creation_timestamp) >= three_days_seconds |
|
|
|
if not diff_flag: |
|
|
|
log_content=f'名片添加好友功能,{wxid} 用户创建不够三天,不能使用该功能' |
|
|
|
logger.warning(log_content) |
|
|
|
response=jsonify({'code': 401, 'message':log_content}) |
|
|
|
response.status_code = 401 |
|
|
|
return response |
|
|
|
|
|
|
|
# 将加好友资料添加到待加好友队列 |
|
|
|
|
|
|
|
|
|
|
|
# 提取alias属性 |
|
|
|
alias_value = root.get("alias") |
|
|
|
except ET.ParseError as e: |
|
|
|
logger.error(f"XML解析错误: {e}") |
|
|
|
except KeyError as e: |
|
|
|
logger.error(f"字典键错误: {e}") |
|
|
|
except Exception as e: |
|
|
|
logger.error(f"未知错误: {e}") |
|
|
|
|
|
|
|
def handle_self_cmd(wxid,msg): |
|
|
|
''' |
|
|
@@ -632,7 +661,7 @@ def handle_xml(token_id,app_id, wxid,msg_data,from_wxid, to_wxid): |
|
|
|
''' |
|
|
|
msg_content_xml=msg_data["Content"]["string"] |
|
|
|
root = ET.fromstring(msg_content_xml) |
|
|
|
type_value = root.find(".//appmsg/type").text |
|
|
|
type_value = int(root.find(".//appmsg/type").text) |
|
|
|
handlers = { |
|
|
|
57: handle_xml_reference, |
|
|
|
5: handle_xml_invite_group |
|
|
|