P
P
p2g2022-04-16 22:31:54
Python
p2g, 2022-04-16 22:31:54

How to connect user selection in InlineKeyboard?

How to connect user selection in InlineKeyboard ?

@bot.message_handler(content_types = ["text"])
def new_obmen(message):
    if message.chat.type == 'private':
        if message.text == 'Цифры':


            markup = types.InlineKeyboardMarkup(row_width=2)
            item1 = types.InlineKeyboardButton("1", callback_data='b')
            item2 = types.InlineKeyboardButton("2", callback_data='l')


            markup.add(item1, item2)

            bot.send_message(message.chat.id, 'Совокупность!', reply_markup=markup)

@bot.callback_query_handler(func=lambda c: True)
def callback_inline(call):
    try:
        if call.message:
            if call.data == 'b':

                bot.send_message(call.message.chat.id, '✅Ага "1" был выбран')

            if call.data == "l":            

                bot.send_message(call.message.chat.id,  text="✅Ага '2' был выбран")


             
                markup = types.InlineKeyboardMarkup(row_width=2)
                item1 = types.InlineKeyboardButton("3", callback_data='bitcoin')
                item2 = types.InlineKeyboardButton("4", callback_data='litcoin')

                markup.add(item1, item2)

                bot.send_message(call.message.chat.id, 'Как получить ответ?', reply_markup=markup)

    except Exception as e:
        print(repr(e))

Here's how it happened:
625b1872affd8261545021.png

Here's how:
625b18a2a0923479565491.png
Here I chose two InlineKeyboard directions and the bot remembered them and combined them into one message.
Please tell me how to do it?

Thanks in advance!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question