Skip to content

Commit

Permalink
Fix missing emoji format [BR#297: youfou]
Browse files Browse the repository at this point in the history
  • Loading branch information
littlecodersh committed Mar 25, 2017
1 parent f89f7c6 commit 8c205a0
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ A: 有些账号是天生无法给自己的账号发送信息的,建议使用`f

[sjdy521/Mojo-Weixin][Mojo-Weixin]: 使用Perl语言编写的微信客户端框架,可通过插件提供基于HTTP协议的api接口供其他语言调用

[HanSon/vbot][HanSon-vbot]: 基于PHP7的微信个人号机器人,通过实现匿名函数可以方便地实现各种自定义的功能

## 问题和建议

如果有什么问题或者建议都可以在这个[Issue][issue#1]和我讨论
Expand Down Expand Up @@ -268,4 +270,5 @@ A: 有些账号是天生无法给自己的账号发送信息的,建议使用`f
[liuwons-wxBot]: https://github.com/liuwons/wxBot
[zixia-wechaty]: https://github.com/zixia/wechaty
[Mojo-Weixin]: https://github.com/sjdy521/Mojo-Weixin
[HanSon-vbot]: https://github.com/hanson/vbot
[issue#1]: https://github.com/littlecodersh/ItChat/issues/1
10 changes: 8 additions & 2 deletions itchat/components/contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,12 @@ def update_local_chatrooms(core, l):
# format new chatrooms
utils.emoji_formatter(chatroom, 'NickName')
for member in chatroom['MemberList']:
utils.emoji_formatter(member, 'NickName')
utils.emoji_formatter(member, 'DisplayName')
if 'NickName' in member:
utils.emoji_formatter(member, 'NickName')
if 'DisplayName' in member:
utils.emoji_formatter(member, 'DisplayName')
if 'RemarkName' in member:
utils.emoji_formatter(member, 'RemarkName')
# update it to old chatrooms
oldChatroom = utils.search_dict_list(
core.chatroomList, 'UserName', chatroom['UserName'])
Expand Down Expand Up @@ -180,6 +184,8 @@ def update_local_friends(core, l):
utils.emoji_formatter(friend, 'NickName')
if 'DisplayName' in friend:
utils.emoji_formatter(friend, 'DisplayName')
if 'RemarkName' in member:
utils.emoji_formatter(member, 'RemarkName')
oldInfoDict = utils.search_dict_list(
fullList, 'UserName', friend['UserName'])
if oldInfoDict is None:
Expand Down
9 changes: 6 additions & 3 deletions itchat/components/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ def produce_group_chat(core, msg):
msg['ActualUserName'] = core.storageClass.userName
msg['ActualNickName'] = core.storageClass.nickName
msg['isAt'] = False
utils.msg_formatter(msg, 'Content')
return
chatroom = core.storageClass.search_chatrooms(userName=chatroomUserName)
member = utils.search_dict_list((chatroom or {}).get(
Expand All @@ -219,16 +220,18 @@ def produce_group_chat(core, msg):
'MemberList') or [], 'UserName', actualUserName)
if member is None:
logger.debug('chatroom member fetch failed with %s' % actualUserName)
msg['ActualNickName'] = ''
msg['isAt'] = False
else:
msg['ActualUserName'] = actualUserName
msg['ActualNickName'] = member['DisplayName'] or member['NickName']
msg['Content'] = content
utils.msg_formatter(msg, 'Content')
atFlag = '@' + (chatroom['self']['DisplayName']
or core.storageClass.nickName)
msg['isAt'] = (
(atFlag + (u'\u2005' if u'\u2005' in msg['Content'] else ' '))
in msg['Content'] or msg['Content'].endswith(atFlag))
msg['ActualUserName'] = actualUserName
msg['Content'] = content
utils.msg_formatter(msg, 'Content')

def send_raw_msg(self, msgType, content, toUserName):
url = '%s/webwxsendmsg' % self.loginInfo['url']
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.32'
VERSION = '1.2.33'
BASE_URL = 'https://login.weixin.qq.com'
OS = platform.system() #Windows, Linux, Darwin
DIR = os.getcwd()
Expand Down
5 changes: 4 additions & 1 deletion itchat/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
NOTE = 'Note'
SHARING = 'Sharing'
PICTURE = 'Picture'
RECORDING = 'Recording'
RECORDING = VOICE = 'Recording'
ATTACHMENT = 'Attachment'
VIDEO = 'Video'
FRIENDS = 'Friends'
SYSTEM = 'System'

INCOME_MSG = [TEXT, MAP, CARD, NOTE, SHARING, PICTURE,
RECORDING, VOICE, ATTACHMENT, VIDEO, FRIENDS, SYSTEM]

0 comments on commit 8c205a0

Please sign in to comment.