javascripttelegram-bottelegraf

Telegram Bot: Game Did not start


I am trying to run my game inside telegram in-app browser.

Below are my code so far


bot.action('wheeloffortune', ctx => {
    bot.telegram.sendGame(ctx.chat.id, 'wheeloffortune');
})


bot.on("callback_query", function (query) {
    let gameurl = "https://dazzling-ritchie-f3ad20.netlify.app/?id="+query.id;
    bot.answerCallbackQuery({
        callback_query_id: query.id,
        url: gameurl
    });
});

bot.on("inline_query", function(iq) {
    bot.answerInlineQuery(iq.id, [ { type: "game", id: "0", game_short_name: 'wheeloffortune' } ] ); 
});

What I expect: after clicking the button 'Play wheeloffortune', the game should open in webview.

What is actually happening:

this image keep rendering

enter image description here

any advice is appreciated


Solution

  • According to the game example of telegraf:

    You can simply use:

    bot.gameQuery((ctx) => {
        let queryId = ctx.callbackQuery.id
        let gameurl = "https://dazzling-ritchie-f3ad20.netlify.app/?id="+queryId;
        ctx.answerGameQuery(gameUrl)
    })