群聊用户删除后不更新本地群聊存储修复
这个问题简而言之就是退了一个用户,之后本地不会删除该用户。
这里给出一个群聊人数监控的示例:
#coding=utf8
import logging
import itchat
from itchat.content import *
logger = logging.getLogger('itchat')
groupName = u'萝卜群'
groupMemberCount = -1
groupUserName = None
itchat.auto_login(True)
group = itchat.search_chatrooms(name=groupName)[0]
if not group['MemberList']:
logger.info('no member list detected')
group = itchat.update_chatroom(group['UserName'])
groupMemberCount = len(group['MemberList'])
groupUserName = group['UserName']
logger.info('%s: %s' % (groupName, groupMemberCount))
@itchat.msg_register(SYSTEM)
def detect_member(msg):
global groupMemberCount
if msg['SystemInfo'] != 'chatrooms':
logger.info(msg['SystemInfo'])
elif groupUserName not in msg['Text']:
logger.info(msg['Text'])
else:
newGroup = itchat.search_chatrooms(userName=groupUserName)
logger.info('%s member updated: %s -> %s' %(
groupName, groupMemberCount, len(newGroup['MemberList'])))
groupMemberCount = len(newGroup['MemberList'])
itchat.run(True)