diff --git a/docs/source/pyrogram/handlers/CallbackQueryHandler.rst b/docs/source/pyrogram/handlers/CallbackQueryHandler.rst new file mode 100644 index 00000000..5c9f4c17 --- /dev/null +++ b/docs/source/pyrogram/handlers/CallbackQueryHandler.rst @@ -0,0 +1,6 @@ +CallbackQueryHandler +==================== + +.. autoclass:: pyrogram.CallbackQueryHandler + :members: + :undoc-members: diff --git a/docs/source/pyrogram/MessageHandler.rst b/docs/source/pyrogram/handlers/MessageHandler.rst similarity index 100% rename from docs/source/pyrogram/MessageHandler.rst rename to docs/source/pyrogram/handlers/MessageHandler.rst diff --git a/docs/source/pyrogram/RawUpdateHandler.rst b/docs/source/pyrogram/handlers/RawUpdateHandler.rst similarity index 100% rename from docs/source/pyrogram/RawUpdateHandler.rst rename to docs/source/pyrogram/handlers/RawUpdateHandler.rst diff --git a/docs/source/pyrogram/handlers/index.rst b/docs/source/pyrogram/handlers/index.rst new file mode 100644 index 00000000..bbd55542 --- /dev/null +++ b/docs/source/pyrogram/handlers/index.rst @@ -0,0 +1,9 @@ +:tocdepth: 1 + +Handlers +======== + +.. toctree:: + MessageHandler + CallbackQueryHandler + RawUpdateHandler \ No newline at end of file diff --git a/docs/source/pyrogram/index.rst b/docs/source/pyrogram/index.rst index c81cdd6e..94cd0f62 100644 --- a/docs/source/pyrogram/index.rst +++ b/docs/source/pyrogram/index.rst @@ -9,8 +9,7 @@ after the well established `Telegram Bot API`_ methods, thus offering a familiar .. toctree:: Client types/index - MessageHandler - RawUpdateHandler + handlers/index Filters ChatAction ParseMode diff --git a/docs/source/pyrogram/types/CallbackQuery.rst b/docs/source/pyrogram/types/CallbackQuery.rst new file mode 100644 index 00000000..9ce0a578 --- /dev/null +++ b/docs/source/pyrogram/types/CallbackQuery.rst @@ -0,0 +1,5 @@ +CallbackQuery +============= + +.. autoclass:: pyrogram.CallbackQuery + :members: diff --git a/docs/source/pyrogram/types/index.rst b/docs/source/pyrogram/types/index.rst index 55c6d8b3..78441878 100644 --- a/docs/source/pyrogram/types/index.rst +++ b/docs/source/pyrogram/types/index.rst @@ -30,4 +30,5 @@ Types reply_markup/InlineKeyboardMarkup reply_markup/KeyboardButton reply_markup/ReplyKeyboardMarkup - reply_markup/ReplyKeyboardRemove \ No newline at end of file + reply_markup/ReplyKeyboardRemove + CallbackQuery \ No newline at end of file diff --git a/pyrogram/client/handlers/handlers.py b/pyrogram/client/handlers/handlers.py index cc91151b..c50e6725 100644 --- a/pyrogram/client/handlers/handlers.py +++ b/pyrogram/client/handlers/handlers.py @@ -37,7 +37,7 @@ class MessageHandler(Handler): client (:obj:`Client `): The Client itself, useful when you want to call other API methods inside the message handler. - message (:obj:`Message `): + message (:obj:`Message `): The received message. """ @@ -53,6 +53,26 @@ class MessageHandler(Handler): class CallbackQueryHandler(Handler): + """The CallbackQuery handler class. Used to handle callback queries coming from inline buttons. + It is intended to be used with :meth:`add_handler() ` + + Args: + callback (``callable``): + Pass a function that will be called when a new CallbackQuery arrives. It takes *(client, callback_query)* + as positional arguments (look at the section below for a detailed description). + + filters (:obj:`Filters `): + Pass one or more filters to allow only a subset of callback queries to be passed + in your callback function. + + Other parameters: + client (:obj:`Client `): + The Client itself, useful when you want to call other API methods inside the message handler. + + callback_query (:obj:`CallbackQuery `): + The received callback query. + """ + def __init__(self, callback: callable, filters=None): super().__init__(callback, filters) diff --git a/pyrogram/client/types/callback_query.py b/pyrogram/client/types/callback_query.py index a015c067..59e229fc 100644 --- a/pyrogram/client/types/callback_query.py +++ b/pyrogram/client/types/callback_query.py @@ -32,14 +32,14 @@ class CallbackQuery(Object): id (``str``): Unique identifier for this query. - from_user (:obj:`User `): + from_user (:obj:`User `): Sender. chat_instance (``str``, optional): Message with the callback button that originated the query. Note that message content and message date will not be available if the message is too old. - message (:obj:`Message `, optional): + message (:obj:`Message `, optional): Identifier of the message sent via the bot in inline mode, that originated the query. inline_message_id (``str``):