环境 | python |
依赖包 | itchat,pyqrcode |
登录:
itchat.login(2) 之后进行扫码登录
获取好友列表:
itchat.get_friends(True) 获取好友列表如下:
json.dumps(json_data,ensure_ascii=False) 得到:
发送消息:
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"])