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

时间:2021-07-29 16:28:47

标签: telegram telegram-bot python-telegram-bot py-telegram-bot-api

我一直在开发一个可以向用户发送视频(大部分大于 500mb)的机器人。 我已经阅读了电报机器人 API 文档。有 50MB 的限制,包括视频/动画/文档。 在最近的变化中,Telegram 宣布现在机器人可以发送高达 2000 MB 的文件。

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

有许多机器人将文件上传到 2GB,那么,我的问题是如何做到这一点?

1 个答案:

答案 0 :(得分:0)

正如@valijon 在此 answer 中所指出的,您还可以尝试通过 InputStream、http url 和缓存的文件 ID 发送文件。另外,我建议您看看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)
相关问题