更新通讯录时,清除所有的群成员信息,更新

This commit is contained in:
liuwei
2025-06-13 18:12:17 +08:00
parent c98d44b02f
commit 000b6c741e
2 changed files with 13 additions and 0 deletions

View File

@@ -574,6 +574,17 @@ class ContactsDBOperator(BaseDBOperator):
self.LOG.error(f"删除群聊{chatroom_id}信息失败: {e}")
return False
def delete_chatroom_members_info(self, chatroom_id: str) -> bool:
"""删除群成员信息"""
try:
sql = "DELETE FROM t_chatroom_member WHERE chatroom_id = %s"
self.execute_update(sql, (chatroom_id,))
self.LOG.info(f"成功删除群聊 {chatroom_id} 的成员信息")
return True
except Exception as e:
self.LOG.error(f"删除群聊{chatroom_id}的成员信息失败: {e}")
return False
# 新增获取群列表接口
def get_chatroom_list(self) -> List[dict]:
"""获取群列表"""

View File

@@ -587,6 +587,8 @@ class Robot:
members = await self.ipad_bot.get_chatroom_member_list(group_id)
# 保存群成员信息
if members:
# 清除所有的成员信息, 重新写入。
self.contacts_db.delete_chatroom_members_info(group_id)
# 兼容逻辑已放到save_chatroom_member_simple内部
self.contacts_db.save_chatroom_member_simple(group_id, members)
self.LOG.info(f"member_list: {members}")