Telethon/readthedocs/examples/users.rst

75 lines
1.5 KiB
ReStructuredText
Raw Normal View History

=====
Users
=====
.. note::
2019-05-09 13:24:37 +03:00
These examples assume you have read :ref:`full-api`.
2018-10-06 21:20:11 +03:00
.. contents::
Retrieving full information
2019-05-09 13:24:37 +03:00
===========================
2018-09-22 20:18:42 +03:00
If you need to retrieve the bio, biography or about information for a user
you should use :tl:`GetFullUser`:
.. code-block:: python
from telethon.tl.functions.users import GetFullUserRequest
full = await client(GetFullUserRequest(user))
2018-06-25 22:14:58 +03:00
# or even
full = await client(GetFullUserRequest('username'))
2018-06-25 22:14:58 +03:00
bio = full.about
See :tl:`UserFull` to know what other fields you can access.
Updating your name and/or bio
2019-05-09 13:24:37 +03:00
=============================
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
await client(UpdateProfileRequest(
2018-08-14 19:48:56 +03:00
about='This is a test from Telethon'
2018-06-25 22:14:58 +03:00
))
Updating your username
2019-05-09 13:24:37 +03:00
======================
You need to use :tl:`account.UpdateUsername`:
.. code-block:: python
from telethon.tl.functions.account import UpdateUsernameRequest
await client(UpdateUsernameRequest('new_username'))
Updating your profile photo
2019-05-09 13:24:37 +03:00
===========================
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
await client(UploadProfilePhotoRequest(
await client.upload_file('/path/to/some/file')
2021-01-20 20:50:45 +03:00
))