头像获取功能
This commit is contained in:
10
robot.py
10
robot.py
@@ -57,6 +57,7 @@ class Robot(Job):
|
|||||||
# 初始化联系人管理器并设置联系人
|
# 初始化联系人管理器并设置联系人
|
||||||
self.contact_manager = ContactManager.get_instance()
|
self.contact_manager = ContactManager.get_instance()
|
||||||
self.allContacts = self.get_all_contacts()
|
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.contact_manager.set_contacts(self.allContacts, self.wcf)
|
||||||
|
|
||||||
self.LOG.info(f"DB+REDIS 连接池开始初始化")
|
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;")
|
contacts = self.wcf.query_sql("MicroMsg.db", "SELECT UserName, NickName FROM Contact;")
|
||||||
return {contact["UserName"]: contact["NickName"] for contact in contacts}
|
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:
|
def keep_running_and_block_process(self) -> None:
|
||||||
"""
|
"""
|
||||||
保持机器人运行,不让进程退出
|
保持机器人运行,不让进程退出
|
||||||
|
|||||||
Reference in New Issue
Block a user