Wechaty是一款面向聊天机器人制作者的对话式RPA SDK
项目描述
python-wechaty

连接聊天机器人
Wechaty是一款面向聊天机器人制作者的对话式SDK,可以帮助您用9行Python代码创建一个机器人。
开发者之声
"Wechaty是一个很好的解决方案,我相信会有更多的用户认识到它。" 链接
— @Gcaufy, 腾讯工程师,WePY的作者"太好用,好用到想哭"
— @xinbenlv, Google工程师,HaoShiYou.org的创始人"最好的微信开发库" 链接
— @Jarvis, 百度工程师"Wechaty让运营人员有更多的时间思考如何进行活动策划、留存用户,实现商业变现" 链接
— @lijiarui, Juzi.BOT的创始人兼CEO"如果你了解js ... 尝试Wechaty,它很容易使用。"
— @Urinx Uri Lee, WeixinBot(Python)的作者
更多信息请查看 Wiki:开发者之声
加入我们
Wechaty被成千上万的开发者用于许多聊天机器人项目。如果您想与其他开发者交流,只需扫描以下微信二维码,使用密钥 python wechaty 加入我们的 Wechaty Python开发者之家。
立即扫描,因为其他Wechaty Python开发者也想和你交流!(秘密代码:python wechaty)
世界上最短的Python聊天机器人:9行代码
from wechaty import Wechaty
import asyncio
async def main():
bot = Wechaty()
bot.on('scan', lambda status, qrcode, data: print('Scan QR Code to login: {}\nhttps://wechaty.js.org/qrcode/{}'.format(status, qrcode)))
bot.on('login', lambda user: print('User {} logged in'.format(user)))
bot.on('message', lambda message: print('Message: {}'.format(message)))
await bot.start()
asyncio.run(main())
Python Wechaty 开发计划
我们已经有Wechaty在TypeScript中的版本,将TypeScript(TS)转换为Python(PY)不会太难,因为wechaty仅有3,000行的TS代码,它们通过wechaty-puppet抽象很好地设计和解耦。因此,在翻译完这3,000行TypeScript代码后,我们几乎就完成了。
由于我们已经有了TypeScript版本的Wechaty生态系统,所以不需要在Python中实现所有内容,尤其是在2020年2月,我们已经完成了wechaty-grpc服务抽象模块的wechaty-puppet-service实现。
以下图表显示了我们可以重用TypeScript中的几乎所有内容,而我们需要做的仅仅是图表右上角的这个块:Wechaty (Python)
。
+--------------------------+ +--------------------------+
| | | |
| Wechaty (TypeScript) | | Wechaty (Python) |
| | | |
+--------------------------+ +--------------------------+
+-------------------------------------------------------+
| Wechaty Puppet Service |
| |
| (wechaty-puppet-service) |
+-------------------------------------------------------+
+--------------------- wechaty-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) |
+--------------------------+ +--------------------------+
示例:如何将TypeScript转换为Python
有一个100行长的名为Image
的类,负责将微信图片下载到不同大小。
这是一个展示如何以Wechaty方式将TypeScript转换为Python的绝佳示例。
Image 类源代码
- TypeScript: https://github.com/wechaty/wechaty/blob/master/src/user/image.ts
- Python: https://github.com/wechaty/python-wechaty/blob/master/src/wechaty/user/image.py
如果你对翻译感兴趣并想了解它是如何工作的,同时阅读和比较这两个Image
类文件将是一个不错的开始。
待办事项清单
- TS: TypeScript
- SLOC: 源代码行数
Wechaty 内部模块
- 类 Wechaty @wj-mCat
- TS SLOC(1160): https://github.com/wechaty/wechaty/blob/master/src/wechaty.ts
- 代码
- 单元测试
- 文档
- 类 Contact
- TS SLOC(804): https://github.com/wechaty/wechaty/blob/master/src/user/contact.ts
- 代码
- 单元测试
- 文档
- 类 ContactSelf
- TS SLOC(199): https://github.com/wechaty/wechaty/blob/master/src/user/contact-self.ts
- 代码
- 单元测试
- 文档
- 类 Message
- TS SLOC(1054): https://github.com/wechaty/wechaty/blob/master/src/user/message.ts
- 代码
- 单元测试
- 文档
- 类 Room
- TS SLOC(1194): https://github.com/wechaty/wechaty/blob/master/src/user/room.ts
- 代码
- 单元测试
- 文档
- 类 Image @wj-mCat
- TS SLOC(60): https://github.com/wechaty/wechaty/blob/master/src/user/image.ts
- 代码
- 单元测试
- 文档
- 类 Accessory @huan
- TS SLOC(179): https://github.com/wechaty/wechaty/blob/master/src/accessory.ts
- 代码
- 单元测试
- 文档
- 类 Config @wj-mCat
- TS SLOC(187): https://github.com/wechaty/wechaty/blob/master/src/config.ts
- 代码
- 单元测试
- 文档
- 类 Favorite
- TS SLOC(52): https://github.com/wechaty/wechaty/blob/master/src/user/favorite.ts
- 代码
- 单元测试
- 文档
- 类 Friendship
- TS SLOC(417): https://github.com/wechaty/wechaty/blob/master/src/user/friendship.ts
- 代码
- 单元测试
- 文档
- 类 MiniProgram
- TS SLOC(70): https://github.com/wechaty/wechaty/blob/master/src/user/mini-program.ts
- 代码
- 单元测试
- 文档
- 类 RoomInvitation
- TS SLOC(317): https://github.com/wechaty/wechaty/blob/master/src/user/room-invitation.ts
- 代码
- 单元测试
- 文档
- 类 Tag
- TS SLOC(190): https://github.com/wechaty/wechaty/blob/master/src/user/tag.ts
- 代码
- 单元测试
- 文档
- 类 UrlLink
- TS SLOC(107): https://github.com/wechaty/wechaty/blob/master/src/user/url-link.ts
- 代码
- 单元测试
- 文档
Wechaty 外部模块
- 类 FileBox
- TS SLOC(638): https://github.com/huan/file-box/blob/master/src/file-box.ts
- 代码
- 单元测试
- 文档
- 类 MemoryCard
- TS SLOC(376): https://github.com/huan/memory-card/blob/master/src/memory-card.ts
- 代码
- 单元测试
- 文档
- 类 WechatyPuppet
- TS SLOC(1115): https://github.com/wechaty/wechaty-puppet/blob/master/src/puppet.ts
- 代码
- 单元测试
- 文档
- 类 WechatyPuppetHostie
用法
进行中...
需求
- Python 3.7+
安装
pip3 install wechaty
另请参阅
类的静态和实例
类型定义
历史
v0.6(2020年6月19日)
Python Wechaty Scala Wechaty BETA 发布!
从我们的博客了解更多关于我们多语言Wechaty BETA发布活动的内容
v0.4(2020年3月15日)master
欢迎 @huangaszaq 加入项目! #42
- 为PyPI用户添加友好的异常信息。 #24
v0.1(2020年3月8日)
- 开始将Wechaty的TypeScript翻译成Python
- DevOps设置
- 类型检查:mypy & pytype
- 单元测试:pytest
- 代码风格检查:pylint, pycodestyle和flake8
- CI/CD:GitHub Actions
- 测试通过后自动发布到PyPI。
v0.0.1(2018年8月25日)
项目创建,在PyPI上发布了一个空的模块 wechaty
。
相关项目
- Wechaty - Wechaty个人账户的对话式AI聊天机器人SDK(TypeScript)
- Python Wechaty - Wechat个人账户的对话式AI聊天机器人SDK(Python)
- Go Wechaty - Wechat个人账户的对话式AI聊天机器人SDK(Go)
- Java Wechaty - Wechat个人账户的对话式AI聊天机器人SDK(Java)
- Scala Wechaty - Wechaty个人账户的对话式AI聊天机器人SDK(Scala)
徽章
[](https://github.com/wechaty/python-wechaty)
随时间变化的星标数量
贡献者
提交者
- @huangaszaq - Chunhong HUANG (黄纯洪)
创建者
- @wj-Mcat - Jingjing WU (吴京京)
- @huan - (李卓桓) zixia@zixia.net
版权 & 许可证
- 代码 & 文档 © 2018 Wechaty贡献者 https://github.com/wechaty
- 代码在Apache-2.0许可证下发布
- 文档在Creative Commons下发布
项目详情
下载文件
下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。
源代码分发
构建发行版
chaty-0.8.11.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 20671e3ee9d15096b91e54bcda45436c9817b7d9ad13455556392b355e8f63ac |
|
MD5 | 6f661370d625c7e7fe801c5788baa8db |
|
BLAKE2b-256 | a5b38d249ea03ee9628d95c22535f15b881d156b69f3fb402a8fe42b8d8c512c |
chaty-0.8.11-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 0180e02c3116df0e92089a8ba0ea06039106145285081f70c66ac20b29fdc3b6 |
|
MD5 | 3957cbec911dfef8a24894439773e713 |
|
BLAKE2b-256 | 495f920069f0b67ae56efa5a68c11b5f90729a31a230312e1efa3c4c41cd5f26 |