很久没有用itchat,最近有需求需要用到,所以把以前用的代码进行复用。
itchat.auto_login(hotReload=True)
itchat.send(content,toUserName='filehelper')
account=itchat.get_friends('user1')
print account
itchat.send(content, toUserName='user1')
结果是用户user1没有收到消息。而filehelper却可以收到用户消息
折腾了一番,去最新的官方更新了看了下,现在只能支持用user1的数字序列进行发送消息。
比如 上面的account中,里面有一个Username @ 一串数字的
<User: {u'UserName': u'@c49f3dd811957bd5ed998410d74560716cc0511e6a861c048adf387aa5c8577c', u'City': u'\u6df1\u5733', u'DisplayName': u'', u'UniFriend': 0, 'MemberList': <ContactList: []>, u'PYQuanPin': u'junge', u'RemarkPYInitial': u'', u'Uin': 0, u'AppAccountFlag': 0, u'VerifyFlag': 0, u'Province': u'\u5e7f\u4e1c', u'KeyWord': u'', u'RemarkName': u'', u'PYInitial': u'JG', u'ChatRoomId': 0, u'IsOwner': 0, u'HideInputBarFlag': 0, u'EncryChatRoomId': u'', u'AttrStatus': 236325, u'SnsFlag': 1, u'MemberCount': 0, u'OwnerUin': 0, u'Alias': u'', u'Signature': u'\u5988\u5988\uff0c\u6211\u6c38\u8fdc\u6000\u5ff5\u60a8\uff0c\u6c38\u8fdc\u6d3b\u5728\u6211\u5fc3\u4e2d\uff0c\u795d\u60a8\u5728\u5929\u5802\u5b89\u597d', u'ContactFlag': 3, u'NickName': u'\u541b\u54e5', u'RemarkPYQuanPin': u'', u'HeadImgUrl': u'/cgi-bin/mmwebwx-bin/webwxgeticon?seq=641471480&username=@c49f3dd811957bd5ed998410d74560716cc0511e6a861c048adf387aa5c8577c&skey=@crypt_7801355c_17bd503bf8c1b2f92998687691a9c156', u'Sex': 1, u'StarFriend': 0, u'Statues': 0}>,
那么上面的数字就是用户的数字序列,你只要把
itchat.send(content, toUserName='user1')
中的user1改为@c49f3dd811957bd5ed998410d74560716cc0511e6a861c048adf387aa5c8577c 就可以了。
记得@不能漏。