From 3a3affd3ecbddeecd689cd9e9b4a71705ee80968 Mon Sep 17 00:00:00 2001 From: lanvent Date: Fri, 7 Apr 2023 20:53:21 +0800 Subject: [PATCH] fix: wechatmp event and query timeout --- channel/wechatmp/receive.py | 8 ++++---- channel/wechatmp/wechatmp_channel.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/channel/wechatmp/receive.py b/channel/wechatmp/receive.py index 1c49b4d..bb431dc 100644 --- a/channel/wechatmp/receive.py +++ b/channel/wechatmp/receive.py @@ -19,10 +19,10 @@ class WeChatMPMessage(ChatMessage): self.from_user_id = xmlData.find('FromUserName').text self.create_time = xmlData.find('CreateTime').text self.msg_type = xmlData.find('MsgType').text - if self.msg_type != 'event': + try: self.msg_id = xmlData.find('MsgId').text - else: - self.msg_id = self.create_time + except: + self.msg_id = self.from_user_id+self.create_time self.is_group = False # reply to other_user_id @@ -39,7 +39,7 @@ class WeChatMPMessage(ChatMessage): self.pic_url = xmlData.find('PicUrl').text self.media_id = xmlData.find('MediaId').text elif self.msg_type == 'event': - self.event = xmlData.find('Event').text + self.content = xmlData.find('Event').text else: # video, shortvideo, location, link # not implemented pass \ No newline at end of file diff --git a/channel/wechatmp/wechatmp_channel.py b/channel/wechatmp/wechatmp_channel.py index 1ac98cf..fb2b7fa 100644 --- a/channel/wechatmp/wechatmp_channel.py +++ b/channel/wechatmp/wechatmp_channel.py @@ -150,7 +150,7 @@ class SubsribeAccountQuery(): channel.query2[cache_key] = False channel.query3[cache_key] = False # Request again - elif cache_key in channel.running: + elif cache_key in channel.running and channel.query1.get(cache_key) == True and channel.query2.get(cache_key) == True and channel.query3.get(cache_key) == True: channel.query1[cache_key] = False #To improve waiting experience, this can be set to True. channel.query2[cache_key] = False #To improve waiting experience, this can be set to True. channel.query3[cache_key] = False @@ -231,7 +231,7 @@ class SubsribeAccountQuery(): return replyPost elif wechat_msg.msg_type == 'event': - logger.info("[wechatmp] Event {} from {}".format(wechat_msg.Event, wechat_msg.from_user_id)) + logger.info("[wechatmp] Event {} from {}".format(wechat_msg.content, wechat_msg.from_user_id)) trigger_prefix = conf().get('single_chat_prefix',[''])[0] content = textwrap.dedent(f"""\ 感谢您的关注!