diff --git a/main.py b/main.py index 31db8a0..16857ce 100644 --- a/main.py +++ b/main.py @@ -68,6 +68,10 @@ def main(chat_type: int): # # 秀人网每天自动发pdf # robot.onEveryTime("17:30", robot.xiu_ren_pdf_send) + # 每天进行二次登录检查 + robot.onEveryTime("00:01", robot.login_twice_auto_auth) + robot.onEveryTime("12:01", robot.login_twice_auto_auth) + # 启动Dashboard服务器 dashboard_server = None try: diff --git a/robot.py b/robot.py index 90e438c..e0fd4e4 100644 --- a/robot.py +++ b/robot.py @@ -179,8 +179,8 @@ class Robot(Job): # 登录成功后加载联系人信息 self.allContacts = self.get_all_contacts() - self.head_images =self.get_all_head_images() - self.contact_manager.set_contacts(self.allContacts,self.head_images) + self.head_images = self.get_all_head_images() + self.contact_manager.set_contacts(self.allContacts, self.head_images) self.message_storage = MessageStorage(self.ipad_bot) @@ -377,7 +377,7 @@ class Robot(Job): nick_name = member.get("NickName", "") displayName = member.get("DisplayName", "") small_head_img_url = member.get("SmallHeadImgUrl", "") - #如果displayName不为空,使用displayName + # 如果displayName不为空,使用displayName if displayName: nick_name = displayName if wxid: @@ -385,7 +385,7 @@ class Robot(Job): self.head_images[wxid] = small_head_img_url - self.contact_manager.set_contacts(self.allContacts,self.head_images) + self.contact_manager.set_contacts(self.allContacts, self.head_images) self.LOG.info(f"已更新群 {group_id} 的成员信息") except Exception as e: self.LOG.error(f"获取群成员信息失败: {e}") @@ -570,7 +570,7 @@ class Robot(Job): nick_name = member.get("NickName", "") displayName = member.get("DisplayName", "") small_head_img_url = member.get("SmallHeadImgUrl", "") - #如果displayName不为空,使用displayName + # 如果displayName不为空,使用displayName if displayName: nick_name = displayName if wxid: @@ -578,7 +578,7 @@ class Robot(Job): self.head_images[wxid] = small_head_img_url - self.contact_manager.set_contacts(self.allContacts,self.head_images) + self.contact_manager.set_contacts(self.allContacts, self.head_images) self.LOG.info(f"已更新群 {group_id} 的成员信息") else: self.LOG.error(f"获取群 {group_id} 信息失败,证明用户无该群信息,删除群的相关资料。") @@ -586,6 +586,17 @@ class Robot(Job): self.contacts_db.delete_chatroom_all_info(group_id) self.LOG.info("联系人信息刷新完成") + def login_twice_auto_auth(self) -> None: + try: + self.LOG.info(f"定时进行二次登录动作") + resp = self.ipad_bot.twice_auto_auth() + if resp: + self.LOG.info(f"定时二次登录成功!") + else: + self.LOG.error(f"定时二次登录失败!") + except Exception as e: + self.LOG.error(f"login_twice_auto_auth error: {e}") + # ============================================== 业务内容========================================================== def news_baidu_report_auto(self) -> None: