0

I'm trying to create a bot game with official PHP API that linked https://github.com/unreal4u/telegram-api

In this section, I am trying to send my own game with a play button. by this codes, my game will send by image and telegram default button. but I want to customise it and I want to send a response to the user when they pressed the button then run the game.

Here is the code

default:
    $keyboard = new Markup();


    $kk = new Button();
    $kk->callback_game;
    $kk->callback_data = 1;


    $keyboard->inline_keyboard[] = $kk;

    $game = new SendGame();
    $game->chat_id = $chatID;
    $game->game_short_name = "lumberjack";
    $game->reply_markup = $keyboard;
    $tgLog->performApiRequest($game);


    $cbquery = new CallbackQuery();
    if ($cbquery->game_short_name) {
        $call_id = $cbquery->id;
        // $call_message_id = $update->callback_query->message->message_id;
        $msg = "all acording the plan";

        $anscall = new AnswerCallbackQuery();
        $anscall->callback_query_id = $call_id;
        $anscall->text = $msg;
        $tgLog->performApiRequest($anscall);

    }
Sunil Garg
  • 14,608
  • 25
  • 132
  • 189

1 Answers1

0

for customize don't create e seperate inline keyboard, I believe the only way is to change this line: $game->reply_markup = $keyboard; and write something like JSON OBJECT instead of $keyboard

(GENERAL HELP) for nodejs it is like this, maybe for php is similar to it, because even for c# I found something similar to this: http://wimi5.com/how-to-create-a-gamebot-in-telegram-with-nodejs/

bot.sendGame(fromId, "TestGame", { reply_markup: JSON.stringify({

                      inline_keyboard: [

                          [ { text: "Play", callback_game: JSON.stringify( { game_short_name: "TestGame" } ) } ],

                          [ { text: "Share", url: "https://telegram.me/wimi5_bot?game=TestGame" } ]

                      ]

                  })

              });