There are 2 files: bot.py and feedback.py . I don’t understand why the last block doesn’t work, in bot.py , @bot.message_handler(func=lambda message... ? If you know, at least where to read, please help

bot.py :

 import telebot import feedback token = "Здесь токен" bot = telebot.TeleBot(token) @bot.message_handler(commands=['start']) def handle_start(message): keyboard = telebot.types.ReplyKeyboardMarkup(True, True) keyboard.row('/start') keyboard.row('Команда 1', 'Команда 2', 'Команда 3') keyboard.row('Обратная связь') bot.send_message(message.from_user.id, 'Добро пожаловать...', reply_markup=keyboard) @bot.message_handler(content_types = ['text']) def handle_text(message): if message.text != '': try: if message.text == 'Обратная связь': bot.send_message(message.from_user.id, 'Ваше имя:') feedback.set_state(message.from_user.id, feedback.States.S_ENTER_FIRSTNAME) except: return False @bot.message_handler(func=lambda message: feedback.get_state(message.from_user.id) == feedback.States.S_ENTER_FIRSTNAME) def user_entering_firstname(message): bot.send_message(message.from_user.id, "Введите фамилию:") feedback.set_state(message.from_user.id, feedback.States.S_ENTER_LASTNAME) bot.polling(none_stop=True, interval=0) 

feedback.py :

 import dbm from enum import Enum id_state = dbm.open('dbm/dbm_id_state', flag='c') class States(Enum): S_START = "0" # Начало нового диалога S_ENTER_FIRSTNAME = "1" S_ENTER_LASTNAME = "2" S_SEND_QUESTION = "3" def get_state(user_id): id_state = dbm.open('dbm/dbm_id_state', flag='c') try: return id_state[user_id] except: return States.S_START def set_state(user_id, new_state): id_state = dbm.open('dbm/dbm_id_state', flag='c') try: id_state[user_id] = new_state return True except: return False 
  • In what sense does not work? It gives an error, the wrong behavior? Indicate this in the question. If there is an error, then add a traceback - Mr Morgan
  • Already decided via reply_to () and register_next_step_handler () - Muhammad B.

0