0
0
0NordWind02021-08-21 20:54:49
Python
0NordWind0, 2021-08-21 20:54:49

How to configure the functionality of inline buttons in telegram?

A little about myself :)
telebot, pytelegrambotapi. Python 3.9.5.

I faced the following task: there is a bot, there is a menu consisting of a message and two inline buttons attached to it. It is necessary that the message after pressing one of these buttons is deleted and a new one is created, or changed. And it should be deleted and created or simply changed to a similar message with inline buttons, but one of the buttons should return everything back. BACK.

Thinking people, tell me what I can use for this, maybe the next_step_handlers handler or some other tricky schemes.
Ultimately attached photos with an example for easier understanding
61213cb932873166445699.png
61213cc1635d8888697841.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Krostelev, 2021-08-21
@0NordWind0

You can enter the necessary information in the callback data of each button, such as what menu level it is or what section it is. For example, create a dictionary in which you will write all this data and convert it to a JSON string. You will pass this line to callback data. And in the button click handler, you collect a dictionary from this JSON string back and dance from this data.
It's better to just change the message, because. Messages can only be deleted within 48 hours.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question