@bot.message_handler(commands=['reg'])
def user_reg(message):
msg = bot.send_message(message.chat.id, "Введите ваше имя:")
bot.register_next_step_handler(msg, process_firstname_step)
def process_firstname_step(message):
try:
user_id = message.from_user.id
user_data[user_id] = User(message.text)
msg = bot.send_message(message.chat.id, "Введите фамилию:")
bot.register_next_step_handler(msg, process_lastname_step)
except Exception as e:
msg = bot.reply_to(message, 'Ошибка')
bot.register_next_step_handler(msg, process_firstname_step)
def process_lastname_step(message):
try:
user_id = message.from_user.id
user = user_data[user_id]
user.last_name = message.text
photo = open('img/tg.jpg', 'rb')
msg = bot.send_photo(message.chat.id, photo, "Отправьте фотографию ПРИМЕРЕ ↑↑↑")
photo.close()
bot.register_next_step_handler(msg, process_photo_step)
except Exception as e:
msg = bot.reply_to(message, 'Вы ввели что то другое.')
bot.register_next_step_handler(msg, process_lastname_step)
def process_photo_step(message):
try:
if message.content_type == 'photo':
user_id = message.from_user.id
user = user_data[user_id]
user.photo_id = message.photo[-1].file_id
msg = bot.send_message(message.chat.id, "Введите описание")
bot.register_next_step_handler(msg, process_descriprtion_step)
else:
bot.reply_to(message, 'Это не фотография, пожалуйста пришлите фото')
process_lastname_step(message)
except Exception as e:
bot.reply_to(message, 'Упссс2')
def process_descriprtion_step(message):
try:
user_id = message.from_user.id
user = user_data[user_id]
user.descriprtion = message.text
except Exception as e:
bot.reply_to(message, 'Это не описание')
bot.enable_save_next_step_handlers(delay=2)
bot.load_next_step_handlers()
if __name__ == '__main__':
while True:
try:
bot.polling(none_stop=True)
except:
sleep(0.3)
постоянно на последним шаге пишет 'Это не описание'
Может кто подсказать ?