Skip to content

Commit 08a7ae9

Browse files
committed
add scan & login event handler
1 parent 95b1445 commit 08a7ae9

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

examples/ding-dong-bot.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import asyncio
2323

2424
from wechaty import (
25+
Contact,
2526
FileBox,
2627
Message,
2728
Wechaty,
@@ -43,6 +44,22 @@ async def on_message(msg: Message):
4344
await msg.say(file_box)
4445

4546

47+
async def on_scan(qrcode: str, status: int):
48+
"""
49+
Scan Handler for the Bot
50+
"""
51+
print(qrcode, status)
52+
# TODO: To be written
53+
54+
55+
async def on_login(user: Contact):
56+
"""
57+
Login Handler for the Bot
58+
"""
59+
print(user)
60+
# TODO: To be written
61+
62+
4663
async def main():
4764
"""
4865
Async Main Entry
@@ -58,7 +75,11 @@ async def main():
5875
''')
5976

6077
bot = Wechaty()
61-
bot.on('message', on_message)
78+
79+
bot.on('scan', on_scan)
80+
bot.on('login', on_login)
81+
bot.on('message', on_message)
82+
6283
await bot.start()
6384

6485
print('[Python Wechaty] Ding Dong Bot started.')

0 commit comments

Comments
 (0)