Skip to content

Commit

Permalink
Fix chatroom['Self'] bug
Browse files Browse the repository at this point in the history
  • Loading branch information
littlecodersh committed Mar 26, 2017
1 parent 6fcce75 commit 439febe
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
13 changes: 7 additions & 6 deletions itchat/components/contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,16 +158,16 @@ def update_local_chatrooms(core, l):
if oldChatroom.get('ChatRoomOwner') and oldChatroom.get('MemberList'):
oldChatroom['OwnerUin'] = utils.search_dict_list(oldChatroom['MemberList'],
'UserName', oldChatroom['ChatRoomOwner']).get('Uin', 0)
# - update isAdmin
# - update IsAdmin
if 'OwnerUin' in oldChatroom and oldChatroom['OwnerUin'] != 0:
oldChatroom['isAdmin'] = \
oldChatroom['IsAdmin'] = \
oldChatroom['OwnerUin'] == int(core.loginInfo['wxuin'])
else:
oldChatroom['isAdmin'] = None
# - update self
oldChatroom['IsAdmin'] = None
# - update Self
newSelf = utils.search_dict_list(oldChatroom['MemberList'],
'UserName', core.storageClass.userName)
oldChatroom['self'] = newSelf or copy.deepcopy(core.loginInfo['User'])
oldChatroom['Self'] = newSelf or copy.deepcopy(core.loginInfo['User'])
return {
'Type' : 'System',
'Text' : [chatroom['UserName'] for chatroom in l],
Expand Down Expand Up @@ -242,7 +242,8 @@ def update_local_uin(core, msg):
if newChatroomDict is None:
newChatroomDict = utils.struct_friend_info({
'UserName': username,
'Uin': uin, })
'Uin': uin,
'Self': copy.deepcopy(core.loginInfo['User'])})
core.chatroomList.append(newChatroomDict)
else:
newChatroomDict['Uin'] = uin
Expand Down
5 changes: 2 additions & 3 deletions itchat/components/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,10 @@ def produce_group_chat(core, msg):
if member is None:
logger.debug('chatroom member fetch failed with %s' % actualUserName)
msg['ActualNickName'] = ''
msg['isAt'] = False
msg['IsAt'] = False
else:
msg['ActualNickName'] = member['DisplayName'] or member['NickName']
atFlag = '@' + (chatroom['self']['DisplayName']
or core.storageClass.nickName)
atFlag = '@' + chatroom['Self'].get('DisplayName', core.storageClass.nickName)
msg['IsAt'] = (
(atFlag + (u'\u2005' if u'\u2005' in msg['Content'] else ' '))
in msg['Content'] or msg['Content'].endswith(atFlag))
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.3.1'
VERSION = '1.3.2'
BASE_URL = 'https://login.weixin.qq.com'
OS = platform.system() #Windows, Linux, Darwin
DIR = os.getcwd()
Expand Down
2 changes: 1 addition & 1 deletion itchat/storage/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def add_member(self, userName):
def send_raw_msg(self, msgType, content):
return self.core.send_raw_msg(msgType, content, self.userName)
def send_msg(self, msg='Test Message'):
return self.core.send_msg(msgType, content, self.userName)
return self.core.send_msg(msg, self.userName)
def send_file(self, fileDir, mediaId=None):
return self.core.send_file(fileDir, self.userName, mediaId)
def send_image(self, fileDir, mediaId=None):
Expand Down

0 comments on commit 439febe

Please sign in to comment.