mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-30 22:05:28 +00:00
Update docs
This commit is contained in:
@@ -3,17 +3,17 @@ Auto Authorization
|
||||
|
||||
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
|
||||
parameters when creating a new Client.
|
||||
parameters when creating a new :class:`Client <pyrogram.Client>`.
|
||||
|
||||
.. 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
|
||||
have to explicitly pass an empty string ""; the default value (None) will trigger the input() call.
|
||||
|
||||
Log In
|
||||
-------
|
||||
|
||||
To automate the **Log In** process, pass your *phone_number* and *password* (if you have one) in the Client parameters.
|
||||
If you want to retrieve the phone code programmatically, pass a callback function in the *phone_code* field — this
|
||||
To automate the **Log In** process, pass your ``phone_number`` and ``password`` (if you have one) in the Client parameters.
|
||||
If you want to retrieve the phone code programmatically, pass a callback function in the ``phone_code`` field — this
|
||||
function must return the correct phone code as string (e.g., "12345") — otherwise, ignore this parameter, Pyrogram will
|
||||
ask you to input the phone code manually.
|
||||
|
||||
@@ -40,7 +40,7 @@ Sign Up
|
||||
-------
|
||||
|
||||
To automate the **Sign Up** process (i.e., automatically create a new Telegram account), simply fill **both**
|
||||
*first_name* and *last_name* fields alongside the other parameters; they will be used to automatically create a new
|
||||
``first_name`` and ``last_name`` fields alongside the other parameters; they will be used to automatically create a new
|
||||
Telegram account in case the phone number you passed is not registered yet.
|
||||
|
||||
.. code-block:: python
|
||||
|
@@ -25,7 +25,7 @@ Usage
|
||||
- ``1``, ``yes``, ``True`` or ``on``: Enables the proxy
|
||||
- ``0``, ``no``, ``False`` or ``off``: Disables the proxy
|
||||
|
||||
- Alternatively, you can setup your proxy without the need of the *config.ini* file by using the *proxy* parameter
|
||||
- Alternatively, you can setup your proxy without the need of the ``config.ini`` file by using the *proxy* parameter
|
||||
in the Client class:
|
||||
|
||||
.. code-block:: python
|
||||
@@ -46,5 +46,5 @@ Usage
|
||||
|
||||
...
|
||||
|
||||
.. note:: If your proxy doesn't require authorization you can omit *username* and *password* by either leaving the
|
||||
.. note:: If your proxy doesn't require authorization you can omit ``username`` and ``password`` by either leaving the
|
||||
values blank/empty or completely delete the lines.
|
@@ -8,7 +8,7 @@ Beside bold, italic, and pre-formatted code, **Pyrogram does also support inline
|
||||
Markdown Style
|
||||
--------------
|
||||
|
||||
To use this mode, pass :obj:`pyrogram.ParseMode.MARKDOWN` or "markdown" in the *parse_mode* field when using
|
||||
To use this mode, pass :obj:`MARKDOWN <pyrogram.ParseMode.MARKDOWN>` or "markdown" in the *parse_mode* field when using
|
||||
:obj:`send_message <pyrogram.Client.send_message>`. Use the following syntax in your message:
|
||||
|
||||
.. code::
|
||||
@@ -30,7 +30,7 @@ To use this mode, pass :obj:`pyrogram.ParseMode.MARKDOWN` or "markdown" in the *
|
||||
HTML Style
|
||||
----------
|
||||
|
||||
To use this mode, pass :obj:`pyrogram.ParseMode.HTML` or "html" in the *parse_mode* field when using
|
||||
To use this mode, pass :obj:`HTML <pyrogram.ParseMode.HTML>` or "html" in the *parse_mode* field when using
|
||||
:obj:`send_message <pyrogram.Client.send_message>`. The following tags are currently supported:
|
||||
|
||||
.. code::
|
||||
|
@@ -2,10 +2,10 @@ Update Handling
|
||||
===============
|
||||
|
||||
Updates are events that happen in your Telegram account (incoming messages, new channel posts, user name changes, ...)
|
||||
and can be handled by using a callback function, that is, a function called every time an :obj:`Update` is received from
|
||||
and can be handled by using a callback function, that is, a function called every time an ``Update`` is received from
|
||||
Telegram.
|
||||
|
||||
To set an update handler simply call :obj:`set_update_handler <pyrogram.Client.set_update_handler>`
|
||||
To set an update handler simply call :meth:`set_update_handler <pyrogram.Client.set_update_handler>`
|
||||
by passing the name of your defined callback function as argument *before* you start the Client.
|
||||
|
||||
Here's a complete example on how to set it up:
|
||||
@@ -28,9 +28,9 @@ Here's a complete example on how to set it up:
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
The last line of the main() function, :obj:`client.idle() <pyrogram.Client.idle>`, is not strictly necessary but highly
|
||||
recommended when using the update handler; it will block your script execution until you press :obj:`CTRL`:obj:`C` and
|
||||
automatically call the :obj:`stop <pyrogram.Client.stop>` method which stops the Client and gently close the underlying
|
||||
The last line of the main function, :meth:`client.idle() <pyrogram.Client.idle>`, is not strictly necessary but highly
|
||||
recommended when using the update handler; it will block your script execution until you press ``CTRL+C`` and
|
||||
automatically call the :meth:`stop <pyrogram.Client.stop>` method which stops the Client and gently close the underlying
|
||||
connection.
|
||||
|
||||
Examples
|
||||
|
Reference in New Issue
Block a user