From 96b39970d6281e62eb57271e249af9a7dab754a7 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sat, 13 Oct 2018 10:55:41 +0200 Subject: [PATCH] Allow on_callback_query to be used as a static decorator --- .../client/methods/decorators/on_callback_query.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pyrogram/client/methods/decorators/on_callback_query.py b/pyrogram/client/methods/decorators/on_callback_query.py index 5f22fc92..8413515d 100644 --- a/pyrogram/client/methods/decorators/on_callback_query.py +++ b/pyrogram/client/methods/decorators/on_callback_query.py @@ -17,6 +17,7 @@ # along with Pyrogram. If not, see . import pyrogram +from pyrogram.client.filters.filter import Filter from ...ext import BaseClient @@ -36,7 +37,14 @@ class OnCallbackQuery(BaseClient): """ def decorator(func): - self.add_handler(pyrogram.CallbackQueryHandler(func, filters), group) - return func + handler = pyrogram.CallbackQueryHandler(func, filters) + + if isinstance(self, Filter): + return pyrogram.CallbackQueryHandler(func, self), group if filters is None else filters + + if self is not None: + self.add_handler(handler, group) + + return handler, group return decorator