加入图片下载逻辑。

This commit is contained in:
liuwei
2025-04-01 17:00:53 +08:00
parent 29bda0ee77
commit ef691e58e2

View File

@@ -114,8 +114,14 @@ class MessageStorage:
try:
# 使用wcf下载图片确保图片存在
if self.wcf and msg.id:
# 尝试使用wcf下载图片到我们的图片目录
download_path = self.wcf.download_image(msg.id, msg.extra, self.image_dir)
# 创建按群ID或个人wxid分割的目录
target_dir = os.path.join(self.image_dir, msg.roomid if msg.roomid else msg.sender)
# 确保目标目录存在
if not os.path.exists(target_dir):
os.makedirs(target_dir, exist_ok=True)
# 尝试使用wcf下载图片到分组后的目录
download_path = self.wcf.download_image(msg.id, msg.extra, target_dir)
if download_path:
logger.info(f"使用wcf下载图片成功: {msg.id} -> {download_path}")