GithubHelp home page GithubHelp logo

hydercps / itchat Goto Github PK

View Code? Open in Web Editor NEW

This project forked from liduanwei/itchat

0.0 2.0 0.0 177 KB

API for Wechat. 微信个人号接口(支持文件、图片上下载)、微信机器人及命令行微信。三十行即可自定义个人号机器人。

Home Page: http://itchat.readthedocs.io/zh/latest/

License: MIT License

Python 100.00%

itchat's Introduction

itchat

Gitter python English version

itchat是一个开源的微信个人号接口,使用他你可以轻松的通过命令行使用个人微信号。

微信机器人的实现及命令行版微信见robot分支

使用不到三十行的代码,你就可以完成一个能够处理所有信息的微信机器人。

如今微信已经成为了个人社交的很大一部分,希望这个项目能够帮助你扩展你的个人的微信号、方便自己的生活。

Documents

你可以在这里获取api的使用帮助。

Installation

可以通过本命令安装itchat:

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_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.run()

Have a try

这是一个基于这一项目的开源小机器人,百闻不如一见,有兴趣可以尝试一下。

QRCode

Screenshots

file_autoreply login_page

FAQ

Q: 为什么中文的文件没有办法上传?

A: 这是由于requests的编码问题导致的。若需要支持中文文件传输,将fields.py文件放入requests包的packages/urllib3下即可

See also

liuwons/wxBot: 类似的基于Python的微信机器人

zixia/wechaty: 基于Javascript(ES6)的微信个人账号机器人NodeJS框架/库

Comments

如果有什么问题或者建议都可以在这个Issue和我讨论

或者也可以在gitter上交流:Gitter

itchat's People

Contributors

littlecodersh avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.