Search code examples
pythontelegramtelebot

Telegram game bot


I'm trying to create a telegram game bot using python. In documentation it is said that the first button has to be the field callback_game in InlineKeyboardButton.

I have my game bot created already

@bot.message_handler(commands=['start'])
def send_game(message):
    user_id = message.chat.id
    
    game_url = f'https://myUrl'
    
    markup = types.InlineKeyboardMarkup(row_width=2)

    game_button = types.InlineKeyboardButton("Play Game", callback_game="your_game_data")
    markup.add(game_button)

    bot.send_game(user_id, game_short_name, reply_markup=None, disable_notification=True, timeout=false)

It opens the game page on my url but i have no idea how to create such button enter image description here


Solution

  • According to the docs, callback_game is just a placeholder to know that the button should open the game.[1] So it should be an empty object (or dictionary, in Python words).