From 3a9cce8720ee19fb13a3eec99e8557dc2b768af5 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sun, 8 Jul 2018 15:11:10 +0200 Subject: [PATCH] Add missing async/await to events' documentation --- readthedocs/extra/basic/getting-started.rst | 4 ++-- telethon/events/__init__.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/readthedocs/extra/basic/getting-started.rst b/readthedocs/extra/basic/getting-started.rst index a3dec33d..ddfa9fbe 100644 --- a/readthedocs/extra/basic/getting-started.rst +++ b/readthedocs/extra/basic/getting-started.rst @@ -79,8 +79,8 @@ Handling Updates from telethon import events @client.on(events.NewMessage(incoming=True, pattern='(?i)hi')) - def handler(event): - event.reply('Hello!') + async def handler(event): + await event.reply('Hello!') client.run_until_disconnected() diff --git a/telethon/events/__init__.py b/telethon/events/__init__.py index 7614dbfe..08ef1701 100644 --- a/telethon/events/__init__.py +++ b/telethon/events/__init__.py @@ -18,13 +18,13 @@ class StopPropagation(Exception): >>> client = TelegramClient(...) >>> >>> @client.on(events.NewMessage) - ... def delete(event): - ... event.delete() + ... async def delete(event): + ... await event.delete() ... # No other event handler will have a chance to handle this event ... raise StopPropagation ... >>> @client.on(events.NewMessage) - ... def _(event): + ... async def _(event): ... # Will never be reached, because it is the second handler ... pass """