【问题标题】:How to send large files through Telegram Bot?如何通过 Telegram Bot 发送大文件?
【发布时间】:2021-07-29 16:28:47
【问题描述】:

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

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

有很多机器人正在上传文件高达 2GB,那么,我的问题是如何做到这一点?

【问题讨论】:

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


    【解决方案1】:

    正如@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)
    

    【讨论】:

    • 非常感谢。像魅力一样工作。
    猜你喜欢
    • 2019-08-23
    • 1970-01-01
    • 2019-02-16
    • 2019-11-18
    • 1970-01-01
    • 1970-01-01
    • 2017-06-06
    • 1970-01-01
    • 2021-05-09
    相关资源
    最近更新 更多