mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-12-04 23:33:46 +03:00
Created Sending stickers (markdown)
parent
7c170ced0f
commit
bc45656623
28
Sending-stickers.md
Normal file
28
Sending-stickers.md
Normal file
|
@ -0,0 +1,28 @@
|
|||
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:
|
||||
|
||||
```python
|
||||
# Get all the sticker sets this user has
|
||||
sticker_sets = client(GetAllStickersRequest(0))
|
||||
|
||||
# Choose a sticker set
|
||||
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(SendMediaRequest(
|
||||
peer=client.get_me(),
|
||||
media=InputMediaDocument(
|
||||
id=InputDocument(
|
||||
id=stickers.documents[0].id,
|
||||
access_hash=stickers.documents[0].access_hash
|
||||
),
|
||||
caption=''
|
||||
)
|
||||
))
|
||||
```
|
Loading…
Reference in New Issue
Block a user