P
P
pprytkin2021-11-08 23:22:34
Python
pprytkin, 2021-11-08 23:22:34

Passing data to callback_data with pyTelegramBotAPI?

The essence of the problem:
There is a telegram bot written in python with the pyTelegramBotAPI library. When sending a message to the bot, the bot sends the user a question with two answer options, written in the form of an inline keyboard, when one of them is pressed, the initial text sent by the user is manipulated. The problem is that you need to pass the same text written by the user to the callback handler, but it’s impossible to pass it through callback_data, since the user’s text does not have to be short, and callback_data has weight restrictions, otherwise it swears and gives an error 400. What other way can I pass the given text from message.text to the callback handler?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
shurshur, 2021-11-09
@shurshur

You can simply remember the user's text, and pass some code designations of the buttons to be pressed to callback_data. When you receive a button code from the user, you can get the previously saved text by its id and perform all the necessary actions.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question