2018-01-05 02:59:53 +03:00
|
|
|
=====================
|
2017-11-19 19:56:05 +03:00
|
|
|
Working with messages
|
2018-01-05 02:59:53 +03:00
|
|
|
=====================
|
2017-11-20 07:12:31 +03:00
|
|
|
|
|
|
|
|
2018-01-20 13:47:17 +03:00
|
|
|
.. note::
|
|
|
|
|
|
|
|
These examples assume you have read :ref:`accessing-the-full-api`.
|
|
|
|
|
2018-10-06 21:20:11 +03:00
|
|
|
.. contents::
|
|
|
|
|
2018-01-20 13:47:17 +03:00
|
|
|
|
2017-11-19 19:56:05 +03:00
|
|
|
Sending stickers
|
2018-01-05 02:59:53 +03:00
|
|
|
****************
|
|
|
|
|
|
|
|
Stickers are nothing else than ``files``, and when you successfully retrieve
|
|
|
|
the stickers for a certain sticker set, all you will have are ``handles`` to
|
|
|
|
these files. Remember, the files Telegram holds on their servers can be
|
|
|
|
referenced through this pair of ID/hash (unique per user), and you need to
|
|
|
|
use this handle when sending a "document" message. This working example will
|
|
|
|
send yourself the very first sticker you have:
|
2017-11-19 19:56:05 +03:00
|
|
|
|
2018-06-20 12:05:33 +03:00
|
|
|
.. code-block:: python
|
2017-11-19 19:56:05 +03:00
|
|
|
|
2018-06-25 22:14:58 +03:00
|
|
|
# Get all the sticker sets this user has
|
|
|
|
from telethon.tl.functions.messages import GetAllStickersRequest
|
|
|
|
sticker_sets = client(GetAllStickersRequest(0))
|
|
|
|
|
|
|
|
# Choose a sticker set
|
|
|
|
from telethon.tl.functions.messages import GetStickerSetRequest
|
|
|
|
from telethon.tl.types import InputStickerSetID
|
|
|
|
sticker_set = sticker_sets.sets[0]
|
|
|
|
|
|
|
|
# Get the stickers for this sticker set
|
|
|
|
stickers = client(GetStickerSetRequest(
|
|
|
|
stickerset=InputStickerSetID(
|
|
|
|
id=sticker_set.id, access_hash=sticker_set.access_hash
|
|
|
|
)
|
|
|
|
))
|
|
|
|
|
|
|
|
# Stickers are nothing more than files, so send that
|
|
|
|
client.send_file('me', stickers.documents[0])
|
2017-11-19 19:56:05 +03:00
|
|
|
|
|
|
|
|
|
|
|
.. _issues: https://github.com/LonamiWebs/Telethon/issues/215
|