Skip to content

modify example code in readme #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Python Wechaty Starter Project Template that Works Out-of-the-Box

[![Powered by Wechaty](https://img.shields.io/badge/Powered%20By-Wechaty-brightgreen.svg)](https://github.com/Wechaty/wechaty)

Wechaty is a RPA SDK for Wechat **Individual** Account that can help you create a chatbot in 6 lines of Python.
Wechaty is a RPA SDK for Wechat **Individual** Account that can help you create a chatbot in 9 lines of Python.

## Requirements

Expand Down Expand Up @@ -51,16 +51,18 @@ Wechaty is a RPA SDK for Wechat **Individual** Account that can help you create
python examples/ding-dong-bot.py
```

## The World's Shortest Python ChatBot: 6 lines of Code
## The World's Shortest Python ChatBot: 9 lines of Code

```python
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()
import asyncio
async def main():
bot = Wechaty()
bot.on('scan', lambda status, qrcode, data: print('Scan QR Code to login: {}\nhttps://api.qrserver.com/v1/create-qr-code/?data={}'.format(status, qrcode)))
bot.on('login', lambda user: print('User {} logined'.format(user)))
bot.on('message', lambda message: print('Message: {}'.format(message)))
await bot.start()
asyncio.run(main())
```

## Wechaty Getting Started in Multiple Languages
Expand Down