Skip to content

Commit

Permalink
Document how to send spoilers and custom emoji
Browse files Browse the repository at this point in the history
  • Loading branch information
Lonami committed Oct 21, 2022
1 parent b3266fa commit 0980d55
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions readthedocs/examples/working-with-messages.rst
Expand Up @@ -86,5 +86,40 @@ 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.


Sending spoilers (hidden text)
==============================

The current markdown and HTML parsers do not offer a way to send spoilers yet.
You need to use :tl:`MessageEntitySpoiler` so that parts of the message text
are shown under a spoiler.

The simplest way to do this is to `modify the builtin parsers`_ to support
sending these new message entities with the features they already provide.


Sending custom emoji
====================

The current markdown and HTML parsers do not offer a way to send custom emoji
yet. You need to use :tl:`MessageEntityCustomEmoji` so that parts of the
message text with emoji are replaced with a custom one instead.

The simplest way to do this is to `modify the builtin parsers`_ to support
sending these new message entities with the features they already provide.

:tl:`MessageEntityCustomEmoji` must wrap an emoji in order to work (you can't
put it around arbitrary ``"text"``, it won't work), so be sure to keep this in
mind when using it.

To find the ``document_id`` for the custom emoji, the simplest way is to send
a message with an official client containing the custom emoji you want, and
then print the ``message.entities`` to find the ``document_id``.

If you prefer, you can also use :tl:`GetFeaturedEmojiStickers` to find about
the ``document_id`` of featured custom emoji.


.. _unicode-table.com: https://unicode-table.com/en/emoji/
.. _emoji: https://pypi.org/project/emoji/
.. _modify the builtin parsers: https://github.com/LonamiWebs/Telethon/wiki/Sending-spoilers-and-custom-emoji

0 comments on commit 0980d55

Please sign in to comment.