Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
support for both sync and async filters #437
Conversation
| @@ -188,8 +188,12 @@ async def update_worker(self, lock): | |||
|
|
|||
| if isinstance(handler, handler_type): | |||
| try: | |||
| if handler.check(parsed_update): | |||
| args = (parsed_update,) | |||
| if callable(handler.filters) and asyncio.iscoroutinefunction(handler.filters.__call__): | |||
delivrance
Jul 8, 2020
Member
callable(handler.filters) is not actually needed. Filter objects in the current API always have __call__ defined, if they don't they are not proper filters and pyrogram will raise an exception when accessing handler.filters.__call__, which is better than having it silently ignore updates.
callable(handler.filters) is not actually needed. Filter objects in the current API always have __call__ defined, if they don't they are not proper filters and pyrogram will raise an exception when accessing handler.filters.__call__, which is better than having it silently ignore updates.
delivrance
Jul 8, 2020
Member
I think we should remove all of these checks here and have handler.check actually check for coroutine functions. It also helps removing one repeated line args = (parsed_update,).
I think we should remove all of these checks here and have handler.check actually check for coroutine functions. It also helps removing one repeated line args = (parsed_update,).
HasibulKabir
Jul 8, 2020
Author
Contributor
sure.
sure.
| @@ -46,5 +46,5 @@ class DeletedMessagesHandler(Handler): | |||
| def __init__(self, callback: callable, filters=None): | |||
| super().__init__(callback, filters) | |||
|
|
|||
| def check(self, messages): | |||
| return super().check(messages[0]) | |||
| async def check(self, messages): | |||
delivrance
Jul 8, 2020
Member
You checked for other usages. Good!
You checked for other usages. Good!
| return (self.filters(update)) | ||
|
|
||
| else: | ||
| return (True) |
delivrance
Jul 8, 2020
Member
Why all these parentheses?
Why all these parentheses?
HasibulKabir
Jul 9, 2020
Author
Contributor
I have checked after this commit. I have removed last line and added parentheses in return.
I have checked after this commit. I have removed last line and added parentheses in return.
No description provided.