forked from kate/uniborg
make await_event stop propagation only if the filter raises
This commit is contained in:
parent
32e9a20f39
commit
98bdf910e4
|
@ -87,9 +87,12 @@ class Uniborg(TelegramClient):
|
||||||
|
|
||||||
@self.on(event_matcher)
|
@self.on(event_matcher)
|
||||||
async def cb(event):
|
async def cb(event):
|
||||||
|
try:
|
||||||
if filter is None or await filter(event):
|
if filter is None or await filter(event):
|
||||||
fut.set_result(event)
|
fut.set_result(event)
|
||||||
raise telethon.events.StopPropagation
|
except telethon.events.StopPropagation:
|
||||||
|
fut.set_result(event)
|
||||||
|
raise
|
||||||
|
|
||||||
fut.add_done_callback(
|
fut.add_done_callback(
|
||||||
lambda _: self.remove_event_handler(cb, event_matcher))
|
lambda _: self.remove_event_handler(cb, event_matcher))
|
||||||
|
|
Loading…
Reference in New Issue