From 2af6d257f5e6505a47042bec7830c206c66d425d Mon Sep 17 00:00:00 2001 From: Yasir Aris M Date: Fri, 3 Nov 2023 13:13:27 +0700 Subject: [PATCH] Fix callback query --- pyrogram/handlers/callback_query_handler.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pyrogram/handlers/callback_query_handler.py b/pyrogram/handlers/callback_query_handler.py index b5fd09d2..75a101ee 100644 --- a/pyrogram/handlers/callback_query_handler.py +++ b/pyrogram/handlers/callback_query_handler.py @@ -98,9 +98,15 @@ class CallbackQueryHandler(Handler): client, query ) - handler_does_match = ( - await self.filters(client, query) if callable(self.filters) else True - ) + if callable(self.filters): + if iscoroutinefunction(self.filters.__call__): + handler_does_match = await self.filters(client, query) + else: + handler_does_match = await client.loop.run_in_executor( + None, self.filters, client, query + ) + else: + handler_does_match = True data = self.compose_data_identifier(query)