2018-04-15 15:04:58 +03:00
|
|
|
=====
|
|
|
|
Users
|
|
|
|
=====
|
|
|
|
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
2019-05-09 13:24:37 +03:00
|
|
|
These examples assume you have read :ref:`full-api`.
|
2018-04-15 15:04:58 +03:00
|
|
|
|
2018-10-06 21:20:11 +03:00
|
|
|
.. contents::
|
|
|
|
|
2018-04-15 15:04:58 +03:00
|
|
|
|
|
|
|
Retrieving full information
|
2019-05-09 13:24:37 +03:00
|
|
|
===========================
|
2018-04-15 15:04:58 +03:00
|
|
|
|
2018-09-22 20:18:42 +03:00
|
|
|
If you need to retrieve the bio, biography or about information for a user
|
2018-04-15 15:04:58 +03:00
|
|
|
you should use :tl:`GetFullUser`:
|
|
|
|
|
|
|
|
|
2018-06-20 12:05:33 +03:00
|
|
|
.. code-block:: python
|
2018-04-15 15:04:58 +03:00
|
|
|
|
2018-06-20 12:05:33 +03:00
|
|
|
from telethon.tl.functions.users import GetFullUserRequest
|
2018-04-15 15:04:58 +03:00
|
|
|
|
2018-06-25 22:14:58 +03:00
|
|
|
full = client(GetFullUserRequest(user))
|
|
|
|
# or even
|
|
|
|
full = client(GetFullUserRequest('username'))
|
2018-04-15 15:04:58 +03:00
|
|
|
|
2018-06-25 22:14:58 +03:00
|
|
|
bio = full.about
|
2018-04-15 15:04:58 +03:00
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
=============================
|
2018-04-15 15:04:58 +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`:
|
|
|
|
|
2018-06-20 12:05:33 +03:00
|
|
|
.. code-block:: python
|
2018-04-15 15:04:58 +03:00
|
|
|
|
2018-06-20 12:05:33 +03:00
|
|
|
from telethon.tl.functions.account import UpdateProfileRequest
|
2018-04-15 15:04:58 +03:00
|
|
|
|
2018-08-14 19:48:56 +03:00
|
|
|
client(UpdateProfileRequest(
|
|
|
|
about='This is a test from Telethon'
|
2018-06-25 22:14:58 +03:00
|
|
|
))
|
2018-04-15 15:04:58 +03:00
|
|
|
|
|
|
|
|
|
|
|
Updating your username
|
2019-05-09 13:24:37 +03:00
|
|
|
======================
|
2018-04-15 15:04:58 +03:00
|
|
|
|
|
|
|
You need to use :tl:`account.UpdateUsername`:
|
|
|
|
|
2018-06-20 12:05:33 +03:00
|
|
|
.. code-block:: python
|
2018-04-15 15:04:58 +03:00
|
|
|
|
2018-06-20 12:05:33 +03:00
|
|
|
from telethon.tl.functions.account import UpdateUsernameRequest
|
2018-04-15 15:04:58 +03:00
|
|
|
|
2018-06-25 22:14:58 +03:00
|
|
|
client(UpdateUsernameRequest('new_username'))
|
2018-04-15 15:04:58 +03:00
|
|
|
|
|
|
|
|
|
|
|
Updating your profile photo
|
2019-05-09 13:24:37 +03:00
|
|
|
===========================
|
2018-04-15 15:04:58 +03:00
|
|
|
|
|
|
|
The easiest way is to upload a new file and use that as the profile photo
|
|
|
|
through :tl:`UploadProfilePhoto`:
|
|
|
|
|
|
|
|
|
2018-06-20 12:05:33 +03:00
|
|
|
.. code-block:: python
|
2018-04-15 15:04:58 +03:00
|
|
|
|
2018-06-20 12:05:33 +03:00
|
|
|
from telethon.tl.functions.photos import UploadProfilePhotoRequest
|
2018-04-15 15:04:58 +03:00
|
|
|
|
2018-06-25 22:14:58 +03:00
|
|
|
client(UploadProfilePhotoRequest(
|
2018-06-20 12:05:33 +03:00
|
|
|
client.upload_file('/path/to/some/file')
|
2018-06-22 15:44:59 +03:00
|
|
|
)))
|