Не выполняется кнопка в телеграмм боте на Python, в чём ошибка?
У меня такой код:
import telebot
from telebot import types
bot = telebot.TeleBot('') #Тут мой реальный код
str1 = types.ReplyKeyboardMarkup()
str2 = types.ReplyKeyboardMarkup()
btnD1 = types.KeyboardButton('№1')
btnD2 = types.KeyboardButton('№2')
btnD3 = types.KeyboardButton('№3')
btnD4 = types.KeyboardButton('№4')
btnD5 = types.KeyboardButton('№5')
btnD6 = types.KeyboardButton('№6')
btnD7 = types.KeyboardButton('№7')
btnD8 = types.KeyboardButton('№8')
btnD9 = types.KeyboardButton('№9')
btnD10 = types.KeyboardButton('№10')
btnL1 = types.KeyboardButton('1️⃣')
btnP1 = types.KeyboardButton('1️⃣⏩')
btnL2 = types.KeyboardButton('⏪2️⃣`')
btnP2 = types.KeyboardButton('2️⃣⏩')
str1.row(btnD1)
str1.row(btnD2)
str1.row(btnD3)
str1.row(btnD4)
str1.row(btnD5)
str1.row(btnL1, btnP1)
str2.row(btnD6)
str2.row(btnD7)
str2.row(btnD8)
str2.row(btnD9)
str2.row(btnD10)
str2.row(btnL2, btnP2)
@bot.message_handler(commands=['start'])
def main(message):
bot.send_message(message.chat.id, 'Привет!')
# time.sleep(2)
bot.send_message(message.chat.id, 'Внизу выведены кнопки', reply_markup=str1)
bot.register_next_step_handler(message, on_click)
def on_click(message):
if message.text == '️1️⃣⏩':
bot.send_message(message.chat.id, 'страница 2', reply_markup=str2)
bot.register_next_step_handler(message, on_click)
bot.polling(none_stop=True)
Только вот проблема, после нажатия кнопки 1️⃣⏩ в чат от меня выводится 1️⃣⏩ (ну как и должно быть), но бот не меняет страницы, т.е. он просто не реагирует, даже не пишет "страница 2" и не выводит никаких ошибок
Пишу я на пайшарме
Ответы (1 шт):
Автор решения: dvd5o
→ Ссылка
Решил проблему
Заменил
def on_click(message):
if message.text == '️1️⃣⏩':
bot.send_message(message.chat.id, 'страница 2', reply_markup=str2)
bot.register_next_step_handler(message, on_click)
bot.polling(none_stop=True)
на
@bot.message_handler(content_types=['text'])
def send_text(message):
if message.text == '1️⃣⏩':
bot.send_message(message.chat.id,'Страница 2', reply_markup=str2)