@@ -22,6 +22,7 @@ use Longman\TelegramBot\Request;
* @method Message getMessage() Optional. Message with the callback button that originated the query. Note that message content and message date will not be available if the message is too old
* @method string getInlineMessageId() Optional. Identifier of the message sent via the bot in inline mode, that originated the query
* @method string getData() Data associated with the callback button. Be aware that a bad client can send arbitrary data in this field
* @method string getGameShortName() Optional. Short name of a Game to be returned, serves as the unique identifier for the game
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespaceLongman\TelegramBot\Entities\Games;
useLongman\TelegramBot\Entities\Entity;
/**
* Class Animation
*
* You can provide an animation for your game so that it looks stylish in chats (check out Lumberjack for an example). This object represents an animation file to be displayed in the message containing a game.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespaceLongman\TelegramBot\Entities\Games;
useLongman\TelegramBot\Entities\Entity;
useLongman\TelegramBot\Entities\MessageEntity;
/**
* Class Game
*
* This object represents a game. Use BotFather to create and edit games, their short names will act as unique identifiers.
*
* @link https://core.telegram.org/bots/api#game
*
* @method string getTitle() Title of the game
* @method string getDescription() Description of the game
* @method string getText() Optional. Brief description of the game or high scores included in the game message. Can be automatically edited to include current high scores for the game when the bot calls setGameScore, or manually edited using editMessageText. 0-4096 characters.
* @method Animation getAnimation() Optional. Animation that will be displayed in the game message in chats. Upload via BotFather
**/
classGameextendsEntity
{
/**
* {@inheritdoc}
*/
protectedfunctionsubEntities()
{
return[
'photo'=>PhotoSize::class,
'text_entities'=>MessageEntity::class,
'animation'=>Animation::class,
];
}
/**
* Photo that will be displayed in the game message in chats.
*
* This method overrides the default getPhoto method
* @method string getText() Label text on the button
* @method string getUrl() Optional. HTTP url to be opened when button is pressed
* @method string getCallbackData() Optional. Data to be sent in a callback query to the bot when button is pressed, 1-64 bytes
* @method string getSwitchInlineQuery() Optional. If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. Can be empty, in which case just the bot’s username will be inserted.
* @method string getSwitchInlineQueryCurrentChat() Optional. If set, pressing the button will insert the bot‘s username and the specified inline query in the current chat's input field. Can be empty, in which case only the bot’s username will be inserted.
* @method bool getPay() Optional. Specify True, to send a Pay button.
* @method string getText() Label text on the button
* @method string getUrl() Optional. HTTP url to be opened when button is pressed
* @method string getCallbackData() Optional. Data to be sent in a callback query to the bot when button is pressed, 1-64 bytes
* @method string getSwitchInlineQuery() Optional. If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. Can be empty, in which case just the bot’s username will be inserted.
* @method string getSwitchInlineQueryCurrentChat() Optional. If set, pressing the button will insert the bot‘s username and the specified inline query in the current chat's input field. Can be empty, in which case only the bot’s username will be inserted.
* @method CallbackGame getCallbackGame() Optional. Description of the game that will be launched when the user presses the button.
* @method bool getPay() Optional. Specify True, to send a Pay button.
*
* @method $this setText(string $text) Label text on the button
* @method $this setUrl(string $url) Optional. HTTP url to be opened when button is pressed
* @method $this setCallbackData(string $callback_data) Optional. Data to be sent in a callback query to the bot when button is pressed, 1-64 bytes
* @method $this setSwitchInlineQuery(string $switch_inline_query) Optional. If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. Can be empty, in which case just the bot’s username will be inserted.
* @method $this setSwitchInlineQueryCurrentChat(string $switch_inline_query_current_chat) Optional. If set, pressing the button will insert the bot‘s username and the specified inline query in the current chat's input field. Can be empty, in which case only the bot’s username will be inserted.
* @method $this setCallbackGame(CallbackGame $callback_game) Optional. Description of the game that will be launched when the user presses the button.
* @method $this setPay(bool $pay) Optional. Specify True, to send a Pay button.
*/
classInlineKeyboardButtonextendsKeyboardButton
...
...
@@ -48,6 +51,7 @@ class InlineKeyboardButton extends KeyboardButton
thrownewTelegramException('You must use only one of these fields: url, callback_data, switch_inline_query, switch_inline_query_current_chat, pay!');
thrownewTelegramException('You must use only one of these fields: url, callback_data, switch_inline_query, switch_inline_query_current_chat, callback_game, pay!');
}
}
...
...
@@ -80,8 +84,8 @@ class InlineKeyboardButton extends KeyboardButton
publicfunction__call($method,$args)
{
// Only 1 of these can be set, so clear the others when setting a new one.
@@ -74,6 +74,9 @@ use Longman\TelegramBot\Exception\TelegramException;
* @method static ServerResponse sendInvoice(array $data) Use this method to send invoices. On success, the sent Message is returned.
* @method static ServerResponse answerShippingQuery(array $data) If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API will send an Update with a shipping_query field to the bot. Use this method to reply to shipping queries. On success, True is returned.
* @method static ServerResponse answerPreCheckoutQuery(array $data) Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the field pre_checkout_query. Use this method to respond to such pre-checkout queries. On success, True is returned.
* @method static ServerResponse sendGame(array $data) Use this method to send a game. On success, the sent Message is returned.
* @method static ServerResponse setGameScore(array $data) Use this method to set the score of the specified user in a game. On success, if the message was sent by the bot, returns the edited Message, otherwise returns True. Returns an error, if the new score is not greater than the user's current score in the chat and force is False.
* @method static ServerResponse getGameHighScores(array $data) Use this method to get data for high score tables. Will return the score of the specified user and several of his neighbors in a game. On success, returns an Array of GameHighScore objects.
* @expectedExceptionMessage You must use only one of these fields: url, callback_data, switch_inline_query, switch_inline_query_current_chat, pay!
* @expectedExceptionMessage You must use only one of these fields: url, callback_data, switch_inline_query, switch_inline_query_current_chat, callback_game, pay!
* @expectedExceptionMessage You must use only one of these fields: url, callback_data, switch_inline_query, switch_inline_query_current_chat, pay!
* @expectedExceptionMessage You must use only one of these fields: url, callback_data, switch_inline_query, switch_inline_query_current_chat, callback_game, pay!