reply_markup #152558
Unanswered
asia-dig
asked this question in
API and Webhooks
reply_markup
#152558
Replies: 1 comment
-
Hi @asia-dig, thanks for being a part of the GitHub Community! You are more likely to get a useful response if you share more information about what your code is about and how you need help, if that's what you're looking for. Giving a few more details might help someone give you a nudge in the right direction. 😄 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Update
from telegram.ext import Updater, CommandHandler, CallbackQueryHandler, CallbackContext
def start(update: Update, context: CallbackContext) -> None:
keyboard = [
[InlineKeyboardButton("Option 1", callback_data='1')],
[InlineKeyboardButton("Option 2", callback_data='2')]
]
reply_markup = InlineKeyboardMarkup(keyboard)
update.message.reply_text("Choose an option:", reply_markup=reply_markup)
def button(update: Update, context: CallbackContext) -> None:
query = update.callback_query
query.answer()
query.edit_message_text(text=f"Selected option: {query.data}")
updater = Updater("YOUR_BOT_TOKEN")
updater.dispatcher.add_handler(CommandHandler("start", start))
updater.dispatcher.add_handler(CallbackQueryHandler(button))
updater.start_polling()
updater.idle()
Beta Was this translation helpful? Give feedback.
All reactions