S
S
Sanezek2017-08-16 07:37:08
Python
Sanezek, 2017-08-16 07:37:08

Is it possible with KeyboardButton to send something like callback_data to InlineKeyboardButton?

I have a field of buttons with the same text, but which should execute different commands, I didn’t find this in the api itself and didn’t see it in bots, but maybe someone traded like that?
PS I write on telepot

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Berloga, 2017-08-24
@Berloga

In general, no. For bots with a "wide" answer tree or with expectation of input, a flat text-based validation system is not suitable.
There is a bad and a good way to get around these:
- bad - insert a unique emoji / unique set of whitespace characters and emulate payload data in this way (does not solve the problem with waiting for input)
- introducing FSM - you need to store the telegram_id -> state link, where state is the state, stage; and every time a new message arrives, get the user's state, and process it according to the state, and then switch the state to the next one. Thus, message processing depends not only on the content of the message (as it is now), but also on some parameter, which allows you to branch the menu structure and add input waiting

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question