Posts

Showing posts with the label python-telegram-bot

How to receive images from Telegram Bot [duplicate]

How to receive images from Telegram Bot [duplicate] This question already has an answer here: Can't receive images from my telegram bot, trying something like this: import telegram from telegram.ext import Updater from telegram.ext import MessageHandler from telegram.ext import Filters def photo_handler(bot, update): file = bot.getFile(update.message.photo.file_id) print ("file_id: " + str(update.message.photo.file_id)) file.download('photo.jpg') updater = Updater(token='my token') dispatcher = updater.dispatcher dispatcher.add_handler(MessageHandler(Filters.photo, photo_handler)) No any errors while running This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question. I already answered this question how save photo in telegram python bot?. First line in photo_handler needs to be file = bot.getFile(update.message.photo[-1].file_id).