Skip to content

Commit

Permalink
Add function get_user_id.
Browse files Browse the repository at this point in the history
  • Loading branch information
liuwons committed Mar 5, 2016
1 parent cf42400 commit f824fff
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions wxbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,16 @@ def send_msg_by_uid(self, word, dst='filehelper'):
dic = r.json()
return dic['BaseResponse']['Ret'] == 0

def get_user_id(self, name):
for contact in self.contact_list:
if 'RemarkName' in contact and contact['RemarkName'] == name:
return contact['UserName']
elif 'NickName' in contact and contact['NickName'] == name:
return contact['UserName']
elif 'DisplayName' in contact and contact['DisplayName'] == name:
return contact['UserName']
return ''

def send_msg(self, name, word, isfile=False):
uid = self.get_user_id(name)
if uid:
Expand Down

0 comments on commit f824fff

Please sign in to comment.