mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-23 10:28:00 +00:00
Update docs
This commit is contained in:
parent
87ad981420
commit
e94dcd3b0b
@ -23,11 +23,11 @@ canonical = "https://docs.pyrogram.org/"
|
|||||||
|
|
||||||
dirs = {
|
dirs = {
|
||||||
".": ("weekly", 1.0),
|
".": ("weekly", 1.0),
|
||||||
"intro": ("weekly", 0.8),
|
"intro": ("weekly", 0.9),
|
||||||
"start": ("weekly", 0.8),
|
"start": ("weekly", 0.9),
|
||||||
"api": ("weekly", 0.6),
|
"api": ("weekly", 0.8),
|
||||||
"topics": ("weekly", 0.6),
|
"topics": ("weekly", 0.8),
|
||||||
"telegram": ("weekly", 0.4)
|
"telegram": ("weekly", 0.6)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,43 +22,65 @@ some of the required arguments.
|
|||||||
|
|
||||||
.. currentmodule:: pyrogram
|
.. currentmodule:: pyrogram
|
||||||
|
|
||||||
- Message_
|
Index
|
||||||
- CallbackQuery_
|
-----
|
||||||
- InlineQuery_
|
|
||||||
|
|
||||||
.. _Message:
|
|
||||||
|
|
||||||
Message
|
Message
|
||||||
|
^^^^^^^
|
||||||
|
|
||||||
|
.. hlist::
|
||||||
|
:columns: 3
|
||||||
|
|
||||||
|
- :meth:`~Message.click`
|
||||||
|
- :meth:`~Message.delete`
|
||||||
|
- :meth:`~Message.download`
|
||||||
|
- :meth:`~Message.edit`
|
||||||
|
- :meth:`~Message.edit_caption`
|
||||||
|
- :meth:`~Message.edit_media`
|
||||||
|
- :meth:`~Message.edit_reply_markup`
|
||||||
|
- :meth:`~Message.forward`
|
||||||
|
- :meth:`~Message.pin`
|
||||||
|
- :meth:`~Message.reply`
|
||||||
|
- :meth:`~Message.reply_animation`
|
||||||
|
- :meth:`~Message.reply_audio`
|
||||||
|
- :meth:`~Message.reply_cached_media`
|
||||||
|
- :meth:`~Message.reply_chat_action`
|
||||||
|
- :meth:`~Message.reply_contact`
|
||||||
|
- :meth:`~Message.reply_document`
|
||||||
|
- :meth:`~Message.reply_game`
|
||||||
|
- :meth:`~Message.reply_inline_bot_result`
|
||||||
|
- :meth:`~Message.reply_location`
|
||||||
|
- :meth:`~Message.reply_media_group`
|
||||||
|
- :meth:`~Message.reply_photo`
|
||||||
|
- :meth:`~Message.reply_poll`
|
||||||
|
- :meth:`~Message.reply_sticker`
|
||||||
|
- :meth:`~Message.reply_venue`
|
||||||
|
- :meth:`~Message.reply_video`
|
||||||
|
- :meth:`~Message.reply_video_note`
|
||||||
|
- :meth:`~Message.reply_voice`
|
||||||
|
|
||||||
|
CallbackQuery
|
||||||
|
^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
.. hlist::
|
||||||
|
:columns: 2
|
||||||
|
|
||||||
|
- :meth:`~CallbackQuery.answer`
|
||||||
|
|
||||||
|
InlineQuery
|
||||||
|
^^^^^^^^^^^
|
||||||
|
|
||||||
|
.. hlist::
|
||||||
|
:columns: 2
|
||||||
|
|
||||||
|
- :meth:`~InlineQuery.answer`
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
|
Details
|
||||||
-------
|
-------
|
||||||
|
|
||||||
- :meth:`Message.click()`
|
.. Message
|
||||||
- :meth:`Message.delete()`
|
|
||||||
- :meth:`Message.download()`
|
|
||||||
- :meth:`Message.edit()`
|
|
||||||
- :meth:`Message.edit_caption()`
|
|
||||||
- :meth:`Message.edit_media()`
|
|
||||||
- :meth:`Message.edit_reply_markup()`
|
|
||||||
- :meth:`Message.forward()`
|
|
||||||
- :meth:`Message.pin()`
|
|
||||||
- :meth:`Message.reply()`
|
|
||||||
- :meth:`Message.reply_animation()`
|
|
||||||
- :meth:`Message.reply_audio()`
|
|
||||||
- :meth:`Message.reply_cached_media()`
|
|
||||||
- :meth:`Message.reply_chat_action()`
|
|
||||||
- :meth:`Message.reply_contact()`
|
|
||||||
- :meth:`Message.reply_document()`
|
|
||||||
- :meth:`Message.reply_game()`
|
|
||||||
- :meth:`Message.reply_inline_bot_result()`
|
|
||||||
- :meth:`Message.reply_location()`
|
|
||||||
- :meth:`Message.reply_media_group()`
|
|
||||||
- :meth:`Message.reply_photo()`
|
|
||||||
- :meth:`Message.reply_poll()`
|
|
||||||
- :meth:`Message.reply_sticker()`
|
|
||||||
- :meth:`Message.reply_venue()`
|
|
||||||
- :meth:`Message.reply_video()`
|
|
||||||
- :meth:`Message.reply_video_note()`
|
|
||||||
- :meth:`Message.reply_voice()`
|
|
||||||
|
|
||||||
.. automethod:: Message.click()
|
.. automethod:: Message.click()
|
||||||
.. automethod:: Message.delete()
|
.. automethod:: Message.delete()
|
||||||
.. automethod:: Message.download()
|
.. automethod:: Message.download()
|
||||||
@ -87,16 +109,8 @@ Message
|
|||||||
.. automethod:: Message.reply_video_note()
|
.. automethod:: Message.reply_video_note()
|
||||||
.. automethod:: Message.reply_voice()
|
.. automethod:: Message.reply_voice()
|
||||||
|
|
||||||
.. _CallbackQuery:
|
.. CallbackQuery
|
||||||
|
|
||||||
CallbackQuery
|
|
||||||
-------------
|
|
||||||
|
|
||||||
.. automethod:: CallbackQuery.answer()
|
.. automethod:: CallbackQuery.answer()
|
||||||
|
|
||||||
.. _InlineQuery:
|
.. InlineQuery
|
||||||
|
.. automethod:: InlineQuery.answer()
|
||||||
InlineQuery
|
|
||||||
-----------
|
|
||||||
|
|
||||||
.. automethod:: InlineQuery.answer()
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
Decorators
|
Decorators
|
||||||
==========
|
==========
|
||||||
|
|
||||||
While still being methods bound to the :obj:`Client <pyrogram.Client>` class, decorators are of a special kind and thus deserve a
|
While still being methods bound to the :class:`~pyrogram.Client` class, decorators are of a special kind and thus
|
||||||
dedicated page.
|
deserve a dedicated page.
|
||||||
|
|
||||||
Decorators are able to register callback functions for handling updates in a much easier and cleaner way compared to
|
Decorators are able to register callback functions for handling updates in a much easier and cleaner way compared to
|
||||||
`Handlers <Handlers.html>`_; they do so by instantiating the correct handler and calling
|
:doc:`Handlers <handlers>`; they do so by instantiating the correct handler and calling
|
||||||
:meth:`add_handler() <pyrogram.Client.add_handler>`, automatically. All you need to do is adding the decorators on top
|
:meth:`~pyrogram.Client.add_handler`, automatically. All you need to do is adding the decorators on top of your
|
||||||
of your functions.
|
functions.
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
:emphasize-lines: 6
|
:emphasize-lines: 6
|
||||||
@ -24,25 +24,34 @@ of your functions.
|
|||||||
|
|
||||||
app.run()
|
app.run()
|
||||||
|
|
||||||
.. currentmodule:: pyrogram.Client
|
.. currentmodule:: pyrogram
|
||||||
|
|
||||||
.. autosummary::
|
Index
|
||||||
:nosignatures:
|
-----
|
||||||
|
|
||||||
on_message
|
.. hlist::
|
||||||
on_callback_query
|
:columns: 3
|
||||||
on_inline_query
|
|
||||||
on_deleted_messages
|
|
||||||
on_user_status
|
|
||||||
on_poll
|
|
||||||
on_disconnect
|
|
||||||
on_raw_update
|
|
||||||
|
|
||||||
.. automethod:: pyrogram.Client.on_message()
|
- :meth:`~Client.on_message`
|
||||||
.. automethod:: pyrogram.Client.on_callback_query()
|
- :meth:`~Client.on_callback_query`
|
||||||
.. automethod:: pyrogram.Client.on_inline_query()
|
- :meth:`~Client.on_inline_query`
|
||||||
.. automethod:: pyrogram.Client.on_deleted_messages()
|
- :meth:`~Client.on_deleted_messages`
|
||||||
.. automethod:: pyrogram.Client.on_user_status()
|
- :meth:`~Client.on_user_status`
|
||||||
.. automethod:: pyrogram.Client.on_poll()
|
- :meth:`~Client.on_poll`
|
||||||
.. automethod:: pyrogram.Client.on_disconnect()
|
- :meth:`~Client.on_disconnect`
|
||||||
.. automethod:: pyrogram.Client.on_raw_update()
|
- :meth:`~Client.on_raw_update`
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
|
Details
|
||||||
|
-------
|
||||||
|
|
||||||
|
.. Decorators
|
||||||
|
.. autodecorator:: pyrogram.Client.on_message()
|
||||||
|
.. autodecorator:: pyrogram.Client.on_callback_query()
|
||||||
|
.. autodecorator:: pyrogram.Client.on_inline_query()
|
||||||
|
.. autodecorator:: pyrogram.Client.on_deleted_messages()
|
||||||
|
.. autodecorator:: pyrogram.Client.on_user_status()
|
||||||
|
.. autodecorator:: pyrogram.Client.on_poll()
|
||||||
|
.. autodecorator:: pyrogram.Client.on_disconnect()
|
||||||
|
.. autodecorator:: pyrogram.Client.on_raw_update()
|
@ -3,8 +3,8 @@ Update Handlers
|
|||||||
|
|
||||||
Handlers are used to instruct Pyrogram about which kind of updates you'd like to handle with your callback functions.
|
Handlers are used to instruct Pyrogram about which kind of updates you'd like to handle with your callback functions.
|
||||||
|
|
||||||
For a much more convenient way of registering callback functions have a look at `Decorators <Decorators.html>`_ instead.
|
For a much more convenient way of registering callback functions have a look at :doc:`Decorators <decorators>` instead.
|
||||||
In case you decided to manually create a handler, use :meth:`add_handler() <pyrogram.Client.add_handler>` to register
|
In case you decided to manually create a handler, use :class:`~pyrogram.Client.add_handler` to register
|
||||||
it.
|
it.
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
@ -25,18 +25,27 @@ it.
|
|||||||
|
|
||||||
.. currentmodule:: pyrogram
|
.. currentmodule:: pyrogram
|
||||||
|
|
||||||
.. autosummary::
|
Index
|
||||||
:nosignatures:
|
-----
|
||||||
|
|
||||||
MessageHandler
|
.. hlist::
|
||||||
DeletedMessagesHandler
|
:columns: 3
|
||||||
CallbackQueryHandler
|
|
||||||
InlineQueryHandler
|
|
||||||
UserStatusHandler
|
|
||||||
PollHandler
|
|
||||||
DisconnectHandler
|
|
||||||
RawUpdateHandler
|
|
||||||
|
|
||||||
|
- :class:`MessageHandler`
|
||||||
|
- :class:`DeletedMessagesHandler`
|
||||||
|
- :class:`CallbackQueryHandler`
|
||||||
|
- :class:`InlineQueryHandler`
|
||||||
|
- :class:`UserStatusHandler`
|
||||||
|
- :class:`PollHandler`
|
||||||
|
- :class:`DisconnectHandler`
|
||||||
|
- :class:`RawUpdateHandler`
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
|
Details
|
||||||
|
-------
|
||||||
|
|
||||||
|
.. Handlers
|
||||||
.. autoclass:: MessageHandler()
|
.. autoclass:: MessageHandler()
|
||||||
.. autoclass:: DeletedMessagesHandler()
|
.. autoclass:: DeletedMessagesHandler()
|
||||||
.. autoclass:: CallbackQueryHandler()
|
.. autoclass:: CallbackQueryHandler()
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
Available Methods
|
Available Methods
|
||||||
=================
|
=================
|
||||||
|
|
||||||
All Pyrogram methods listed here are bound to a :obj:`Client <pyrogram.Client>` instance.
|
All Pyrogram methods listed here are bound to a :class:`~pyrogram.Client` instance.
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
:emphasize-lines: 6
|
:emphasize-lines: 6
|
||||||
@ -13,253 +13,249 @@ All Pyrogram methods listed here are bound to a :obj:`Client <pyrogram.Client>`
|
|||||||
with app:
|
with app:
|
||||||
app.send_message("haskell", "hi")
|
app.send_message("haskell", "hi")
|
||||||
|
|
||||||
.. currentmodule:: pyrogram.Client
|
.. currentmodule:: pyrogram
|
||||||
|
|
||||||
|
Index
|
||||||
|
-----
|
||||||
|
|
||||||
Utilities
|
Utilities
|
||||||
---------
|
^^^^^^^^^
|
||||||
|
|
||||||
.. autosummary::
|
.. hlist::
|
||||||
:nosignatures:
|
:columns: 4
|
||||||
|
|
||||||
start
|
- :meth:`~Client.start`
|
||||||
stop
|
- :meth:`~Client.stop`
|
||||||
restart
|
- :meth:`~Client.restart`
|
||||||
idle
|
- :meth:`~Client.idle`
|
||||||
run
|
- :meth:`~Client.run`
|
||||||
add_handler
|
- :meth:`~Client.add_handler`
|
||||||
remove_handler
|
- :meth:`~Client.remove_handler`
|
||||||
send
|
- :meth:`~Client.send`
|
||||||
resolve_peer
|
- :meth:`~Client.resolve_peer`
|
||||||
save_file
|
- :meth:`~Client.save_file`
|
||||||
stop_transmission
|
- :meth:`~Client.stop_transmission`
|
||||||
|
|
||||||
Messages
|
Messages
|
||||||
--------
|
^^^^^^^^
|
||||||
|
|
||||||
.. autosummary::
|
.. hlist::
|
||||||
:nosignatures:
|
:columns: 3
|
||||||
|
|
||||||
send_message
|
- :meth:`~Client.send_message`
|
||||||
forward_messages
|
- :meth:`~Client.forward_messages`
|
||||||
send_photo
|
- :meth:`~Client.send_photo`
|
||||||
send_audio
|
- :meth:`~Client.send_audio`
|
||||||
send_document
|
- :meth:`~Client.send_document`
|
||||||
send_sticker
|
- :meth:`~Client.send_sticker`
|
||||||
send_video
|
- :meth:`~Client.send_video`
|
||||||
send_animation
|
- :meth:`~Client.send_animation`
|
||||||
send_voice
|
- :meth:`~Client.send_voice`
|
||||||
send_video_note
|
- :meth:`~Client.send_video_note`
|
||||||
send_media_group
|
- :meth:`~Client.send_media_group`
|
||||||
send_location
|
- :meth:`~Client.send_location`
|
||||||
send_venue
|
- :meth:`~Client.send_venue`
|
||||||
send_contact
|
- :meth:`~Client.send_contact`
|
||||||
send_cached_media
|
- :meth:`~Client.send_cached_media`
|
||||||
send_chat_action
|
- :meth:`~Client.send_chat_action`
|
||||||
edit_message_text
|
- :meth:`~Client.edit_message_text`
|
||||||
edit_message_caption
|
- :meth:`~Client.edit_message_caption`
|
||||||
edit_message_reply_markup
|
- :meth:`~Client.edit_message_reply_markup`
|
||||||
edit_message_media
|
- :meth:`~Client.edit_message_media`
|
||||||
delete_messages
|
- :meth:`~Client.delete_messages`
|
||||||
get_messages
|
- :meth:`~Client.get_messages`
|
||||||
get_history
|
- :meth:`~Client.get_history`
|
||||||
get_history_count
|
- :meth:`~Client.get_history_count`
|
||||||
iter_history
|
- :meth:`~Client.iter_history`
|
||||||
send_poll
|
- :meth:`~Client.send_poll`
|
||||||
vote_poll
|
- :meth:`~Client.vote_poll`
|
||||||
stop_poll
|
- :meth:`~Client.stop_poll`
|
||||||
retract_vote
|
- :meth:`~Client.retract_vote`
|
||||||
download_media
|
- :meth:`~Client.download_media`
|
||||||
|
|
||||||
Chats
|
Chats
|
||||||
-----
|
^^^^^
|
||||||
|
|
||||||
.. autosummary::
|
.. hlist::
|
||||||
:nosignatures:
|
:columns: 3
|
||||||
|
|
||||||
join_chat
|
- :meth:`~Client.join_chat`
|
||||||
leave_chat
|
- :meth:`~Client.leave_chat`
|
||||||
kick_chat_member
|
- :meth:`~Client.kick_chat_member`
|
||||||
unban_chat_member
|
- :meth:`~Client.unban_chat_member`
|
||||||
restrict_chat_member
|
- :meth:`~Client.restrict_chat_member`
|
||||||
promote_chat_member
|
- :meth:`~Client.promote_chat_member`
|
||||||
export_chat_invite_link
|
- :meth:`~Client.export_chat_invite_link`
|
||||||
set_chat_photo
|
- :meth:`~Client.set_chat_photo`
|
||||||
delete_chat_photo
|
- :meth:`~Client.delete_chat_photo`
|
||||||
set_chat_title
|
- :meth:`~Client.set_chat_title`
|
||||||
set_chat_description
|
- :meth:`~Client.set_chat_description`
|
||||||
pin_chat_message
|
- :meth:`~Client.pin_chat_message`
|
||||||
unpin_chat_message
|
- :meth:`~Client.unpin_chat_message`
|
||||||
get_chat
|
- :meth:`~Client.get_chat`
|
||||||
get_chat_member
|
- :meth:`~Client.get_chat_member`
|
||||||
get_chat_members
|
- :meth:`~Client.get_chat_members`
|
||||||
get_chat_members_count
|
- :meth:`~Client.get_chat_members_count`
|
||||||
iter_chat_members
|
- :meth:`~Client.iter_chat_members`
|
||||||
get_dialogs
|
- :meth:`~Client.get_dialogs`
|
||||||
iter_dialogs
|
- :meth:`~Client.iter_dialogs`
|
||||||
get_dialogs_count
|
- :meth:`~Client.get_dialogs_count`
|
||||||
restrict_chat
|
- :meth:`~Client.restrict_chat`
|
||||||
update_chat_username
|
- :meth:`~Client.update_chat_username`
|
||||||
|
|
||||||
Users
|
Users
|
||||||
-----
|
^^^^^
|
||||||
|
|
||||||
.. autosummary::
|
.. hlist::
|
||||||
:nosignatures:
|
:columns: 2
|
||||||
|
|
||||||
get_me
|
- :meth:`~Client.get_me`
|
||||||
get_users
|
- :meth:`~Client.get_users`
|
||||||
get_user_profile_photos
|
- :meth:`~Client.get_user_profile_photos`
|
||||||
get_user_profile_photos_count
|
- :meth:`~Client.get_user_profile_photos_count`
|
||||||
set_user_profile_photo
|
- :meth:`~Client.set_user_profile_photo`
|
||||||
delete_user_profile_photos
|
- :meth:`~Client.delete_user_profile_photos`
|
||||||
update_username
|
- :meth:`~Client.update_username`
|
||||||
|
- :meth:`~Client.get_user_dc`
|
||||||
|
|
||||||
Contacts
|
Contacts
|
||||||
--------
|
^^^^^^^^
|
||||||
|
|
||||||
.. autosummary::
|
.. hlist::
|
||||||
:nosignatures:
|
:columns: 3
|
||||||
|
|
||||||
add_contacts
|
- :meth:`~Client.add_contacts`
|
||||||
get_contacts
|
- :meth:`~Client.get_contacts`
|
||||||
get_contacts_count
|
- :meth:`~Client.get_contacts_count`
|
||||||
delete_contacts
|
- :meth:`~Client.delete_contacts`
|
||||||
|
|
||||||
Password
|
Password
|
||||||
--------
|
^^^^^^^^
|
||||||
|
|
||||||
.. autosummary::
|
.. hlist::
|
||||||
:nosignatures:
|
:columns: 3
|
||||||
|
|
||||||
enable_cloud_password
|
- :meth:`~Client.enable_cloud_password`
|
||||||
change_cloud_password
|
- :meth:`~Client.change_cloud_password`
|
||||||
remove_cloud_password
|
- :meth:`~Client.remove_cloud_password`
|
||||||
|
|
||||||
Bots
|
Bots
|
||||||
----
|
^^^^
|
||||||
|
|
||||||
.. autosummary::
|
.. hlist::
|
||||||
:nosignatures:
|
:columns: 3
|
||||||
|
|
||||||
get_inline_bot_results
|
- :meth:`~Client.get_inline_bot_results`
|
||||||
send_inline_bot_result
|
- :meth:`~Client.send_inline_bot_result`
|
||||||
answer_callback_query
|
- :meth:`~Client.answer_callback_query`
|
||||||
answer_inline_query
|
- :meth:`~Client.answer_inline_query`
|
||||||
request_callback_answer
|
- :meth:`~Client.request_callback_answer`
|
||||||
send_game
|
- :meth:`~Client.send_game`
|
||||||
set_game_score
|
- :meth:`~Client.set_game_score`
|
||||||
get_game_high_scores
|
- :meth:`~Client.get_game_high_scores`
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
|
Details
|
||||||
|
-------
|
||||||
|
|
||||||
.. Utilities
|
.. Utilities
|
||||||
---------
|
.. automethod:: Client.start()
|
||||||
|
.. automethod:: Client.stop()
|
||||||
.. automethod:: pyrogram.Client.start()
|
.. automethod:: Client.restart()
|
||||||
.. automethod:: pyrogram.Client.stop()
|
.. automethod:: Client.idle()
|
||||||
.. automethod:: pyrogram.Client.restart()
|
.. automethod:: Client.run()
|
||||||
.. automethod:: pyrogram.Client.idle()
|
.. automethod:: Client.add_handler()
|
||||||
.. automethod:: pyrogram.Client.run()
|
.. automethod:: Client.remove_handler()
|
||||||
.. automethod:: pyrogram.Client.add_handler()
|
.. automethod:: Client.send()
|
||||||
.. automethod:: pyrogram.Client.remove_handler()
|
.. automethod:: Client.resolve_peer()
|
||||||
.. automethod:: pyrogram.Client.send()
|
.. automethod:: Client.save_file()
|
||||||
.. automethod:: pyrogram.Client.resolve_peer()
|
.. automethod:: Client.stop_transmission()
|
||||||
.. automethod:: pyrogram.Client.save_file()
|
|
||||||
.. automethod:: pyrogram.Client.stop_transmission()
|
|
||||||
|
|
||||||
.. Messages
|
.. Messages
|
||||||
--------
|
.. automethod:: Client.send_message()
|
||||||
|
.. automethod:: Client.forward_messages()
|
||||||
.. automethod:: pyrogram.Client.send_message()
|
.. automethod:: Client.send_photo()
|
||||||
.. automethod:: pyrogram.Client.forward_messages()
|
.. automethod:: Client.send_audio()
|
||||||
.. automethod:: pyrogram.Client.send_photo()
|
.. automethod:: Client.send_document()
|
||||||
.. automethod:: pyrogram.Client.send_audio()
|
.. automethod:: Client.send_sticker()
|
||||||
.. automethod:: pyrogram.Client.send_document()
|
.. automethod:: Client.send_video()
|
||||||
.. automethod:: pyrogram.Client.send_sticker()
|
.. automethod:: Client.send_animation()
|
||||||
.. automethod:: pyrogram.Client.send_video()
|
.. automethod:: Client.send_voice()
|
||||||
.. automethod:: pyrogram.Client.send_animation()
|
.. automethod:: Client.send_video_note()
|
||||||
.. automethod:: pyrogram.Client.send_voice()
|
.. automethod:: Client.send_media_group()
|
||||||
.. automethod:: pyrogram.Client.send_video_note()
|
.. automethod:: Client.send_location()
|
||||||
.. automethod:: pyrogram.Client.send_media_group()
|
.. automethod:: Client.send_venue()
|
||||||
.. automethod:: pyrogram.Client.send_location()
|
.. automethod:: Client.send_contact()
|
||||||
.. automethod:: pyrogram.Client.send_venue()
|
.. automethod:: Client.send_cached_media()
|
||||||
.. automethod:: pyrogram.Client.send_contact()
|
.. automethod:: Client.send_chat_action()
|
||||||
.. automethod:: pyrogram.Client.send_cached_media()
|
.. automethod:: Client.edit_message_text()
|
||||||
.. automethod:: pyrogram.Client.send_chat_action()
|
.. automethod:: Client.edit_message_caption()
|
||||||
.. automethod:: pyrogram.Client.edit_message_text()
|
.. automethod:: Client.edit_message_reply_markup()
|
||||||
.. automethod:: pyrogram.Client.edit_message_caption()
|
.. automethod:: Client.edit_message_media()
|
||||||
.. automethod:: pyrogram.Client.edit_message_reply_markup()
|
.. automethod:: Client.delete_messages()
|
||||||
.. automethod:: pyrogram.Client.edit_message_media()
|
.. automethod:: Client.get_messages()
|
||||||
.. automethod:: pyrogram.Client.delete_messages()
|
.. automethod:: Client.get_history()
|
||||||
.. automethod:: pyrogram.Client.get_messages()
|
.. automethod:: Client.get_history_count()
|
||||||
.. automethod:: pyrogram.Client.get_history()
|
.. automethod:: Client.iter_history()
|
||||||
.. automethod:: pyrogram.Client.get_history_count()
|
.. automethod:: Client.send_poll()
|
||||||
.. automethod:: pyrogram.Client.iter_history()
|
.. automethod:: Client.vote_poll()
|
||||||
.. automethod:: pyrogram.Client.send_poll()
|
.. automethod:: Client.stop_poll()
|
||||||
.. automethod:: pyrogram.Client.vote_poll()
|
.. automethod:: Client.retract_vote()
|
||||||
.. automethod:: pyrogram.Client.stop_poll()
|
.. automethod:: Client.download_media()
|
||||||
.. automethod:: pyrogram.Client.retract_vote()
|
|
||||||
.. automethod:: pyrogram.Client.download_media()
|
|
||||||
|
|
||||||
.. Chats
|
.. Chats
|
||||||
-----
|
.. automethod:: Client.join_chat()
|
||||||
|
.. automethod:: Client.leave_chat()
|
||||||
.. automethod:: pyrogram.Client.join_chat()
|
.. automethod:: Client.kick_chat_member()
|
||||||
.. automethod:: pyrogram.Client.leave_chat()
|
.. automethod:: Client.unban_chat_member()
|
||||||
.. automethod:: pyrogram.Client.kick_chat_member()
|
.. automethod:: Client.restrict_chat_member()
|
||||||
.. automethod:: pyrogram.Client.unban_chat_member()
|
.. automethod:: Client.promote_chat_member()
|
||||||
.. automethod:: pyrogram.Client.restrict_chat_member()
|
.. automethod:: Client.export_chat_invite_link()
|
||||||
.. automethod:: pyrogram.Client.promote_chat_member()
|
.. automethod:: Client.set_chat_photo()
|
||||||
.. automethod:: pyrogram.Client.export_chat_invite_link()
|
.. automethod:: Client.delete_chat_photo()
|
||||||
.. automethod:: pyrogram.Client.set_chat_photo()
|
.. automethod:: Client.set_chat_title()
|
||||||
.. automethod:: pyrogram.Client.delete_chat_photo()
|
.. automethod:: Client.set_chat_description()
|
||||||
.. automethod:: pyrogram.Client.set_chat_title()
|
.. automethod:: Client.pin_chat_message()
|
||||||
.. automethod:: pyrogram.Client.set_chat_description()
|
.. automethod:: Client.unpin_chat_message()
|
||||||
.. automethod:: pyrogram.Client.pin_chat_message()
|
.. automethod:: Client.get_chat()
|
||||||
.. automethod:: pyrogram.Client.unpin_chat_message()
|
.. automethod:: Client.get_chat_member()
|
||||||
.. automethod:: pyrogram.Client.get_chat()
|
.. automethod:: Client.get_chat_members()
|
||||||
.. automethod:: pyrogram.Client.get_chat_member()
|
.. automethod:: Client.get_chat_members_count()
|
||||||
.. automethod:: pyrogram.Client.get_chat_members()
|
.. automethod:: Client.iter_chat_members()
|
||||||
.. automethod:: pyrogram.Client.get_chat_members_count()
|
.. automethod:: Client.get_dialogs()
|
||||||
.. automethod:: pyrogram.Client.iter_chat_members()
|
.. automethod:: Client.iter_dialogs()
|
||||||
.. automethod:: pyrogram.Client.get_dialogs()
|
.. automethod:: Client.get_dialogs_count()
|
||||||
.. automethod:: pyrogram.Client.iter_dialogs()
|
.. automethod:: Client.restrict_chat()
|
||||||
.. automethod:: pyrogram.Client.get_dialogs_count()
|
.. automethod:: Client.update_chat_username()
|
||||||
.. automethod:: pyrogram.Client.restrict_chat()
|
|
||||||
.. automethod:: pyrogram.Client.update_chat_username()
|
|
||||||
|
|
||||||
.. Users
|
.. Users
|
||||||
-----
|
.. automethod:: Client.get_me()
|
||||||
|
.. automethod:: Client.get_users()
|
||||||
.. automethod:: pyrogram.Client.get_me()
|
.. automethod:: Client.get_user_profile_photos()
|
||||||
.. automethod:: pyrogram.Client.get_users()
|
.. automethod:: Client.get_user_profile_photos_count()
|
||||||
.. automethod:: pyrogram.Client.get_user_profile_photos()
|
.. automethod:: Client.set_user_profile_photo()
|
||||||
.. automethod:: pyrogram.Client.get_user_profile_photos_count()
|
.. automethod:: Client.delete_user_profile_photos()
|
||||||
.. automethod:: pyrogram.Client.set_user_profile_photo()
|
.. automethod:: Client.update_username()
|
||||||
.. automethod:: pyrogram.Client.delete_user_profile_photos()
|
.. automethod:: Client.get_user_dc()
|
||||||
.. automethod:: pyrogram.Client.update_username()
|
|
||||||
|
|
||||||
.. Contacts
|
.. Contacts
|
||||||
--------
|
.. automethod:: Client.add_contacts()
|
||||||
|
.. automethod:: Client.get_contacts()
|
||||||
.. automethod:: pyrogram.Client.add_contacts()
|
.. automethod:: Client.get_contacts_count()
|
||||||
.. automethod:: pyrogram.Client.get_contacts()
|
.. automethod:: Client.delete_contacts()
|
||||||
.. automethod:: pyrogram.Client.get_contacts_count()
|
|
||||||
.. automethod:: pyrogram.Client.delete_contacts()
|
|
||||||
|
|
||||||
.. Password
|
.. Password
|
||||||
--------
|
.. automethod:: Client.enable_cloud_password()
|
||||||
|
.. automethod:: Client.change_cloud_password()
|
||||||
.. automethod:: pyrogram.Client.enable_cloud_password()
|
.. automethod:: Client.remove_cloud_password()
|
||||||
.. automethod:: pyrogram.Client.change_cloud_password()
|
|
||||||
.. automethod:: pyrogram.Client.remove_cloud_password()
|
|
||||||
|
|
||||||
.. Bots
|
.. Bots
|
||||||
----
|
.. automethod:: Client.get_inline_bot_results()
|
||||||
|
.. automethod:: Client.send_inline_bot_result()
|
||||||
.. automethod:: pyrogram.Client.get_inline_bot_results()
|
.. automethod:: Client.answer_callback_query()
|
||||||
.. automethod:: pyrogram.Client.send_inline_bot_result()
|
.. automethod:: Client.answer_inline_query()
|
||||||
.. automethod:: pyrogram.Client.answer_callback_query()
|
.. automethod:: Client.request_callback_answer()
|
||||||
.. automethod:: pyrogram.Client.answer_inline_query()
|
.. automethod:: Client.send_game()
|
||||||
.. automethod:: pyrogram.Client.request_callback_answer()
|
.. automethod:: Client.set_game_score()
|
||||||
.. automethod:: pyrogram.Client.send_game()
|
.. automethod:: Client.get_game_high_scores()
|
||||||
.. automethod:: pyrogram.Client.set_game_score()
|
|
||||||
.. automethod:: pyrogram.Client.get_game_high_scores()
|
|
||||||
|
@ -15,102 +15,108 @@ All Pyrogram types listed here are accessible through the main package directly.
|
|||||||
|
|
||||||
.. currentmodule:: pyrogram
|
.. currentmodule:: pyrogram
|
||||||
|
|
||||||
|
Index
|
||||||
|
-----
|
||||||
|
|
||||||
Users & Chats
|
Users & Chats
|
||||||
-------------
|
^^^^^^^^^^^^^
|
||||||
|
|
||||||
.. autosummary::
|
.. hlist::
|
||||||
:nosignatures:
|
:columns: 5
|
||||||
|
|
||||||
User
|
- :class:`User`
|
||||||
UserStatus
|
- :class:`UserStatus`
|
||||||
Chat
|
- :class:`Chat`
|
||||||
ChatPreview
|
- :class:`ChatPreview`
|
||||||
ChatPhoto
|
- :class:`ChatPhoto`
|
||||||
ChatMember
|
- :class:`ChatMember`
|
||||||
ChatMembers
|
- :class:`ChatMembers`
|
||||||
ChatPermissions
|
- :class:`ChatPermissions`
|
||||||
Dialog
|
- :class:`Dialog`
|
||||||
Dialogs
|
- :class:`Dialogs`
|
||||||
|
|
||||||
Messages & Media
|
Messages & Media
|
||||||
----------------
|
^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
.. autosummary::
|
.. hlist::
|
||||||
:nosignatures:
|
:columns: 5
|
||||||
|
|
||||||
Message
|
- :class:`Message`
|
||||||
Messages
|
- :class:`Messages`
|
||||||
MessageEntity
|
- :class:`MessageEntity`
|
||||||
Photo
|
- :class:`Photo`
|
||||||
PhotoSize
|
- :class:`PhotoSize`
|
||||||
UserProfilePhotos
|
- :class:`UserProfilePhotos`
|
||||||
Audio
|
- :class:`Audio`
|
||||||
Document
|
- :class:`Document`
|
||||||
Animation
|
- :class:`Animation`
|
||||||
Video
|
- :class:`Video`
|
||||||
Voice
|
- :class:`Voice`
|
||||||
VideoNote
|
- :class:`VideoNote`
|
||||||
Contact
|
- :class:`Contact`
|
||||||
Location
|
- :class:`Location`
|
||||||
Venue
|
- :class:`Venue`
|
||||||
Sticker
|
- :class:`Sticker`
|
||||||
Game
|
- :class:`Game`
|
||||||
Poll
|
- :class:`Poll`
|
||||||
PollOption
|
- :class:`PollOption`
|
||||||
|
|
||||||
Keyboards
|
Keyboards
|
||||||
---------
|
^^^^^^^^^
|
||||||
|
|
||||||
.. autosummary::
|
.. hlist::
|
||||||
:nosignatures:
|
:columns: 4
|
||||||
|
|
||||||
ReplyKeyboardMarkup
|
- :class:`ReplyKeyboardMarkup`
|
||||||
KeyboardButton
|
- :class:`KeyboardButton`
|
||||||
ReplyKeyboardRemove
|
- :class:`ReplyKeyboardRemove`
|
||||||
InlineKeyboardMarkup
|
- :class:`InlineKeyboardMarkup`
|
||||||
InlineKeyboardButton
|
- :class:`InlineKeyboardButton`
|
||||||
ForceReply
|
- :class:`ForceReply`
|
||||||
CallbackQuery
|
- :class:`CallbackQuery`
|
||||||
GameHighScore
|
- :class:`GameHighScore`
|
||||||
GameHighScores
|
- :class:`GameHighScores`
|
||||||
CallbackGame
|
- :class:`CallbackGame`
|
||||||
|
|
||||||
Input Media
|
Input Media
|
||||||
-----------
|
^^^^^^^^^^^
|
||||||
|
|
||||||
.. autosummary::
|
.. hlist::
|
||||||
:nosignatures:
|
:columns: 4
|
||||||
|
|
||||||
InputMedia
|
- :class:`InputMedia`
|
||||||
InputMediaPhoto
|
- :class:`InputMediaPhoto`
|
||||||
InputMediaVideo
|
- :class:`InputMediaVideo`
|
||||||
InputMediaAudio
|
- :class:`InputMediaAudio`
|
||||||
InputMediaAnimation
|
- :class:`InputMediaAnimation`
|
||||||
InputMediaDocument
|
- :class:`InputMediaDocument`
|
||||||
InputPhoneContact
|
- :class:`InputPhoneContact`
|
||||||
|
|
||||||
Inline Mode
|
Inline Mode
|
||||||
------------
|
^^^^^^^^^^^
|
||||||
|
|
||||||
.. autosummary::
|
.. hlist::
|
||||||
:nosignatures:
|
:columns: 3
|
||||||
|
|
||||||
InlineQuery
|
- :class:`InlineQuery`
|
||||||
InlineQueryResult
|
- :class:`InlineQueryResult`
|
||||||
InlineQueryResultArticle
|
- :class:`InlineQueryResultArticle`
|
||||||
|
|
||||||
InputMessageContent
|
InputMessageContent
|
||||||
-------------------
|
^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
.. autosummary::
|
.. hlist::
|
||||||
:nosignatures:
|
:columns: 3
|
||||||
|
|
||||||
InputMessageContent
|
- :class:`InputMessageContent`
|
||||||
InputTextMessageContent
|
- :class:`InputTextMessageContent`
|
||||||
|
|
||||||
|
-----
|
||||||
|
|
||||||
|
Details
|
||||||
|
-------
|
||||||
|
|
||||||
.. User & Chats
|
.. User & Chats
|
||||||
------------
|
|
||||||
|
|
||||||
.. autoclass:: User()
|
.. autoclass:: User()
|
||||||
.. autoclass:: UserStatus()
|
.. autoclass:: UserStatus()
|
||||||
.. autoclass:: Chat()
|
.. autoclass:: Chat()
|
||||||
@ -123,8 +129,6 @@ InputMessageContent
|
|||||||
.. autoclass:: Dialogs()
|
.. autoclass:: Dialogs()
|
||||||
|
|
||||||
.. Messages & Media
|
.. Messages & Media
|
||||||
----------------
|
|
||||||
|
|
||||||
.. autoclass:: Message()
|
.. autoclass:: Message()
|
||||||
.. autoclass:: Messages()
|
.. autoclass:: Messages()
|
||||||
.. autoclass:: MessageEntity()
|
.. autoclass:: MessageEntity()
|
||||||
@ -146,8 +150,6 @@ InputMessageContent
|
|||||||
.. autoclass:: PollOption()
|
.. autoclass:: PollOption()
|
||||||
|
|
||||||
.. Keyboards
|
.. Keyboards
|
||||||
---------
|
|
||||||
|
|
||||||
.. autoclass:: ReplyKeyboardMarkup()
|
.. autoclass:: ReplyKeyboardMarkup()
|
||||||
.. autoclass:: KeyboardButton()
|
.. autoclass:: KeyboardButton()
|
||||||
.. autoclass:: ReplyKeyboardRemove()
|
.. autoclass:: ReplyKeyboardRemove()
|
||||||
@ -160,8 +162,6 @@ InputMessageContent
|
|||||||
.. autoclass:: CallbackGame()
|
.. autoclass:: CallbackGame()
|
||||||
|
|
||||||
.. Input Media
|
.. Input Media
|
||||||
-----------
|
|
||||||
|
|
||||||
.. autoclass:: InputMedia()
|
.. autoclass:: InputMedia()
|
||||||
.. autoclass:: InputMediaPhoto()
|
.. autoclass:: InputMediaPhoto()
|
||||||
.. autoclass:: InputMediaVideo()
|
.. autoclass:: InputMediaVideo()
|
||||||
@ -171,14 +171,10 @@ InputMessageContent
|
|||||||
.. autoclass:: InputPhoneContact()
|
.. autoclass:: InputPhoneContact()
|
||||||
|
|
||||||
.. Inline Mode
|
.. Inline Mode
|
||||||
-----------
|
|
||||||
|
|
||||||
.. autoclass:: InlineQuery()
|
.. autoclass:: InlineQuery()
|
||||||
.. autoclass:: InlineQueryResult()
|
.. autoclass:: InlineQueryResult()
|
||||||
.. autoclass:: InlineQueryResultArticle()
|
.. autoclass:: InlineQueryResultArticle()
|
||||||
|
|
||||||
.. InputMessageContent
|
.. InputMessageContent
|
||||||
-------------------
|
|
||||||
|
|
||||||
.. autoclass:: InputMessageContent()
|
.. autoclass:: InputMessageContent()
|
||||||
.. autoclass:: InputTextMessageContent()
|
.. autoclass:: InputTextMessageContent()
|
||||||
|
@ -43,7 +43,6 @@ autodoc_member_order = "bysource"
|
|||||||
|
|
||||||
version = __version__
|
version = __version__
|
||||||
release = version
|
release = version
|
||||||
version_rst = ".. |version| replace:: {}".format(version)
|
|
||||||
|
|
||||||
templates_path = ["_templates"]
|
templates_path = ["_templates"]
|
||||||
|
|
||||||
@ -61,7 +60,8 @@ html_theme_options = {
|
|||||||
"collapse_navigation": True,
|
"collapse_navigation": True,
|
||||||
"sticky_navigation": False,
|
"sticky_navigation": False,
|
||||||
"logo_only": True,
|
"logo_only": True,
|
||||||
"display_version": True
|
"display_version": True,
|
||||||
|
"style_external_links": True
|
||||||
}
|
}
|
||||||
|
|
||||||
html_logo = "_images/pyrogram.png"
|
html_logo = "_images/pyrogram.png"
|
||||||
|
@ -17,10 +17,9 @@ What is Pyrogram?
|
|||||||
|
|
||||||
**Pyrogram** is an elegant, easy-to-use Telegram_ client library and framework written from the ground up in Python and
|
**Pyrogram** is an elegant, easy-to-use Telegram_ client library and framework written from the ground up in Python and
|
||||||
C. It enables you to easily create custom applications for both user and bot identities (bot API alternative) via the
|
C. It enables you to easily create custom applications for both user and bot identities (bot API alternative) via the
|
||||||
`MTProto API`_ with the Python programming language.
|
:doc:`MTProto API <topics/mtproto-vs-botapi>` with the Python programming language.
|
||||||
|
|
||||||
.. _Telegram: https://telegram.org
|
.. _Telegram: https://telegram.org
|
||||||
.. _MTProto API: topics/mtproto-vs-botapi#what-is-the-mtproto-api
|
|
||||||
|
|
||||||
Where does the name come from?
|
Where does the name come from?
|
||||||
------------------------------
|
------------------------------
|
||||||
@ -47,19 +46,17 @@ Why Pyrogram?
|
|||||||
- **Type-hinted**: Exposed Pyrogram types and method parameters are all type-hinted.
|
- **Type-hinted**: Exposed Pyrogram types and method parameters are all type-hinted.
|
||||||
- **Updated**, to make use of the latest Telegram API version and features.
|
- **Updated**, to make use of the latest Telegram API version and features.
|
||||||
- **Bot API-like**: Similar to the Bot API in its simplicity, but much more powerful and detailed.
|
- **Bot API-like**: Similar to the Bot API in its simplicity, but much more powerful and detailed.
|
||||||
- **Pluggable**: The `Smart Plugin`_ system allows to write components with minimal boilerplate code.
|
- **Pluggable**: The :doc:`Smart Plugin <topics/smart-plugins>` system allows to write components with minimal
|
||||||
- **Comprehensive**: Execute any `advanced action`_ an official client is able to do, and even more.
|
boilerplate code.
|
||||||
|
- **Comprehensive**: Execute any :doc:`advanced action <topics/advanced-usage>` an official client is able to do, and
|
||||||
|
even more.
|
||||||
|
|
||||||
.. _TgCrypto: https://github.com/pyrogram/tgcrypto
|
.. _TgCrypto: https://github.com/pyrogram/tgcrypto
|
||||||
.. _Smart Plugin: topics/smart-plugins
|
|
||||||
.. _advanced action: topics/advanced-usage
|
|
||||||
|
|
||||||
What can MTProto do more than the Bot API?
|
What can MTProto do more than the Bot API?
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
|
|
||||||
For a detailed answer, please refer to the `MTProto vs. Bot API`_ page.
|
For a detailed answer, please refer to the :doc:`MTProto vs. Bot API <topics/mtproto-vs-botapi>` page.
|
||||||
|
|
||||||
.. _MTProto vs. Bot API: topics/mtproto-vs-botapi
|
|
||||||
|
|
||||||
Why do I need an API key for bots?
|
Why do I need an API key for bots?
|
||||||
----------------------------------
|
----------------------------------
|
||||||
@ -97,9 +94,9 @@ Telegram is slowly changing some server's internals and it's doing it in such a
|
|||||||
inevitably. Not only this, but it seems that the new, hypothetical, file ids could also possibly expire at anytime, thus
|
inevitably. Not only this, but it seems that the new, hypothetical, file ids could also possibly expire at anytime, thus
|
||||||
losing the *persistence* feature.
|
losing the *persistence* feature.
|
||||||
|
|
||||||
This change will most likely affect the official `Bot API <topics/mtproto-vs-botapi#what-is-the-bot-api>`_ too
|
This change will most likely affect the official :doc:`Bot API <topics/mtproto-vs-botapi>` too (unless Telegram
|
||||||
(unless Telegram implements some workarounds server-side to keep backwards compatibility, which Pyrogram could in turn
|
implements some workarounds server-side to keep backwards compatibility, which Pyrogram could in turn make use of) and
|
||||||
make use of) and we can expect a proper notice from Telegram.
|
we can expect a proper notice from Telegram.
|
||||||
|
|
||||||
Can I use multiple clients at once on the same account?
|
Can I use multiple clients at once on the same account?
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
@ -125,8 +122,8 @@ from the beginning every time, and use one separate session for each parallel cl
|
|||||||
I started a client and nothing happens!
|
I started a client and nothing happens!
|
||||||
---------------------------------------
|
---------------------------------------
|
||||||
|
|
||||||
If you are connecting from Russia, China or Iran `you need a proxy`_, because Telegram could be partially or
|
If you are connecting from Russia, China or Iran :doc:`you need a proxy <topics/proxy>`, because Telegram could be
|
||||||
totally blocked in those countries.
|
partially or totally blocked in those countries.
|
||||||
|
|
||||||
Another possible cause might be network issues, either yours or Telegram's. To confirm this, add the following code on
|
Another possible cause might be network issues, either yours or Telegram's. To confirm this, add the following code on
|
||||||
the top of your script and run it again. You should see some error mentioning a socket timeout or an unreachable network
|
the top of your script and run it again. You should see some error mentioning a socket timeout or an unreachable network
|
||||||
@ -146,8 +143,6 @@ fails or not:
|
|||||||
- DC4: ``149.154.167.91``
|
- DC4: ``149.154.167.91``
|
||||||
- DC5: ``91.108.56.149``
|
- DC5: ``91.108.56.149``
|
||||||
|
|
||||||
.. _you need a proxy: topics/proxy
|
|
||||||
|
|
||||||
I keep getting PEER_ID_INVALID error!
|
I keep getting PEER_ID_INVALID error!
|
||||||
-------------------------------------------
|
-------------------------------------------
|
||||||
|
|
||||||
@ -182,20 +177,5 @@ recover@telegram.org, contact `@smstelegram`_ on Twitter or use `this form`_.
|
|||||||
.. _@smstelegram: https://twitter.com/smstelegram
|
.. _@smstelegram: https://twitter.com/smstelegram
|
||||||
.. _this form: https://telegram.org/support
|
.. _this form: https://telegram.org/support
|
||||||
|
|
||||||
About the License
|
|
||||||
-----------------
|
|
||||||
|
|
||||||
.. image:: https://www.gnu.org/graphics/lgplv3-with-text-154x68.png
|
|
||||||
:align: left
|
|
||||||
|
|
||||||
Pyrogram is free software and is currently licensed under the terms of the
|
|
||||||
`GNU Lesser General Public License v3 or later (LGPLv3+)`_. In short: you may use, redistribute and/or modify it
|
|
||||||
provided that modifications are described and licensed for free under LGPLv3+.
|
|
||||||
|
|
||||||
In other words: you can use and integrate Pyrogram into your own code --- either open source, under the same or
|
|
||||||
different license, or even proprietary --- without being required to release the source code of your own applications.
|
|
||||||
However, any modifications to the library itself are required to be published for free under the same LGPLv3+ license.
|
|
||||||
|
|
||||||
.. _GNU Lesser General Public License v3 or later (LGPLv3+): https://github.com/pyrogram/pyrogram/blob/develop/COPYING.lesser
|
|
||||||
.. _Bug Report: https://github.com/pyrogram/pyrogram/issues/new?labels=bug&template=bug_report.md
|
.. _Bug Report: https://github.com/pyrogram/pyrogram/issues/new?labels=bug&template=bug_report.md
|
||||||
.. _Feature Request: https://github.com/pyrogram/pyrogram/issues/new?labels=enhancement&template=feature_request.md
|
.. _Feature Request: https://github.com/pyrogram/pyrogram/issues/new?labels=enhancement&template=feature_request.md
|
||||||
|
@ -18,7 +18,7 @@ general. Some words may as well link to dedicated articles in case the topic is
|
|||||||
API key
|
API key
|
||||||
A secret code used to authenticate and/or authorize a specific application to Telegram in order for it to
|
A secret code used to authenticate and/or authorize a specific application to Telegram in order for it to
|
||||||
control how the API is being used, for example, to prevent abuses of the API.
|
control how the API is being used, for example, to prevent abuses of the API.
|
||||||
`More on API keys <intro/setup#api-keys>`_.
|
:doc:`More on API keys <intro/setup>`.
|
||||||
|
|
||||||
DC
|
DC
|
||||||
Also known as *data center*, is a place where lots of computer systems are housed and used together in order to
|
Also known as *data center*, is a place where lots of computer systems are housed and used together in order to
|
||||||
@ -30,21 +30,21 @@ general. Some words may as well link to dedicated articles in case the topic is
|
|||||||
|
|
||||||
RPCError
|
RPCError
|
||||||
An error caused by an RPC which must be returned in place of the successful result in order to let the caller
|
An error caused by an RPC which must be returned in place of the successful result in order to let the caller
|
||||||
know something went wrong. `More on RPCError <start/errors>`_.
|
know something went wrong. :doc:`More on RPCError <start/errors>`.
|
||||||
|
|
||||||
MTProto
|
MTProto
|
||||||
The name of the custom-made, open and encrypted protocol by Telegram, implemented in Pyrogram.
|
The name of the custom-made, open and encrypted protocol by Telegram, implemented in Pyrogram.
|
||||||
`More on MTProto <topics/mtproto-vs-botapi>`_.
|
:doc:`More on MTProto <topics/mtproto-vs-botapi>`.
|
||||||
|
|
||||||
MTProto API
|
MTProto API
|
||||||
The Telegram main API Pyrogram makes use of, which is able to connect both users and normal bots to Telegram
|
The Telegram main API Pyrogram makes use of, which is able to connect both users and normal bots to Telegram
|
||||||
using MTProto as application layer protocol and execute any method Telegram provides from its public TL-schema.
|
using MTProto as application layer protocol and execute any method Telegram provides from its public TL-schema.
|
||||||
`More on MTProto API <topics/mtproto-vs-botapi#what-is-the-mtproto-api>`_.
|
:doc:`More on MTProto API <topics/mtproto-vs-botapi>`.
|
||||||
|
|
||||||
Bot API
|
Bot API
|
||||||
The Telegram Bot API that is able to only connect normal bots only to Telegram using HTTP as application layer
|
The Telegram Bot API that is able to only connect normal bots only to Telegram using HTTP as application layer
|
||||||
protocol and allows to execute a sub-set of the main Telegram API.
|
protocol and allows to execute a sub-set of the main Telegram API.
|
||||||
`More on Bot API <topics/mtproto-vs-botapi#what-is-the-bot-api>`_.
|
:doc:`More on Bot API <topics/mtproto-vs-botapi>`.
|
||||||
|
|
||||||
Pyrogrammer
|
Pyrogrammer
|
||||||
A developer that uses Pyrogram to build Telegram applications.
|
A developer that uses Pyrogram to build Telegram applications.
|
||||||
@ -65,11 +65,11 @@ general. Some words may as well link to dedicated articles in case the topic is
|
|||||||
Handler
|
Handler
|
||||||
An object that wraps around a callback function that is *actually meant* to be registered into the framework,
|
An object that wraps around a callback function that is *actually meant* to be registered into the framework,
|
||||||
which will then be able to handle a specific kind of events, such as a new incoming message, for example.
|
which will then be able to handle a specific kind of events, such as a new incoming message, for example.
|
||||||
`More on Handlers <start/updates>`_.
|
:doc:`More on Handlers <start/updates>`.
|
||||||
|
|
||||||
Decorator
|
Decorator
|
||||||
Also known as *function decorator*, in Python, is a callable object that is used to modify another function.
|
Also known as *function decorator*, in Python, is a callable object that is used to modify another function.
|
||||||
Decorators in Pyrogram are used to automatically register callback functions for handling updates.
|
Decorators in Pyrogram are used to automatically register callback functions for handling updates.
|
||||||
`More on Decorators <start/updates#using-decorators>`_.
|
:doc:`More on Decorators <start/updates>`.
|
||||||
|
|
||||||
.. _Feature Request: https://github.com/pyrogram/pyrogram/issues/new?labels=enhancement&template=feature_request.md
|
.. _Feature Request: https://github.com/pyrogram/pyrogram/issues/new?labels=enhancement&template=feature_request.md
|
||||||
|
@ -42,10 +42,9 @@ Welcome to Pyrogram
|
|||||||
|
|
||||||
**Pyrogram** is an elegant, easy-to-use Telegram_ client library and framework written from the ground up in Python and
|
**Pyrogram** is an elegant, easy-to-use Telegram_ client library and framework written from the ground up in Python and
|
||||||
C. It enables you to easily create custom apps for both user and bot identities (bot API alternative) via the
|
C. It enables you to easily create custom apps for both user and bot identities (bot API alternative) via the
|
||||||
`MTProto API`_.
|
:doc:`MTProto API <topics/mtproto-vs-botapi>`.
|
||||||
|
|
||||||
.. _Telegram: https://telegram.org
|
.. _Telegram: https://telegram.org
|
||||||
.. _MTProto API: topics/mtproto-vs-botapi#what-is-the-mtproto-api
|
|
||||||
|
|
||||||
How the Documentation is Organized
|
How the Documentation is Organized
|
||||||
----------------------------------
|
----------------------------------
|
||||||
@ -60,15 +59,10 @@ First Steps
|
|||||||
.. hlist::
|
.. hlist::
|
||||||
:columns: 2
|
:columns: 2
|
||||||
|
|
||||||
- `Quick Start`_: Overview to get you started quickly.
|
- :doc:`Quick Start <intro/quickstart>`: Overview to get you started quickly.
|
||||||
- `Calling Methods`_: How to call Pyrogram's methods.
|
- :doc:`Calling Methods <start/invoking>`: How to call Pyrogram's methods.
|
||||||
- `Handling Updates`_: How to handle Telegram updates.
|
- :doc:`Handling Updates <start/updates>`: How to handle Telegram updates.
|
||||||
- `Error Handling`_: How to handle API errors correctly.
|
- :doc:`Error Handling <start/errors>`: How to handle API errors correctly.
|
||||||
|
|
||||||
.. _Quick Start: intro/quickstart
|
|
||||||
.. _Calling Methods: start/invoking
|
|
||||||
.. _Handling Updates: start/updates
|
|
||||||
.. _Error Handling: start/errors
|
|
||||||
|
|
||||||
API Reference
|
API Reference
|
||||||
-------------
|
-------------
|
||||||
@ -76,15 +70,10 @@ API Reference
|
|||||||
.. hlist::
|
.. hlist::
|
||||||
:columns: 2
|
:columns: 2
|
||||||
|
|
||||||
- `Pyrogram Client`_: Reference details about the Client class.
|
- :doc:`Pyrogram Client <api/client>`: Reference details about the Client class.
|
||||||
- `Available Methods`_: List of available high-level methods.
|
- :doc:`Available Methods <api/methods>`: List of available high-level methods.
|
||||||
- `Available Types`_: List of available high-level types.
|
- :doc:`Available Types <api/types>`: List of available high-level types.
|
||||||
- `Bound Methods`_: List of convenient bound methods.
|
- :doc:`Bound Methods <api/bound-methods>`: List of convenient bound methods.
|
||||||
|
|
||||||
.. _Pyrogram Client: ./api/client
|
|
||||||
.. _Available Methods: api/methods
|
|
||||||
.. _Available Types: api/types
|
|
||||||
.. _Bound Methods: api/bound-methods
|
|
||||||
|
|
||||||
Meta
|
Meta
|
||||||
----
|
----
|
||||||
@ -92,17 +81,12 @@ Meta
|
|||||||
.. hlist::
|
.. hlist::
|
||||||
:columns: 2
|
:columns: 2
|
||||||
|
|
||||||
- `Pyrogram FAQ`_: Answers to common Pyrogram questions.
|
- :doc:`Pyrogram FAQ <faq>`: Answers to common Pyrogram questions.
|
||||||
- `Pyrogram Glossary`_: List of words with brief explanations.
|
- :doc:`Pyrogram Glossary <glossary>`: List of words with brief explanations.
|
||||||
- `Release Notes`_: Release notes for Pyrogram releases.
|
- :doc:`Release Notes <releases>`: Release notes for Pyrogram releases.
|
||||||
- `Powered by Pyrogram`_: Collection of Pyrogram Projects.
|
- :doc:`Powered by Pyrogram <powered-by>`: Collection of Pyrogram Projects.
|
||||||
- `Support Pyrogram`_: Ways to show your appreciation.
|
- :doc:`Support Pyrogram <support-pyrogram>`: Ways to show your appreciation.
|
||||||
|
- :doc:`About the License <license>`: Information about the Project license.
|
||||||
.. _Pyrogram FAQ: faq
|
|
||||||
.. _Pyrogram Glossary: glossary
|
|
||||||
.. _Release Notes: releases
|
|
||||||
.. _Powered by Pyrogram: powered-by
|
|
||||||
.. _Support Pyrogram: support-pyrogram
|
|
||||||
|
|
||||||
.. toctree::
|
.. toctree::
|
||||||
:hidden:
|
:hidden:
|
||||||
@ -163,10 +147,13 @@ Meta
|
|||||||
releases
|
releases
|
||||||
powered-by
|
powered-by
|
||||||
support-pyrogram
|
support-pyrogram
|
||||||
|
license
|
||||||
|
|
||||||
.. toctree::
|
.. toctree::
|
||||||
:hidden:
|
:hidden:
|
||||||
:caption: Telegram API
|
:caption: Telegram API
|
||||||
|
|
||||||
telegram/functions/index
|
telegram/functions/index
|
||||||
telegram/types/index
|
telegram/types/index
|
||||||
|
|
||||||
|
Last updated on |today|
|
@ -20,7 +20,7 @@ Install Pyrogram
|
|||||||
|
|
||||||
$ pip3 install -U pyrogram
|
$ pip3 install -U pyrogram
|
||||||
|
|
||||||
- or, with TgCrypto_ as extra requirement (recommended):
|
- or, with :doc:`TgCrypto <../topics/tgcrypto>` as extra requirement (recommended):
|
||||||
|
|
||||||
.. code-block:: text
|
.. code-block:: text
|
||||||
|
|
||||||
@ -89,5 +89,4 @@ If no error shows up you are good to go.
|
|||||||
>>> pyrogram.__version__
|
>>> pyrogram.__version__
|
||||||
'|version|'
|
'|version|'
|
||||||
|
|
||||||
.. _TgCrypto: ../topics/tgcrypto
|
|
||||||
.. _`Github repo`: http://github.com/pyrogram/pyrogram
|
.. _`Github repo`: http://github.com/pyrogram/pyrogram
|
||||||
|
@ -43,7 +43,7 @@ Enjoy the API
|
|||||||
That was just a quick overview that barely scratched the surface!
|
That was just a quick overview that barely scratched the surface!
|
||||||
In the next few pages of the introduction, we'll take a much more in-depth look of what we have just done above.
|
In the next few pages of the introduction, we'll take a much more in-depth look of what we have just done above.
|
||||||
|
|
||||||
Feeling eager to continue? You can take a shortcut to `Calling Methods`_ and come back later to learn some more details.
|
Feeling eager to continue? You can take a shortcut to :doc:`Calling Methods <../start/invoking>` and come back later to
|
||||||
|
learn some more details.
|
||||||
|
|
||||||
.. _community: //t.me/Pyrogram
|
.. _community: //t.me/Pyrogram
|
||||||
.. _Calling Methods: ../start/invoking
|
|
@ -1,8 +1,8 @@
|
|||||||
Project Setup
|
Project Setup
|
||||||
=============
|
=============
|
||||||
|
|
||||||
We have just `installed Pyrogram`_. In this page we'll discuss what you need to do in order to set up a project with
|
We have just :doc:`installed Pyrogram <install>`. In this page we'll discuss what you need to do in order to set up a
|
||||||
the library. Let's see how it's done.
|
project with the library. Let's see how it's done.
|
||||||
|
|
||||||
API Keys
|
API Keys
|
||||||
--------
|
--------
|
||||||
@ -26,7 +26,7 @@ The very first step requires you to obtain a valid Telegram API key (API id/hash
|
|||||||
Configuration
|
Configuration
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
Having the API key from the `previous step <#api-keys>`_ in handy, we can now begin to configure a Pyrogram project.
|
Having the API key from the previous step in handy, we can now begin to configure a Pyrogram project.
|
||||||
There are two ways to do so, and you can choose what fits better for you:
|
There are two ways to do so, and you can choose what fits better for you:
|
||||||
|
|
||||||
- First option (recommended): create a new ``config.ini`` file at the root of your working directory, copy-paste the
|
- First option (recommended): create a new ``config.ini`` file at the root of your working directory, copy-paste the
|
||||||
@ -57,5 +57,3 @@ There are two ways to do so, and you can choose what fits better for you:
|
|||||||
|
|
||||||
To keep code snippets clean and concise, from now on it is assumed you are making use of the ``config.ini`` file,
|
To keep code snippets clean and concise, from now on it is assumed you are making use of the ``config.ini`` file,
|
||||||
thus, the *api_id* and *api_hash* parameters usage won't be shown anymore.
|
thus, the *api_id* and *api_hash* parameters usage won't be shown anymore.
|
||||||
|
|
||||||
.. _installed Pyrogram: install.html
|
|
||||||
|
15
docs/source/license.rst
Normal file
15
docs/source/license.rst
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
About the License
|
||||||
|
=================
|
||||||
|
|
||||||
|
.. image:: https://www.gnu.org/graphics/lgplv3-with-text-154x68.png
|
||||||
|
:align: left
|
||||||
|
|
||||||
|
Pyrogram is free software and is currently licensed under the terms of the
|
||||||
|
`GNU Lesser General Public License v3 or later (LGPLv3+)`_. In short: you may use, redistribute and/or modify it
|
||||||
|
provided that modifications are described and licensed for free under LGPLv3+.
|
||||||
|
|
||||||
|
In other words: you can use and integrate Pyrogram into your own code --- either open source, under the same or
|
||||||
|
different license, or even proprietary --- without being required to release the source code of your own applications.
|
||||||
|
However, any modifications to the library itself are required to be published for free under the same LGPLv3+ license.
|
||||||
|
|
||||||
|
.. _GNU Lesser General Public License v3 or later (LGPLv3+): https://github.com/pyrogram/pyrogram/blob/develop/COPYING.lesser
|
@ -1,7 +1,7 @@
|
|||||||
Authorization
|
Authorization
|
||||||
=============
|
=============
|
||||||
|
|
||||||
Once a `project is set up`_, you will still have to follow a few steps before you can actually use Pyrogram to make
|
Once a :doc:`project is set up <../intro/setup>`, you will still have to follow a few steps before you can actually use Pyrogram to make
|
||||||
API calls. This section provides all the information you need in order to authorize yourself as user or bot.
|
API calls. This section provides all the information you need in order to authorize yourself as user or bot.
|
||||||
|
|
||||||
User Authorization
|
User Authorization
|
||||||
@ -9,8 +9,8 @@ User Authorization
|
|||||||
|
|
||||||
In order to use the API, Telegram requires that users be authorized via their phone numbers.
|
In order to use the API, Telegram requires that users be authorized via their phone numbers.
|
||||||
Pyrogram automatically manages this process, all you need to do is create an instance of the
|
Pyrogram automatically manages this process, all you need to do is create an instance of the
|
||||||
:class:`Client <pyrogram.Client>` class by passing to it a ``session_name`` of your choice (e.g.: "my_account") and call
|
:class:`~pyrogram.Client` class by passing to it a ``session_name`` of your choice (e.g.: "my_account") and call
|
||||||
the :meth:`run() <pyrogram.Client.run>` method:
|
the :meth:`~pyrogram.Client.run` method:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ Bot Authorization
|
|||||||
|
|
||||||
Bots are a special kind of users that are authorized via their tokens (instead of phone numbers), which are created by
|
Bots are a special kind of users that are authorized via their tokens (instead of phone numbers), which are created by
|
||||||
the `Bot Father`_. Bot tokens replace the users' phone numbers only — you still need to
|
the `Bot Father`_. Bot tokens replace the users' phone numbers only — you still need to
|
||||||
`configure a Telegram API key <../intro/setup#configuration>`_ with Pyrogram, even when using bots.
|
:doc:`configure a Telegram API key <../intro/setup>` with Pyrogram, even when using bots.
|
||||||
|
|
||||||
The authorization process is automatically managed. All you need to do is choose a ``session_name`` (can be anything,
|
The authorization process is automatically managed. All you need to do is choose a ``session_name`` (can be anything,
|
||||||
usually your bot username) and pass your bot token using the ``bot_token`` parameter. The session file will be named
|
usually your bot username) and pass your bot token using the ``bot_token`` parameter. The session file will be named
|
||||||
@ -64,6 +64,5 @@ after the session name, which will be ``my_bot.session`` for the example below.
|
|||||||
|
|
||||||
app.run()
|
app.run()
|
||||||
|
|
||||||
.. _project is set up: ../intro/setup
|
|
||||||
.. _Country Code: https://en.wikipedia.org/wiki/List_of_country_calling_codes
|
.. _Country Code: https://en.wikipedia.org/wiki/List_of_country_calling_codes
|
||||||
.. _Bot Father: https://t.me/botfather
|
.. _Bot Father: https://t.me/botfather
|
@ -1,8 +1,8 @@
|
|||||||
Calling Methods
|
Calling Methods
|
||||||
===============
|
===============
|
||||||
|
|
||||||
At this point, we have successfully `installed Pyrogram`_ and authorized_ our account; we are now aiming towards the
|
At this point, we have successfully :doc:`installed Pyrogram <../intro/install>` and :doc:`authorized <auth>` our
|
||||||
core of the library. It's time to start playing with the API!
|
account; we are now aiming towards the core of the library. It's time to start playing with the API!
|
||||||
|
|
||||||
Basic Usage
|
Basic Usage
|
||||||
-----------
|
-----------
|
||||||
@ -63,8 +63,8 @@ Context Manager
|
|||||||
---------------
|
---------------
|
||||||
|
|
||||||
You can also use Pyrogram's Client in a context manager with the ``with`` statement. The client will automatically
|
You can also use Pyrogram's Client in a context manager with the ``with`` statement. The client will automatically
|
||||||
:meth:`start() <pyrogram.Client.start>` and :meth:`stop() <pyrogram.Client.stop>` gracefully, even in case of unhandled
|
:meth:`~pyrogram.Client.start` and :meth:`~pyrogram.Client.stop` gracefully, even in case of unhandled exceptions in
|
||||||
exceptions in your code. The example above can be therefore rewritten in a much nicer way:
|
your code. The example above can be therefore rewritten in a much nicer way:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@ -79,6 +79,3 @@ exceptions in your code. The example above can be therefore rewritten in a much
|
|||||||
app.send_sticker("me", "CAADBAADyg4AAvLQYAEYD4F7vcZ43AI")
|
app.send_sticker("me", "CAADBAADyg4AAvLQYAEYD4F7vcZ43AI")
|
||||||
|
|
||||||
More examples can be found on `GitHub <https://github.com/pyrogram/pyrogram/tree/develop/examples>`_.
|
More examples can be found on `GitHub <https://github.com/pyrogram/pyrogram/tree/develop/examples>`_.
|
||||||
|
|
||||||
.. _installed Pyrogram: ../intro/install.html
|
|
||||||
.. _authorized: ../intro/setup.html
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
Handling Updates
|
Handling Updates
|
||||||
================
|
================
|
||||||
|
|
||||||
Calling `API methods`_ sequentially is cool, but how to react when, for example, a new message arrives? This page deals
|
Calling :doc:`API methods <invoking>` sequentially is cool, but how to react when, for example, a new message arrives?
|
||||||
with updates and how to handle such events in Pyrogram. Let's have a look at how they work.
|
This page deals with updates and how to handle such events in Pyrogram. Let's have a look at how they work.
|
||||||
|
|
||||||
Defining Updates
|
Defining Updates
|
||||||
----------------
|
----------------
|
||||||
@ -10,7 +10,7 @@ Defining Updates
|
|||||||
First, let's define what are these updates. As hinted already, updates are simply events that happen in your Telegram
|
First, let's define what are these updates. As hinted already, updates are simply events that happen in your Telegram
|
||||||
account (incoming messages, new members join, bot button presses, etc...), which are meant to notify you about a new
|
account (incoming messages, new members join, bot button presses, etc...), which are meant to notify you about a new
|
||||||
specific state that has changed. These updates are handled by registering one or more callback functions in your app
|
specific state that has changed. These updates are handled by registering one or more callback functions in your app
|
||||||
using `Handlers <../api/handlers>`_.
|
using :doc:`Handlers <../api/handlers>`.
|
||||||
|
|
||||||
Each handler deals with a specific event and once a matching update arrives from Telegram, your registered callback
|
Each handler deals with a specific event and once a matching update arrives from Telegram, your registered callback
|
||||||
function will be called back by the framework and its body executed.
|
function will be called back by the framework and its body executed.
|
||||||
@ -18,17 +18,16 @@ function will be called back by the framework and its body executed.
|
|||||||
Registering a Handler
|
Registering a Handler
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
To explain how handlers work let's have a look at the most used one, the
|
To explain how handlers work let's have a look at the most used one, the :class:`~pyrogram.MessageHandler`, which will
|
||||||
:obj:`MessageHandler <pyrogram.MessageHandler>`, which will be in charge for handling :obj:`Message <pyrogram.Message>`
|
be in charge for handling :class:`~pyrogram.Message` updates coming from all around your chats. Every other handler shares
|
||||||
updates coming from all around your chats. Every other handler shares the same setup logic; you should not have troubles
|
the same setup logic; you should not have troubles settings them up once you learn from this section.
|
||||||
settings them up once you learn from this section.
|
|
||||||
|
|
||||||
Using add_handler()
|
Using add_handler()
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
The :meth:`add_handler() <pyrogram.Client.add_handler>` method takes any handler instance that wraps around your defined
|
The :meth:`~pyrogram.Client.add_handler` method takes any handler instance that wraps around your defined callback
|
||||||
callback function and registers it in your Client. Here's a full example that prints out the content of a message as
|
function and registers it in your Client. Here's a full example that prints out the content of a message as soon as it
|
||||||
soon as it arrives:
|
arrives:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@ -55,24 +54,23 @@ call that function by passing the client instance and the new message instance a
|
|||||||
def my_function(client, message):
|
def my_function(client, message):
|
||||||
print(message)
|
print(message)
|
||||||
|
|
||||||
Second one: the :obj:`MessageHandler <pyrogram.MessageHandler>`. This object tells Pyrogram the function we defined
|
Second one: the :class:`~pyrogram.MessageHandler`. This object tells Pyrogram the function we defined above must only
|
||||||
above must only handle updates that are in form of a :obj:`Message <pyrogram.Message>`:
|
handle updates that are in form of a :class:`~pyrogram.Message`:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
my_handler = MessageHandler(my_function)
|
my_handler = MessageHandler(my_function)
|
||||||
|
|
||||||
Third: the method :meth:`add_handler() <pyrogram.Client.add_handler>`. This method is used to actually register the
|
Third: the method :meth:`~pyrogram.Client.add_handler`. This method is used to actually register the handler and let
|
||||||
handler and let Pyrogram know it needs to be taken into consideration when new updates arrive and the internal
|
Pyrogram know it needs to be taken into consideration when new updates arrive and the internal dispatching phase begins.
|
||||||
dispatching phase begins.
|
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
app.add_handler(my_handler)
|
app.add_handler(my_handler)
|
||||||
|
|
||||||
Last one, the :meth:`run() <pyrogram.Client.run>` method. What this does is simply call
|
Last one, the :meth:`~pyrogram.Client.run` method. What this does is simply call :meth:`~pyrogram.Client.start` and a
|
||||||
:meth:`start() <pyrogram.Client.start>` and a special method :meth:`idle() <pyrogram.Client.idle>` that keeps your main
|
special method :meth:`~pyrogram.Client.idle` that keeps your main scripts alive until you press ``CTRL+C``; the client
|
||||||
scripts alive until you press ``CTRL+C``; the client will be automatically stopped after that.
|
will be automatically stopped after that.
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@ -82,7 +80,7 @@ Using Decorators
|
|||||||
----------------
|
----------------
|
||||||
|
|
||||||
All of the above will become quite verbose, especially in case you have lots of handlers to register. A much nicer way
|
All of the above will become quite verbose, especially in case you have lots of handlers to register. A much nicer way
|
||||||
to do so is by decorating your callback function with the :meth:`on_message() <pyrogram.Client.on_message>` decorator.
|
to do so is by decorating your callback function with the :meth:`~pyrogram.Client.on_message` decorator.
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@ -108,5 +106,3 @@ to do so is by decorating your callback function with the :meth:`on_message() <p
|
|||||||
In case, for some reason, you want to get your own function back after it has been decorated, you need to access
|
In case, for some reason, you want to get your own function back after it has been decorated, you need to access
|
||||||
``my_function[0].callback``, that is, the *callback* field of the *handler* object which is the first element in the
|
``my_function[0].callback``, that is, the *callback* field of the *handler* object which is the first element in the
|
||||||
tuple, accessed by bracket notation *[0]*.
|
tuple, accessed by bracket notation *[0]*.
|
||||||
|
|
||||||
.. _API methods: invoking
|
|
@ -1,8 +1,9 @@
|
|||||||
Advanced Usage
|
Advanced Usage
|
||||||
==============
|
==============
|
||||||
|
|
||||||
Pyrogram's API, which consists of well documented convenience methods_ and facade types_, exists to provide a much
|
Pyrogram's API, which consists of well documented convenience :doc:`methods <../api/methods>` and facade
|
||||||
easier interface to the undocumented and often confusing Telegram API.
|
:doc:`types <../api/types>`, exists to provide a much easier interface to the undocumented and often confusing Telegram
|
||||||
|
API.
|
||||||
|
|
||||||
In this section, you'll be shown the alternative way of communicating with Telegram using Pyrogram: the main "raw"
|
In this section, you'll be shown the alternative way of communicating with Telegram using Pyrogram: the main "raw"
|
||||||
Telegram API with its functions and types.
|
Telegram API with its functions and types.
|
||||||
@ -11,7 +12,7 @@ Telegram Raw API
|
|||||||
----------------
|
----------------
|
||||||
|
|
||||||
If you can't find a high-level method for your needs or if you want complete, low-level access to the whole
|
If you can't find a high-level method for your needs or if you want complete, low-level access to the whole
|
||||||
Telegram API, you have to use the raw :mod:`functions <pyrogram.api.functions>` and :mod:`types <pyrogram.api.types>`.
|
Telegram API, you have to use the raw :mod:`~pyrogram.api.functions` and :mod:`~pyrogram.api.types`.
|
||||||
|
|
||||||
As already hinted, raw functions and types can be really confusing, mainly because people don't realize soon enough they
|
As already hinted, raw functions and types can be really confusing, mainly because people don't realize soon enough they
|
||||||
accept *only* the right types and that all required parameters must be filled in. This section will therefore explain
|
accept *only* the right types and that all required parameters must be filled in. This section will therefore explain
|
||||||
@ -21,24 +22,25 @@ some pitfalls to take into consideration when working with the raw API.
|
|||||||
|
|
||||||
Every available high-level methods in Pyrogram is built on top of these raw functions.
|
Every available high-level methods in Pyrogram is built on top of these raw functions.
|
||||||
|
|
||||||
Nothing stops you from using the raw functions only, but they are rather complex and `plenty of them`_ are already
|
Nothing stops you from using the raw functions only, but they are rather complex and
|
||||||
re-implemented by providing a much simpler and cleaner interface which is very similar to the Bot API (yet much more
|
:doc:`plenty of them <../api/methods>` are already re-implemented by providing a much simpler and cleaner interface
|
||||||
powerful).
|
which is very similar to the Bot API (yet much more powerful).
|
||||||
|
|
||||||
If you think a raw function should be wrapped and added as a high-level method, feel free to ask in our Community_!
|
If you think a raw function should be wrapped and added as a high-level method, feel free to ask in our Community_!
|
||||||
|
|
||||||
Invoking Functions
|
Invoking Functions
|
||||||
^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
Unlike the methods_ found in Pyrogram's API, which can be called in the usual simple way, functions to be invoked from
|
Unlike the :doc:`methods <../api/methods>` found in Pyrogram's API, which can be called in the usual simple way,
|
||||||
the raw Telegram API have a different way of usage and are more complex.
|
functions to be invoked from the raw Telegram API have a different way of usage and are more complex.
|
||||||
|
|
||||||
First of all, both `raw functions`_ and `raw types`_ live in their respective packages (and sub-packages):
|
First of all, both :doc:`raw functions <../telegram/functions/index>` and :doc:`raw types <../telegram/types/index>` live in their
|
||||||
``pyrogram.api.functions``, ``pyrogram.api.types``. They all exist as Python classes, meaning you need to create an
|
respective packages (and sub-packages): ``pyrogram.api.functions``, ``pyrogram.api.types``. They all exist as Python
|
||||||
instance of each every time you need them and fill them in with the correct values using named arguments.
|
classes, meaning you need to create an instance of each every time you need them and fill them in with the correct
|
||||||
|
values using named arguments.
|
||||||
|
|
||||||
Next, to actually invoke the raw function you have to use the :meth:`send() <pyrogram.Client.send>` method provided by
|
Next, to actually invoke the raw function you have to use the :meth:`~pyrogram.Client.send` method provided by the
|
||||||
the Client class and pass the function object you created.
|
Client class and pass the function object you created.
|
||||||
|
|
||||||
Here's some examples:
|
Here's some examples:
|
||||||
|
|
||||||
@ -101,12 +103,12 @@ sending messages with IDs only thanks to cached access hashes.
|
|||||||
There are three different InputPeer types, one for each kind of Telegram entity.
|
There are three different InputPeer types, one for each kind of Telegram entity.
|
||||||
Whenever an InputPeer is needed you must pass one of these:
|
Whenever an InputPeer is needed you must pass one of these:
|
||||||
|
|
||||||
- :obj:`InputPeerUser <../telegram/types/InputPeerUser>` - Users
|
- :class:`~pyrogram.api.types.InputPeerUser` - Users
|
||||||
- :obj:`InputPeerChat <../telegram/types/InputPeerChat>` - Basic Chats
|
- :class:`~pyrogram.api.types.InputPeerChat` - Basic Chats
|
||||||
- :obj:`InputPeerChannel <../telegram/types/InputPeerChannel>` - Either Channels or Supergroups
|
- :class:`~pyrogram.api.types.InputPeerChannel` - Either Channels or Supergroups
|
||||||
|
|
||||||
But you don't necessarily have to manually instantiate each object because, luckily for you, Pyrogram already provides
|
But you don't necessarily have to manually instantiate each object because, luckily for you, Pyrogram already provides
|
||||||
:meth:`resolve_peer() <pyrogram.Client.resolve_peer>` as a convenience utility method that returns the correct InputPeer
|
:meth:`~pyrogram.Client.resolve_peer` as a convenience utility method that returns the correct InputPeer
|
||||||
by accepting a peer ID only.
|
by accepting a peer ID only.
|
||||||
|
|
||||||
Another thing to take into consideration about chat IDs is the way they are represented: they are all integers and
|
Another thing to take into consideration about chat IDs is the way they are represented: they are all integers and
|
||||||
@ -125,9 +127,4 @@ For example, given the ID *123456789*, here's how Pyrogram can tell entities apa
|
|||||||
So, every time you take a raw ID, make sure to translate it into the correct ID when you want to use it with an
|
So, every time you take a raw ID, make sure to translate it into the correct ID when you want to use it with an
|
||||||
high-level method.
|
high-level method.
|
||||||
|
|
||||||
.. _methods: ../api/methods
|
|
||||||
.. _types: ../api/types
|
|
||||||
.. _plenty of them: ../api/methods
|
|
||||||
.. _raw functions: ../telegram/functions
|
|
||||||
.. _raw types: ../telegram/types
|
|
||||||
.. _Community: https://t.me/Pyrogram
|
.. _Community: https://t.me/Pyrogram
|
@ -3,7 +3,7 @@ Auto Authorization
|
|||||||
|
|
||||||
Manually writing phone number, phone code and password on the terminal every time you want to login can be tedious.
|
Manually writing phone number, phone code and password on the terminal every time you want to login can be tedious.
|
||||||
Pyrogram is able to automate both **Log In** and **Sign Up** processes, all you need to do is pass the relevant
|
Pyrogram is able to automate both **Log In** and **Sign Up** processes, all you need to do is pass the relevant
|
||||||
parameters when creating a new :class:`Client <pyrogram.Client>`.
|
parameters when creating a new :class:`~pyrogram.Client`.
|
||||||
|
|
||||||
.. note:: If you omit any of the optional parameter required for the authorization, Pyrogram will ask you to
|
.. note:: If you omit any of the optional parameter required for the authorization, Pyrogram will ask you to
|
||||||
manually write it. For instance, if you don't want to set a ``last_name`` when creating a new account you
|
manually write it. For instance, if you don't want to set a ``last_name`` when creating a new account you
|
||||||
|
@ -7,8 +7,7 @@ Inline Bots
|
|||||||
-----------
|
-----------
|
||||||
|
|
||||||
- If a bot accepts inline queries, you can call it by using
|
- If a bot accepts inline queries, you can call it by using
|
||||||
:meth:`get_inline_bot_results() <pyrogram.Client.get_inline_bot_results>` to get the list of its inline results
|
:meth:`~pyrogram.Client.get_inline_bot_results` to get the list of its inline results for a query:
|
||||||
for a query:
|
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@ -24,7 +23,7 @@ Inline Bots
|
|||||||
results list.
|
results list.
|
||||||
|
|
||||||
- After you retrieved the bot results, you can use
|
- After you retrieved the bot results, you can use
|
||||||
:meth:`send_inline_bot_result() <pyrogram.Client.send_inline_bot_result>` to send a chosen result to any chat:
|
:meth:`~pyrogram.Client.send_inline_bot_result` to send a chosen result to any chat:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ Using Filters
|
|||||||
So far we've seen how to register a callback function that executes every time a specific update comes from the server,
|
So far we've seen how to register a callback function that executes every time a specific update comes from the server,
|
||||||
but there's much more than that to come.
|
but there's much more than that to come.
|
||||||
|
|
||||||
Here we'll discuss about :class:`Filters <pyrogram.Filters>`. Filters enable a fine-grain control over what kind of
|
Here we'll discuss about :class:`~pyrogram.Filters`. Filters enable a fine-grain control over what kind of
|
||||||
updates are allowed or not to be passed in your callback functions, based on their inner details.
|
updates are allowed or not to be passed in your callback functions, based on their inner details.
|
||||||
|
|
||||||
Single Filters
|
Single Filters
|
||||||
@ -12,7 +12,7 @@ Single Filters
|
|||||||
|
|
||||||
Let's start right away with a simple example:
|
Let's start right away with a simple example:
|
||||||
|
|
||||||
- This example will show you how to **only** handle messages containing an :obj:`Audio <pyrogram.Audio>` object and
|
- This example will show you how to **only** handle messages containing an :class:`~pyrogram.Audio` object and
|
||||||
ignore any other message. Filters are passed as the first argument of the decorator:
|
ignore any other message. Filters are passed as the first argument of the decorator:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
@ -69,7 +69,7 @@ Here are some examples:
|
|||||||
Advanced Filters
|
Advanced Filters
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
Some filters, like :meth:`command() <pyrogram.Filters.command>` or :meth:`regex() <pyrogram.Filters.regex>`
|
Some filters, like :meth:`~pyrogram.Filters.command` or :meth:`~pyrogram.Filters.regex`
|
||||||
can also accept arguments:
|
can also accept arguments:
|
||||||
|
|
||||||
- Message is either a */start* or */help* **command**.
|
- Message is either a */start* or */help* **command**.
|
||||||
@ -109,18 +109,18 @@ More handlers using different filters can also live together.
|
|||||||
Custom Filters
|
Custom Filters
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
Pyrogram already provides lots of built-in :class:`Filters <pyrogram.Filters>` to work with, but in case you can't find
|
Pyrogram already provides lots of built-in :class:`~pyrogram.Filters` to work with, but in case you can't find
|
||||||
a specific one for your needs or want to build a custom filter by yourself (to be used in a different kind of handler,
|
a specific one for your needs or want to build a custom filter by yourself (to be used in a different kind of handler,
|
||||||
for example) you can use :meth:`Filters.create() <pyrogram.Filters.create>`.
|
for example) you can use :meth:`~pyrogram.Filters.create`.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
At the moment, the built-in filters are intended to be used with the :obj:`MessageHandler <pyrogram.MessageHandler>`
|
|
||||||
only.
|
At the moment, the built-in filters are intended to be used with the :class:`~pyrogram.MessageHandler` only.
|
||||||
|
|
||||||
An example to demonstrate how custom filters work is to show how to create and use one for the
|
An example to demonstrate how custom filters work is to show how to create and use one for the
|
||||||
:obj:`CallbackQueryHandler <pyrogram.CallbackQueryHandler>`. Note that callback queries updates are only received by
|
:class:`~pyrogram.CallbackQueryHandler`. Note that callback queries updates are only received by bots; create and
|
||||||
bots; create and `authorize your bot <../start/Setup.html#bot-authorization>`_, then send a message with an inline
|
:doc:`authorize your bot <../start/auth>`, then send a message with an inline keyboard to yourself. This allows you to
|
||||||
keyboard to yourself. This allows you to test your filter by pressing the inline button:
|
test your filter by pressing the inline button:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ keyboard to yourself. This allows you to test your filter by pressing the inline
|
|||||||
Basic Filters
|
Basic Filters
|
||||||
^^^^^^^^^^^^^
|
^^^^^^^^^^^^^
|
||||||
|
|
||||||
For this basic filter we will be using only the first two parameters of :meth:`Filters.create() <pyrogram.Filters.create>`.
|
For this basic filter we will be using only the first two parameters of :meth:`~pyrogram.Filters.create`.
|
||||||
|
|
||||||
The code below creates a simple filter for hardcoded, static callback data. This filter will only allow callback queries
|
The code below creates a simple filter for hardcoded, static callback data. This filter will only allow callback queries
|
||||||
containing "Pyrogram" as data, that is, the function *func* you pass returns True in case the callback query data
|
containing "Pyrogram" as data, that is, the function *func* you pass returns True in case the callback query data
|
||||||
@ -175,7 +175,7 @@ Filters with Arguments
|
|||||||
^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
A much cooler filter would be one that accepts "Pyrogram" or any other data as argument at usage time.
|
A much cooler filter would be one that accepts "Pyrogram" or any other data as argument at usage time.
|
||||||
A dynamic filter like this will make use of the third parameter of :meth:`Filters.create() <pyrogram.Filters.create>`.
|
A dynamic filter like this will make use of the third parameter of :meth:`~pyrogram.Filters.create`.
|
||||||
|
|
||||||
This is how a dynamic custom filter looks like:
|
This is how a dynamic custom filter looks like:
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
More on Updates
|
More on Updates
|
||||||
===============
|
===============
|
||||||
|
|
||||||
Here we'll show some advanced usages when working with `update handlers`_ and `filters`_.
|
Here we'll show some advanced usages when working with :doc:`update handlers <../start/updates>` and
|
||||||
|
:doc:`filters <filters>`.
|
||||||
|
|
||||||
Handler Groups
|
Handler Groups
|
||||||
--------------
|
--------------
|
||||||
@ -44,7 +45,7 @@ Or, if you want ``just_text`` to be fired *before* ``text_or_sticker`` (note ``-
|
|||||||
def just_text(client, message):
|
def just_text(client, message):
|
||||||
print("Just Text")
|
print("Just Text")
|
||||||
|
|
||||||
With :meth:`add_handler() <pyrogram.Client.add_handler>` (without decorators) the same can be achieved with:
|
With :meth:`~pyrogram.Client.add_handler` (without decorators) the same can be achieved with:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@ -217,6 +218,3 @@ The output of both (equivalent) examples will be:
|
|||||||
0
|
0
|
||||||
1
|
1
|
||||||
2
|
2
|
||||||
|
|
||||||
.. _`update handlers`: ../start/updates
|
|
||||||
.. _`filters`: filters
|
|
@ -9,7 +9,8 @@ For Humans - str(obj)
|
|||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
If you want a nicely formatted, human readable JSON representation of any object in the API -- namely, any object from
|
If you want a nicely formatted, human readable JSON representation of any object in the API -- namely, any object from
|
||||||
`Pyrogram types`_, `raw functions`_ and `raw types`_ -- you can use use ``str(obj)``.
|
:doc:`Pyrogram types <../api/types>`, :doc:`raw functions <../telegram/functions/index>` and
|
||||||
|
:doc:`raw types <../telegram/types/index>` -- you can use use ``str(obj)``.
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
@ -25,10 +26,6 @@ If you want a nicely formatted, human readable JSON representation of any object
|
|||||||
When using ``print()`` you don't actually need to use ``str()`` on the object because it is called automatically, we
|
When using ``print()`` you don't actually need to use ``str()`` on the object because it is called automatically, we
|
||||||
have done that above just to show you how to explicitly convert a Pyrogram object to JSON.
|
have done that above just to show you how to explicitly convert a Pyrogram object to JSON.
|
||||||
|
|
||||||
.. _Pyrogram types: ../api/types
|
|
||||||
.. _raw functions: ../telegram/functions
|
|
||||||
.. _raw types: ../telegram/types
|
|
||||||
|
|
||||||
For Machines - repr(obj)
|
For Machines - repr(obj)
|
||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ As you may probably know, Telegram allows users (and bots) having more than one
|
|||||||
in the system at the same time.
|
in the system at the same time.
|
||||||
|
|
||||||
Briefly explaining, sessions are simply new logins in your account. They can be reviewed in the settings of an official
|
Briefly explaining, sessions are simply new logins in your account. They can be reviewed in the settings of an official
|
||||||
app (or by invoking `GetAuthorizations <../telegram/functions/account/GetAuthorizations.html>`_ with Pyrogram). They
|
app (or by invoking :class:`~pyrogram.api.functions.account.GetAuthorizations` with Pyrogram). They
|
||||||
store some useful information such as the client who's using them and from which country and IP address.
|
store some useful information such as the client who's using them and from which country and IP address.
|
||||||
|
|
||||||
.. figure:: https://i.imgur.com/YaqtMLO.png
|
.. figure:: https://i.imgur.com/YaqtMLO.png
|
||||||
|
@ -65,8 +65,8 @@ after importing your modules, like this:
|
|||||||
app.run()
|
app.run()
|
||||||
|
|
||||||
This is already nice and doesn't add *too much* boilerplate code, but things can get boring still; you have to
|
This is already nice and doesn't add *too much* boilerplate code, but things can get boring still; you have to
|
||||||
manually ``import``, manually :meth:`add_handler() <pyrogram.Client.add_handler>` and manually instantiate each
|
manually ``import``, manually :meth:`~pyrogram.Client.add_handler` and manually instantiate each
|
||||||
:obj:`MessageHandler <pyrogram.MessageHandler>` object because **you can't use those cool decorators** for your
|
:class:`~pyrogram.MessageHandler` object because **you can't use those cool decorators** for your
|
||||||
functions. So, what if you could? Smart Plugins solve this issue by taking care of handlers registration automatically.
|
functions. So, what if you could? Smart Plugins solve this issue by taking care of handlers registration automatically.
|
||||||
|
|
||||||
Using Smart Plugins
|
Using Smart Plugins
|
||||||
@ -80,7 +80,7 @@ Setting up your Pyrogram project to accommodate Smart Plugins is pretty straight
|
|||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
This is the same example application `as shown above <#introduction>`_, written using the Smart Plugin system.
|
This is the same example application as shown above, written using the Smart Plugin system.
|
||||||
|
|
||||||
.. code-block:: text
|
.. code-block:: text
|
||||||
:emphasize-lines: 2, 3
|
:emphasize-lines: 2, 3
|
||||||
@ -156,7 +156,7 @@ found inside each module will be, instead, loaded in the order they are defined,
|
|||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
Remember: there can be at most one handler, within a group, dealing with a specific update. Plugins with overlapping
|
Remember: there can be at most one handler, within a group, dealing with a specific update. Plugins with overlapping
|
||||||
filters included a second time will not work. Learn more at `More on Updates <more-on-updates>`_.
|
filters included a second time will not work. Learn more at :doc:`More on Updates <more-on-updates>`.
|
||||||
|
|
||||||
This default loading behaviour is usually enough, but sometimes you want to have more control on what to include (or
|
This default loading behaviour is usually enough, but sometimes you want to have more control on what to include (or
|
||||||
exclude) and in which exact order to load plugins. The way to do this is to make use of ``include`` and ``exclude``
|
exclude) and in which exact order to load plugins. The way to do this is to make use of ``include`` and ``exclude``
|
||||||
@ -288,9 +288,8 @@ also organized in subfolders:
|
|||||||
Load/Unload Plugins at Runtime
|
Load/Unload Plugins at Runtime
|
||||||
------------------------------
|
------------------------------
|
||||||
|
|
||||||
In the `previous section <#specifying-the-plugins-to-include>`_ we've explained how to specify which plugins to load and
|
In the previous section we've explained how to specify which plugins to load and which to ignore before your Client
|
||||||
which to ignore before your Client starts. Here we'll show, instead, how to unload and load again a previously
|
starts. Here we'll show, instead, how to unload and load again a previously registered plugin at runtime.
|
||||||
registered plugin at runtime.
|
|
||||||
|
|
||||||
Each function decorated with the usual ``on_message`` decorator (or any other decorator that deals with Telegram updates
|
Each function decorated with the usual ``on_message`` decorator (or any other decorator that deals with Telegram updates
|
||||||
) will be modified in such a way that, when you reference them later on, they will be actually pointing to a tuple of
|
) will be modified in such a way that, when you reference them later on, they will be actually pointing to a tuple of
|
||||||
@ -318,7 +317,7 @@ Unloading
|
|||||||
^^^^^^^^^
|
^^^^^^^^^
|
||||||
|
|
||||||
In order to unload a plugin, or any other handler, all you need to do is obtain a reference to it by importing the
|
In order to unload a plugin, or any other handler, all you need to do is obtain a reference to it by importing the
|
||||||
relevant module and call :meth:`remove_handler() <pyrogram.Client.remove_handler>` Client's method with your function
|
relevant module and call :meth:`~pyrogram.Client.remove_handler` Client's method with your function
|
||||||
name preceded by the star ``*`` operator as argument. Example:
|
name preceded by the star ``*`` operator as argument. Example:
|
||||||
|
|
||||||
- ``main.py``
|
- ``main.py``
|
||||||
@ -343,7 +342,7 @@ Loading
|
|||||||
^^^^^^^
|
^^^^^^^
|
||||||
|
|
||||||
Similarly to the unloading process, in order to load again a previously unloaded plugin you do the same, but this time
|
Similarly to the unloading process, in order to load again a previously unloaded plugin you do the same, but this time
|
||||||
using :meth:`add_handler() <pyrogram.Client.add_handler>` instead. Example:
|
using :meth:`~pyrogram.Client.add_handler` instead. Example:
|
||||||
|
|
||||||
- ``main.py``
|
- ``main.py``
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ Markdown Style
|
|||||||
--------------
|
--------------
|
||||||
|
|
||||||
To use this mode, pass "markdown" in the *parse_mode* field when using
|
To use this mode, pass "markdown" in the *parse_mode* field when using
|
||||||
:obj:`send_message() <pyrogram.Client.send_message>`. Use the following syntax in your message:
|
:meth:`~pyrogram.Client.send_message`. Use the following syntax in your message:
|
||||||
|
|
||||||
.. code-block:: text
|
.. code-block:: text
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ To use this mode, pass "markdown" in the *parse_mode* field when using
|
|||||||
HTML Style
|
HTML Style
|
||||||
----------
|
----------
|
||||||
|
|
||||||
To use this mode, pass "html" in the *parse_mode* field when using :obj:`send_message() <pyrogram.Client.send_message>`.
|
To use this mode, pass "html" in the *parse_mode* field when using :meth:`~pyrogram.Client.send_message`.
|
||||||
The following tags are currently supported:
|
The following tags are currently supported:
|
||||||
|
|
||||||
.. code-block:: text
|
.. code-block:: text
|
||||||
|
@ -51,7 +51,7 @@ class SetChatPhoto(BaseClient):
|
|||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
RPCError: In case of a Telegram RPC error.
|
RPCError: In case of a Telegram RPC error.
|
||||||
``ValueError`` if a chat_id belongs to user.
|
ValueError: if a chat_id belongs to user.
|
||||||
"""
|
"""
|
||||||
peer = self.resolve_peer(chat_id)
|
peer = self.resolve_peer(chat_id)
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ class Message(PyrogramType, Update):
|
|||||||
new_chat_photo, delete_chat_photo, group_chat_created, supergroup_chat_created, channel_chat_created,
|
new_chat_photo, delete_chat_photo, group_chat_created, supergroup_chat_created, channel_chat_created,
|
||||||
migrate_to_chat_id, migrate_from_chat_id, pinned_message.
|
migrate_to_chat_id, migrate_from_chat_id, pinned_message.
|
||||||
|
|
||||||
media (``bool`` *optional*):
|
media (``bool``, *optional*):
|
||||||
The message is a media message.
|
The message is a media message.
|
||||||
A media message has one and only one of these fields set: audio, document, photo, sticker, video, animation,
|
A media message has one and only one of these fields set: audio, document, photo, sticker, video, animation,
|
||||||
voice, video_note, contact, location, venue.
|
voice, video_note, contact, location, venue.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user