Stop propagation of awaited events

This commit is contained in:
Dan Elkouby 2018-04-08 16:09:57 +03:00
parent 4c7923dd44
commit 881266f96e
1 changed files with 2 additions and 0 deletions

View File

@ -9,6 +9,7 @@ from pathlib import Path
from telethon import TelegramClient from telethon import TelegramClient
import telethon.utils import telethon.utils
import telethon.events
from . import hacks from . import hacks
@ -84,6 +85,7 @@ class Uniborg(TelegramClient):
async def cb(event): async def cb(event):
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
fut.add_done_callback(lambda _: fut.add_done_callback(lambda _:
self.remove_event_handler(cb, event_matcher)) self.remove_event_handler(cb, event_matcher))