Wechaty is a Bot SDK for Wechat Personal Account
Project description
python-wechaty
![PyPI GitHub Actions](https://pypi-camo.freetls.fastly.net/93b501741b90a334f6b315191640a3f5e7e7eb9e/68747470733a2f2f6769746875622e636f6d2f776563686174792f707974686f6e2d776563686174792f776f726b666c6f77732f507950492f62616467652e737667)
Connecting Chatbots
Wechaty is a RPA SDK for Wechat Individual Account that can help you create a chatbot in 6 lines of Python.
WORK IN PROGRESS
Work in progress...
Please come back after 4 weeks...
Voice of the Developers
"Wechaty is a great solution, I believe there would be much more users recognize it." link
-- @Gcaufy, Tencent Engineer, Author of WePY
"太好用,好用的想哭"
-- @xinbenlv, Google Engineer, Founder of HaoShiYou.org
"最好的微信开发库" link
-- @Jarvis, Baidu Engineer
"Wechaty让运营人员更多的时间思考如何进行活动策划、留存用户,商业变现" link
-- @lijiarui, CEO of BotOrange.
"If you know js ... try Chatie/wechaty, it's easy to use."
-- @Urinx Uri Lee, Author of WeixinBot(Python)
See more at Wiki:Voice Of Developer
Join Us
Wechaty is used in many ChatBot projects by thousands of developers. If you want to talk with other developers, just scan the following QR Code in WeChat with secret code python wechaty, join our Wechaty Python Developers' Home.
Scan now, because other Wechaty Python developers want to talk with you too! (secret code: python wechaty)
The World's Shortest Python ChatBot: 6 lines of Code
from wechaty import Wechaty
Wechaty.instance() // Global Instance
.on('scan', lambda qrcode, status : print('Scan QR Code to login: {}\nhttps://api.qrserver.com/v1/create-qr-code/?data={}'.format(status, encodeURIComponent(qrcode))))
.on('login', lambda user: print('User {} logined'.format(user)))
.on('message', lambda message: print('Message: {}'.format(message)))
.start()
Python Wechaty Developing Plan
We already have Wechaty in TypeScript, It will be not too hard to translate the TypeScript(TS) to Python(PY) because wechaty has only 3,000 lines of the TS code, they are well designed and de-coupled by the wechaty-puppet abstraction. So after we have translated those 3,000 lines of TypeScript code, we will almost be done.
As we have already a ecosystem of Wechaty in TypeScript, so we will not have to implement everything in Python, especially, in the Feb 2020, we have finished the @chatie/grpc service abstracting module with the wechaty-puppet-hostie implmentation.
The following diagram shows out that we can reuse almost everything in TypeScript, and what we need to do is only the block located at the top right of the diagram: Wechaty (Python)
.
+--------------------------+ +--------------------------+
| | | |
| Wechaty (TypeScript) | | Wechaty (Python) |
| | | |
+--------------------------+ +--------------------------+
+-------------------------------------------------------+
| Wechaty Puppet Hostie |
| |
| (wechaty-puppet-hostie) |
+-------------------------------------------------------+
+--------------------- @chatie/grpc ----------------------+
+-------------------------------------------------------+
| Wechaty Puppet Abstract |
| |
| (wechaty-puppet) |
+-------------------------------------------------------+
+--------------------------+ +--------------------------+
| Pad Protocol | | Web Protocol |
| | | |
| wechaty-puppet-padplus | |(wechaty-puppet-puppeteer)|
+--------------------------+ +--------------------------+
+--------------------------+ +--------------------------+
| Windows Protocol | | Mac Protocol |
| | | |
| (wechaty-puppet-windows) | | (wechaty-puppet-macpro) |
+--------------------------+ +--------------------------+
Example: How to Translate TypeScript to Python
There's a 100 lines class named Image
in charge of downloading the WeChat image to different sizes.
It is a great example for demonstrating how do we translate the TypeScript to Python in Wechaty Way:
Image Class Source Code
- TypeScript: https://github.com/wechaty/wechaty/blob/master/src/user/image.ts
- Python: https://github.com/wechaty/python-wechaty/blob/master/src/wechaty/user/images.py
If you are interested in the translation and want to look at how it works, it will be a good start from reading and comparing those two Image
class files in TypeScript and Python at the same time.
To-do List
- TS: TypeScript
- SLOC: Source Lines Of Code
Wechaty Internal Modules
- Class Wechaty @wj-mCat
- TS SLOC(1160): https://github.com/wechaty/wechaty/blob/master/src/wechaty.ts
- Code
- Unit Tests
- Documentation
- Class Contact
- TS SLOC(804): https://github.com/wechaty/wechaty/blob/master/src/user/contact.ts
- Code
- Unit Tests
- Documentation
- Class ContactSelf
- TS SLOC(199): https://github.com/wechaty/wechaty/blob/master/src/user/contact-self.ts
- Code
- Unit Tests
- Documentation
- Class Message
- TS SLOC(1054): https://github.com/wechaty/wechaty/blob/master/src/user/message.ts
- Code
- Unit Tests
- Documentation
- Class Room
- TS SLOC(1194): https://github.com/wechaty/wechaty/blob/master/src/user/room.ts
- Code
- Unit Tests
- Documentation
- Class Image @wj-mCat
- TS SLOC(60): https://github.com/wechaty/wechaty/blob/master/src/user/image.ts
- Code
- Unit Tests
- Documentation
- Class Accessory @huan
- TS SLOC(179): https://github.com/wechaty/wechaty/blob/master/src/accessory.ts
- Code
- Unit Tests
- Documentation
- Class Config @wj-mCat
- TS SLOC(187): https://github.com/wechaty/wechaty/blob/master/src/config.ts
- Code
- Unit Tests
- Documentation
- Class Favorite
- TS SLOC(52): https://github.com/wechaty/wechaty/blob/master/src/user/favorite.ts
- Code
- Unit Tests
- Documentation
- Class Friendship
- TS SLOC(417): https://github.com/wechaty/wechaty/blob/master/src/user/friendship.ts
- Code
- Unit Tests
- Documentation
- Class MiniProgram
- TS SLOC(70): https://github.com/wechaty/wechaty/blob/master/src/user/mini-program.ts
- Code
- Unit Tests
- Documentation
- Class RoomInvitation
- TS SLOC(317): https://github.com/wechaty/wechaty/blob/master/src/user/room-invitation.ts
- Code
- Unit Tests
- Documentation
- Class Tag
- TS SLOC(190): https://github.com/wechaty/wechaty/blob/master/src/user/tag.ts
- Code
- Unit Tests
- Documentation
- Class UrlLink
- TS SLOC(107): https://github.com/wechaty/wechaty/blob/master/src/user/url-link.ts
- Code
- Unit Tests
- Documentation
Wechaty External Modules
- Class FileBox
- TS SLOC(638): https://github.com/huan/file-box/blob/master/src/file-box.ts
- Code
- Unit Tests
- Documentation
- Class MemoryCard
- TS SLOC(376): https://github.com/huan/memory-card/blob/master/src/memory-card.ts
- Code
- Unit Tests
- Documentation
- Class WechatyPuppet
- TS SLOC(1115): https://github.com/wechaty/wechaty-puppet/blob/master/src/puppet.ts
- Code
- Unit Tests
- Documentation
- Class WechatyPuppetHostie
- TS SLOC(909): https://github.com/wechaty/wechaty-puppet-hostie/blob/master/src/grpc/puppet-client.ts
- Code
- Unit Tests
- Documentation
Usage
WIP...
Requirements
- Python 3.7+
Install
pip3 install wechaty
See Also
Static & Instance of Class
Typings
History
master
v0.1 (Mar 8, 2020)
Welcome @wj-Mcat for joining the project!
- Starting translate TypeScript of Wechaty to Python
- DevOps Setup
- Type Checking: mypy & pytype
- Unit Testing: pytest
- Linting: pylint, pycodestyle, and flake8
- CI/CD: GitHub Actions
- Publish to PyPI automatically after the tests passed.
v0.0.1 (Aug 25, 2018)
Project created, publish a empty module wechaty
on PyPI.
Related Projects
- Wechaty - WeChat Bot SDK for Individual Account in TypeScript
Author
Copyright & License
- Code & Docs © 2018-now Huan LI <zixia@zixia.net>
- Code released under the Apache-2.0 License
- Docs released under Creative Commons
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
Built Distribution
Hashes for wechaty-0.1.dev4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f085fd1a7897a18c307a4e7643deb957b0f4fe1b52be68585dbc0766775746d |
|
MD5 | 47054b24f1136e7a8d5b829082282960 |
|
BLAKE2b-256 | 51276eb6f4fd6638bae1bde20c230b146e318222ade5fb53d3f1e69616d69d5e |