Не срабатывает message_hendler
Перестает работать на третьем вызове message_handler
@bot.message_handler(commands = ['start'])
def welcome(message):
chanel_markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
item1 = types.KeyboardButton("Сделать пост")
item2 = types.KeyboardButton("Пока ХЗ что сделать")
chanel_markup.add(item1, item2)
bot.send_message(message.chat.id, "Добро пожаловать", {0}, reply_markup=chanel_markup)
@bot.message_handler(content_types = ['text'])
def what_you_want(message):
if message.text == 'Сделать пост':
markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
item1 = types.KeyboardButton("канал1")
item2 = types.KeyboardButton("канал2")
item3 = types.KeyboardButton("какой-то третий канал")
markup.add(item1, item2, item3)
print("Перед вопросом")
bot.send_message(message.chat.id, "Для какого канал? \n\n1)канал1 \n2)канал2 \n3)какой-то третий канал", {0}, reply_markup=markup)
print("После вопроса")
@bot.message_handler(content_types = ['text']) #здесь перестает работать , ошибок в консоли нет
def postmessage(message):
print("Ответ поймал")
# RUN
bot.polling(none_stop=True)
Ответы (1 шт):
Автор решения: iwacam
→ Ссылка
msg = bot.send_message(message.chat.id, "Для какого канал? \n\n1)канал1 \n2)канал2 \n3)какой-то третий канал", {0}, reply_markup=markup)
print("После вопроса")
bot.register_next_step_handler(msg, postmessage)