跳转到主要内容

Wechaty是一款面向聊天机器人制作者的对话式RPA SDK

项目描述

python-wechaty PyPI版本 PyPI GitHub Actions

Python Wechaty

Python Wechaty Getting Started Python 3.7 Downloads Wechaty in Python

连接聊天机器人

Powered by 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 Friday.BOT QR Code

立即扫描,因为其他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 类源代码

如果你对翻译感兴趣并想了解它是如何工作的,同时阅读和比较这两个Image类文件将是一个不错的开始。

待办事项清单

  • TS: TypeScript
  • SLOC: 源代码行数

Wechaty 内部模块

  1. 类 Wechaty @wj-mCat
  2. 类 Contact
  3. 类 ContactSelf
  4. 类 Message
  5. 类 Room
  6. 类 Image @wj-mCat
  7. 类 Accessory @huan
  8. 类 Config @wj-mCat
  9. 类 Favorite
  10. 类 Friendship
  11. 类 MiniProgram
  12. 类 RoomInvitation
  13. 类 Tag
  14. 类 UrlLink

Wechaty 外部模块

  1. 类 FileBox
  2. 类 MemoryCard
  3. 类 WechatyPuppet
  4. 类 WechatyPuppetHostie

用法

进行中...

需求

  1. 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

  1. 为PyPI用户添加友好的异常信息。 #24

v0.1(2020年3月8日)

欢迎 @wj-Mcat 加入项目! #4

  1. 开始将Wechaty的TypeScript翻译成Python
  2. DevOps设置
    1. 类型检查:mypy & pytype
    2. 单元测试:pytest
    3. 代码风格检查:pylint, pycodestyle和flake8
    4. CI/CD:GitHub Actions
  3. 测试通过后自动发布到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)

徽章

Wechaty in Python

[![Wechaty in Python](https://img.shields.io/badge/Wechaty-Python-blue)](https://github.com/wechaty/python-wechaty)

随时间变化的星标数量

Stargazers over time

贡献者

contributor contributor contributor contributor contributor contributor contributor contributor

提交者

  1. @huangaszaq - Chunhong HUANG (黄纯洪)

创建者

版权 & 许可证

  • 代码 & 文档 © 2018 Wechaty贡献者 https://github.com/wechaty
  • 代码在Apache-2.0许可证下发布
  • 文档在Creative Commons下发布

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。

源代码分发

chaty-0.8.11.tar.gz (40.1 kB 查看散列值)

上传于 源代码

构建发行版

chaty-0.8.11-py3-none-any.whl (55.4 kB 查看哈希值)

上传于 Python 3

由以下支持