【问题标题】:How to upload file using multipart/form-data through python for telegram bot如何通过 python 为电报机器人使用 multipart/form-data 上传文件
【发布时间】:2020-10-06 13:10:30
【问题描述】:

我正在通过 google colab 在 python 中制作一个简单的电报机器人,并希望通过 sendVoice 方法上传语音笔记,并希望电报客户端将文件显示为可播放的语音消息。为此,我从 Telegram bot API 手册中发现,我必须使用 multipart/form-data 将音频上传到 bot。 这个 multipart/form-data 是什么,我如何通过 sendVoice 方法上传和使用它。

谢谢。

【问题讨论】:

    标签: python telegram-bot python-telegram-bot


    【解决方案1】:

    可以通过telebot通过以下方式发送文件,您无需担心表单数据。

        f = open('file_path', 'rb')
        bot.send_audio(chat_id, f)
    

    【讨论】:

      猜你喜欢
      • 2017-10-13
      • 2016-12-14
      • 1970-01-01
      • 2019-08-27
      • 1970-01-01
      • 2018-03-28
      • 2015-10-23
      • 1970-01-01
      • 2014-05-28
      相关资源
      最近更新 更多