From bf3ec0a27b9adeee5c6a1a231a3419ad4fb9491d Mon Sep 17 00:00:00 2001 From: liuwei Date: Tue, 15 Apr 2025 11:11:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=B4=E5=83=8F=E8=8E=B7=E5=8F=96=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- robot.py | 10 ++++++++++ 1 file changed, 10 insertions(+) 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: """ 保持机器人运行,不让进程退出