Skip to content

Commit 439febe

Browse files
committed
Fix chatroom['Self'] bug
1 parent 6fcce75 commit 439febe

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

itchat/components/contact.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,16 +158,16 @@ def update_local_chatrooms(core, l):
158158
if oldChatroom.get('ChatRoomOwner') and oldChatroom.get('MemberList'):
159159
oldChatroom['OwnerUin'] = utils.search_dict_list(oldChatroom['MemberList'],
160160
'UserName', oldChatroom['ChatRoomOwner']).get('Uin', 0)
161-
# - update isAdmin
161+
# - update IsAdmin
162162
if 'OwnerUin' in oldChatroom and oldChatroom['OwnerUin'] != 0:
163-
oldChatroom['isAdmin'] = \
163+
oldChatroom['IsAdmin'] = \
164164
oldChatroom['OwnerUin'] == int(core.loginInfo['wxuin'])
165165
else:
166-
oldChatroom['isAdmin'] = None
167-
# - update self
166+
oldChatroom['IsAdmin'] = None
167+
# - update Self
168168
newSelf = utils.search_dict_list(oldChatroom['MemberList'],
169169
'UserName', core.storageClass.userName)
170-
oldChatroom['self'] = newSelf or copy.deepcopy(core.loginInfo['User'])
170+
oldChatroom['Self'] = newSelf or copy.deepcopy(core.loginInfo['User'])
171171
return {
172172
'Type' : 'System',
173173
'Text' : [chatroom['UserName'] for chatroom in l],
@@ -242,7 +242,8 @@ def update_local_uin(core, msg):
242242
if newChatroomDict is None:
243243
newChatroomDict = utils.struct_friend_info({
244244
'UserName': username,
245-
'Uin': uin, })
245+
'Uin': uin,
246+
'Self': copy.deepcopy(core.loginInfo['User'])})
246247
core.chatroomList.append(newChatroomDict)
247248
else:
248249
newChatroomDict['Uin'] = uin

itchat/components/messages.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,10 @@ def produce_group_chat(core, msg):
244244
if member is None:
245245
logger.debug('chatroom member fetch failed with %s' % actualUserName)
246246
msg['ActualNickName'] = ''
247-
msg['isAt'] = False
247+
msg['IsAt'] = False
248248
else:
249249
msg['ActualNickName'] = member['DisplayName'] or member['NickName']
250-
atFlag = '@' + (chatroom['self']['DisplayName']
251-
or core.storageClass.nickName)
250+
atFlag = '@' + chatroom['Self'].get('DisplayName', core.storageClass.nickName)
252251
msg['IsAt'] = (
253252
(atFlag + (u'\u2005' if u'\u2005' in msg['Content'] else ' '))
254253
in msg['Content'] or msg['Content'].endswith(atFlag))

itchat/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os, platform
22

3-
VERSION = '1.3.1'
3+
VERSION = '1.3.2'
44
BASE_URL = 'https://login.weixin.qq.com'
55
OS = platform.system() #Windows, Linux, Darwin
66
DIR = os.getcwd()

itchat/storage/templates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def add_member(self, userName):
8585
def send_raw_msg(self, msgType, content):
8686
return self.core.send_raw_msg(msgType, content, self.userName)
8787
def send_msg(self, msg='Test Message'):
88-
return self.core.send_msg(msgType, content, self.userName)
88+
return self.core.send_msg(msg, self.userName)
8989
def send_file(self, fileDir, mediaId=None):
9090
return self.core.send_file(fileDir, self.userName, mediaId)
9191
def send_image(self, fileDir, mediaId=None):

0 commit comments

Comments
 (0)