Search code examples
telegram-botpython-telegram-bot

Python-Telegram-Bot How to allow for multiple callbackdata when using InlineKeyboard?


Is it possible for the user to click on multiple buttons, thereby appending all the callback_data into one single data set, and only quit the current state of a handler after clicking on the Done button?

My understanding so far is that you can only click on the buttons a single time which will send a single callback_data as the query.

def start(update, context):
    keyboard = [[InlineKeyboardButton("bal bla", callback_data='1'),
                 InlineKeyboardButton("bla bla", callback_data='2')],
                [InlineKeyboardButton("bla bla)", callback_data='3'),
                InlineKeyboardButton("bla bla", callback_data= '4')],
                [InlineKeyboardButton("bla bla", callback_data='5')],
                [InlineKeyboardButton("Done", callback_data='Done')]
]

    reply_markup = InlineKeyboardMarkup(keyboard)
    update.message.reply_text('Please choose:', reply_markup=reply_markup)

Solution

  • My understanding so far is that you can only click on the buttons a single time which will send a single callback_data as the query.

    That is correct. You can still design your code such that it saves all the selected data and only starts the next step when the user presses the Done button.