问题描述
我正在编写一个 Telegram 机器人,我想让它发送一个贴纸.
I'm writing a Telegram bot and I want it to send a sticker.
据说这里,要发送 Telegram 服务器上已经存在的贴纸,我们可以简单地通过 file_id.问题是,我完全不知道如何获取任何贴纸的 file_id.例如.我如何发送Greater Minds 包中的任何贴纸?我想,这个包在 Telegram 服务器上,因为它们包含在每个应用程序中.
It is said here, that to send a sticker that already exists on Telegram servers we can simply pass file_id. The thing is, I have absolutely no idea how to obtain file_id of any sticker. E.g. how do I send any sticker from Greater Minds pack? I suppose, this pack is on Telegram servers since they include it in every app.
推荐答案
发现贴纸的file_id
:
将 Telegram 应用中的贴纸发送到您的机器人.
Send the sticker from Telegram App to your bot.
使用机器人的 getUpdates
方法接收贴纸.您应该会在消息中看到贴纸的 file_id
.
Use the bot's getUpdates
method to receive the sticker. You should see the sticker's file_id
in the message.
您的机器人可能会使用该 file_id
将相同的贴纸发送给其他用户.当心;在消息中有一个 thumb
字段,它也有一个 file_id
.不要不要使用那个来发送贴纸.它不会工作.
Your bot may use that file_id
to send the same sticker to another user. Be careful; in the message there is a thumb
field, which also has a file_id
. Do not use that one to send the sticker. It won't work.
您可能知道的另一种可能性是,您始终可以将贴纸图像下载到磁盘文件,然后将该文件用作 sendSticker
sticker 参数> 方法,相当于上传文件.
Another possibility, of which you may be aware, is that you can always download the sticker image to a disk file, then use that file as the sticker
parameter for sendSticker
method, equivalent to uploading the file.
这篇关于电报,获取现有贴纸的 file_id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!