mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-10 19:46:36 +03:00
Add new examples to the docs and update project structure
This commit is contained in:
parent
ffdfa8f262
commit
34f4730337
|
@ -37,7 +37,11 @@ Auto-generated code
|
|||
*******************
|
||||
|
||||
The files under ``telethon_generator/`` are used to generate the code
|
||||
that gets placed under ``telethon/tl/``. The ``TLGenerator`` takes in a
|
||||
``.tl`` file, and spits out the generated classes which represent, as
|
||||
Python classes, the request and types defined in the ``.tl`` file. It
|
||||
also constructs an index so that they can be imported easily.
|
||||
that gets placed under ``telethon/tl/``. The parsers take in files in
|
||||
a specific format (such as ``.tl`` for objects and ``.json`` for errors)
|
||||
and spit out the generated classes which represent, as Python classes,
|
||||
the request and types defined in the ``.tl`` file. It also constructs
|
||||
an index so that they can be imported easily.
|
||||
|
||||
Custom documentation can also be generated to easily navigate through
|
||||
the vast amount of items offered by the API.
|
||||
|
|
70
readthedocs/extra/examples/users.rst
Normal file
70
readthedocs/extra/examples/users.rst
Normal file
|
@ -0,0 +1,70 @@
|
|||
=====
|
||||
Users
|
||||
=====
|
||||
|
||||
|
||||
.. note::
|
||||
|
||||
These examples assume you have read :ref:`accessing-the-full-api`.
|
||||
|
||||
|
||||
Retrieving full information
|
||||
***************************
|
||||
|
||||
If you need to retrieve the bio, biography or about information for an user
|
||||
you should use :tl:`GetFullUser`:
|
||||
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from telethon.tl.functions.users import GetFullUserRequest
|
||||
|
||||
full = client(GetFullUserRequest(user))
|
||||
# or even
|
||||
full = client(GetFullUserRequest('username'))
|
||||
|
||||
bio = full.about
|
||||
|
||||
|
||||
See :tl:`UserFull` to know what other fields you can access.
|
||||
|
||||
|
||||
Updating your name and/or bio
|
||||
*****************************
|
||||
|
||||
The first name, last name and bio (about) can all be changed with the same
|
||||
request. Omitted fields won't change after invoking :tl:`UpdateProfile`:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from telethon.tl.functions.account import UpdateProfileRequest
|
||||
|
||||
client(UpdateProfileRequest(about='This is a test from Telethon'))
|
||||
|
||||
|
||||
Updating your username
|
||||
**********************
|
||||
|
||||
You need to use :tl:`account.UpdateUsername`:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from telethon.tl.functions.account import UpdateUsernameRequest
|
||||
|
||||
client(UpdateUsernameRequest('new_username'))
|
||||
|
||||
|
||||
Updating your profile photo
|
||||
***************************
|
||||
|
||||
The easiest way is to upload a new file and use that as the profile photo
|
||||
through :tl:`UploadProfilePhoto`:
|
||||
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from telethon.tl.functions.photos import UploadProfilePhotoRequest
|
||||
|
||||
client(functions.photos.UploadProfilePhotoRequest(
|
||||
client.upload_file('/path/to/some/file')
|
||||
))
|
|
@ -61,6 +61,7 @@ heavy job for you, so you can focus on developing an application.
|
|||
|
||||
extra/examples/working-with-messages
|
||||
extra/examples/chats-and-channels
|
||||
extra/examples/users
|
||||
extra/examples/bots
|
||||
extra/examples/projects-using-telethon
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user