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_dealer(['Text', 'Map', 'Card', 'Note', 'Sharing'])
def text_reply(msg):
    itchat.send('%s: %s'%(msg['Type'], msg['Text']), msg['FromUserName'])

@itchat.msg_dealer(['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_dealer('Friends')
def add_friend(msg):
    itchat.add_friend(**msg['Text'])
    itchat.get_contract()
    itchat.send('Nice to meet you!', msg['RecommendInfo']['UserName'])

@itchat.msg_dealer('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 Distribution

itchat-1.0.3.zip (3.8 kB view details)

Uploaded Source

File details

Details for the file itchat-1.0.3.zip.

File metadata

  • Download URL: itchat-1.0.3.zip
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for itchat-1.0.3.zip
Algorithm Hash digest
SHA256 0e2ab55689faf3f893a832853a6ffebccef19677e5a20d852842baae70aaa22e
MD5 10c625198f5f91d07038fe1ef82d0618
BLAKE2b-256 26f29d774a449cc82118a3ccfe382c2468639b64e0d670f1320239d1dd91370b

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