I’m trying to get input text from the user..
He arrive to the function after he interact with
keyboard = [[InlineKeyboardButton("exapmple", callback_data='example')]]
reply_markup = InlineKeyboardMarkup(keyboard)
so in update I’m getting callback_query
after he choose the button example I ask him for input text.
this work for me I get input with the button but not with his own input
def getInput(update, context):
query = update.callback_query
query.answer()
input = query.data
I want to get the input like
input = update.message.text
but since I get callback_query I don’t have the message..
so how I switch to message or get input with callback_query
edit:
I arrive to getInput with
dp.add_handler(CallbackQueryHandler(getInput, pattern='example'))
3
Answers
The response from a callback query is
If the user decides to type instead something then the message is processed as a default text message
If you want to get the text just after the user clicks the button, use ConversationHandler.
Docs: https://python-telegram-bot.readthedocs.io/en/stable/telegram.ext.conversationhandler.html
Example: https://github.com/python-telegram-bot/python-telegram-bot/blob/master/examples/conversationbot.py
def get_text_from_user(updater, context):
text = updater.message.text # <- this is text from user
print(text)
updater.dispatcher.add_handler(telegram.exe.MessageHandler(telegram.exe.Filters.text,get_text_from_user))