重大版本调整:gewechat兼容。
This commit is contained in:
@@ -5,7 +5,9 @@
|
||||
import logging
|
||||
from typing import Dict, Optional, List, Tuple
|
||||
|
||||
from wcferry import Wcf
|
||||
from gewechat_client import GewechatClient
|
||||
|
||||
from utils.json_converter import json_to_object
|
||||
|
||||
|
||||
class ContactManager:
|
||||
@@ -50,7 +52,7 @@ class ContactManager:
|
||||
cls._instance = ContactManager()
|
||||
return cls._instance
|
||||
|
||||
def set_contacts(self, contacts: Dict[str, str], head_imgs: Dict[str, str], wcf: Wcf) -> None:
|
||||
def set_contacts(self, contacts: Dict[str, str]) -> None:
|
||||
"""设置联系人字典
|
||||
|
||||
Args:
|
||||
@@ -67,13 +69,12 @@ class ContactManager:
|
||||
"gender": gender}
|
||||
"""
|
||||
self._contacts = contacts
|
||||
self._friends = wcf.get_friends()
|
||||
self._head_images = head_imgs
|
||||
self._friends = contacts
|
||||
self._logger.info(f"联系人信息已更新,共 {len(contacts)} 个联系人")
|
||||
# 分类联系人
|
||||
self._classify_contacts(wcf)
|
||||
self._classify_contacts()
|
||||
|
||||
def _classify_contacts(self, wcf: Wcf) -> None:
|
||||
def _classify_contacts(self) -> None:
|
||||
"""将联系人分类为群组、个人联系人、公共好友和公众号"""
|
||||
self._group_contacts = {}
|
||||
self._personal_contacts = {}
|
||||
@@ -90,8 +91,6 @@ class ContactManager:
|
||||
# 判断是否为群组(wxid以@chatroom结尾)
|
||||
elif wxid.endswith('@chatroom'):
|
||||
self._group_contacts[wxid] = nickname
|
||||
# 如果是群,这处理群列表内容
|
||||
self._group_contacts_friends[wxid] = wcf.get_chatroom_members(wxid)
|
||||
|
||||
# # 其他为普通好友和群成员
|
||||
# else:
|
||||
@@ -216,7 +215,7 @@ class ContactManager:
|
||||
self._personal_contacts[wxid] = nickname
|
||||
self._logger.debug(f"已更新联系人: {wxid} -> {nickname}")
|
||||
|
||||
def refresh_contacts(self, new_contacts: Dict[str, str], head_imgs: Dict[str, str], wcf: Wcf) -> None:
|
||||
def refresh_contacts(self, new_contacts: Dict[str, str]) -> None:
|
||||
"""刷新联系人信息
|
||||
|
||||
Args:
|
||||
@@ -235,11 +234,9 @@ class ContactManager:
|
||||
# "province": cnt.get("province", ""),
|
||||
# "city": cnt.get("city", ""),
|
||||
# "gender": gender}
|
||||
self._friends = wcf.get_friends()
|
||||
self._head_images = head_imgs
|
||||
self._friends = self.message_util.get_friends()
|
||||
self._logger.info(f"联系人信息已刷新,共 {len(new_contacts)} 个联系人")
|
||||
# 重新分类联系人
|
||||
self._classify_contacts(wcf)
|
||||
self._classify_contacts()
|
||||
|
||||
def get_contact_statistics(self) -> Tuple[int, int, int, int, int]:
|
||||
"""获取联系人统计信息
|
||||
|
||||
Reference in New Issue
Block a user