diff --git a/README.md b/README.md index 75ab46e..59e2f9d 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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