I am utilizing the Telebot library and encountering an issue. I want the button to update its text after the user submits their input. Here’s a sample code snippet:
bot.register_next_input_handler(user_message, handle_input)
@bot.message_handler(commands=['begin'])
def initiate(message):
keyboard = types.InlineKeyboardMarkup()
button1 = types.InlineKeyboardButton(text='Login', callback_data='button1')
keyboard.add(button1)
bot.send_message(message.chat.id, 'Menu:', reply_markup=keyboard)
def input_address(message):
keyboard = types.InlineKeyboardMarkup()
back_button = types.InlineKeyboardButton(text='↩ Back', callback_data='back_action')
keyboard.add(back_button)
bot.edit_message_text(chat_id=message.chat.id, message_id=message.id, text='Please enter your wallet address:', reply_markup=keyboard)
bot.register_next_input_handler(message, handle_input)
def handle_input(message):
keyboard = types.InlineKeyboardMarkup()
back_button = types.InlineKeyboardButton(text='↩ Back', callback_data='back_action')
keyboard.add(back_button)
bot.edit_message_text(chat_id=message.chat.id, message_id=message.id, text='You entered an invalid wallet address.', reply_markup=keyboard)
@bot.callback_query_handler(func=lambda call: call.data)
def on_button_click(call):
if call.data == 'button1':
input_address(call.message)
What changes do I need to implement to achieve this?