|
| 1 | +Decorators |
| 2 | +========== |
| 3 | + |
| 4 | +Decorators are able to register callback functions for handling updates in a much easier and cleaner way compared to |
| 5 | +:doc:`Handlers <handlers>`; they do so by instantiating the correct handler and calling |
| 6 | +:meth:`~pyrogram.Client.add_handler` automatically. All you need to do is adding the decorators on top of your |
| 7 | +functions. |
| 8 | + |
| 9 | +.. code-block:: python |
| 10 | +
|
| 11 | + from pyrogram import Client |
| 12 | +
|
| 13 | + app = Client("my_account") |
| 14 | +
|
| 15 | +
|
| 16 | + @app.on_message() |
| 17 | + def log(client, message): |
| 18 | + print(message) |
| 19 | +
|
| 20 | +
|
| 21 | + app.run() |
| 22 | +
|
| 23 | +
|
| 24 | +----- |
| 25 | + |
| 26 | +.. currentmodule:: pyrogram |
| 27 | + |
| 28 | +Index |
| 29 | +----- |
| 30 | + |
| 31 | +.. hlist:: |
| 32 | + :columns: 3 |
| 33 | + |
| 34 | + - :meth:`~Client.on_message` |
| 35 | + - :meth:`~Client.on_edited_message` |
| 36 | + - :meth:`~Client.on_callback_query` |
| 37 | + - :meth:`~Client.on_inline_query` |
| 38 | + - :meth:`~Client.on_chosen_inline_result` |
| 39 | + - :meth:`~Client.on_chat_member_updated` |
| 40 | + - :meth:`~Client.on_chat_join_request` |
| 41 | + - :meth:`~Client.on_deleted_messages` |
| 42 | + - :meth:`~Client.on_user_status` |
| 43 | + - :meth:`~Client.on_poll` |
| 44 | + - :meth:`~Client.on_disconnect` |
| 45 | + - :meth:`~Client.on_raw_update` |
| 46 | + |
| 47 | +----- |
| 48 | + |
| 49 | +Details |
| 50 | +------- |
| 51 | + |
| 52 | +.. Decorators |
| 53 | +.. autodecorator:: pyrogram.Client.on_message() |
| 54 | +.. autodecorator:: pyrogram.Client.on_edited_message() |
| 55 | +.. autodecorator:: pyrogram.Client.on_callback_query() |
| 56 | +.. autodecorator:: pyrogram.Client.on_inline_query() |
| 57 | +.. autodecorator:: pyrogram.Client.on_chosen_inline_result() |
| 58 | +.. autodecorator:: pyrogram.Client.on_chat_member_updated() |
| 59 | +.. autodecorator:: pyrogram.Client.on_chat_join_request() |
| 60 | +.. autodecorator:: pyrogram.Client.on_deleted_messages() |
| 61 | +.. autodecorator:: pyrogram.Client.on_user_status() |
| 62 | +.. autodecorator:: pyrogram.Client.on_poll() |
| 63 | +.. autodecorator:: pyrogram.Client.on_disconnect() |
| 64 | +.. autodecorator:: pyrogram.Client.on_raw_update() |
0 commit comments