2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-29 05:18:10 +00:00

Allow on_callback_query to be used as a static decorator

This commit is contained in:
Dan 2018-10-13 10:55:41 +02:00
parent 6fdb90e4a4
commit 96b39970d6

View File

@ -17,6 +17,7 @@
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
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