【问题标题】:how to send image from url using telethon如何使用 telethon 从 url 发送图像
【发布时间】:2022-12-01 05:48:29
【问题描述】:

我想知道如何从 URL 链接发送图像或媒体,

file = BOT.upload_file('/user/home/photo.jpg')
BOT.send_file(chat , file)

我知道使用这种方法我们可以从路径发送图像,但我想知道是否可以从 URL 链接发送图像。但我正在尝试在 Heruku 上运行代码,因此无法从补丁上传它,所以如果有办法使用 URL 链接发送它,请告诉我该怎么做。

谁能帮我解决这个问题。

【问题讨论】:

    标签: python python-telegram-bot telethon


    【解决方案1】:

    1-您不必明确上传文件,telethon 会在内部上传文件,因此:

    BOT.send_file(chat , '/user/home/photo.jpg')
    

    足够的

    2- 您可以将 URL 传递给 send_file,Telegram 服务器将获取并发送它(注意文件大小有限制,具体请查看官方 bot-api 文档)

    BOT.send_file(chat , url)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-04-11
      • 1970-01-01
      • 1970-01-01
      • 2016-11-01
      • 2013-07-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多