Skip to content

Commit 86dac7c

Browse files
committed
20200625 modify example code in readme
1 parent dd95e47 commit 86dac7c

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Python Wechaty Starter Project Template that Works Out-of-the-Box
1111

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

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

1616
## Requirements
1717

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

54-
## The World's Shortest Python ChatBot: 6 lines of Code
54+
## The World's Shortest Python ChatBot: 9 lines of Code
5555

5656
```python
5757
from wechaty import Wechaty
58-
59-
Wechaty.instance() // Global Instance
60-
.on('scan', lambda qrcode, status : print('Scan QR Code to login: {}\nhttps://api.qrserver.com/v1/create-qr-code/?data={}'.format(status, encodeURIComponent(qrcode))))
61-
.on('login', lambda user: print('User {} logined'.format(user)))
62-
.on('message', lambda message: print('Message: {}'.format(message)))
63-
.start()
58+
import asyncio
59+
async def main():
60+
bot = Wechaty()
61+
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)))
62+
bot.on('login', lambda user: print('User {} logined'.format(user)))
63+
bot.on('message', lambda message: print('Message: {}'.format(message)))
64+
await bot.start()
65+
asyncio.run(main())
6466
```
6567

6668
## Wechaty Getting Started in Multiple Languages

0 commit comments

Comments
 (0)