Add SendGame method
This commit is contained in:
parent
d206d20dd5
commit
6119b39ec7
2 changed files with 73 additions and 1 deletions
|
@ -32,6 +32,7 @@
|
|||
use TgBotLib\Methods\DeleteMessages;
|
||||
use TgBotLib\Methods\DeleteMyCommands;
|
||||
use TgBotLib\Methods\DeleteStickerFromSet;
|
||||
use TgBotLib\Methods\DeleteStickerSet;
|
||||
use TgBotLib\Methods\DeleteWebhook;
|
||||
use TgBotLib\Methods\EditChatInviteLink;
|
||||
use TgBotLib\Methods\EditChatSubscriptionInviteLink;
|
||||
|
@ -83,6 +84,7 @@
|
|||
use TgBotLib\Methods\SendContact;
|
||||
use TgBotLib\Methods\SendDice;
|
||||
use TgBotLib\Methods\SendDocument;
|
||||
use TgBotLib\Methods\SendGame;
|
||||
use TgBotLib\Methods\SendInvoice;
|
||||
use TgBotLib\Methods\SendLocation;
|
||||
use TgBotLib\Methods\SendMediaGroup;
|
||||
|
@ -251,6 +253,7 @@
|
|||
case ANSWER_PRE_CHECKOUT_QUERY = 'answerPreCheckoutQuery';
|
||||
case GET_STAR_TRANSACTIONS = 'getStarTransactions';
|
||||
case SET_PASSPORT_DATA_ERRORS = 'setPassportDataErrors';
|
||||
case SEND_GAME = 'sendGame';
|
||||
|
||||
/**
|
||||
* Executes a command on the provided bot with the given parameters.
|
||||
|
@ -376,7 +379,7 @@
|
|||
self::SET_STICKER_SET_TITLE => SetStickerSetTitle::execute($bot, $parameters),
|
||||
self::SET_STICKER_SET_THUMBNAIL => SetStickerSetThumbnail::execute($bot, $parameters),
|
||||
self::SET_CUSTOM_EMOJI_STICKER_SET_THUMBNAIL => SetCustomEmojiStickerSetThumbnail::execute($bot, $parameters),
|
||||
self::DELETE_STICKER_SET => DeleteStickerFromSet::execute($bot, $parameters),
|
||||
self::DELETE_STICKER_SET => DeleteStickerSet::execute($bot, $parameters),
|
||||
self::ANSWER_INLINE_QUERY => AnswerInlineQuery::execute($bot, $parameters),
|
||||
self::ANSWER_WEB_APP_QUERY => AnswerWebAppQuery::execute($bot, $parameters),
|
||||
self::SAVE_PREPARED_INLINE_MESSAGE => SavePreparedInlineMessage::execute($bot, $parameters),
|
||||
|
@ -386,6 +389,7 @@
|
|||
self::ANSWER_PRE_CHECKOUT_QUERY => AnswerPreCheckoutQuery::execute($bot, $parameters),
|
||||
self::GET_STAR_TRANSACTIONS => GetStarTransactions::execute($bot, $parameters),
|
||||
self::SET_PASSPORT_DATA_ERRORS => SetPassportDataErrors::execute($bot, $parameters),
|
||||
self::SEND_GAME => SendGame::execute($bot, $parameters),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
68
src/TgBotLib/Methods/SendGame.php
Normal file
68
src/TgBotLib/Methods/SendGame.php
Normal file
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Methods;
|
||||
|
||||
use TgBotLib\Abstracts\Method;
|
||||
use TgBotLib\Bot;
|
||||
use TgBotLib\Enums\Methods;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\Message;
|
||||
use TgBotLib\Objects\ReplyParameters;
|
||||
|
||||
class SendGame extends Method
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function execute(Bot $bot, array $parameters = []): Message
|
||||
{
|
||||
|
||||
if(isset($parameters['reply_parameters']) && $parameters['reply_parameters'] instanceof ReplyParameters)
|
||||
{
|
||||
$parameters['reply_parameters'] = $parameters['reply_parameters']->toArray();
|
||||
}
|
||||
|
||||
if (isset($parameters['reply_markup']))
|
||||
{
|
||||
if ($parameters['reply_markup'] instanceof ObjectTypeInterface)
|
||||
{
|
||||
$parameters['reply_markup'] = json_encode($parameters['reply_markup']->toArray());
|
||||
}
|
||||
elseif (is_array($parameters['reply_markup']))
|
||||
{
|
||||
$parameters['reply_markup'] = json_encode($parameters['reply_markup']);
|
||||
}
|
||||
}
|
||||
|
||||
return Message::fromArray(self::executeCurl(self::buildPost($bot, Methods::SEND_GAME->value, $parameters)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getRequiredParameters(): ?array
|
||||
{
|
||||
return [
|
||||
'chat_id',
|
||||
'game_short_name'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getOptionalParameters(): ?array
|
||||
{
|
||||
return [
|
||||
'business_connection_id',
|
||||
'message_thread_id',
|
||||
'disable_notification',
|
||||
'protect_content',
|
||||
'allow_paid_broadcasts',
|
||||
'message_effect_id',
|
||||
'reply_parameters',
|
||||
'reply_markup'
|
||||
];
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue