My source is telebot lib and I am writing in Python 3.11.5
I want to have a Go Back button when I click on the support button and be able to go back the previous buttons
contact_sup_markup = telebot.types.ReplyKeyboardMarkup(resize_keyboard=True)
contact_sup_button = telebot.types.KeyboardButton('contact support')
contact_sup_markup.add(contact_sup_button)
@bot.message_handler(func= lambda m: m.text == 'contact support')
def contact_support(message):
bot.send_message(chat_id= message.chat.id, text= f'<b>You can now texted support admin bot</b>', parse_mode="HTML")
bot.set_state(user_id= message.from_user.id, state= Support.text, chat_id= message.chat.id)
I want to have a button called back after clicking the Contact Support button, I need how to write the code
To add a "Go Back" button after clicking the "Contact Support" button, you can modify your code as follows:
In this code, we first create a custom keyboard markup go_back_markup with a "Go Back" button row. We assign this markup to the reply_markup parameter when sending the message to the user after clicking the "Contact Support" button.
We also add a new message handler for the "Go Back" button. When the user clicks the "Go Back" button, it will trigger this message handler. In the handler, we send a message to the user and provide the contact_sup_markup as the reply_markup parameter to display the original menu with the "Contact Support" button. We also clear the current state from the user's session to go back to the previous state.
With this code, when the user clicks the "Contact Support" button, they will be presented with the option to go back by clicking the "Go Back" button.