Developing a Telegram bot: How can I implement an inline query switch (similar to switch_pm) for selecting chats and returning to the bot? Code sample below:
from telegram import InlineKeyboardButton, InlineKeyboardMarkup
from telegram.ext import CommandHandler, CallbackQueryHandler
def initiate_inline(update, context):
buttons = [[InlineKeyboardButton('Choose', switch_inline_query_current_chat='')]]
markup = InlineKeyboardMarkup(buttons)
update.message.reply_text('Select an option:', reply_markup=markup)
def process_response(update, context):
callback = update.callback_query
callback.answer()
callback.edit_message_text(text=f'Selected: {callback.data}')
dispatcher.add_handler(CommandHandler('start', initiate_inline))
dispatcher.add_handler(CallbackQueryHandler(process_response))