def handle_message(message):
if message.text == "/start":
bot.send_message(message.from_user.id, "Привет, я бот для оброботки фото. Пришли фото для его обработки")
elif message.text == "/help":
bot.send_message(message.from_user.id, "Нажми /start")
else:
photo=message.photo[-1]
file_info = bot.get_file(photo.file_id)
downloaded_file = bot.download_file(file_info.file_path)
save_path = 'photo.png'
with open(save_path, 'wb') as new_file:
new_file.write(downloaded_file)
bot.reply_to(message, 'Фотография сохранена.')
im = Image.open("photo.png")
out = im.resize(size)
out.save('photoresize.png')
with open('photoresize.png', 'rb') as f:
bot.send_photo(message.from_user.id, f)
TypeError
'NoneType' object is not subscriptable
File "C:\Users\Administrator\Desktop\Bot\Bot.py", line 21, in handle_message
photo=message.photo[-1] # Сохранение фото на ваш компьютер
File "C:\Users\Administrator\Desktop\Bot\Bot.py", line 35, in
bot.polling()
TypeError: 'NoneType' object is not subscriptable
if message.photo:
photo = message.photo[-1]
# other code
else:
bot.reply_to(message, 'Гони фотку.')