微信自动回复、给所有好友发送消息

环境

python

依赖包

itchat,pyqrcode

 

登录:

itchat.login(2) 之后进行扫码登录

 

获取好友列表:

itchat.get_friends(True)   获取好友列表如下:

微信自动回复、给所有好友发送消息_第1张图片

 

json.dumps(json_data,ensure_ascii=False)  得到:

微信自动回复、给所有好友发送消息_第2张图片

 

 

发送消息:

itchat.send(message, UserName="@.......")

自动回复消息:

import itchat
from itchat.content import TEXT

@itchat.msg_register(TEXT, isFriendChat=True, isGroupChat=True, isMpChat=True)
def simple_reply(msg):
    return 'I received: %s' % msg.text

itchat.auto_login(True)
itchat.run()

给所有好友发送消息:

for user in itchat.get_friends(True):

    itchat.send(message, user["UserName"])

你可能感兴趣的:(微信,自动回复,发送消息,itchat,python)