Moved InputMessageContent
This commit is contained in:
parent
dfb812237b
commit
fb2a06024d
17 changed files with 23 additions and 18 deletions
|
@ -8,7 +8,7 @@
|
|||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\Inline\InlineKeyboardMarkup;
|
||||
use TgBotLib\Objects\Inline\InlineQueryResult;
|
||||
use TgBotLib\Objects\InputMessageContent;
|
||||
use TgBotLib\Objects\Inline\InputMessageContent;
|
||||
|
||||
class InlineQueryResultArticle extends InlineQueryResult implements ObjectTypeInterface
|
||||
{
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\Inline\InlineKeyboardMarkup;
|
||||
use TgBotLib\Objects\Inline\InlineQueryResult;
|
||||
use TgBotLib\Objects\InputMessageContent;
|
||||
use TgBotLib\Objects\Inline\InputMessageContent;
|
||||
use TgBotLib\Objects\MessageEntity;
|
||||
|
||||
class InlineQueryResultAudio extends InlineQueryResult implements ObjectTypeInterface
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\Inline\InlineKeyboardMarkup;
|
||||
use TgBotLib\Objects\Inline\InlineQueryResult;
|
||||
use TgBotLib\Objects\InputMessageContent;
|
||||
use TgBotLib\Objects\Inline\InputMessageContent;
|
||||
|
||||
class InlineQueryResultContact extends InlineQueryResult implements ObjectTypeInterface
|
||||
{
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\Inline\InlineKeyboardMarkup;
|
||||
use TgBotLib\Objects\Inline\InlineQueryResult;
|
||||
use TgBotLib\Objects\InputMessageContent;
|
||||
use TgBotLib\Objects\Inline\InputMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputVenueMessageContent;
|
||||
use TgBotLib\Objects\MessageEntity;
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\Inline\InlineKeyboardMarkup;
|
||||
use TgBotLib\Objects\Inline\InlineQueryResult;
|
||||
use TgBotLib\Objects\InputMessageContent;
|
||||
use TgBotLib\Objects\Inline\InputMessageContent;
|
||||
use TgBotLib\Objects\MessageEntity;
|
||||
|
||||
class InlineQueryResultGif extends InlineQueryResult implements ObjectTypeInterface
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\Inline\InlineKeyboardMarkup;
|
||||
use TgBotLib\Objects\Inline\InlineQueryResult;
|
||||
use TgBotLib\Objects\InputMessageContent;
|
||||
use TgBotLib\Objects\Inline\InputMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputContactMessageContent;
|
||||
|
||||
class InlineQueryResultLocation extends InlineQueryResult implements ObjectTypeInterface
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\Inline\InlineKeyboardMarkup;
|
||||
use TgBotLib\Objects\Inline\InlineQueryResult;
|
||||
use TgBotLib\Objects\InputMessageContent;
|
||||
use TgBotLib\Objects\Inline\InputMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputVenueMessageContent;
|
||||
use TgBotLib\Objects\MessageEntity;
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\Inline\InlineKeyboardMarkup;
|
||||
use TgBotLib\Objects\Inline\InlineQueryResult;
|
||||
use TgBotLib\Objects\InputMessageContent;
|
||||
use TgBotLib\Objects\Inline\InputMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputTextMessageContent;
|
||||
use TgBotLib\Objects\MessageEntity;
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\Inline\InlineKeyboardMarkup;
|
||||
use TgBotLib\Objects\Inline\InlineQueryResult;
|
||||
use TgBotLib\Objects\InputMessageContent;
|
||||
use TgBotLib\Objects\Inline\InputMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputVenueMessageContent;
|
||||
|
||||
class InlineQueryResultVenue extends InlineQueryResult implements ObjectTypeInterface
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\Inline\InlineKeyboardMarkup;
|
||||
use TgBotLib\Objects\Inline\InlineQueryResult;
|
||||
use TgBotLib\Objects\InputMessageContent;
|
||||
use TgBotLib\Objects\Inline\InputMessageContent;
|
||||
use TgBotLib\Objects\MessageEntity;
|
||||
|
||||
class InlineQueryResultVideo extends InlineQueryResult implements ObjectTypeInterface
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\Inline\InlineKeyboardMarkup;
|
||||
use TgBotLib\Objects\Inline\InlineQueryResult;
|
||||
use TgBotLib\Objects\InputMessageContent;
|
||||
use TgBotLib\Objects\Inline\InputMessageContent;
|
||||
use TgBotLib\Objects\MessageEntity;
|
||||
|
||||
class InlineQueryResultVoice extends InlineQueryResult implements ObjectTypeInterface
|
||||
|
|
64
src/TgBotLib/Objects/Inline/InputMessageContent.php
Normal file
64
src/TgBotLib/Objects/Inline/InputMessageContent.php
Normal file
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Objects\Inline;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use TgBotLib\Enums\Types\InputMessageContentType;
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\InputMessageContent\InputInvoiceMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputLocationMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputTextMessageContent;
|
||||
use TgBotLib\Objects\InputMessageContent\InputVenueMessageContent;
|
||||
|
||||
abstract class InputMessageContent implements ObjectTypeInterface
|
||||
{
|
||||
protected InputMessageContentType $type;
|
||||
|
||||
/**
|
||||
* Returns the type for the Input message content
|
||||
*
|
||||
* @return InputMessageContentType
|
||||
*/
|
||||
public function getType(): InputMessageContentType
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public abstract function toArray(): array;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function fromArray(?array $data): ?InputMessageContent
|
||||
{
|
||||
if($data === null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if(isset($data['message_text']))
|
||||
{
|
||||
return InputTextMessageContent::fromArray($data);
|
||||
}
|
||||
|
||||
if(isset($data['latitude']) && isset($data['longitude']) && isset($data['tile']) && isset($data['address']))
|
||||
{
|
||||
return InputVenueMessageContent::fromArray($data);
|
||||
}
|
||||
|
||||
if(isset($data['latitude']) && isset($data['longitude']))
|
||||
{
|
||||
return InputLocationMessageContent::fromArray($data);
|
||||
}
|
||||
|
||||
if(isset($data['title']) && isset($data['description']) && isset($data['payload']))
|
||||
{
|
||||
return InputInvoiceMessageContent::fromArray($data);
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException("Invalid object type, unexpected type");
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue