diff --git a/requirements.txt b/requirements.txt index e59f01a..740a13b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -44,4 +44,5 @@ pywin32==306 gewechat-client==0.1.5 fastapi~=0.115.12 -uvicorn~=0.34.2 \ No newline at end of file +uvicorn~=0.34.2 +dacite~=1.9.2 \ No newline at end of file diff --git a/robot.py b/robot.py index 23ce706..e91f4a6 100644 --- a/robot.py +++ b/robot.py @@ -3,6 +3,8 @@ import logging import re import time +import dacite + from base.func_epic import is_friday, get_free from base.func_news import News @@ -65,7 +67,12 @@ class Robot(Job): self.contact_manager.set_contacts(self.allContacts) # 获取个人信息 - profile: Profile = self.client.get_profile(self.app_id) + profile_dict = self.client.get_profile(self.app_id) + try: + profile: Profile = dacite.from_dict(Profile, profile_dict) + except Exception as e: + self.LOG.info(f"Profile dict 转换失败: {e}") + return if profile.data.wxid is None: self.LOG.info(f"获取个人信息失败,退出程序!") return