[英]Send large video file by file_id with telegram bot
I'm using python and telebotAPI for my bot and I noticed that the command bot.send_video(chat_id, open(file_name, 'rb'))
only sends videos smaller than 10mb, is there a way to send very large video files?我正在为我的机器人使用 python 和 telebotAPI,我注意到命令
bot.send_video(chat_id, open(file_name, 'rb'))
只发送小于 10mb 的视频,有没有办法发送非常大的视频文件?
UPDATE: After some comments I read in the telegram documentation: if the file is already stored somewhere on the Telegram servers, you don't need to reupload it: each file object has a file_id field, simply pass this file_id as a parameter instead of uploading.更新:在我在电报文档中阅读了一些评论后:如果文件已经存储在电报服务器上的某个位置,则无需重新上传:每个文件 object 都有一个 file_id 字段,只需将此 file_id 作为参数传递,而不是上传。 There are no limits for files sent this way.
以这种方式发送的文件没有限制。 So how I can send a video to the telegram server and then send the file_id to the chat?
那么如何将视频发送到电报服务器,然后将 file_id 发送到聊天室?
There is an attribute in send_video function as 'timeout'. send_video function 中有一个属性为“超时”。 By default timeout is 20s.
默认超时为 20 秒。 If you need more time for sending your video, set it at your desired time in seconds.
如果您需要更多时间来发送视频,请将其设置为您想要的时间(以秒为单位)。 For example:
例如:
bot.send_video(chat_id='receiver chat id', video=open(file_name, 'rb')), timeout=10000)
Good Luck!祝你好运!
To send using 'file_id' - for example, send file to the bot, the bot will trigger callback, find the remoteFile there, and take id - it will look something like this使用 'file_id' 发送 - 例如,向机器人发送文件,机器人将触发回调,在那里找到 remoteFile,并获取 id - 它看起来像这样
AAMCAgADGQEAAqCnXv7lHCkd-2Br08TSugdUR45LVyIAAnoIABJctPlLDk4X8ug8tDcaMSmVLgADAQAHbQADoKoAAhgE
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.