Python Wechaty Starter Project Template that Works Out-of-the-Box
Wechaty is a RPA SDK for Wechat Individual Account that can help you create a chatbot in 9 lines of Python.
- python3.7+
Here's a great live coding video tutorial from our Python Wechaty creator @wj-Mcat: https://wechaty.js.org/2020/10/26/python-wechaty-live-coding/
-
Clone python-wechaty-getting-started repository
git clone https://github.com/wechaty/python-wechaty-getting-started cd python-wechaty-getting-started
-
Install Dependencies
make install # or pip install -r requirements.txt
-
Set token for your bot
You need a Wechaty Puppet Service Token first, you can learn how to get it from our official docs at https://wechaty.js.org/docs/puppet-services/.
```sh
# examples/ding-dong-bot.py : func-> main()
# it must be donut token
export WECHATY_PUPPET=wechaty-puppet-service
export WECHATY_PUPPET_SERVICE_TOKEN=your_token_at_here
```
or you can use `TOKEN` or `token` environment variable alias name to set **token**, for example:
```shell
export TOKEN=your_token_at_here
# or
export token=your_token_at_here
```
Learn more about the token related concepts by reading our blog post: Introducing Wechaty Puppet Service (Providers), @huan, Jan 14, 2021
-
Run the bot
make bot # or python examples/ding-dong-bot.py
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.wechaty.js/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())
- TypeScript Wechaty Getting Started
- Python Wechaty Getting Started
- Java Wechaty Getting Started
- Go Wechaty Getting Started
[![Wechaty in Python](https://img.shields.io/badge/Wechaty-Python-blue)](https://github.com/wechaty/python-wechaty)
- Code & Docs © 2020 Wechaty Contributors https://github.com/wechaty
- Code released under the Apache-2.0 License
- Docs released under Creative Commons