From 6a9c7312ccf6daf56c8140e394b0cb7aeed0bc98 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sat, 15 Dec 2018 09:10:19 +0100 Subject: [PATCH] Document how decorated functions are modified --- pyrogram/client/methods/decorators/on_callback_query.py | 7 +++++++ pyrogram/client/methods/decorators/on_deleted_messages.py | 7 +++++++ pyrogram/client/methods/decorators/on_message.py | 7 +++++++ pyrogram/client/methods/decorators/on_raw_update.py | 7 +++++++ pyrogram/client/methods/decorators/on_user_status.py | 7 +++++++ 5 files changed, 35 insertions(+) diff --git a/pyrogram/client/methods/decorators/on_callback_query.py b/pyrogram/client/methods/decorators/on_callback_query.py index a7079236..51a6df2e 100644 --- a/pyrogram/client/methods/decorators/on_callback_query.py +++ b/pyrogram/client/methods/decorators/on_callback_query.py @@ -27,6 +27,13 @@ class OnCallbackQuery(BaseClient): callback queries. This does the same thing as :meth:`add_handler` using the :class:`CallbackQueryHandler`. + .. note:: + This decorator will wrap your defined function in a tuple consisting of *(Handler, group)*. + + To reference your own function after it has been decorated, you need to access + *my_function[0].callback*, that is, the *callback* field of Handler object which is the the + first element in the tuple. + Args: filters (:obj:`Filters `): Pass one or more filters to allow only a subset of callback queries to be passed diff --git a/pyrogram/client/methods/decorators/on_deleted_messages.py b/pyrogram/client/methods/decorators/on_deleted_messages.py index 2fd8f298..c23b7594 100644 --- a/pyrogram/client/methods/decorators/on_deleted_messages.py +++ b/pyrogram/client/methods/decorators/on_deleted_messages.py @@ -27,6 +27,13 @@ class OnDeletedMessages(BaseClient): deleted messages. This does the same thing as :meth:`add_handler` using the :class:`DeletedMessagesHandler`. + .. note:: + This decorator will wrap your defined function in a tuple consisting of *(Handler, group)*. + + To reference your own function after it has been decorated, you need to access + *my_function[0].callback*, that is, the *callback* field of Handler object which is the the + first element in the tuple. + Args: filters (:obj:`Filters `): Pass one or more filters to allow only a subset of messages to be passed diff --git a/pyrogram/client/methods/decorators/on_message.py b/pyrogram/client/methods/decorators/on_message.py index 690f8368..a098cfa2 100644 --- a/pyrogram/client/methods/decorators/on_message.py +++ b/pyrogram/client/methods/decorators/on_message.py @@ -27,6 +27,13 @@ class OnMessage(BaseClient): messages. This does the same thing as :meth:`add_handler` using the :class:`MessageHandler`. + .. note:: + This decorator will wrap your defined function in a tuple consisting of *(Handler, group)*. + + To reference your own function after it has been decorated, you need to access + *my_function[0].callback*, that is, the *callback* field of Handler object which is the the + first element in the tuple. + Args: filters (:obj:`Filters `): Pass one or more filters to allow only a subset of messages to be passed diff --git a/pyrogram/client/methods/decorators/on_raw_update.py b/pyrogram/client/methods/decorators/on_raw_update.py index 1391482f..52728e1c 100644 --- a/pyrogram/client/methods/decorators/on_raw_update.py +++ b/pyrogram/client/methods/decorators/on_raw_update.py @@ -26,6 +26,13 @@ class OnRawUpdate(BaseClient): raw updates. This does the same thing as :meth:`add_handler` using the :class:`RawUpdateHandler`. + .. note:: + This decorator will wrap your defined function in a tuple consisting of *(Handler, group)*. + + To reference your own function after it has been decorated, you need to access + *my_function[0].callback*, that is, the *callback* field of Handler object which is the the + first element in the tuple. + Args: group (``int``, *optional*): The group identifier, defaults to 0. diff --git a/pyrogram/client/methods/decorators/on_user_status.py b/pyrogram/client/methods/decorators/on_user_status.py index 5aa6f783..2ca41e56 100644 --- a/pyrogram/client/methods/decorators/on_user_status.py +++ b/pyrogram/client/methods/decorators/on_user_status.py @@ -27,6 +27,13 @@ class OnUserStatus(BaseClient): user status updates. This does the same thing as :meth:`add_handler` using the :class:`UserStatusHandler`. + .. note:: + This decorator will wrap your defined function in a tuple consisting of *(Handler, group)*. + + To reference your own function after it has been decorated, you need to access + *my_function[0].callback*, that is, the *callback* field of Handler object which is the the + first element in the tuple. + Args: filters (:obj:`Filters `): Pass one or more filters to allow only a subset of UserStatus updated to be passed in your function.