Skip to content

Commit

Permalink
Fix <br/> & groupChat's @
Browse files Browse the repository at this point in the history
  • Loading branch information
littlecodersh committed Aug 3, 2016
1 parent 604b6b0 commit a4542be
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion itchat/__init__.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
14 changes: 10 additions & 4 deletions itchat/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'(.+?\(.+?\))'
Expand Down Expand Up @@ -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 = {
Expand Down
1 change: 1 addition & 0 deletions itchat/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('<br/>', '\n')
d[k] = htmlParser.unescape(d[k])
def check_file(fileDir):
try:
Expand Down

0 comments on commit a4542be

Please sign in to comment.