Added method SendDice
This commit is contained in:
parent
64e40f62cb
commit
b8f6c81833
3 changed files with 162 additions and 0 deletions
|
@ -15,6 +15,7 @@
|
|||
use TgBotLib\Methods\SendAnimation;
|
||||
use TgBotLib\Methods\SendAudio;
|
||||
use TgBotLib\Methods\SendContact;
|
||||
use TgBotLib\Methods\SendDice;
|
||||
use TgBotLib\Methods\SendDocument;
|
||||
use TgBotLib\Methods\SendLocation;
|
||||
use TgBotLib\Methods\SendMediaGroup;
|
||||
|
@ -50,6 +51,7 @@
|
|||
case SEND_VENUE = 'sendVenue';
|
||||
case SEND_CONTACT = 'sendContact';
|
||||
case SEND_POLL = 'sendPoll';
|
||||
case SEND_DICE = 'sendDice';
|
||||
|
||||
/**
|
||||
* Executes a command on the provided bot with the given parameters.
|
||||
|
@ -84,6 +86,7 @@
|
|||
self::SEND_VENUE => SendVenue::execute($bot, $parameters),
|
||||
self::SEND_CONTACT => SendContact::execute($bot, $parameters),
|
||||
self::SEND_POLL => SendPoll::execute($bot, $parameters),
|
||||
self::SEND_DICE => SendDice::execute($bot, $parameters),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
60
src/TgBotLib/Methods/SendDice.php
Normal file
60
src/TgBotLib/Methods/SendDice.php
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Methods;
|
||||
|
||||
use TgBotLib\Abstracts\Method;
|
||||
use TgBotLib\Bot;
|
||||
use TgBotLib\Enums\Methods;
|
||||
use TgBotLib\Objects\Message;
|
||||
use TgBotLib\Objects\ReplyParameters;
|
||||
|
||||
class SendDice extends Method
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function execute(Bot $bot, array $parameters = []): mixed
|
||||
{
|
||||
// Handle reply parameters
|
||||
if (isset($parameters['reply_parameters']) && $parameters['reply_parameters'] instanceof ReplyParameters)
|
||||
{
|
||||
$parameters['reply_parameters'] = $parameters['reply_parameters']->toArray();
|
||||
}
|
||||
|
||||
// Handle reply markup
|
||||
if (isset($parameters['reply_markup']) && method_exists($parameters['reply_markup'], 'toArray'))
|
||||
{
|
||||
$parameters['reply_markup'] = $parameters['reply_markup']->toArray();
|
||||
}
|
||||
|
||||
// Make request
|
||||
return Message::fromArray(self::executeCurl(self::buildPost($bot, Methods::SEND_DICE->value, $parameters)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getRequiredParameters(): ?array
|
||||
{
|
||||
return [
|
||||
'chat_id'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getOptionalParameters(): ?array
|
||||
{
|
||||
return [
|
||||
'business_connection_id',
|
||||
'message_thread_id',
|
||||
'emoji',
|
||||
'disable_notification',
|
||||
'protect_content',
|
||||
'message_effect_id',
|
||||
'reply_parameters',
|
||||
'reply_markup'
|
||||
];
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue