-2
我的电报bot如何下载用户没有Telegram bot Api发送给它的照片? (IM使用pyTelegramBotAPI)没有Telegram bot api的下载照片
我的电报bot如何下载用户没有Telegram bot Api发送给它的照片? (IM使用pyTelegramBotAPI)没有Telegram bot api的下载照片
如果您正在使用pyTelegramBotAPI您可以使用此代码:
@bot.message_handler(content_types=['photo'])
def handle_photo(message):
raw = message.photo[2].file_id
name = raw+".jpg"
file_info = bot.get_file(raw)
downloaded_file = bot.download_file(file_info.file_path)
with open(name,'wb') as new_file:
new_file.write(downloaded_file)