ContactsManager
通讯录管理器,提供群聊列表遍历功能。
方法
open(filter_type="全部")
打开通讯录面板。
- filter_type
str— 筛选类型:"全部"/"群聊"等
iter_rooms(count=None, speed=1)
逐条遍历群聊列表(通过滚动)。
- count
int | None— 最多获取数量 - speed
int— 滚动速度 - Yields
dict— 群聊信息
遍历结果字典结构:
python
{
"name": "群名称",
"member_count": 50, # 群成员数(如有)
"remark": "备注名", # 如有
}示例
python
from pywxauto import Weixin
wx = Weixin()
# 遍历所有群聊
for room in wx.contacts.iter_rooms(count=100):
print(f"{room['name']} - 成员数: {room.get('member_count', '未知')}")