Skip to content

Latest commit

 

History

History
92 lines (56 loc) · 3.78 KB

README_EN.md

File metadata and controls

92 lines (56 loc) · 3.78 KB

itchat

Gitter python 中文版

itchat is an open source api for WeChat, a commonly-used Chinese social networking app, you can easily access your personal wechat account through itchat in cmd.

Wechat is structured with a wechat robot and a command line, you can view them in robot branch.

A wechat robot can handle all the basic messages with only less than 30 lines of codes.

Now Wechat is an important part of personal life, hopefully this repo can help you extend your personal wechat account's functionality and enbetter user's experience with wechat.

Python 2.7.11 version is also available here.

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('Nice to meet you!', msg['RecommendInfo']['UserName'])

@itchat.msg_register('Text', isGroupChat = True)
def text_reply(msg):
    if msg['isAt']:
        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.

Author

LittleCoder: Structure and py2 version

Chyroc: py3 version

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