S
S
Studentka19962020-08-13 20:41:12
Python
Studentka1996, 2020-08-13 20:41:12

How to properly implement list navigation in a chatbot?

Hello. There is a product output cycle, how to make product navigation. For example, I display one product (+ inline button(s)) and attach a "Next" button, clicking this button opens the next product, while updating the message (the first product). The "Back" button is the reverse action. I roughly understand that you need to use answerCallbackQuery() (although I may not understand it), but how ... How to implement it correctly ... Please help. Maybe there are other solutions ..

Something like a multi-level menu

for i in ['Товар1', 'Товар2', 'Товар3']:
       отправляю боту текст кнопок i + реплай кнопку Далее

I see the output of the buttons. You need to display one button, scrolling Next :) Interrupt, continue the cycle? I do not understand

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Krostelev, 2020-08-14
@Studentka1996

If I understand the essence of the question correctly, then here is a solution:
When creating inline buttons "Next" and "Back" in the callback data, write down the ID of the next and previous product, respectively. When you click on the button, just take the ID that is loaded into it, use it to access the database, pull out all the information about the product and the IDs of neighboring products. Do edit_message_text by changing the data in the message and filling inline buttons with new IDs.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question