【问题标题】:Bot can't send channel photo by file_idBot 无法通过 file_id 发送频道照片
【发布时间】:2018-04-09 21:25:12
【问题描述】:

我使用python,这里有一个问题。首先我以get_chat方法获取图片聊天的file_id为例。

import telebot
bot = telebot.TeleBot("xxxxxxxxxxxxxxxxxxxxxxxx")
s = bot.get_chat('@codygarbrandt_best')
print(s.photo.big_file_id)

那我想把这张照片发给自己。

bot.send_photo(my_chat_id , s.photo.big_file_id )

但我收到以下错误。

错误请求:文件类型不匹配

我记得它以前工作过,我现在怎样才能做到这一点?

【问题讨论】:

  • type(s.photo.big_file_id) 是什么?
  • 它是一种照片类型,以及这张照片的 big_file_id
  • 当然那是照片的id...我问的是具体类型,你可以用print(type(s.photo.big_file_id))查看。
  • 对不起,这是一个字符串

标签: python telegram telegram-bot


【解决方案1】:

big_file_id可以通过get_chat方法读取,只能用于下载图片。
您必须自己将文件存储在本地,然后重新发送。

大 (640x640) 聊天照片的唯一文件标识符。此 file_id 只能用于照片下载。 [doc]

【讨论】:

    猜你喜欢
    • 2017-06-06
    • 1970-01-01
    • 2018-11-27
    • 2016-08-12
    • 1970-01-01
    • 1970-01-01
    • 2021-09-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多