Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tolgahanuzun/a626fce8497e5e85f23fc525abdbcf84 to your computer and use it in GitHub Desktop.
Save tolgahanuzun/a626fce8497e5e85f23fc525abdbcf84 to your computer and use it in GitHub Desktop.
from telegram import InlineKeyboardButton, InlineKeyboardMarkup
from telegram.ext import Updater, CommandHandler, CallbackQueryHandler
def start(update, context):
keyboard = [[InlineKeyboardButton("Option 1", callback_data='1'),
InlineKeyboardButton("Option 2", callback_data='2')],
[InlineKeyboardButton("Option 3", callback_data='3')]]
reply_markup = InlineKeyboardMarkup(keyboard)
update.message.reply_text('Please choose:', reply_markup=reply_markup)
def button(update, context):
query = update.callback_query
query.answer()
query.edit_message_text(text="Selected option: {}".format(query.data))
def help(update, context):
update.message.reply_text("Use /start to test this bot.")
def main():
updater = Updater("88", use_context=True)
updater.dispatcher.add_handler(CommandHandler('start', start))
updater.dispatcher.add_handler(CallbackQueryHandler(button))
updater.dispatcher.add_handler(CommandHandler('help', help))
updater.start_polling()
updater.idle()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment