How can I remove inline keyboard after click?

12,760

Solution 1

Just in case you are using telebot, one option could be using one_time_keyboard=True parameter to hide button once it's clicked.

keyboard = types.ReplyKeyboardMarkup(row_width=1, resize_keyboard=True, one_time_keyboard=True)

Solution 2

You'll need to edit the message. Use the method editMessageReplyMarkup

Send reply_markup parameter as null.

Share:
12,760
Alex Nikitin
Author by

Alex Nikitin

Updated on June 22, 2022

Comments

  • Alex Nikitin
    Alex Nikitin almost 2 years

    My bot sends a pick with 2 inline callback buttons: like / dislike. After a user clicks on like or dislike button, I want this inline keyboard to disappear.

    This is how I make a dislike button

     dislike_button =types.InlineKeyboardButton (text=emojize("Dislike :broken_heart:", use_aliases=True), callback_data='dislike')
        keyboard.add(dislike_button)
    

    And this is how handle click on this button

    @bot.callback_query_handler(func=lambda call: True)
    def query_handler(call):
    
       if call.data == 'dislike':
          bot.answer_callback_query(callback_query_id=call.id, text='you disliked it!')
    

    How can I make this buttons to disappear after the click? Or how can I make impossible to click on this like or dislike button again?