TelegramPHP Documentation

GameApi

This file is generated from spec/openapi.json (Bot API 10.3) by tools/generate.php.

Do not edit it by hand - run composer spec:build instead.

HTML5 games and their high-score tables.

Mixed into Telegram through Methods. Every method is named exactly as the Bot API names it, takes exactly the fields the Bot API documents (use named arguments for the optional ones), and resolves with the hydrated result.

Tags
link
https://core.telegram.org/bots/api
since

v10.3

Table of Contents

Methods

getGameHighScores()  : PromiseInterface<string|int, Collection<string|int, GameHighScore>>
Use this method to get data for high score tables. Will return the score of the specified user and several of their neighbors in a game. Returns an Array of GameHighScore objects.
sendGame()  : PromiseInterface<string|int, Message>
Use this method to send a game. On success, the sent Message is returned.
setGameScore()  : PromiseInterface<string|int, Message|bool>
Use this method to set the score of the specified user in a game message. On success, if the message is not an inline message, the Message is returned, otherwise True is returned. Returns an error, if the new score is not greater than the user's current score in the chat and force is False.

Methods

getGameHighScores()

Use this method to get data for high score tables. Will return the score of the specified user and several of their neighbors in a game. Returns an Array of GameHighScore objects.

public getGameHighScores(int $user_id[, int|null $chat_id = null ][, int|null $message_id = null ][, string|null $inline_message_id = null ]) : PromiseInterface<string|int, Collection<string|int, GameHighScore>>
Parameters
$user_id : int

Target user id

$chat_id : int|null = null

Optional. Required if inline_message_id is not specified. Unique identifier for the target chat.

$message_id : int|null = null

Optional. Required if inline_message_id is not specified. Identifier of the sent message.

$inline_message_id : string|null = null

Optional. Required if chat_id and message_id are not specified. Identifier of the inline message.

Tags
link
https://core.telegram.org/bots/api#getgamehighscores
Return values
PromiseInterface<string|int, Collection<string|int, GameHighScore>>

sendGame()

Use this method to send a game. On success, the sent Message is returned.

public sendGame(int|string $chat_id, string $game_short_name[, string|null $business_connection_id = null ][, int|null $message_thread_id = null ][, bool|null $disable_notification = null ][, bool|null $protect_content = null ][, bool|null $allow_paid_broadcast = null ][, string|null $message_effect_id = null ][, ReplyParameters|array<string|int, mixed>|null $reply_parameters = null ][, InlineKeyboardMarkup|array<string|int, mixed>|null $reply_markup = null ]) : PromiseInterface<string|int, Message>
Parameters
$chat_id : int|string

Unique identifier for the target chat or username of the target bot in the format @username. Games can't be sent to channel direct messages chats and channel chats.

$game_short_name : string

Short name of the game, serves as the unique identifier for the game. Set up your games via @BotFather.

$business_connection_id : string|null = null

Optional. Unique identifier of the business connection on behalf of which the message will be sent

$message_thread_id : int|null = null

Optional. Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only

$disable_notification : bool|null = null

Optional. Sends the message silently. Users will receive a notification with no sound.

$protect_content : bool|null = null

Optional. Protects the contents of the sent message from forwarding and saving

$allow_paid_broadcast : bool|null = null

Optional. Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance.

$message_effect_id : string|null = null

Optional. Unique identifier of the message effect to be added to the message; for private chats only

$reply_parameters : ReplyParameters|array<string|int, mixed>|null = null

Optional. Description of the message to reply to

$reply_markup : InlineKeyboardMarkup|array<string|int, mixed>|null = null

Optional. A JSON-serialized object for an inline keyboard. If empty, one 'Play game_title' button will be shown. If not empty, the first button must launch the game.

Tags
link
https://core.telegram.org/bots/api#sendgame
Return values
PromiseInterface<string|int, Message>

setGameScore()

Use this method to set the score of the specified user in a game message. On success, if the message is not an inline message, the Message is returned, otherwise True is returned. Returns an error, if the new score is not greater than the user's current score in the chat and force is False.

public setGameScore(int $user_id, int $score[, bool|null $force = null ][, bool|null $disable_edit_message = null ][, int|null $chat_id = null ][, int|null $message_id = null ][, string|null $inline_message_id = null ]) : PromiseInterface<string|int, Message|bool>
Parameters
$user_id : int

User identifier

$score : int

New score, must be non-negative

$force : bool|null = null

Optional. Pass True if the high score is allowed to decrease. This can be useful when fixing mistakes or banning cheaters.

$disable_edit_message : bool|null = null

Optional. Pass True if the game message should not be automatically edited to include the current scoreboard

$chat_id : int|null = null

Optional. Required if inline_message_id is not specified. Unique identifier for the target chat.

$message_id : int|null = null

Optional. Required if inline_message_id is not specified. Identifier of the sent message.

$inline_message_id : string|null = null

Optional. Required if chat_id and message_id are not specified. Identifier of the inline message.

Tags
link
https://core.telegram.org/bots/api#setgamescore
Return values
PromiseInterface<string|int, Message|bool>
On this page

Search results