Issue
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?
Solution
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])
Answered By - Родион Мороз
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.