Add SetGameScore method

This commit is contained in:
netkas 2024-11-28 00:24:43 -05:00
parent 6119b39ec7
commit ecac3c6ae5
2 changed files with 47 additions and 0 deletions

View file

@ -105,6 +105,7 @@
use TgBotLib\Methods\SetChatStickerSet;
use TgBotLib\Methods\SetChatTitle;
use TgBotLib\Methods\SetCustomEmojiStickerSetThumbnail;
use TgBotLib\Methods\SetGameScore;
use TgBotLib\Methods\SetMessageReaction;
use TgBotLib\Methods\SetMyCommands;
use TgBotLib\Methods\SetMyDefaultAdministratorRights;
@ -254,6 +255,7 @@
case GET_STAR_TRANSACTIONS = 'getStarTransactions';
case SET_PASSPORT_DATA_ERRORS = 'setPassportDataErrors';
case SEND_GAME = 'sendGame';
case SET_GAME_SCORE = 'setGameScore';
/**
* Executes a command on the provided bot with the given parameters.
@ -390,6 +392,7 @@
self::GET_STAR_TRANSACTIONS => GetStarTransactions::execute($bot, $parameters),
self::SET_PASSPORT_DATA_ERRORS => SetPassportDataErrors::execute($bot, $parameters),
self::SEND_GAME => SendGame::execute($bot, $parameters),
self::SET_GAME_SCORE => SetGameScore::execute($bot, $parameters),
};
}
}

View file

@ -0,0 +1,44 @@
<?php
namespace TgBotLib\Methods;
use TgBotLib\Abstracts\Method;
use TgBotLib\Bot;
use TgBotLib\Enums\Methods;
class SetGameScore extends Method
{
/**
* @inheritDoc
*/
public static function execute(Bot $bot, array $parameters = []): true
{
return (bool)self::executeCurl(self::buildPost($bot, Methods::SET_GAME_SCORE->value, $parameters));
}
/**
* @inheritDoc
*/
public static function getRequiredParameters(): ?array
{
return [
'user_id',
'score'
];
}
/**
* @inheritDoc
*/
public static function getOptionalParameters(): ?array
{
return [
'force',
'disable_edit_message',
'chat_id',
'message_id',
'inline_message_id'
];
}
}