From 3d264207a8ecac53ed7b6137986f61c233dcb821 Mon Sep 17 00:00:00 2001 From: lichengzhe <38408577@qq.com> Date: Tue, 21 Mar 2023 22:12:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A6=82=E5=90=AF=E7=94=A8hot=5Freload?= =?UTF-8?q?=EF=BC=8C=E4=B8=8D=E5=A4=84=E7=90=861=E5=88=86=E9=92=9F?= =?UTF-8?q?=E5=89=8D=E7=9A=84=E5=8E=86=E5=8F=B2=E6=B6=88=E6=81=AF=E9=81=BF?= =?UTF-8?q?=E5=85=8D=E9=87=8D=E5=A4=8D=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- channel/wechat/wechat_channel.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/channel/wechat/wechat_channel.py b/channel/wechat/wechat_channel.py index 5a06227..45fd537 100644 --- a/channel/wechat/wechat_channel.py +++ b/channel/wechat/wechat_channel.py @@ -14,6 +14,7 @@ from common.tmp_dir import TmpDir from config import conf import requests import io +import time thread_pool = ThreadPoolExecutor(max_workers=8) @@ -74,7 +75,11 @@ class WechatChannel(Channel): from_user_id = msg['FromUserName'] to_user_id = msg['ToUserName'] # 接收人id other_user_id = msg['User']['UserName'] # 对手方id + create_time = msg['CreateTime'] # 消息时间 match_prefix = self.check_prefix(content, conf().get('single_chat_prefix')) + if conf().get('hot_reload') == True and int(create_time) < int(time.time()) - 60: #跳过1分钟前的历史消息 + logger.debug("[WX]history message skipped") + return if "」\n- - - - - - - - - - - - - - -" in content: logger.debug("[WX]reference query skipped") return @@ -108,6 +113,10 @@ class WechatChannel(Channel): logger.debug("[WX]receive group msg: " + json.dumps(msg, ensure_ascii=False)) group_name = msg['User'].get('NickName', None) group_id = msg['User'].get('UserName', None) + create_time = msg['CreateTime'] # 消息时间 + if conf().get('hot_reload') == True and int(create_time) < int(time.time()) - 60: #跳过1分钟前的历史消息 + logger.debug("[WX]history group message skipped") + return if not group_name: return "" origin_content = msg['Content']