itchat is an open source api for WeChat, a famous Chinese communicating app, you can easily use your personal wechat account through itchat in cmd.
A wechat robot and a command line version of wechat are also structured, you can view them in robot branch.
Consisted of less than 30 lines of codes, a wechat robot can deal with all the oridinary messages.
Now Wechat is an important part of personal sociality, hope that this repo can help you extend your personal wechat account and make your life easier.
You may get the document of this api from here.
itchat can be installed with this little one-line command:
pip install itchat
The following is a demo of how itchat is configured to fetch and reply daily information.
import itchat, time
@itchat.msg_register(['Text', 'Map', 'Card', 'Note', 'Sharing'])
def text_reply(msg):
itchat.send('%s: %s'%(msg['Type'], msg['Text']), msg['FromUserName'])
@itchat.msg_register(['Picture', 'Recording', 'Attachment', 'Video'])
def download_files(msg):
fileDir = '%s%s'%(msg['Type'], int(time.time()))
msg['Text'](fileDir)
itchat.send('%s received'%msg['Type'], msg['FromUserName'])
itchat.send('@%s@%s'%('img' if msg['Type'] == 'Picture' else 'fil', fileDir), msg['FromUserName'])
@itchat.msg_register('Friends')
def add_friend(msg):
itchat.add_friend(**msg['Text'])
itchat.get_contract()
itchat.send_msg(msg['RecommendInfo']['UserName'], 'Nice to meet you!')
@itchat.msg_register('Text', isGroupChat = True)
def text_reply(msg):
itchat.send(u'@%s\u2005I received: %s'%(msg['ActualNickName'], msg['Content']), msg['FromUserName'])
itchat.auto_login()
itchat.run()
This QRCode is a wechat account based on the framework of robot branch. Seeing is believing, so have a try:)
Q: Why I can't upload files whose name is not purely english?
A: This is caused because of the encoding of requests
, you may fix it by placing fields.py in packages/urllib of requests.
liuwons/wxBot: A wechat robot similiar to the robot branch
zixia/wechaty: wechat for bot in Javascript(ES6), Personal Account Robot Framework/Library.
If you have any problems or suggestions, feel free to put it up in this Issue.