Skip to content

Latest commit

 

History

History
83 lines (51 loc) · 3.5 KB

README_EN.md

File metadata and controls

83 lines (51 loc) · 3.5 KB

itchat

Gitter python 中文版

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.

Documents

You may get the document of this api from here.

Installation

itchat can be installed with this little one-line command:

pip install itchat

Simple uses

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()

Have a try

This QRCode is a wechat account based on the framework of robot branch. Seeing is believing, so have a try:)

QRCode

Screenshots

file_autoreply login_page

FAQ

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.

See also

liuwons/wxBot: A wechat robot similiar to the robot branch

zixia/wechaty: wechat for bot in Javascript(ES6), Personal Account Robot Framework/Library.

Comments

If you have any problems or suggestions, feel free to put it up in this Issue.

Or you may also use Gitter