Skip to content

Commit

Permalink
Fix chatroom member contact no deletion bug [qq: 123]
Browse files Browse the repository at this point in the history
  • Loading branch information
littlecodersh committed Dec 22, 2016
1 parent 99a1293 commit 599dd5e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion itchat/components/contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ def update_local_chatrooms(core, l):
else:
oldChatroom = chatroom
core.chatroomList.append(chatroom)
# delete useless members
if len(chatroom['MemberList']) != len(oldChatroom['MemberList']) and \
chatroom['MemberList']:
existsUserNames = [member['UserName'] for member in chatroom['MemberList']]
delList = []
for i, member in enumerate(oldChatroom['MemberList']):
if member['UserName'] not in existsUserNames: delList.append(i)
delList.sort(reverse=True)
for i in delList: del oldChatroom['MemberList'][i]
# - update OwnerUin
if oldChatroom.get('ChatRoomOwner') and oldChatroom.get('MemberList'):
oldChatroom['OwnerUin'] = utils.search_dict_list(oldChatroom['MemberList'],
Expand Down Expand Up @@ -328,7 +337,7 @@ def get_head_img(self, userName=None, chatroomUserName=None, picDir=None):
* if you want to get chatroom member header: set both
'''
params = {
'userName': userName or chatroomUserName,
'userName': userName or chatroomUserName or self.storageClass.userName,
'skey': self.loginInfo['skey'], }
url = '%s/webwxgeticon' % self.loginInfo['url']
if chatroomUserName is None:
Expand Down
2 changes: 1 addition & 1 deletion itchat/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os, platform

VERSION = '1.2.15'
VERSION = '1.2.16'
BASE_URL = 'https://login.weixin.qq.com'
OS = platform.system() #Windows, Linux, Darwin
DIR = os.getcwd()
Expand Down

0 comments on commit 599dd5e

Please sign in to comment.