优化联系人信息,解决总结时使用了其他群的备注信息

This commit is contained in:
liuwei
2025-05-28 15:33:23 +08:00
parent 3c460ce4a7
commit 6c9b99afcf
7 changed files with 91 additions and 72 deletions

View File

@@ -9,6 +9,7 @@ import requests
from utils.revoke.message_auto_revoke import MessageAutoRevoke
from utils.string_utils import remove_trailing_content
from utils.wechat.contact_manager import ContactManager
from utils.wechat.message_to_db import MessageStorage
from utils.compress_chat_data import compress_chat_data
from base.plugin_common.message_plugin_interface import MessagePluginInterface
@@ -109,8 +110,9 @@ class MessageSummaryPlugin(MessagePluginInterface):
return False, None
# 从消息历史中获取群聊记录
all_contacts: dict = message.get("all_contacts")
group_members: dict = ContactManager.get_instance().get_group_members()
chat_content = self.message_storage.get_messages(group_id, all_contacts)
chat_content = self.message_storage.get_messages(group_id, group_members)
if len(chat_content) < 100:
return False, None
@@ -141,11 +143,13 @@ class MessageSummaryPlugin(MessagePluginInterface):
await self.bot.send_image_message(group_id, Path(image_path))
else:
client_msg_id, create_time, new_msg_id = await self.bot.send_text_message(group_id, "❌ 生成总结图片失败")
client_msg_id, create_time, new_msg_id = await self.bot.send_text_message(group_id,
"❌ 生成总结图片失败")
self.revoke.add_message_to_revoke(group_id, client_msg_id, create_time, new_msg_id, 5)
except Exception as e:
self.LOG.error(f"异步生成总结失败: {e}")
client_msg_id, create_time, new_msg_id = await self.bot.send_text_message(group_id, f"❌ 生成总结失败: {str(e)}")
client_msg_id, create_time, new_msg_id = await self.bot.send_text_message(group_id,
f"❌ 生成总结失败: {str(e)}")
self.revoke.add_message_to_revoke(group_id, client_msg_id, create_time, new_msg_id, 5)
def _sanitize_group_name(self, group_name: str) -> str: