diff --git a/robot.py b/robot.py index 003b93b..be3afab 100644 --- a/robot.py +++ b/robot.py @@ -57,6 +57,7 @@ class Robot(Job): # 初始化联系人管理器并设置联系人 self.contact_manager = ContactManager.get_instance() self.allContacts = self.get_all_contacts() + self.all_head_img = self.get_all_head_img_url() self.contact_manager.set_contacts(self.allContacts, self.wcf) self.LOG.info(f"DB+REDIS 连接池开始初始化") @@ -337,6 +338,15 @@ class Robot(Job): contacts = self.wcf.query_sql("MicroMsg.db", "SELECT UserName, NickName FROM Contact;") return {contact["UserName"]: contact["NickName"] for contact in contacts} + def get_all_head_img_url(self) -> dict: + try: + head_img_urls = self.wcf.query_sql("MicroMsg.db", "SELECT usrName ,bigHeadImgUrl FROM ContactHeadImgUrl;") + self.LOG.info(f"head_img_urls: {head_img_urls}") + return {contact["usrName"]: contact["bigHeadImgUrl"] for contact in head_img_urls} + except Exception as e: + self.LOG.error(f"get_all_head_img_url error: {e}") + return {} + def keep_running_and_block_process(self) -> None: """ 保持机器人运行,不让进程退出