How to send stickers using the id (string) in telethon

Viewed 1432

Is there any method to send stickers using the id attribute of event.file? The documentation points out to send it using the id and the access_hash of a particular sticker set and then finally using index with sticker_set to send the sticker. Since there's unique id for particular sticker stored in telegram servers, I was wondering if there's any method of using that to send stickers?

1 Answers
from telethon.tl.functions.messages import GetAllStickersRequest
sticker_sets = await 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 = await client(GetStickerSetRequest(
    stickerset=InputStickerSetID(
        id=sticker_set.id, access_hash=sticker_set.access_hash
    )
))

# Stickers are nothing more than files, so send that
await client.send_file('me', stickers.documents[0])
Related