make await_event stop propagation only if the filter raises

This commit is contained in:
udf 2018-04-08 22:13:20 +02:00
parent 32e9a20f39
commit 98bdf910e4
1 changed files with 5 additions and 2 deletions

View File

@ -87,9 +87,12 @@ class Uniborg(TelegramClient):
@self.on(event_matcher)
async def cb(event):
if filter is None or await filter(event):
try:
if filter is None or await filter(event):
fut.set_result(event)
except telethon.events.StopPropagation:
fut.set_result(event)
raise telethon.events.StopPropagation
raise
fut.add_done_callback(
lambda _: self.remove_event_handler(cb, event_matcher))