Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. HELP = range(1)
  2.  
  3. def start(bot, update):
  4. keyboard = [
  5. [InlineKeyboardButton('Help', callback_data='help')]
  6. ]
  7.  
  8. # Create initial message:
  9. message = 'Welcome.'
  10.  
  11. update.message.reply_text(message, reply_markup=InlineKeyboardMarkup(keyboard))
  12.  
  13. def help(bot, update):
  14.  
  15. keyboard = [
  16. [InlineKeyboardButton('Help', callback_data='help')]
  17. ]
  18.  
  19. bot.edit_message_text(
  20. text='Help ... help..',
  21. chat_id=update.callback_query.message.chat_id,
  22. message_id=update.callback_query.message.message_id,
  23. reply_markup=InlineKeyboardMarkup(keyboard)
  24. )
  25. bot.answer_callback_query(update.callback_query.id, text='')
  26.  
  27. def unknown(bot, update):
  28.  
  29. message = 'Please press the Help button for more instructions.'
  30.  
  31. keyboard = [
  32. [InlineKeyboardButton('Help', callback_data='help')]
  33. ]
  34.  
  35. update.message.reply_text(message, reply_markup=InlineKeyboardMarkup(keyboard))
  36.  
  37.  
  38.  
  39. # Create the EventHandler and pass it your bot's token.
  40. updater = Updater(token=config.TELEGRAM_API_TOKEN)
  41.  
  42. # Get the dispatcher to register handlers:
  43. dispatcher = updater.dispatcher
  44.  
  45. dispatcher.add_handler(CommandHandler('start', start))
  46. dispatcher.add_handler(CallbackQueryHandler(help, pattern='help'))
  47. dispatcher.add_handler(MessageHandler(Filters.all, unknown))
  48.  
  49. updater.start_polling()
  50.  
  51. updater.idle()
  52.  
  53. sent_message = update.message.reply_text(
  54. message,
  55. reply_markup=InlineKeyboardMarkup(keyboard)
  56. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement