diff --git a/itchat/__init__.py b/itchat/__init__.py index bec17044..20ff0e96 100644 --- a/itchat/__init__.py +++ b/itchat/__init__.py @@ -1,7 +1,7 @@ import time from .client import client -__version__ = '1.1.0' +__version__ = '1.1.1' __client = client() def auto_login(hotReload = False, statusStorageDir = 'itchat.pkl', enableCmdQR = False): diff --git a/itchat/client.py b/itchat/client.py index 7841c187..5c734b3c 100644 --- a/itchat/client.py +++ b/itchat/client.py @@ -255,8 +255,10 @@ def __produce_msg(self, l): srl = [40, 43, 50, 52, 53, 9999] # 40 msg, 43 videochat, 50 VOIPMSG, 52 voipnotifymsg, 53 webwxvoipnotifymsg, 9999 sysnotice for m in l: - tools.msg_formatter(m, 'Content') - if '@@' in m['FromUserName']: self.__produce_group_chat(m) + if '@@' in m['FromUserName']: + self.__produce_group_chat(m) + else: + tools.msg_formatter(m, 'Content') if m['MsgType'] == 1: # words if m['Url']: regx = r'(.+?\(.+?\))' @@ -395,9 +397,13 @@ def __produce_group_chat(self, msg): groupMemberList = self.get_batch_contract(msg['FromUserName'])['MemberList'] self.storageClass.groupDict[msg['FromUserName']] = {member['UserName']: member for member in groupMemberList} msg['ActualUserName'] = actualUserName - msg['ActualNickName'] = self.storageClass.groupDict[msg['FromUserName']][actualUserName]['NickName'] + msg['ActualNickName'] = (self.storageClass.groupDict[msg['FromUserName']][actualUserName]['DisplayName'] or + self.storageClass.groupDict[msg['FromUserName']][actualUserName]['NickName']) msg['Content'] = content - msg['isAt'] = u'@%s\u2005'%self.storageClass.nickName in msg['Content'] + tools.msg_formatter(msg, 'Content') + msg['isAt'] = u'@%s\u2005' % ( + self.storageClass.groupDict[msg['FromUserName']][self.storageClass.userName]['DisplayName'] + or self.storageClass.nickName) in msg['Content'] def send_msg(self, msg = 'Test Message', toUserName = None): url = '%s/webwxsendmsg'%self.loginInfo['url'] payloads = { diff --git a/itchat/tools.py b/itchat/tools.py index e8c64e74..30042c7e 100644 --- a/itchat/tools.py +++ b/itchat/tools.py @@ -48,6 +48,7 @@ def _emoji_formatter(m): d[k] = emojiRegex.sub(_emoji_formatter, d[k]) def msg_formatter(d, k): emoji_formatter(d, k) + d[k] = d[k].replace('
', '\n') d[k] = htmlParser.unescape(d[k]) def check_file(fileDir): try: