Add message origin classes

This commit is contained in:
netkas 2024-09-30 13:04:23 -04:00
parent 1e3824a87a
commit c4c307fcf1
7 changed files with 343 additions and 0 deletions

View 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)));
}
}