From b0051dc97d41003552bc35e984f138e06c23c1d6 Mon Sep 17 00:00:00 2001 From: liuwei Date: Wed, 28 May 2025 15:38:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=81=94=E7=B3=BB=E4=BA=BA?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=EF=BC=8C=E8=A7=A3=E5=86=B3=E6=80=BB=E7=BB=93?= =?UTF-8?q?=E6=97=B6=E4=BD=BF=E7=94=A8=E4=BA=86=E5=85=B6=E4=BB=96=E7=BE=A4?= =?UTF-8?q?=E7=9A=84=E5=A4=87=E6=B3=A8=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/wechat/contact_manager.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/utils/wechat/contact_manager.py b/utils/wechat/contact_manager.py index 5036e73..d58053e 100644 --- a/utils/wechat/contact_manager.py +++ b/utils/wechat/contact_manager.py @@ -95,6 +95,9 @@ class ContactManager: # 判断是否为群组(wxid以@chatroom结尾) elif wxid.endswith('@chatroom'): self._group_contacts[wxid] = nickname + # 确保群ID在字典中存在 + if wxid not in self._group_contacts_friends: + self._group_contacts_friends[wxid] = {} # 获取群成员信息: for friend in self._group_members: if friend.get('chatroom_id') == wxid: @@ -241,7 +244,10 @@ class ContactManager: self._official_accounts[wxid] = nickname elif wxid.endswith('@chatroom'): self._group_contacts[wxid] = nickname - # 需要获取群成员昵称信息; 从数据库里面提取。 + # 确保群ID在字典中存在 + if wxid not in self._group_contacts_friends: + self._group_contacts_friends[wxid] = {} + # 获取群成员信息: for friend in self._group_members: if friend.get('chatroom_id') == wxid: self._group_contacts_friends[wxid].update(