Update some raw API examples

This commit is contained in:
Lonami Exo 2022-09-21 10:50:07 +02:00
parent 1f42e6e32f
commit 6d02a1c6ff
2 changed files with 47 additions and 2 deletions

View File

@ -25,7 +25,7 @@ you should use :tl:`GetFullUser`:
# or even # or even
full = await client(GetFullUserRequest('username')) full = await client(GetFullUserRequest('username'))
bio = full.about bio = full.full_user.about
See :tl:`UserFull` to know what other fields you can access. See :tl:`UserFull` to know what other fields you can access.

View File

@ -42,4 +42,49 @@ send yourself the very first sticker you have:
await client.send_file('me', stickers.documents[0]) await client.send_file('me', stickers.documents[0])
.. _issues: https://github.com/LonamiWebs/Telethon/issues/215 Sending reactions
=================
It works very similar to replying to a message. You need to specify the chat,
message ID you wish to react to, and reaction, using :tl:`SendReaction`:
.. code-block:: python
from telethon.tl.functions.messages import SendReactionRequest
await client(SendReactionRequest(
peer=chat,
msg_id=42,
reaction='❤️'
))
Note that you cannot use strings like ``:heart:`` for the reaction. You must
use the desired emoji directly. You can most easily achieve this by
copy-pasting the emoji from an official application such as Telegram Desktop.
If for some reason you cannot embed emoji directly into the code, you can also
use its unicode escape (which you can find using websites like
`unicode-table.com`_), or install a different package, like `emoji`_:
.. code-block:: python
# All of these work exactly the same (you only need one):
import emoji
reaction = emoji.emojize(':red_heart:')
reaction = '❤️'
reaction = '\u2764'
from telethon.tl.functions.messages import SendReactionRequest
await client(SendReactionRequest(
peer=chat,
msg_id=42,
reaction=reaction
))
Please make sure to check the help pages of the respective websites you use
if you need a more in-depth explanation on how they work. Telethon only needs
you to provide the emoji in some form. Some packages or websites can make this
easier.
.. _unicode-table.com: https://unicode-table.com/en/emoji/
.. _emoji: https://pypi.org/project/emoji/