Skip to content

Commit

Permalink
Fix bugs caused by strange contact return values [PR#208: lostdragon]
Browse files Browse the repository at this point in the history
  • Loading branch information
littlecodersh committed Jan 23, 2017
1 parent 71d5c57 commit c58174e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
7 changes: 4 additions & 3 deletions docs/tutorial/tutorial1.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Python与基本的网络基础都不困难,所以即使没有这方面基础

![QRCode](http://7xrip4.com1.z0.glb.clouddn.com/ItChat%2FQRCode2.jpg?imageView/2/w/400/)

##本部分所需环境
## 本部分所需环境

本文是这一教程的第一部分,需要配置抓包与Python环境。

Expand Down Expand Up @@ -59,6 +59,7 @@ Wireshark是常见的抓包软件,这里通过一些配置抓取微信网页
我们都登录过网页端微信,没有的话可以现在做一个尝试:[微信网页端](https://wx.qq.com)

这个过程简单而言可以分为如下几步:

1. 向服务器提供一些用于获取二维码的数据
1. 服务器返回二维码
1. 向服务器询问二维码扫描状态
Expand Down Expand Up @@ -313,9 +314,9 @@ print('Log in as %s'%dic['User']['NickName'])

那么做一个小练习好了,测试一下学到的东西:读取命令行的输入并发送给自己。(这部分的源码放在了文末)

##具体运用时可能遇到的难点
## 具体运用时可能遇到的难点

###命令行登录一段时间后无法与服务器正常交互
### 命令行登录一段时间后无法与服务器正常交互

这是因为微信网页端存在心跳机制,一段时间不交互将会断开连接。

Expand Down
14 changes: 11 additions & 3 deletions itchat/components/contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,10 @@ def update_local_friends(core, l):
'''
fullList = core.memberList + core.mpList
for friend in l:
utils.emoji_formatter(friend, 'NickName')
utils.emoji_formatter(friend, 'DisplayName')
if 'NickName' in friend:
utils.emoji_formatter(friend, 'NickName')
if 'DisplayName' in friend:
utils.emoji_formatter(friend, 'DisplayName')
oldInfoDict = utils.search_dict_list(
fullList, 'UserName', friend['UserName'])
if oldInfoDict is None:
Expand Down Expand Up @@ -223,7 +225,13 @@ def update_local_uin(core, msg):
update_chatroom(core, username)
newChatroomDict = utils.search_dict_list(
core.chatroomList, 'UserName', username)
newChatroomDict['Uin'] = uin
if newChatroomDict is None:
newChatroomDict = utils.struct_friend_info({
'UserName': username,
'Uin': uin, })
core.chatroomList.append(newChatroomDict)
else:
newChatroomDict['Uin'] = uin
elif '@' in username:
update_friend(core, username)
newFriendDict = utils.search_dict_list(
Expand Down

0 comments on commit c58174e

Please sign in to comment.