Answer the question
In order to leave comments, you need to log in
How to write a button bot in Telegram in Python?
I understand how to set button options and enable the bot, but the next steps after using the last button are not clear.
import telebot
bot = telebot.TeleBot('мой токен')
keyboard1 = telebot.types.ReplyKeyboardMarkup(True, True)
keyboard2 = telebot.types.ReplyKeyboardMarkup(True, True)
keyboard1.row('А','Б')
keyboard2.row('1,'2')
@bot.message_handler(commands=['start'])
def start_message(message):
bot.send_message(message.chat.id, 'Привет. А или Б?',reply_markup=keyboard1)
@bot.message_handler(content_types=['text'])
def send_text(message):
if message.text.lower() == 'А':
bot.send_message(message.chat.id, '1 или 2?', reply_markup=keyboard2)
elif message.text.lower() == 'Б':
bot.send_message(message.chat.id, '1 или 2?',reply_markup=keyboard2)
bot.register_next_step_handler(message,data);
??
bot.polling()
Answer the question
In order to leave comments, you need to log in
Alternatively
if message.text == 'A':
bot.register_next_step_hendler(message, function1)
elif message.text == 'B':
bot.register_next_step_hendler(message, function2
)
Etc
converts the string to lowercase, and then compares it to an uppercase letter.
Doing so is not good.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question