From 9e39f7f0b8182d70ae24c6bbe6093ae36cc9da8e Mon Sep 17 00:00:00 2001 From: liuwei Date: Mon, 28 Apr 2025 13:19:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E5=9B=BE=E7=89=87=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- robot.py | 2 +- utils/wechat/message_to_db.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/robot.py b/robot.py index 68c398d..049a415 100644 --- a/robot.py +++ b/robot.py @@ -227,7 +227,7 @@ class Robot(Job): # # 聊天记录入库动作: try: self.message_storage.archive_message(msg) - # 单独处理图片消息 + # 单独处理图片消息 后续写定时任务自动完成下载。延时处理。 if msg.msg_type == MessageType.IMAGE: # 图片消息类型 self.message_storage.process_image(msg) except Exception as e: diff --git a/utils/wechat/message_to_db.py b/utils/wechat/message_to_db.py index b148eec..7ea0620 100644 --- a/utils/wechat/message_to_db.py +++ b/utils/wechat/message_to_db.py @@ -1,3 +1,4 @@ +import time from datetime import datetime, timedelta import xml.etree.ElementTree as ET import logging @@ -121,7 +122,9 @@ class MessageStorage: # 确保目标目录存在 if not os.path.exists(target_dir): os.makedirs(target_dir, exist_ok=True) - + # 延时10秒下载试试 + logger.info(f"延时10秒下载图片{msg.content.xml_content}") + time.sleep(10) # 尝试使用wcf下载图片到分组后的目录 json = self.client.download_image(msg.appid, msg.content.xml_content, 1) # {