I am coding a Telegram bot in Python and was wondering how I could get or store the value of the "text" key when I press a button in in my bot instance. As I want to use it to adapt the displayed message in the next called function (I hope that it's clear...)
My current code is this:
def live_main(update: Update, context: CallbackContext) -> None:
query = update.callback_query
query.answer()
keyboard = [
[
InlineKeyboardButton("1", callback_data=str(LIVE)),
InlineKeyboardButton("2", callback_data=str(LIVE))
],
[InlineKeyboardButton("Back", callback_data=str(STARTOVER))]
]
reply_markup = InlineKeyboardMarkup(keyboard)
query.edit_message_text(
text="How many people will attend the live session?", reply_markup=reply_markup
)
return FIRST
def live(update: Update, context: CallbackContext) -> None:
query = update.callback_query
query.answer()
keyboard = [
[InlineKeyboardButton("Btc", callback_data=str(PAYLIVE))],
[InlineKeyboardButton("Paypal", callback_data=str(PAYLIVE))],
[InlineKeyboardButton("Back", callback_data=str(LIVEM))]
]
reply_markup = InlineKeyboardMarkup(keyboard)
query.edit_message_text(
text="Price for {**CallbackQuery.text**} { is {price_live/**CallbackQuery.text**)} USD or the equivalent in crypto-currencies. Please, choose your payment method. (And to be perfectly honest, we prefer crypto...)", reply_markup=reply_markup
)
return FIRST
So as you can see, I want to use either the "1" or "2" value from the live_main function inside the live function (where I put the CallbackQuery.text placeholders). I hope someone can help. Regards