Answer the question
In order to leave comments, you need to log in
How to split bot files?
def get_class(message):
if str(message.text) == '11':
bot.send_message(message.chat.id,'Загрузите фотографию 11')
bot.register_next_step_handler(message, get_photo11)
elif str(message.text) == '10':
bot.send_message(message.chat.id,'Загрузите фотографию 10')
bot.register_next_step_handler(message, get_photo10)
elif str(message.text) == '9':
bot.send_message(message.chat.id,'Загрузите фотографию 9')
bot.register_next_step_handler(message, get_photo9)
elif str(message.text) == '8':
bot.send_message(message.chat.id,'Загрузите фотографию 8')
bot.register_next_step_handler(message, get_photo8)
elif str(message.text) == '7':
bot.send_message(message.chat.id,'Загрузите фотографию 7')
bot.register_next_step_handler(message, get_photo7)
elif str(message.text) == '6':
bot.send_message(message.chat.id,'Загрузите фотографию 6')
bot.register_next_step_handler(message, get_photo6)
elif str(message.text) == '5':
bot.send_message(message.chat.id,'Загрузите фотографию 5')
bot.register_next_step_handler(message, get_photo5)
Answer the question
In order to leave comments, you need to log in
Read about modules. And specifically your example, without any checks
def get_class(message):
if int(message.text) in range(5, 12):
bot.send_message(message.chat.id, f'Загрузите фотографию {message.text}')
bot.register_next_step_handler(message, globals()[f'get_photo{message.text}'])
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question