D
D
DUDE2019-12-19 23:28:28
Python
DUDE, 2019-12-19 23:28:28

How to use InlineKeyboard?

Hello everyone, I've run into a problem. I am using the TELEBOT library . This is how I create the keyboard:

def admin_keyboard(message):
    ...
    keyboard = types.InlineKeyboardMarkup()
    keyboard.add(
        types.InlineKeyboardButton(text='Edit message', callback_data='edit_message_callback'),
        types.InlineKeyboardButton(text='Foo', callback_data='foo_callback')
    )
    BOT.send_message(message.chat.id, "First message", reply_markup=keyboard)

@BOT.callback_query_handler(func=lambda call: True)
def callback_data_handler(call):
    ...
    if call.data == 'edit_message_callback':
        for some in some_list:
            keyboard.add(
                types.InlineKeyboardButton(text='Foo foo', callback_data='foo_foo_callback')
            )

Yes, writing processing in a function in callback_data_handler, well, that's understandable too. The question is: how can I change the message above the buttons and bring up another keyboard for a specific callback?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
DUDE, 2019-12-20
@stympel

Figured out how to fix the problem. Let there be a callback, I process it with some function as follows:
Where call is the argument coming to the handler function.

S
Seva Shpun, 2019-12-20
@SevaShpun

Here I think you will find the answer.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question