Add message origin classes
This commit is contained in:
parent
1e3824a87a
commit
c4c307fcf1
7 changed files with 343 additions and 0 deletions
30
src/TgBotLib/Methods/SendMessage.php
Normal file
30
src/TgBotLib/Methods/SendMessage.php
Normal file
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Methods;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use TgBotLib\Abstracts\Method;
|
||||
use TgBotLib\Bot;
|
||||
use TgBotLib\Enums\Methods;
|
||||
use TgBotLib\Objects\Telegram\Message;
|
||||
|
||||
class SendMessage extends Method
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function execute(Bot $bot, array $parameters = []): Message
|
||||
{
|
||||
if(!isset($parameters['chat_id']))
|
||||
{
|
||||
throw new InvalidArgumentException('chat_id is required');
|
||||
}
|
||||
|
||||
if(!isset($parameters['text']))
|
||||
{
|
||||
throw new InvalidArgumentException('text is required');
|
||||
}
|
||||
|
||||
return Message::fromArray(self::executeCurl(self::buildPost($bot, Methods::SEND_MESSAGE->value, $parameters)));
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue