如何在 telethon 中使用 id(字符串)发送贴纸
How to send stickers using the id (string) in telethon
有什么方法可以利用event.file的id属性发送贴纸吗?文档指出使用特定贴纸集的 id 和 access_hash 发送它,然后最后使用带有 sticker_set 的索引发送贴纸。由于电报服务器中存储了特定贴纸的唯一 ID,我想知道是否有任何方法可以使用它来发送贴纸?
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])
有什么方法可以利用event.file的id属性发送贴纸吗?文档指出使用特定贴纸集的 id 和 access_hash 发送它,然后最后使用带有 sticker_set 的索引发送贴纸。由于电报服务器中存储了特定贴纸的唯一 ID,我想知道是否有任何方法可以使用它来发送贴纸?
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])