diff --git a/robot.py b/robot.py index ebf1f99..bb8158b 100644 --- a/robot.py +++ b/robot.py @@ -217,7 +217,7 @@ class Robot(Job): try: data = await self.ipad_bot.sync_message() except Exception as e: - self.LOG.warning(f"获取新消息失败 {e}") + self.LOG.error(f"获取新消息失败 {e}") if e == "用户可能退出": self.LOG.error(f"获取新消息失败 {e},请重启应用重新登录!") self.ipad_running = False @@ -227,6 +227,7 @@ class Robot(Job): data = data.get("AddMsgs") if data: for message in data: + self.LOG.debug(f"sync_message.处理消息消息内容: {message}") # 处理消息 try: wxmsg: WxMessage = WxMessage.from_json(message) @@ -237,7 +238,7 @@ class Robot(Job): await self._process_ipad_message(wxmsg) except Exception as e: self.LOG.error(f"捕获消息处理异常,继续进行下一个消息处理{e}") - continue # 跳过本条消息,继续处理下一条 + continue # 使用异步睡眠替代忙等待循环 await asyncio.sleep(0.5) @@ -679,7 +680,7 @@ class Robot(Job): except Exception as e: self.LOG.error(f"xiu_ren_download_task error:{e}") - def generate_and_send_ranking(self): + async def generate_and_send_ranking(self): try: receivers = self.gbm.get_group_list() if not receivers: @@ -687,6 +688,6 @@ class Robot(Job): for r in receivers: if self.gbm.get_group_permission(r, Feature.DAILY_SUMMARY) == PermissionStatus.ENABLED: output = self.message_storage.generate_and_send_ranking(r, self.allContacts) - self.ipad_bot.send_text_message(r, output) + await self.ipad_bot.send_text_message(r, output) except Exception as e: self.LOG.error(f"SendRanking error:{e}") diff --git a/utils/markdown_to_image.py b/utils/markdown_to_image.py index 2e4b375..82b5a9c 100644 --- a/utils/markdown_to_image.py +++ b/utils/markdown_to_image.py @@ -3,6 +3,8 @@ from playwright.async_api import async_playwright import os import asyncio +# linux 下需要安装字体 +# sudo apt-get install -y fonts-noto-cjk fonts-noto-cjk-extra # 将 Markdown 字符串转换为 HTML def md_str_to_html(md_content, output_html):