Skip to content

Commit

Permalink
Fix contact spelling bug & fix None assignment bug [BR#226: cubesky]
Browse files Browse the repository at this point in the history
  • Loading branch information
littlecodersh committed Feb 20, 2017
1 parent d42f0f4 commit 2f1ffe2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/intro/login.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ itchat.auto_login(enableCmdQR=-1)

获取微信的所有好友信息并更新。

* 方法名称:`get_friends`(曾用名:`get_contract`
* 方法名称:`get_friends`(曾用名:`get_contact`
* 所需值:无
* 返回值:存储好友信息的列表

Expand Down
8 changes: 7 additions & 1 deletion itchat/components/contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,13 @@ def update_local_uin(core, msg):
update_friend(core, username)
newFriendDict = utils.search_dict_list(
core.memberList, 'UserName', username)
newFriendDict['Uin'] = uin
if newFriendDict is None:
newFriendDict = utils.struct_friend_info({
'UserName': username,
'Uin': uin, })
core.memberList.append(newFriendDict)
else:
newFriendDict['Uin'] = uin
usernameChangedList.append(username)
logger.debug('Uin fetched: %s, %s' % (username, uin))
else:
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.25'
VERSION = '1.2.26'
BASE_URL = 'https://login.weixin.qq.com'
OS = platform.system() #Windows, Linux, Darwin
DIR = os.getcwd()
Expand Down
10 changes: 5 additions & 5 deletions itchat/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,20 @@ def search_friends(self, name=None, userName=None, remarkName=None, nickName=Non
for k in ('RemarkName', 'NickName', 'Alias'):
if matchDict[k] is None: del matchDict[k]
if name: # select based on name
contract = []
contact = []
for m in self.memberList:
if any([m.get(k) == name for k in ('RemarkName', 'NickName', 'Alias')]):
contract.append(m)
contact.append(m)
else:
contract = self.memberList[:]
contact = self.memberList[:]
if matchDict: # select again based on matchDict
friendList = []
for m in contract:
for m in contact:
if all([m.get(k) == v for k, v in matchDict.items()]):
friendList.append(m)
return copy.deepcopy(friendList)
else:
return copy.deepcopy(contract)
return copy.deepcopy(contact)
def search_chatrooms(self, name=None, userName=None):
if userName is not None:
for m in self.chatroomList:
Expand Down

0 comments on commit 2f1ffe2

Please sign in to comment.