Answer the question
In order to leave comments, you need to log in
How to get photo from user via pyTelegramBotAPI?
Hello.
I'm trying to achieve this logic from the Telegram bot (I use the desktop version of the client):
import telebot
bot_token = '1279****77:AAHJDPFJ************KJfLbiI'
bot = telebot.TeleBot(bot_token, parse_mode='html')
photo_list = []
@bot.message_handler(commands=['start'])
def send_welcome(message):
send = bot.send_message(message.from_user.id, 'Send your pics...')
bot.register_next_step_handler(send, get_user_pics)
return
@bot.message_handler(content_types=['photo'])
def get_user_pics(message):
if message.photo[-1].file_id not in photo_list:
photo_list.append(message.photo[-1].file_id)
if len(photo_list) == 1:
send = bot.send_message(message.from_user.id, "Photos received...")
bot.register_next_step_handler(send, process_messages())
return
def process_messages():
print(photo_list)
return
bot.polling()
Answer the question
In order to leave comments, you need to log in
According to the idea with this code, the bot will exit after the first photo....
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question