Skip to content

Instantly share code, notes, and snippets.

@intel777
Created March 25, 2020 11:26
Show Gist options
  • Select an option

  • Save intel777/bdf07746d5e15943cf73facba91bf5bc to your computer and use it in GitHub Desktop.

Select an option

Save intel777/bdf07746d5e15943cf73facba91bf5bc to your computer and use it in GitHub Desktop.
from telegram.ext import Updater, CallbackQueryHandler, CallbackContext
from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup
import random
import logging
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.DEBUG)
bot_token = %YOUR_BOT_TOKEN_HERE%
test_channel_id = %YOUR_TEST_CHANNEL_ID_HERE%
def get_test_keyboard():
return InlineKeyboardMarkup(
[
[InlineKeyboardButton(random.randint(1, 1000000000), callback_data='pressed')]
])
def handle(update: Update, context: CallbackContext):
update.callback_query.answer()
update.callback_query.edit_message_reply_markup(get_test_keyboard())
updater = Updater(bot_token, use_context=True)
updater.dispatcher.add_handler(CallbackQueryHandler(handle, pattern='pressed'))
updater.start_polling()
updater.bot.send_message(test_channel_id, 'YourTestMessage', reply_markup=get_test_keyboard())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment