Skip to main content

A complete wechat personal account api

Project description

itchat is a open souce wechat api project for personal account.

It enables you to access your personal wechat account through command line.

Here is the document.

So enjoy:)

Try:

You may have a try of the robot based on this project first:

QRCodeOfRobot

Here is the code.

Installation

pip install itchat

Simple uses

import itchat, time

itchat.auto_login()

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

@itchat.msg_register('Text', isGroupChat = True)
def text_reply(msg):
    itchat.send(u'@%s\u2005I received: %s'%(msg['ActualNickName'], msg['Content']), msg['FromUserName'])

itchat.run()

FAQ

Why I can’t send files whose name is encoded in utf8?

That’s because of the upload setting of requests, you can put this file into packages/urllib3 of requests package.

Comments

If you have any problems or suggestions, you can talk to me in this issue

Or on gitter.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

itchat-1.0.5-py2.py3-none-any.whl (10.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file itchat-1.0.5-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for itchat-1.0.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 80daa7df7e3545575fcc56d18b275723b2f1d34772d5b0b8dcd38622094c3f4e
MD5 d107c92990702705d1125ba10bdde55e
BLAKE2b-256 d954c67d6d596ba855057bc60527269c1241277cc6859be8a98bbdd328826194

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page