2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-28 21:07:59 +00:00

Update docs

This commit is contained in:
Dan 2018-03-25 21:30:39 +02:00
parent e5ae1acc37
commit 1e6a7008fb
9 changed files with 28 additions and 32 deletions

View File

@ -3590,7 +3590,7 @@ code,.rst-content tt,.rst-content code{
max-width:100%;
background:#fff;
border:solid 1px #e1e4e5;
font-size:85%;
font-size:80%;
padding:0 5px;
font-family:Consolas,"Andale Mono WT","Andale Mono","Lucida Console","Lucida Sans Typewriter","DejaVu Sans Mono","Bitstream Vera Sans Mono","Liberation Mono","Nimbus Mono L",Monaco,"Courier New",Courier,monospace;
color:#E74C3C;
@ -4518,11 +4518,11 @@ footer span.commit code,footer span.commit .rst-content tt,.rst-content footer s
line-height:normal
}
.rst-content tt.literal,.rst-content tt.literal,.rst-content code.literal{
color:#E74C3C
color:#404040
}
.rst-content tt.xref,a .rst-content tt,.rst-content tt.xref,.rst-content code.xref,a .rst-content tt,a .rst-content code{
font-weight:bold;
color:#404040
color:#2980B9
}
.rst-content a tt,.rst-content a tt,.rst-content a code{
color:#2980B9

View File

@ -1,6 +1,2 @@
Emoji
======
.. autoclass:: pyrogram.Emoji
:members:
:undoc-members:

View File

@ -3,7 +3,7 @@ Pyrogram
In this section you can find a detailed description of the Pyrogram API.
:obj:`pyrogram.Client` is the main class you have to deal with.
:class:`Client <pyrogram.Client>` is the main class you have to deal with.
You will notice that methods are named after the well established `Telegram Bot API`_ and that most of them accept
the same parameters as well, thus offering a familiar look to Bot developers.

View File

@ -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

View File

@ -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.

View File

@ -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::

View File

@ -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

View File

@ -3,14 +3,14 @@ Basic Usage
.. note::
All the snippets below assume you have successfully created and started a :obj:`pyrogram.Client` instance.
You also must be authorized, that is, a valid *.session file does exist in your working directory.
All the snippets below assume you have successfully created and started a :class:`Client <pyrogram.Client>`
instance. You also must be authorized, that is, a valid *.session file does exist in your working directory.
Simple API Access
-----------------
The easiest way to interact with the API is via the :obj:`pyrogram.Client` class which exposes bot-like_ methods.
The purpose of this Client class is to make it even simpler to work with Telegram's API by abstracting the
The easiest way to interact with the API is via the :class:`Client <pyrogram.Client>` class which exposes bot-like_
methods. The purpose of this Client class is to make it even simpler to work with Telegram's API by abstracting the
raw functions listed in the API scheme.
The result is a much cleaner interface that allows you to:
@ -30,7 +30,7 @@ The result is a much cleaner interface that allows you to:
text="Hi there! I'm using Pyrogram"
)
.. seealso:: For a complete list of the available methods have a look at the :obj:`pyrogram.Client` class.
.. seealso:: For a complete list of the available methods have a look at the :class:`Client <pyrogram.Client>` class.
.. _using-raw-functions:
@ -38,8 +38,8 @@ Using Raw Functions
-------------------
If you want **complete**, low-level access to the Telegram API you have to use the raw
:obj:`functions <pyrogram.api.functions>` and :obj:`types <pyrogram.api.types>` exposed by the ``pyrogram.api``
package and call any Telegram API method you wish using the :obj:`send <pyrogram.Client.send>` method provided by
:mod:`functions <pyrogram.api.functions>` and :mod:`types <pyrogram.api.types>` exposed by the ``pyrogram.api``
package and call any Telegram API method you wish using the :meth:`send <pyrogram.Client.send>` method provided by
the Client class.
Here some examples:

View File

@ -44,15 +44,15 @@ There are two ways to configure a Pyrogram application project, and you can choo
)
.. note:: The examples below will assume you have created a *config.ini* file, thus they won't show the *api_key*
parameter usage in the Client class.
parameter usage in the :class:`Client <pyrogram.Client>` class.
Authorization
-------------
Telegram requires that users be authorized in order to use the API.
Pyrogram automatically manages this access, all you need to do is create an instance of
the :class:`pyrogram.Client` class by passing to it a ``<session_name>`` of your choice
and call the :obj:`start <pyrogram.Client.start>` method:
the :class:`Client <pyrogram.Client>` class by passing to it a ``<session_name>`` of your choice
and call the :meth:`start <pyrogram.Client.start>` method:
.. code-block:: python