如何通过 Telegram Bot 发送大文件?

How to send large files through Telegram Bot?

我一直在研究一个可以向用户发送视频(大部分大于 500mb)的机器人。 我已经阅读了电报机器人 api 文档。有 50MB 和 videos/animations/documents 的限制。 在最近的变化中,Telegram 宣布现在机器人可以发送最大 2000 MB 的文件。

我正在使用 Python Telegram Bot 包装器。我尝试使用直接 url 和目录发送视频。但它失败并显示文件大小限制错误。 我还尝试向 Telegram Bot API 发送请求。失败了。

有很多机器人上传文件高达 2GB,那么,我的问题是如何上传文件?

正如@valijon 在此 answer you could also try to send files through InputStream, http url and cached file IDs. Also, I'd recommend you to take a look at Pyrogram 中所指出的:

# Keep track of the progress while uploading
def progress(current, total):
    print(f"{current * 100 / total:.1f}%")

app.send_video("me", "video.mp4", progress=progress)