2019-05-09 02:28:46 +00:00
|
|
|
Decorators
|
|
|
|
==========
|
|
|
|
|
|
|
|
Decorators are able to register callback functions for handling updates in a much easier and cleaner way compared to
|
2019-05-28 14:41:55 +00:00
|
|
|
:doc:`Handlers <handlers>`; they do so by instantiating the correct handler and calling
|
2019-06-27 21:16:21 +00:00
|
|
|
:meth:`~pyrogram.Client.add_handler` automatically. All you need to do is adding the decorators on top of your
|
2019-05-28 14:41:55 +00:00
|
|
|
functions.
|
2019-05-09 02:28:46 +00:00
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
from pyrogram import Client
|
|
|
|
|
2019-05-16 19:28:34 +00:00
|
|
|
app = Client("my_account")
|
2019-05-09 02:28:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
@app.on_message()
|
|
|
|
def log(client, message):
|
|
|
|
print(message)
|
|
|
|
|
|
|
|
|
|
|
|
app.run()
|
|
|
|
|
2020-04-01 18:08:46 +00:00
|
|
|
.. contents:: Contents
|
|
|
|
:backlinks: none
|
2020-08-22 06:05:05 +00:00
|
|
|
:depth: 1
|
2020-04-01 18:08:46 +00:00
|
|
|
:local:
|
|
|
|
|
|
|
|
-----
|
|
|
|
|
2019-05-28 14:41:55 +00:00
|
|
|
.. currentmodule:: pyrogram
|
|
|
|
|
|
|
|
Index
|
|
|
|
-----
|
|
|
|
|
|
|
|
.. hlist::
|
|
|
|
:columns: 3
|
|
|
|
|
|
|
|
- :meth:`~Client.on_message`
|
2022-04-24 09:56:07 +00:00
|
|
|
- :meth:`~Client.on_edited_message`
|
2019-05-28 14:41:55 +00:00
|
|
|
- :meth:`~Client.on_callback_query`
|
|
|
|
- :meth:`~Client.on_inline_query`
|
2020-04-03 15:15:28 +00:00
|
|
|
- :meth:`~Client.on_chosen_inline_result`
|
2021-03-17 14:11:23 +00:00
|
|
|
- :meth:`~Client.on_chat_member_updated`
|
2022-04-11 09:21:28 +00:00
|
|
|
- :meth:`~Client.on_chat_join_request`
|
2019-05-28 14:41:55 +00:00
|
|
|
- :meth:`~Client.on_deleted_messages`
|
|
|
|
- :meth:`~Client.on_user_status`
|
|
|
|
- :meth:`~Client.on_poll`
|
|
|
|
- :meth:`~Client.on_disconnect`
|
|
|
|
- :meth:`~Client.on_raw_update`
|
|
|
|
|
|
|
|
-----
|
|
|
|
|
|
|
|
Details
|
|
|
|
-------
|
|
|
|
|
|
|
|
.. Decorators
|
|
|
|
.. autodecorator:: pyrogram.Client.on_message()
|
2022-04-24 09:56:07 +00:00
|
|
|
.. autodecorator:: pyrogram.Client.on_edited_message()
|
2019-05-28 14:41:55 +00:00
|
|
|
.. autodecorator:: pyrogram.Client.on_callback_query()
|
|
|
|
.. autodecorator:: pyrogram.Client.on_inline_query()
|
2020-04-03 15:15:28 +00:00
|
|
|
.. autodecorator:: pyrogram.Client.on_chosen_inline_result()
|
2021-03-17 14:11:23 +00:00
|
|
|
.. autodecorator:: pyrogram.Client.on_chat_member_updated()
|
2022-04-11 09:21:28 +00:00
|
|
|
.. autodecorator:: pyrogram.Client.on_chat_join_request()
|
2019-05-28 14:41:55 +00:00
|
|
|
.. autodecorator:: pyrogram.Client.on_deleted_messages()
|
|
|
|
.. autodecorator:: pyrogram.Client.on_user_status()
|
|
|
|
.. autodecorator:: pyrogram.Client.on_poll()
|
|
|
|
.. autodecorator:: pyrogram.Client.on_disconnect()
|
2022-04-11 09:21:28 +00:00
|
|
|
.. autodecorator:: pyrogram.Client.on_raw_update()
|