S
S
SashaN692021-03-31 15:03:07
CMS
SashaN69, 2021-03-31 15:03:07

How to get the text of the message to which the inline keyboard is attached?

How to get the text of a message that has an inline keyboard attached to it?
I tried this but it only works if after sending the message to restart the bot

@dp.callback_query_handler(lambda c: c.data == 'button8')
async def process_callback_button1(callback_query: types.CallbackQuery):
    await bot.send_message(callback_query.from_user.id, callback_query['message']['text'])

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sanes, 2018-04-17
@Sanes

Self-made.

M
MinTnt, 2021-03-31
@SashaN69

Well, since callback_query.message.text does not show, then the maximum is still possible: 1) Store messages separately somewhere in the database. 2) When creating an inline button, set the callback value = text value + some kind of separator character set + other important callback info. For example callback = "Hello everyone/asdgse/StartTime". And then, when reading, you can get the text through .split('/asdgse/'), as a set of separator characters.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question