加入图片下载逻辑。

This commit is contained in:
liuwei
2025-04-01 16:43:54 +08:00
parent 57947bde07
commit c95b5b8a9d
4 changed files with 229 additions and 45 deletions

View File

@@ -59,7 +59,7 @@ class Robot(Job):
self.contact_manager = ContactManager.get_instance()
self.allContacts = self.get_all_contacts()
self.contact_manager.set_contacts(self.allContacts)
self.LOG.info(f"DB+REDIS 连接池开始初始化")
# 使用单例模式获取实例
self.db_manager = DBConnectionManager.get_instance(
@@ -105,7 +105,7 @@ class Robot(Job):
self.LOG.info("插件系统初始化完成")
# 消息存档模块初始化,自动完成入库动作
self.message_storage = MessageStorage()
self.message_storage = MessageStorage(self.wcf)
if ChatType.is_in_chat_types(chat_type):
if chat_type == ChatType.TIGER_BOT.value and TigerBot.value_check(self.config.TIGERBOT):
self.chat = TigerBot(self.config.TIGERBOT)
@@ -238,7 +238,7 @@ class Robot(Job):
GroupBotManager.set_group_permission(msg.roomid, Feature.ROBOT, PermissionStatus.ENABLED)
except Exception as e:
self.LOG.error(f"加入新群,自动添加并开启机器人功能 error: {e}")
# 发布消息接收事件
self.event_system.publish(EventType.MESSAGE_RECEIVED, {"message": msg})
@@ -258,6 +258,9 @@ class Robot(Job):
# 聊天记录入库动作:
try:
self.message_storage.archive_message(msg)
# 单独处理图片消息
if msg.type == 3: # 图片消息类型
self.message_storage.process_image(msg)
except Exception as e:
self.LOG.error(f"archive_message error: {e}")
@@ -413,7 +416,7 @@ class Robot(Job):
self.allContacts[msg.sender] = nickName[0]
self.contact_manager.update_contact(msg.sender, nickName[0])
self.send_text_msg(f"Hi {nickName[0]},我自动通过了你的好友请求。", msg.sender)
def send_group_txt_message(self, msg: str, feature: Feature):
try:
receivers = self.gbm.get_group_list()