From 1a0220a9073603ab7dec32a077fb3193460d4106 Mon Sep 17 00:00:00 2001 From: liuwei Date: Fri, 16 May 2025 09:58:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E5=90=8C=E6=AD=A5=E5=A4=84?= =?UTF-8?q?=E7=90=86=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- robot.py | 12 +++++------- utils/markdown_to_image.py | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/robot.py b/robot.py index bb8158b..e0029a8 100644 --- a/robot.py +++ b/robot.py @@ -220,12 +220,13 @@ class Robot(Job): self.LOG.error(f"获取新消息失败 {e}") if e == "用户可能退出": self.LOG.error(f"获取新消息失败 {e},请重启应用重新登录!") - self.ipad_running = False + # self.ipad_running = False await asyncio.sleep(5) continue data = data.get("AddMsgs") if data: + tasks = [] for message in data: self.LOG.debug(f"sync_message.处理消息消息内容: {message}") # 处理消息 @@ -234,12 +235,9 @@ class Robot(Job): except Exception as e: self.LOG.error(f"WxMessage.from_json 解析失败,消息内容: {message},错误: {e}") continue # 跳过本条消息,继续处理下一条 - try: - await self._process_ipad_message(wxmsg) - except Exception as e: - self.LOG.error(f"捕获消息处理异常,继续进行下一个消息处理{e}") - continue - + tasks.append(self._process_ipad_message(wxmsg)) + if tasks: + await asyncio.gather(*tasks) # 使用异步睡眠替代忙等待循环 await asyncio.sleep(0.5) diff --git a/utils/markdown_to_image.py b/utils/markdown_to_image.py index 82b5a9c..7fd62b4 100644 --- a/utils/markdown_to_image.py +++ b/utils/markdown_to_image.py @@ -5,7 +5,7 @@ import asyncio # linux 下需要安装字体 # sudo apt-get install -y fonts-noto-cjk fonts-noto-cjk-extra - +# sudo apt-get install -y fonts-noto-color-emoji fonts-noto-cjk fonts-wqy-microhei # 将 Markdown 字符串转换为 HTML def md_str_to_html(md_content, output_html): """