diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 225a4bfb..76cd14fe 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -13,14 +13,6 @@ jobs: os: - ubuntu-latest php: - - "5.5" - - "5.6" - - "7.0" - - "7.1" - - "7.2" - - "7.3" - - "7.4" - - "8.0" - "8.1" - "8.2" steps: diff --git a/composer.json b/composer.json index 85fe2440..c41dbb68 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ } ], "require": { - "php" : ">=5.5.0", + "php" : ">=8.1", "ext-curl": "*", "ext-json": "*" }, diff --git a/psalm.xml b/psalm.xml index d0e78e7a..4cfcea27 100644 --- a/psalm.xml +++ b/psalm.xml @@ -1,7 +1,7 @@ token = $token; $this->endpoint = ($endpoint ?: self::URL_PREFIX) . $token; $this->fileEndpoint = $endpoint ? null : (self::FILE_URL_PREFIX . $token); $this->httpClient = $httpClient ?: new CurlHttpClient(); - - if ($trackerToken) { - @trigger_error(sprintf('Passing $trackerToken to %s is deprecated', self::class), \E_USER_DEPRECATED); - $this->tracker = new Botan($trackerToken); - } } /** @@ -643,12 +619,6 @@ public function getUpdates($offset = 0, $limit = 100, $timeout = 0) 'timeout' => $timeout, ])); - if ($this->tracker instanceof Botan) { - foreach ($updates as $update) { - $this->trackUpdate($update); - } - } - return $updates; } @@ -1804,56 +1774,6 @@ public function deleteMessage($chatId, $messageId) ]); } - /** - * @deprecated - * - * @param Update $update - * @param string $eventName - * - * @throws Exception - * - * @return void - */ - public function trackUpdate(Update $update, $eventName = 'Message') - { - @trigger_error(sprintf('Method "%s::%s" is deprecated', __CLASS__, __METHOD__), \E_USER_DEPRECATED); - - if (!in_array($update->getUpdateId(), $this->trackedEvents)) { - $message = $update->getMessage(); - if (!$message) { - return; - } - $this->trackedEvents[] = $update->getUpdateId(); - - $this->track($message, $eventName); - - if (count($this->trackedEvents) > self::MAX_TRACKED_EVENTS) { - $this->trackedEvents = array_slice($this->trackedEvents, (int) round(self::MAX_TRACKED_EVENTS / 4)); - } - } - } - - /** - * @deprecated - * - * Wrapper for tracker - * - * @param Message $message - * @param string $eventName - * - * @throws Exception - * - * @return void - */ - public function track(Message $message, $eventName = 'Message') - { - @trigger_error(sprintf('Method "%s::%s" is deprecated', __CLASS__, __METHOD__), \E_USER_DEPRECATED); - - if ($this->tracker instanceof Botan) { - $this->tracker->track($message, $eventName); - } - } - /** * Use this method to send invoices. On success, the sent Message is returned. * diff --git a/src/Botan.php b/src/Botan.php deleted file mode 100644 index efc9f67f..00000000 --- a/src/Botan.php +++ /dev/null @@ -1,95 +0,0 @@ -token = $token; - $this->curl = curl_init(); - } - - /** - * Event tracking - * - * @param \TelegramBot\Api\Types\Message $message - * @param string $eventName - * - * @throws \TelegramBot\Api\Exception - * @throws \TelegramBot\Api\HttpException - * - * @return void - */ - public function track(Message $message, $eventName = 'Message') - { - $uid = $message->getFrom()->getId(); - - $options = [ - CURLOPT_URL => self::BASE_URL . "?token={$this->token}&uid={$uid}&name={$eventName}", - CURLOPT_RETURNTRANSFER => true, - CURLOPT_POST => true, - CURLOPT_HTTPHEADER => [ - 'Content-Type: application/json' - ], - CURLOPT_POSTFIELDS => $message->toJson(), - CURLOPT_TIMEOUT => 5, - ]; - - curl_setopt_array($this->curl, $options); - /** @var string $response */ - $response = curl_exec($this->curl); - /** @var array $result */ - $result = BotApi::jsonValidate($response, true); - - BotApi::curlValidate($this->curl); - - if ($result['status'] !== 'accepted') { - throw new Exception('Error Processing Request'); - } - } - - /** - * Destructor. Close curl - */ - public function __destruct() - { - $this->curl && curl_close($this->curl); - } -} diff --git a/src/Client.php b/src/Client.php index c81abd68..b9da94ba 100644 --- a/src/Client.php +++ b/src/Client.php @@ -40,17 +40,13 @@ class Client * Client constructor * * @param string $token Telegram Bot API token - * @param string|null $trackerToken Yandex AppMetrica application api_key * @param HttpClientInterface|null $httpClient * @param string|null $endpoint */ - public function __construct($token, $trackerToken = null, HttpClientInterface $httpClient = null, $endpoint = null) + public function __construct($token, HttpClientInterface $httpClient = null, $endpoint = null) { - if ($trackerToken) { - @trigger_error(sprintf('Passing $trackerToken to %s is deprecated', self::class), \E_USER_DEPRECATED); - } - $this->api = new BotApi($token, $trackerToken, $httpClient, $endpoint); - $this->events = new EventCollection($trackerToken); + $this->api = new BotApi($token, $httpClient, $endpoint); + $this->events = new EventCollection(); } /** diff --git a/src/Events/EventCollection.php b/src/Events/EventCollection.php index 510854d5..84d98abd 100644 --- a/src/Events/EventCollection.php +++ b/src/Events/EventCollection.php @@ -3,8 +3,6 @@ namespace TelegramBot\Api\Events; use Closure; -use ReflectionFunction; -use TelegramBot\Api\Botan; use TelegramBot\Api\Types\Update; class EventCollection @@ -14,28 +12,7 @@ class EventCollection * * @var array */ - protected $events; - - /** - * Botan tracker - * - * @var \TelegramBot\Api\Botan|null - */ - protected $tracker; - - /** - * EventCollection constructor. - * - * @param string $trackerToken - */ - public function __construct($trackerToken = null) - { - $this->events = []; - if ($trackerToken) { - @trigger_error(sprintf('Passing $trackerToken to %s is deprecated', self::class), \E_USER_DEPRECATED); - $this->tracker = new Botan($trackerToken); - } - } + protected $events = []; /** * Add new event to collection @@ -62,10 +39,6 @@ public function handle(Update $update) /* @var \TelegramBot\Api\Events\Event $event */ if ($event->executeChecker($update) === true) { if ($event->executeAction($update) === false) { - if ($this->tracker && ($message = $update->getMessage())) { - $checker = new ReflectionFunction($event->getChecker()); - $this->tracker->track($message, $checker->getStaticVariables()['name']); - } break; } } diff --git a/src/Types/Animation.php b/src/Types/Animation.php index c33deeba..141cc7aa 100644 --- a/src/Types/Animation.php +++ b/src/Types/Animation.php @@ -74,55 +74,33 @@ class Animation extends BaseType implements TypeInterface protected $duration; /** - * Video thumbnail + * Optional. Animation thumbnail as defined by sender * * @var PhotoSize */ protected $thumbnail; /** - * Optional. Animation thumbnail as defined by sender + * Optional. Original animation filename as defined by sender * * @var string|null */ protected $fileName; /** - * Optional. Mime type of a file as defined by sender + * Optional. MIME type of the file as defined by sender * * @var string|null */ protected $mimeType; /** - * Optional. File size + * Optional. File size in bytes. It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value. * * @var int|null */ protected $fileSize; - /** - * @return int - */ - public function getDuration() - { - return $this->duration; - } - - /** - * @param mixed $duration - * @return void - * @throws InvalidArgumentException - */ - public function setDuration($duration) - { - if (is_integer($duration)) { - $this->duration = $duration; - } else { - throw new InvalidArgumentException(); - } - } - /** * @return string */ @@ -158,22 +136,22 @@ public function setFileUniqueId($fileUniqueId) } /** - * @return int|null + * @return int */ - public function getFileSize() + public function getWidth() { - return $this->fileSize; + return $this->width; } /** - * @param mixed $fileSize + * @param int $width * @return void * @throws InvalidArgumentException */ - public function setFileSize($fileSize) + public function setWidth($width) { - if (is_integer($fileSize)) { - $this->fileSize = $fileSize; + if (is_integer($width)) { + $this->width = $width; } else { throw new InvalidArgumentException(); } @@ -188,7 +166,7 @@ public function getHeight() } /** - * @param mixed $height + * @param int $height * @return void * @throws InvalidArgumentException */ @@ -202,20 +180,25 @@ public function setHeight($height) } /** - * @return null|string + * @return int */ - public function getMimeType() + public function getDuration() { - return $this->mimeType; + return $this->duration; } /** - * @param string $mimeType + * @param int $duration * @return void + * @throws InvalidArgumentException */ - public function setMimeType($mimeType) + public function setDuration($duration) { - $this->mimeType = $mimeType; + if (is_integer($duration)) { + $this->duration = $duration; + } else { + throw new InvalidArgumentException(); + } } /** @@ -236,61 +219,56 @@ public function setThumbnail(PhotoSize $thumbnail) } /** - * @deprecated use getThumbnail method - * - * @return PhotoSize|null + * @return string|null */ - public function getThumb() + public function getFileName() { - return $this->getThumbnail(); + return $this->fileName; } /** - * @deprecated use setThumbnail method - * - * @param PhotoSize $thumb - * + * @param string $fileName * @return void */ - public function setThumb($thumb) + public function setFileName($fileName) { - $this->setThumbnail($thumb); + $this->fileName = $fileName; } /** - * @return null|string $fileName + * @return string|null */ - public function getFileName() + public function getMimeType() { - return $this->fileName; + return $this->mimeType; } /** - * @param string $fileName + * @param string $mimeType * @return void */ - public function setFileName($fileName) + public function setMimeType($mimeType) { - $this->fileName = $fileName; + $this->mimeType = $mimeType; } /** - * @return int + * @return int|null */ - public function getWidth() + public function getFileSize() { - return $this->width; + return $this->fileSize; } /** - * @param mixed $width + * @param int|null $fileSize * @return void * @throws InvalidArgumentException */ - public function setWidth($width) + public function setFileSize($fileSize) { - if (is_integer($width)) { - $this->width = $width; + if (is_integer($fileSize) || is_null($fileSize)) { + $this->fileSize = $fileSize; } else { throw new InvalidArgumentException(); } diff --git a/src/Types/ArrayOfBusinessOpeningHoursInterval.php b/src/Types/ArrayOfBusinessOpeningHoursInterval.php new file mode 100644 index 00000000..d2b497d6 --- /dev/null +++ b/src/Types/ArrayOfBusinessOpeningHoursInterval.php @@ -0,0 +1,20 @@ + true, 'performer' => true, 'title' => true, + 'file_name' => true, 'mime_type' => true, - 'file_size' => true + 'file_size' => true, + 'thumbnail' => PhotoSize::class ]; /** @@ -44,7 +46,14 @@ class Audio extends BaseType implements TypeInterface protected $fileId; /** - * Photo width + * Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. + * + * @var string + */ + protected $fileUniqueId; + + /** + * Duration of the audio in seconds as defined by sender * * @var int */ @@ -64,6 +73,13 @@ class Audio extends BaseType implements TypeInterface */ protected $title; + /** + * Optional. Original filename as defined by sender + * + * @var string|null + */ + protected $fileName; + /** * Optional. MIME type of the file as defined by sender * @@ -72,18 +88,52 @@ class Audio extends BaseType implements TypeInterface protected $mimeType; /** - * Optional. File size + * Optional. File size in bytes. It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value. * * @var int|null */ protected $fileSize; /** - * Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. + * Optional. Thumbnail of the album cover to which the music file belongs * - * @var string + * @var PhotoSize|null */ - protected $fileUniqueId; + protected $thumbnail; + + /** + * @return string + */ + public function getFileId() + { + return $this->fileId; + } + + /** + * @param string $fileId + * @return void + */ + public function setFileId($fileId) + { + $this->fileId = $fileId; + } + + /** + * @return string + */ + public function getFileUniqueId() + { + return $this->fileUniqueId; + } + + /** + * @param string $fileUniqueId + * @return void + */ + public function setFileUniqueId($fileUniqueId) + { + $this->fileUniqueId = $fileUniqueId; + } /** * @return int @@ -94,7 +144,7 @@ public function getDuration() } /** - * @param mixed $duration + * @param int $duration * @return void * @throws InvalidArgumentException */ @@ -108,7 +158,7 @@ public function setDuration($duration) } /** - * @return null|string + * @return string|null */ public function getPerformer() { @@ -116,7 +166,7 @@ public function getPerformer() } /** - * @param string $performer + * @param string|null $performer * @return void */ public function setPerformer($performer) @@ -125,7 +175,7 @@ public function setPerformer($performer) } /** - * @return null|string + * @return string|null */ public function getTitle() { @@ -133,7 +183,7 @@ public function getTitle() } /** - * @param string $title + * @param string|null $title * @return void */ public function setTitle($title) @@ -142,75 +192,75 @@ public function setTitle($title) } /** - * @return string + * @return string|null */ - public function getFileId() + public function getFileName() { - return $this->fileId; + return $this->fileName; } /** - * @param string $fileId + * @param string|null $fileName * @return void */ - public function setFileId($fileId) + public function setFileName($fileName) { - $this->fileId = $fileId; + $this->fileName = $fileName; } /** - * @return int|null + * @return string|null */ - public function getFileSize() + public function getMimeType() { - return $this->fileSize; + return $this->mimeType; } /** - * @param mixed $fileSize + * @param string|null $mimeType * @return void - * @throws InvalidArgumentException */ - public function setFileSize($fileSize) + public function setMimeType($mimeType) { - if (is_integer($fileSize)) { - $this->fileSize = $fileSize; - } else { - throw new InvalidArgumentException(); - } + $this->mimeType = $mimeType; } /** - * @return null|string + * @return int|null */ - public function getMimeType() + public function getFileSize() { - return $this->mimeType; + return $this->fileSize; } /** - * @param string $mimeType + * @param int|null $fileSize * @return void + * @throws InvalidArgumentException */ - public function setMimeType($mimeType) + public function setFileSize($fileSize) { - $this->mimeType = $mimeType; + if (is_integer($fileSize) || is_null($fileSize)) { + $this->fileSize = $fileSize; + } else { + throw new InvalidArgumentException(); + } } /** - * @return string + * @return PhotoSize|null */ - public function getFileUniqueId() + public function getThumbnail() { - return $this->fileUniqueId; + return $this->thumbnail; } /** - * @param string $fileUniqueId + * @param PhotoSize|null $thumbnail * @return void */ - public function setFileUniqueId($fileUniqueId) + public function setThumbnail($thumbnail) { - $this->fileUniqueId = $fileUniqueId; + $this->thumbnail = $thumbnail; } } diff --git a/src/Types/BackgroundFill.php b/src/Types/BackgroundFill.php new file mode 100644 index 00000000..8da9d869 --- /dev/null +++ b/src/Types/BackgroundFill.php @@ -0,0 +1,39 @@ +type; + } + + /** + * @param string $type + * @return void + */ + public function setType($type) + { + $this->type = $type; + } +} diff --git a/src/Types/BackgroundFillFreeformGradient.php b/src/Types/BackgroundFillFreeformGradient.php new file mode 100644 index 00000000..3d028e04 --- /dev/null +++ b/src/Types/BackgroundFillFreeformGradient.php @@ -0,0 +1,53 @@ + true, + 'colors' => true, + ]; + + /** + * A list of the 3 or 4 base colors that are used to generate the freeform gradient in the RGB24 format + * + * @var array + */ + protected $colors; + + /** + * @return array + */ + public function getColors() + { + return $this->colors; + } + + /** + * @param array $colors + * @return void + */ + public function setColors($colors) + { + $this->colors = $colors; + } +} diff --git a/src/Types/BackgroundFillGradient.php b/src/Types/BackgroundFillGradient.php new file mode 100644 index 00000000..740a9249 --- /dev/null +++ b/src/Types/BackgroundFillGradient.php @@ -0,0 +1,97 @@ + true, + 'top_color' => true, + 'bottom_color' => true, + 'rotation_angle' => true, + ]; + + /** + * Top color of the gradient in the RGB24 format + * + * @var int + */ + protected $topColor; + + /** + * Bottom color of the gradient in the RGB24 format + * + * @var int + */ + protected $bottomColor; + + /** + * Clockwise rotation angle of the background fill in degrees; 0-359 + * + * @var int + */ + protected $rotationAngle; + + /** + * @return int + */ + public function getTopColor() + { + return $this->topColor; + } + + /** + * @param int $topColor + * @return void + */ + public function setTopColor($topColor) + { + $this->topColor = $topColor; + } + + /** + * @return int + */ + public function getBottomColor() + { + return $this->bottomColor; + } + + /** + * @param int $bottomColor + * @return void + */ + public function setBottomColor($bottomColor) + { + $this->bottomColor = $bottomColor; + } + + /** + * @return int + */ + public function getRotationAngle() + { + return $this->rotationAngle; + } + + /** + * @param int $rotationAngle + * @return void + */ + public function setRotationAngle($rotationAngle) + { + $this->rotationAngle = $rotationAngle; + } +} diff --git a/src/Types/BackgroundFillSolid.php b/src/Types/BackgroundFillSolid.php new file mode 100644 index 00000000..f9fe2bf8 --- /dev/null +++ b/src/Types/BackgroundFillSolid.php @@ -0,0 +1,53 @@ + true, + 'color' => true, + ]; + + /** + * The color of the background fill in the RGB24 format + * + * @var int + */ + protected $color; + + /** + * @return int + */ + public function getColor() + { + return $this->color; + } + + /** + * @param int $color + * @return void + */ + public function setColor($color) + { + $this->color = $color; + } +} diff --git a/src/Types/BackgroundType.php b/src/Types/BackgroundType.php new file mode 100644 index 00000000..dc2d8c30 --- /dev/null +++ b/src/Types/BackgroundType.php @@ -0,0 +1,39 @@ +type; + } + + /** + * @param string $type + * @return void + */ + public function setType($type) + { + $this->type = $type; + } +} diff --git a/src/Types/BackgroundTypeChatTheme.php b/src/Types/BackgroundTypeChatTheme.php new file mode 100644 index 00000000..6fb4d567 --- /dev/null +++ b/src/Types/BackgroundTypeChatTheme.php @@ -0,0 +1,53 @@ + true, + 'theme_name' => true, + ]; + + /** + * Name of the chat theme, which is usually an emoji + * + * @var string + */ + protected $themeName; + + /** + * @return string + */ + public function getThemeName() + { + return $this->themeName; + } + + /** + * @param string $themeName + * @return void + */ + public function setThemeName($themeName) + { + $this->themeName = $themeName; + } +} diff --git a/src/Types/BackgroundTypeFill.php b/src/Types/BackgroundTypeFill.php new file mode 100644 index 00000000..dab90920 --- /dev/null +++ b/src/Types/BackgroundTypeFill.php @@ -0,0 +1,78 @@ + true, + 'fill' => BackgroundFill::class, + 'dark_theme_dimming' => true, + ]; + + /** + * The background fill + * + * @var BackgroundFill + */ + protected $fill; + + /** + * Dimming of the background in dark themes, as a percentage; 0-100 + * + * @var int + */ + protected $darkThemeDimming; + + /** + * @return BackgroundFill + */ + public function getFill() + { + return $this->fill; + } + + /** + * @param BackgroundFill $fill + * @return void + */ + public function setFill(BackgroundFill $fill) + { + $this->fill = $fill; + } + + /** + * @return int + */ + public function getDarkThemeDimming() + { + return $this->darkThemeDimming; + } + + /** + * @param int $darkThemeDimming + * @return void + */ + public function setDarkThemeDimming($darkThemeDimming) + { + $this->darkThemeDimming = $darkThemeDimming; + } +} diff --git a/src/Types/BackgroundTypePattern.php b/src/Types/BackgroundTypePattern.php new file mode 100644 index 00000000..c9c37b66 --- /dev/null +++ b/src/Types/BackgroundTypePattern.php @@ -0,0 +1,153 @@ + true, + 'document' => Document::class, + 'fill' => BackgroundFill::class, + 'intensity' => true, + 'is_inverted' => true, + 'is_moving' => true, + ]; + + /** + * Document with the pattern + * + * @var Document + */ + protected $document; + + /** + * The background fill that is combined with the pattern + * + * @var BackgroundFill + */ + protected $fill; + + /** + * Intensity of the pattern when it is shown above the filled background; 0-100 + * + * @var int + */ + protected $intensity; + + /** + * Optional. True, if the background fill must be applied only to the pattern itself. All other pixels are black in this case. For dark themes only + * + * @var bool|null + */ + protected $isInverted; + + /** + * Optional. True, if the background moves slightly when the device is tilted + * + * @var bool|null + */ + protected $isMoving; + + /** + * @return Document + */ + public function getDocument() + { + return $this->document; + } + + /** + * @param Document $document + * @return void + */ + public function setDocument(Document $document) + { + $this->document = $document; + } + + /** + * @return BackgroundFill + */ + public function getFill() + { + return $this->fill; + } + + /** + * @param BackgroundFill $fill + * @return void + */ + public function setFill(BackgroundFill $fill) + { + $this->fill = $fill; + } + + /** + * @return int + */ + public function getIntensity() + { + return $this->intensity; + } + + /** + * @param int $intensity + * @return void + */ + public function setIntensity($intensity) + { + $this->intensity = $intensity; + } + + /** + * @return bool|null + */ + public function getIsInverted() + { + return $this->isInverted; + } + + /** + * @param bool $isInverted + * @return void + */ + public function setIsInverted($isInverted) + { + $this->isInverted = $isInverted; + } + + /** + * @return bool|null + */ + public function getIsMoving() + { + return $this->isMoving; + } + + /** + * @param bool $isMoving + * @return void + */ + public function setIsMoving($isMoving) + { + $this->isMoving = $isMoving; + } +} diff --git a/src/Types/BackgroundTypeWallpaper.php b/src/Types/BackgroundTypeWallpaper.php new file mode 100644 index 00000000..dba3baa7 --- /dev/null +++ b/src/Types/BackgroundTypeWallpaper.php @@ -0,0 +1,128 @@ + true, + 'document' => Document::class, + 'dark_theme_dimming' => true, + 'is_blurred' => true, + 'is_moving' => true, + ]; + + /** + * Document with the wallpaper + * + * @var Document + */ + protected $document; + + /** + * Dimming of the background in dark themes, as a percentage; 0-100 + * + * @var int + */ + protected $darkThemeDimming; + + /** + * Optional. True, if the wallpaper is downscaled to fit in a 450x450 square and then box-blurred with radius 12 + * + * @var bool|null + */ + protected $isBlurred; + + /** + * Optional. True, if the background moves slightly when the device is tilted + * + * @var bool|null + */ + protected $isMoving; + + /** + * @return Document + */ + public function getDocument() + { + return $this->document; + } + + /** + * @param Document $document + * @return void + */ + public function setDocument(Document $document) + { + $this->document = $document; + } + + /** + * @return int + */ + public function getDarkThemeDimming() + { + return $this->darkThemeDimming; + } + + /** + * @param int $darkThemeDimming + * @return void + */ + public function setDarkThemeDimming($darkThemeDimming) + { + $this->darkThemeDimming = $darkThemeDimming; + } + + /** + * @return bool|null + */ + public function getIsBlurred() + { + return $this->isBlurred; + } + + /** + * @param bool $isBlurred + * @return void + */ + public function setIsBlurred($isBlurred) + { + $this->isBlurred = $isBlurred; + } + + /** + * @return bool|null + */ + public function getIsMoving() + { + return $this->isMoving; + } + + /** + * @param bool $isMoving + * @return void + */ + public function setIsMoving($isMoving) + { + $this->isMoving = $isMoving; + } +} diff --git a/src/Types/Birthdate.php b/src/Types/Birthdate.php new file mode 100644 index 00000000..2e2d1b7e --- /dev/null +++ b/src/Types/Birthdate.php @@ -0,0 +1,99 @@ + true, + 'month' => true, + 'year' => true, + ]; + + /** + * Day of the user's birth; 1-31 + * + * @var int + */ + protected $day; + + /** + * Month of the user's birth; 1-12 + * + * @var int + */ + protected $month; + + /** + * Optional. Year of the user's birth + * + * @var int|null + */ + protected $year; + + /** + * @return int + */ + public function getDay() + { + return $this->day; + } + + /** + * @param int $day + * @return void + */ + public function setDay($day) + { + $this->day = $day; + } + + /** + * @return int + */ + public function getMonth() + { + return $this->month; + } + + /** + * @param int $month + * @return void + */ + public function setMonth($month) + { + $this->month = $month; + } + + /** + * @return int|null + */ + public function getYear() + { + return $this->year; + } + + /** + * @param int|null $year + * @return void + */ + public function setYear($year) + { + $this->year = $year; + } +} diff --git a/src/Types/BotDescription.php b/src/Types/BotDescription.php new file mode 100644 index 00000000..28188681 --- /dev/null +++ b/src/Types/BotDescription.php @@ -0,0 +1,54 @@ + true + ]; + + /** + * The bot's description + * + * @var string + */ + protected $description; + + /** + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * @param string $description + */ + public function setDescription($description) + { + $this->description = $description; + } +} diff --git a/src/Types/BotShortDescription.php b/src/Types/BotShortDescription.php new file mode 100644 index 00000000..29bb381d --- /dev/null +++ b/src/Types/BotShortDescription.php @@ -0,0 +1,54 @@ + true + ]; + + /** + * The bot's short description + * + * @var string + */ + protected $shortDescription; + + /** + * @return string + */ + public function getShortDescription() + { + return $this->shortDescription; + } + + /** + * @param string $shortDescription + */ + public function setShortDescription($shortDescription) + { + $this->shortDescription = $shortDescription; + } +} diff --git a/src/Types/BusinessConnection.php b/src/Types/BusinessConnection.php new file mode 100644 index 00000000..247f051f --- /dev/null +++ b/src/Types/BusinessConnection.php @@ -0,0 +1,174 @@ + true, + 'user' => User::class, + 'user_chat_id' => true, + 'date' => true, + 'can_reply' => true, + 'is_enabled' => true + ]; + + /** + * Unique identifier of the business connection + * + * @var string + */ + protected $id; + + /** + * Business account user that created the business connection + * + * @var User + */ + protected $user; + + /** + * Identifier of a private chat with the user who created the business connection + * + * @var int + */ + protected $userChatId; + + /** + * Date the connection was established in Unix time + * + * @var int + */ + protected $date; + + /** + * True, if the bot can act on behalf of the business account in chats that were active in the last 24 hours + * + * @var bool + */ + protected $canReply; + + /** + * True, if the connection is active + * + * @var bool + */ + protected $isEnabled; + + /** + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * @param string $id + */ + public function setId($id) + { + $this->id = $id; + } + + /** + * @return User + */ + public function getUser() + { + return $this->user; + } + + /** + * @param User $user + */ + public function setUser($user) + { + $this->user = $user; + } + + /** + * @return int + */ + public function getUserChatId() + { + return $this->userChatId; + } + + /** + * @param int $userChatId + */ + public function setUserChatId($userChatId) + { + $this->userChatId = $userChatId; + } + + /** + * @return int + */ + public function getDate() + { + return $this->date; + } + + /** + * @param int $date + */ + public function setDate($date) + { + $this->date = $date; + } + + /** + * @return bool + */ + public function getCanReply() + { + return $this->canReply; + } + + /** + * @param bool $canReply + */ + public function setCanReply($canReply) + { + $this->canReply = $canReply; + } + + /** + * @return bool + */ + public function getIsEnabled() + { + return $this->isEnabled; + } + + /** + * @param bool $isEnabled + */ + public function setIsEnabled($isEnabled) + { + $this->isEnabled = $isEnabled; + } +} diff --git a/src/Types/BusinessIntro.php b/src/Types/BusinessIntro.php new file mode 100644 index 00000000..7b6030df --- /dev/null +++ b/src/Types/BusinessIntro.php @@ -0,0 +1,92 @@ + true, + 'message' => true, + 'sticker' => Sticker::class, + ]; + + /** + * Optional. Title text of the business intro + * + * @var string|null + */ + protected $title; + + /** + * Optional. Message text of the business intro + * + * @var string|null + */ + protected $message; + + /** + * Optional. Sticker of the business intro + * + * @var Sticker|null + */ + protected $sticker; + + /** + * @return string|null + */ + public function getTitle() + { + return $this->title; + } + + /** + * @param string|null $title + * @return void + */ + public function setTitle($title) + { + $this->title = $title; + } + + /** + * @return string|null + */ + public function getMessage() + { + return $this->message; + } + + /** + * @param string|null $message + * @return void + */ + public function setMessage($message) + { + $this->message = $message; + } + + /** + * @return Sticker|null + */ + public function getSticker() + { + return $this->sticker; + } + + /** + * @param Sticker|null $sticker + * @return void + */ + public function setSticker($sticker) + { + $this->sticker = $sticker; + } +} diff --git a/src/Types/BusinessLocation.php b/src/Types/BusinessLocation.php new file mode 100644 index 00000000..9d8e2b0d --- /dev/null +++ b/src/Types/BusinessLocation.php @@ -0,0 +1,74 @@ + true, + 'location' => Location::class, + ]; + + /** + * Address of the business + * + * @var string + */ + protected $address; + + /** + * Optional. Location of the business + * + * @var Location|null + */ + protected $location; + + /** + * @return string + */ + public function getAddress() + { + return $this->address; + } + + /** + * @param string $address + * @return void + */ + public function setAddress($address) + { + $this->address = $address; + } + + /** + * @return Location|null + */ + public function getLocation() + { + return $this->location; + } + + /** + * @param Location|null $location + * @return void + */ + public function setLocation($location) + { + $this->location = $location; + } +} diff --git a/src/Types/BusinessMessagesDeleted.php b/src/Types/BusinessMessagesDeleted.php new file mode 100644 index 00000000..68438f1b --- /dev/null +++ b/src/Types/BusinessMessagesDeleted.php @@ -0,0 +1,102 @@ + true, + 'chat' => Chat::class, + 'message_ids' => true + ]; + + /** + * Unique identifier of the business connection + * + * @var string + */ + protected $businessConnectionId; + + /** + * Information about a chat in the business account. The bot may not have access to the chat or the corresponding user. + * + * @var Chat + */ + protected $chat; + + /** + * The list of identifiers of deleted messages in the chat of the business account + * + * @var int[] + */ + protected $messageIds; + + /** + * @return string + */ + public function getBusinessConnectionId() + { + return $this->businessConnectionId; + } + + /** + * @param string $businessConnectionId + */ + public function setBusinessConnectionId($businessConnectionId) + { + $this->businessConnectionId = $businessConnectionId; + } + + /** + * @return Chat + */ + public function getChat() + { + return $this->chat; + } + + /** + * @param Chat $chat + */ + public function setChat($chat) + { + $this->chat = $chat; + } + + /** + * @return int[] + */ + public function getMessageIds() + { + return $this->messageIds; + } + + /** + * @param int[] $messageIds + */ + public function setMessageIds(array $messageIds) + { + $this->messageIds = $messageIds; + } +} diff --git a/src/Types/BusinessOpeningHours.php b/src/Types/BusinessOpeningHours.php new file mode 100644 index 00000000..67ea67a3 --- /dev/null +++ b/src/Types/BusinessOpeningHours.php @@ -0,0 +1,74 @@ + true, + 'opening_hours' => ArrayOfBusinessOpeningHoursInterval::class, + ]; + + /** + * Unique name of the time zone for which the opening hours are defined + * + * @var string + */ + protected $timeZoneName; + + /** + * List of time intervals describing business opening hours + * + * @var array + */ + protected $openingHours; + + /** + * @return string + */ + public function getTimeZoneName() + { + return $this->timeZoneName; + } + + /** + * @param string $timeZoneName + * @return void + */ + public function setTimeZoneName($timeZoneName) + { + $this->timeZoneName = $timeZoneName; + } + + /** + * @return array + */ + public function getOpeningHours() + { + return $this->openingHours; + } + + /** + * @param array $openingHours + * @return void + */ + public function setOpeningHours($openingHours) + { + $this->openingHours = $openingHours; + } +} diff --git a/src/Types/BusinessOpeningHoursInterval.php b/src/Types/BusinessOpeningHoursInterval.php new file mode 100644 index 00000000..6f7b8065 --- /dev/null +++ b/src/Types/BusinessOpeningHoursInterval.php @@ -0,0 +1,74 @@ + true, + 'closing_minute' => true, + ]; + + /** + * The minute's sequence number in a week, starting on Monday, marking the start of the time interval during which the business is open; 0 - 7 * 24 * 60 + * + * @var int + */ + protected $openingMinute; + + /** + * The minute's sequence number in a week, starting on Monday, marking the end of the time interval during which the business is open; 0 - 8 * 24 * 60 + * + * @var int + */ + protected $closingMinute; + + /** + * @return int + */ + public function getOpeningMinute() + { + return $this->openingMinute; + } + + /** + * @param int $openingMinute + * @return void + */ + public function setOpeningMinute($openingMinute) + { + $this->openingMinute = $openingMinute; + } + + /** + * @return int + */ + public function getClosingMinute() + { + return $this->closingMinute; + } + + /** + * @param int $closingMinute + * @return void + */ + public function setClosingMinute($closingMinute) + { + $this->closingMinute = $closingMinute; + } +} diff --git a/src/Types/CallbackGame.php b/src/Types/CallbackGame.php new file mode 100644 index 00000000..193daad7 --- /dev/null +++ b/src/Types/CallbackGame.php @@ -0,0 +1,10 @@ + true, 'from' => User::class, - 'message' => Message::class, + 'message' => MaybeInaccessibleMessage::class, 'inline_message_id' => true, 'chat_instance' => true, 'data' => true, @@ -59,7 +58,7 @@ class CallbackQuery extends BaseType * Note that message content and message date will not be available * if the message is too old * - * @var \TelegramBot\Api\Types\Message|null + * @var \TelegramBot\Api\Types\MaybeInaccessibleMessage|null */ protected $message; @@ -130,7 +129,7 @@ public function setFrom(User $from) } /** - * @return Message|null + * @return MaybeInaccessibleMessage|null */ public function getMessage() { @@ -138,7 +137,7 @@ public function getMessage() } /** - * @param Message $message + * @param MaybeInaccessibleMessage $message * @return void */ public function setMessage($message) diff --git a/src/Types/Chat.php b/src/Types/Chat.php index 1eee67e6..9ff38e9a 100644 --- a/src/Types/Chat.php +++ b/src/Types/Chat.php @@ -6,6 +6,12 @@ use TelegramBot\Api\InvalidArgumentException; use TelegramBot\Api\TypeInterface; +/** + * Class Chat + * This object represents a chat. + * + * @package TelegramBot\Api\Types + */ class Chat extends BaseType implements TypeInterface { /** @@ -27,221 +33,60 @@ class Chat extends BaseType implements TypeInterface 'username' => true, 'first_name' => true, 'last_name' => true, - 'photo' => ChatPhoto::class, - 'bio' => true, - 'description' => true, - 'invite_link' => true, - 'pinned_message' => Message::class, - 'permissions' => ChatPermissions::class, - 'slow_mode_delay' => true, - 'sticker_set_name' => true, - 'can_set_sticker_set' => true, - 'linked_chat_id' => true, - 'location' => ChatLocation::class, - 'join_to_send_messages' => true, - 'join_by_request' => true, - 'message_auto_delete_time' => true, - 'has_protected_content' => true, 'is_forum' => true, - 'active_usernames' => true, - 'emoji_status_custom_emoji_id' => true, - 'has_private_forwards' => true, - 'has_restricted_voice_and_video_messages' => true, ]; /** - * Unique identifier for this chat, not exceeding 1e13 by absolute value + * Unique identifier for this chat. * - * @var int|float|string + * @var int|float */ protected $id; /** - * Type of chat, can be either “private”, “group”, “supergroup” or “channel” + * Type of chat, can be either “private”, “group”, “supergroup” or “channel”. * * @var string */ protected $type; /** - * Optional. Title, for channels and group chats + * Optional. Title, for supergroups, channels and group chats. * * @var string|null */ protected $title; /** - * Optional. Username, for private chats and channels if available + * Optional. Username, for private chats, supergroups and channels if available. * * @var string|null */ protected $username; /** - * Optional. First name of the other party in a private chat + * Optional. First name of the other party in a private chat. * * @var string|null */ protected $firstName; /** - * Optional. Last name of the other party in a private chat + * Optional. Last name of the other party in a private chat. * * @var string|null */ protected $lastName; /** - * Optional. Chat photo. Returned only in getChat. - * - * @var ChatPhoto|null - */ - protected $photo; - - /** - * Optional. Bio of the other party in a private chat. Returned only in getChat - * - * @var string|null - */ - protected $bio; - - /** - * Optional. Description, for supergroups and channel chats. Returned only in getChat. - * - * @var string|null - */ - protected $description; - - /** - * Optional. Chat invite link, for supergroups and channel chats. Returned only in getChat. - * - * @var string|null - */ - protected $inviteLink; - - /** - * Optional. Pinned message, for supergroups. Returned only in getChat. - * - * @var Message|null - */ - protected $pinnedMessage; - - /** - * Optional. Default chat member permissions, for groups and supergroups. Returned only in getChat. - * - * @var ChatPermissions|null - */ - protected $permissions; - - /** - * Optional. For supergroups, the minimum allowed delay between consecutive messages sent by each unpriviledged - * user. Returned only in getChat. - * - * @var int|null - */ - protected $slowModeDelay; - - /** - * Optional. For supergroups, name of group sticker set. Returned only in getChat. - * - * @var string|null - */ - protected $stickerSetName; - - /** - * Optional. True, if the bot can change the group sticker set. Returned only in getChat. - * - * @var bool|null - */ - protected $canSetStickerSet; - - /** - * Optional. Unique identifier for the linked chat, i.e. the discussion group identifier for a channel and vice - * versa; for supergroups and channel chats. This identifier may be greater than 32 bits and some programming - * languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 - * bit integer or double-precision float type are safe for storing this identifier. Returned only in getChat. - * - * @var int|null - */ - protected $linkedChatId; - - /** - * Optional. For supergroups, the location to which the supergroup is connected. Returned only in getChat. - * - * @var ChatLocation|null - */ - protected $location; - - /** - * Optional. True, if users need to join the supergroup before they can send messages. Returned only in getChat. - * - * @var bool|null - */ - protected $joinToSendMessages; - - /** - * Optional. True, if all users directly joining the supergroup need to be approved by supergroup administrators. Returned only in getChat. - * - * @var bool|null - */ - protected $joinByRequest; - - /** - * Optional. Time after which all messages sent to the chat will be automatically deleted; in seconds. Returned - * only in getChat. - * - * @var int|null - */ - protected $messageAutoDeleteTime; - - /** - * Optional. True, if messages from the chat can't be forwarded to other chats. Returned only in getChat. - * - * @var bool|null - */ - protected $hasProtectedContent; - - /** - * Optional. True, if the supergroup chat is a forum (has topics enabled) + * Optional. True, if the supergroup chat is a forum (has topics enabled). * * @var bool|null */ protected $isForum; /** - * Optional. If non-empty, the list of all active chat usernames; - * for private chats, supergroups and channels. Returned only in getChat. - * - * @var array[]|null - */ - protected $activeUsernames; - - /** - * Optional. Custom emoji identifier of emoji status of the other party in a private chat. Returned only in getChat. - * - * @var string|null - */ - protected $emojiStatusCustomEmojiId; - - /** - * Optional. True, if privacy settings of the other party in the private chat allows - * to use tg://user?id= links only in chats with the user. - * Returned only in getChat. - * - * @var bool|null - */ - protected $hasPrivateForwards; - - /** - * Optional. True, if the privacy settings of the other party restrict sending voice and video note messages in the private chat. - * Returned only in getChat. - * - * @var bool|null - */ - protected $hasRestrictedVoiceAndVideoMessages; - - /** - * @return int|float|string + * @return int|float */ public function getId() { @@ -253,9 +98,9 @@ public function getId() * @return void * @throws InvalidArgumentException */ - public function setId($id) + public function setId($id): void { - if (is_integer($id) || is_float($id) || is_string($id)) { + if (is_integer($id) || is_float($id)) { $this->id = $id; } else { throw new InvalidArgumentException(); @@ -272,15 +117,14 @@ public function getType() /** * @param string $type - * @return void */ - public function setType($type) + public function setType($type): void { $this->type = $type; } /** - * @return null|string + * @return string|null */ public function getTitle() { @@ -288,16 +132,15 @@ public function getTitle() } /** - * @param string $title - * @return void + * @param string|null $title */ - public function setTitle($title) + public function setTitle($title): void { $this->title = $title; } /** - * @return null|string + * @return string|null */ public function getUsername() { @@ -305,16 +148,15 @@ public function getUsername() } /** - * @param string $username - * @return void + * @param string|null $username */ - public function setUsername($username) + public function setUsername($username): void { $this->username = $username; } /** - * @return null|string + * @return string|null */ public function getFirstName() { @@ -322,16 +164,15 @@ public function getFirstName() } /** - * @param string $firstName - * @return void + * @param string|null $firstName */ - public function setFirstName($firstName) + public function setFirstName($firstName): void { $this->firstName = $firstName; } /** - * @return null|string + * @return string|null */ public function getLastName() { @@ -339,269 +180,13 @@ public function getLastName() } /** - * @param string $lastName - * @return void + * @param string|null $lastName */ - public function setLastName($lastName) + public function setLastName($lastName): void { $this->lastName = $lastName; } - /** - * @return ChatPhoto|null - */ - public function getPhoto() - { - return $this->photo; - } - - /** - * @param ChatPhoto $photo - * @return void - */ - public function setPhoto($photo) - { - $this->photo = $photo; - } - - /** - * @return null|string - */ - public function getBio() - { - return $this->bio; - } - - /** - * @param string $bio - * @return void - */ - public function setBio($bio) - { - $this->bio = $bio; - } - - /** - * @return null|string - */ - public function getDescription() - { - return $this->description; - } - - /** - * @param string $description - * @return void - */ - public function setDescription($description) - { - $this->description = $description; - } - - /** - * @return null|string - */ - public function getInviteLink() - { - return $this->inviteLink; - } - - /** - * @param string $inviteLink - * @return void - */ - public function setInviteLink($inviteLink) - { - $this->inviteLink = $inviteLink; - } - - /** - * @return Message|null - */ - public function getPinnedMessage() - { - return $this->pinnedMessage; - } - - /** - * @param Message $pinnedMessage - * @return void - */ - public function setPinnedMessage($pinnedMessage) - { - $this->pinnedMessage = $pinnedMessage; - } - - /** - * @return ChatPermissions|null - */ - public function getPermissions() - { - return $this->permissions; - } - - /** - * @param ChatPermissions $permissions - * @return void - */ - public function setPermissions($permissions) - { - $this->permissions = $permissions; - } - - /** - * @return int|null - */ - public function getSlowModeDelay() - { - return $this->slowModeDelay; - } - - /** - * @param int $slowModeDelay - * @return void - */ - public function setSlowModeDelay($slowModeDelay) - { - $this->slowModeDelay = $slowModeDelay; - } - - /** - * @return null|string - */ - public function getStickerSetName() - { - return $this->stickerSetName; - } - - /** - * @param string $stickerSetName - * @return void - */ - public function setStickerSetName($stickerSetName) - { - $this->stickerSetName = $stickerSetName; - } - - /** - * @return bool|null - */ - public function getCanSetStickerSet() - { - return $this->canSetStickerSet; - } - - /** - * @param bool $canSetStickerSet - * @return void - */ - public function setCanSetStickerSet($canSetStickerSet) - { - $this->canSetStickerSet = $canSetStickerSet; - } - - /** - * @return int|null - */ - public function getLinkedChatId() - { - return $this->linkedChatId; - } - - /** - * @param int $linkedChatId - * @return void - */ - public function setLinkedChatId($linkedChatId) - { - $this->linkedChatId = $linkedChatId; - } - - /** - * @return ChatLocation|null - */ - public function getLocation() - { - return $this->location; - } - - /** - * @param ChatLocation $location - * @return void - */ - public function setLocation($location) - { - $this->location = $location; - } - - /** - * @return bool|null - */ - public function getJoinToSendMessages() - { - return $this->joinToSendMessages; - } - - /** - * @param bool $joinToSendMessages - * @return void - */ - public function setJoinToSendMessages($joinToSendMessages) - { - $this->joinToSendMessages = $joinToSendMessages; - } - - /** - * @return bool|null - */ - public function getJoinByRequest() - { - return $this->joinByRequest; - } - - /** - * @param bool $joinByRequest - * @return void - */ - public function setJoinByRequest($joinByRequest) - { - $this->joinByRequest = $joinByRequest; - } - - /** - * @return int|null - */ - public function getMessageAutoDeleteTime() - { - return $this->messageAutoDeleteTime; - } - - /** - * @param int $messageAutoDeleteTime - * @return void - */ - public function setMessageAutoDeleteTime($messageAutoDeleteTime) - { - $this->messageAutoDeleteTime = $messageAutoDeleteTime; - } - - /** - * @return bool|null - */ - public function getHasProtectedContent() - { - return $this->hasProtectedContent; - } - - /** - * @param bool $hasProtectedContent - * @return void - */ - public function setHasProtectedContent($hasProtectedContent) - { - $this->hasProtectedContent = $hasProtectedContent; - } - /** * @return bool|null */ @@ -611,81 +196,10 @@ public function getIsForum() } /** - * @param bool $isForum - * @return void + * @param bool|null $isForum */ - public function setIsForum($isForum) + public function setIsForum($isForum): void { $this->isForum = $isForum; } - - /** - * @return array[]|null - * - * @psalm-return array|null - */ - public function getActiveUsernames() - { - return $this->activeUsernames; - } - - /** - * @param array $activeUsernames - * @return void - */ - public function setActiveUsernames($activeUsernames) - { - $this->activeUsernames = $activeUsernames; - } - - /** - * @return null|string - */ - public function getEmojiStatusCustomEmojiId() - { - return $this->emojiStatusCustomEmojiId; - } - - /** - * @param string $emojiStatusCustomEmojiId - * @return void - */ - public function setEmojiStatusCustomEmojiId($emojiStatusCustomEmojiId) - { - $this->emojiStatusCustomEmojiId = $emojiStatusCustomEmojiId; - } - - /** - * @return bool|null - */ - public function getHasPrivateForwards() - { - return $this->hasPrivateForwards; - } - - /** - * @param bool $hasPrivateForwards - * @return void - */ - public function setHasPrivateForwards($hasPrivateForwards) - { - $this->hasPrivateForwards = $hasPrivateForwards; - } - - /** - * @return bool|null - */ - public function getHasRestrictedVoiceAndVideoMessages() - { - return $this->hasRestrictedVoiceAndVideoMessages; - } - - /** - * @param bool $hasRestrictedVoiceAndVideoMessages - * @return void - */ - public function setHasRestrictedVoiceAndVideoMessages($hasRestrictedVoiceAndVideoMessages) - { - $this->hasRestrictedVoiceAndVideoMessages = $hasRestrictedVoiceAndVideoMessages; - } } diff --git a/src/Types/ChatAdministratorRights.php b/src/Types/ChatAdministratorRights.php new file mode 100644 index 00000000..a2b54a9c --- /dev/null +++ b/src/Types/ChatAdministratorRights.php @@ -0,0 +1,411 @@ + true, + 'can_manage_chat' => true, + 'can_delete_messages' => true, + 'can_manage_video_chats' => true, + 'can_restrict_members' => true, + 'can_promote_members' => true, + 'can_change_info' => true, + 'can_invite_users' => true, + 'can_post_stories' => true, + 'can_edit_stories' => true, + 'can_delete_stories' => true, + 'can_post_messages' => true, + 'can_edit_messages' => true, + 'can_pin_messages' => true, + 'can_manage_topics' => true, + ]; + + /** + * True, if the user's presence in the chat is hidden + * + * @var bool + */ + protected $isAnonymous; + + /** + * True, if the administrator can access the chat event log, get boost list, see hidden supergroup and channel members, report spam messages and ignore slow mode. Implied by any other administrator privilege. + * + * @var bool + */ + protected $canManageChat; + + /** + * True, if the administrator can delete messages of other users + * + * @var bool + */ + protected $canDeleteMessages; + + /** + * True, if the administrator can manage video chats + * + * @var bool + */ + protected $canManageVideoChats; + + /** + * True, if the administrator can restrict, ban or unban chat members, or access supergroup statistics + * + * @var bool + */ + protected $canRestrictMembers; + + /** + * True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that they have promoted, directly or indirectly (promoted by administrators that were appointed by the user) + * + * @var bool + */ + protected $canPromoteMembers; + + /** + * True, if the user is allowed to change the chat title, photo and other settings + * + * @var bool + */ + protected $canChangeInfo; + + /** + * True, if the user is allowed to invite new users to the chat + * + * @var bool + */ + protected $canInviteUsers; + + /** + * True, if the administrator can post stories to the chat + * + * @var bool + */ + protected $canPostStories; + + /** + * True, if the administrator can edit stories posted by other users, post stories to the chat page, pin chat stories, and access the chat's story archive + * + * @var bool + */ + protected $canEditStories; + + /** + * True, if the administrator can delete stories posted by other users + * + * @var bool + */ + protected $canDeleteStories; + + /** + * Optional. True, if the administrator can post messages in the channel, or access channel statistics; for channels only + * + * @var bool|null + */ + protected $canPostMessages; + + /** + * Optional. True, if the administrator can edit messages of other users and can pin messages; for channels only + * + * @var bool|null + */ + protected $canEditMessages; + + /** + * Optional. True, if the user is allowed to pin messages; for groups and supergroups only + * + * @var bool|null + */ + protected $canPinMessages; + + /** + * Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; for supergroups only + * + * @var bool|null + */ + protected $canManageTopics; + + /** + * @return bool + */ + public function isAnonymous() + { + return $this->isAnonymous; + } + + /** + * @param bool $isAnonymous + * @return void + */ + public function setIsAnonymous($isAnonymous) + { + $this->isAnonymous = $isAnonymous; + } + + /** + * @return bool + */ + public function canManageChat() + { + return $this->canManageChat; + } + + /** + * @param bool $canManageChat + * @return void + */ + public function setCanManageChat($canManageChat) + { + $this->canManageChat = $canManageChat; + } + + /** + * @return bool + */ + public function canDeleteMessages() + { + return $this->canDeleteMessages; + } + + /** + * @param bool $canDeleteMessages + * @return void + */ + public function setCanDeleteMessages($canDeleteMessages) + { + $this->canDeleteMessages = $canDeleteMessages; + } + + /** + * @return bool + */ + public function canManageVideoChats() + { + return $this->canManageVideoChats; + } + + /** + * @param bool $canManageVideoChats + * @return void + */ + public function setCanManageVideoChats($canManageVideoChats) + { + $this->canManageVideoChats = $canManageVideoChats; + } + + /** + * @return bool + */ + public function canRestrictMembers() + { + return $this->canRestrictMembers; + } + + /** + * @param bool $canRestrictMembers + * @return void + */ + public function setCanRestrictMembers($canRestrictMembers) + { + $this->canRestrictMembers = $canRestrictMembers; + } + + /** + * @return bool + */ + public function canPromoteMembers() + { + return $this->canPromoteMembers; + } + + /** + * @param bool $canPromoteMembers + * @return void + */ + public function setCanPromoteMembers($canPromoteMembers) + { + $this->canPromoteMembers = $canPromoteMembers; + } + + /** + * @return bool + */ + public function canChangeInfo() + { + return $this->canChangeInfo; + } + + /** + * @param bool $canChangeInfo + * @return void + */ + public function setCanChangeInfo($canChangeInfo) + { + $this->canChangeInfo = $canChangeInfo; + } + + /** + * @return bool + */ + public function canInviteUsers() + { + return $this->canInviteUsers; + } + + /** + * @param bool $canInviteUsers + * @return void + */ + public function setCanInviteUsers($canInviteUsers) + { + $this->canInviteUsers = $canInviteUsers; + } + + /** + * @return bool + */ + public function canPostStories() + { + return $this->canPostStories; + } + + /** + * @param bool $canPostStories + * @return void + */ + public function setCanPostStories($canPostStories) + { + $this->canPostStories = $canPostStories; + } + + /** + * @return bool + */ + public function canEditStories() + { + return $this->canEditStories; + } + + /** + * @param bool $canEditStories + * @return void + */ + public function setCanEditStories($canEditStories) + { + $this->canEditStories = $canEditStories; + } + + /** + * @return bool + */ + public function canDeleteStories() + { + return $this->canDeleteStories; + } + + /** + * @param bool $canDeleteStories + * @return void + */ + public function setCanDeleteStories($canDeleteStories) + { + $this->canDeleteStories = $canDeleteStories; + } + + /** + * @return bool|null + */ + public function canPostMessages() + { + return $this->canPostMessages; + } + + /** + * @param bool|null $canPostMessages + * @return void + */ + public function setCanPostMessages($canPostMessages) + { + $this->canPostMessages = $canPostMessages; + } + + /** + * @return bool|null + */ + public function canEditMessages() + { + return $this->canEditMessages; + } + + /** + * @param bool|null $canEditMessages + * @return void + */ + public function setCanEditMessages($canEditMessages) + { + $this->canEditMessages = $canEditMessages; + } + + /** + * @return bool|null + */ + public function canPinMessages() + { + return $this->canPinMessages; + } + + /** + * @param bool|null $canPinMessages + * @return void + */ + public function setCanPinMessages($canPinMessages) + { + $this->canPinMessages = $canPinMessages; + } + + /** + * @return bool|null + */ + public function canManageTopics() + { + return $this->canManageTopics; + } + + /** + * @param bool|null $canManageTopics + * @return void + */ + public function setCanManageTopics($canManageTopics) + { + $this->canManageTopics = $canManageTopics; + } +} diff --git a/src/Types/ChatBackground.php b/src/Types/ChatBackground.php new file mode 100644 index 00000000..614c9469 --- /dev/null +++ b/src/Types/ChatBackground.php @@ -0,0 +1,55 @@ + BackgroundType::class, + ]; + + /** + * Type of the background + * + * @var BackgroundType + */ + protected $type; + + /** + * @return BackgroundType + */ + public function getType() + { + return $this->type; + } + + /** + * @param BackgroundType $type + * @return void + */ + public function setType(BackgroundType $type) + { + $this->type = $type; + } +} diff --git a/src/Types/ChatBoost.php b/src/Types/ChatBoost.php new file mode 100644 index 00000000..a913c839 --- /dev/null +++ b/src/Types/ChatBoost.php @@ -0,0 +1,126 @@ + true, + 'add_date' => true, + 'expiration_date' => true, + 'source' => ChatBoostSource::class + ]; + + /** + * Unique identifier of the boost + * + * @var string + */ + protected $boostId; + + /** + * Point in time (Unix timestamp) when the chat was boosted + * + * @var int + */ + protected $addDate; + + /** + * Point in time (Unix timestamp) when the boost will automatically expire, unless the booster's Telegram Premium subscription is prolonged + * + * @var int + */ + protected $expirationDate; + + /** + * Source of the added boost + * + * @var ChatBoostSource + */ + protected $source; + + /** + * @return string + */ + public function getBoostId() + { + return $this->boostId; + } + + /** + * @param string $boostId + */ + public function setBoostId($boostId) + { + $this->boostId = $boostId; + } + + /** + * @return int + */ + public function getAddDate() + { + return $this->addDate; + } + + /** + * @param int $addDate + */ + public function setAddDate($addDate) + { + $this->addDate = $addDate; + } + + /** + * @return int + */ + public function getExpirationDate() + { + return $this->expirationDate; + } + + /** + * @param int $expirationDate + */ + public function setExpirationDate($expirationDate) + { + $this->expirationDate = $expirationDate; + } + + /** + * @return ChatBoostSource + */ + public function getSource() + { + return $this->source; + } + + /** + * @param ChatBoostSource $source + */ + public function setSource($source) + { + $this->source = $source; + } +} diff --git a/src/Types/ChatBoostAdded.php b/src/Types/ChatBoostAdded.php new file mode 100644 index 00000000..5e040e80 --- /dev/null +++ b/src/Types/ChatBoostAdded.php @@ -0,0 +1,55 @@ + true, + ]; + + /** + * Number of boosts added by the user + * + * @var int + */ + protected $boostCount; + + /** + * @return int + */ + public function getBoostCount() + { + return $this->boostCount; + } + + /** + * @param int $boostCount + * @return void + */ + public function setBoostCount($boostCount) + { + $this->boostCount = $boostCount; + } +} diff --git a/src/Types/ChatBoostRemoved.php b/src/Types/ChatBoostRemoved.php new file mode 100644 index 00000000..8ec1e8f9 --- /dev/null +++ b/src/Types/ChatBoostRemoved.php @@ -0,0 +1,126 @@ + Chat::class, + 'boost_id' => true, + 'remove_date' => true, + 'source' => ChatBoostSource::class + ]; + + /** + * Chat which was boosted + * + * @var Chat + */ + protected $chat; + + /** + * Unique identifier of the boost + * + * @var string + */ + protected $boostId; + + /** + * Point in time (Unix timestamp) when the boost was removed + * + * @var int + */ + protected $removeDate; + + /** + * Source of the removed boost + * + * @var ChatBoostSource + */ + protected $source; + + /** + * @return Chat + */ + public function getChat() + { + return $this->chat; + } + + /** + * @param Chat $chat + */ + public function setChat($chat) + { + $this->chat = $chat; + } + + /** + * @return string + */ + public function getBoostId() + { + return $this->boostId; + } + + /** + * @param string $boostId + */ + public function setBoostId($boostId) + { + $this->boostId = $boostId; + } + + /** + * @return int + */ + public function getRemoveDate() + { + return $this->removeDate; + } + + /** + * @param int $removeDate + */ + public function setRemoveDate($removeDate) + { + $this->removeDate = $removeDate; + } + + /** + * @return ChatBoostSource + */ + public function getSource() + { + return $this->source; + } + + /** + * @param ChatBoostSource $source + */ + public function setSource($source) + { + $this->source = $source; + } +} diff --git a/src/Types/ChatBoostSource.php b/src/Types/ChatBoostSource.php new file mode 100644 index 00000000..bb3a0917 --- /dev/null +++ b/src/Types/ChatBoostSource.php @@ -0,0 +1,96 @@ + true, + 'user' => User::class, + ]; + + public static function fromResponse($data) + { + self::validate($data); + $source = $data['source']; + + switch ($source) { + case 'premium': + return ChatBoostSourcePremium::fromResponse($data); + case 'gift_code': + return ChatBoostSourceGiftCode::fromResponse($data); + case 'giveaway': + return ChatBoostSourceGiveaway::fromResponse($data); + default: + throw new InvalidArgumentException("Unknown chat boost source: $source"); + } + } + + /** + * Source of the boost, always “premium”, “gift_code”, or “giveaway” + * + * @var string + */ + protected $source; + + /** + * User that boosted the chat or for which the gift code was created + * + * @var User + */ + protected $user; + + /** + * @return string + */ + public function getSource() + { + return $this->source; + } + + /** + * @param string $source + */ + public function setSource($source) + { + $this->source = $source; + } + + /** + * @return User + */ + public function getUser() + { + return $this->user; + } + + /** + * @param User $user + */ + public function setUser($user) + { + $this->user = $user; + } +} diff --git a/src/Types/ChatBoostSourceGiftCode.php b/src/Types/ChatBoostSourceGiftCode.php new file mode 100644 index 00000000..f54f6cc7 --- /dev/null +++ b/src/Types/ChatBoostSourceGiftCode.php @@ -0,0 +1,53 @@ + true, + 'user' => User::class + ]; + + /** + * Source of the boost, always “gift_code” + * + * @var string + */ + protected $source = 'gift_code'; + + /** + * User for which the gift code was created + * + * @var User + */ + protected $user; + + public static function fromResponse($data) + { + self::validate($data); + /** @psalm-suppress UnsafeInstantiation */ + $instance = new static(); + $instance->map($data); + + return $instance; + } +} diff --git a/src/Types/ChatBoostSourceGiveaway.php b/src/Types/ChatBoostSourceGiveaway.php new file mode 100644 index 00000000..941e45a8 --- /dev/null +++ b/src/Types/ChatBoostSourceGiveaway.php @@ -0,0 +1,103 @@ + true, + 'giveaway_message_id' => true, + 'user' => User::class, + 'is_unclaimed' => true + ]; + + public static function fromResponse($data) + { + self::validate($data); + /** @psalm-suppress UnsafeInstantiation */ + $instance = new static(); + $instance->map($data); + + return $instance; + } + + /** + * Source of the boost, always “giveaway” + * + * @var string + */ + protected $source = 'giveaway'; + + /** + * Identifier of a message in the chat with the giveaway + * + * @var int|null + */ + protected $giveawayMessageId; + + /** + * Optional. User that won the prize in the giveaway if any + * + * @var User|null + */ + protected $user; + + /** + * Optional. True, if the giveaway was completed, but there was no user to win the prize + * + * @var bool|null + */ + protected $isUnclaimed; + + /** + * @return int|null + */ + public function getGiveawayMessageId(): ?int + { + return $this->giveawayMessageId; + } + + /** + * @param int|null $giveawayMessageId + * @return void + */ + public function setGiveawayMessageId(?int $giveawayMessageId): void + { + $this->giveawayMessageId = $giveawayMessageId; + } + + /** + * @return bool|null + */ + public function getIsUnclaimed(): ?bool + { + return $this->isUnclaimed; + } + + /** + * @param bool|null $isUnclaimed + * @return void + */ + public function setIsUnclaimed(?bool $isUnclaimed): void + { + $this->isUnclaimed = $isUnclaimed; + } +} diff --git a/src/Types/ChatBoostSourcePremium.php b/src/Types/ChatBoostSourcePremium.php new file mode 100644 index 00000000..9e05b62f --- /dev/null +++ b/src/Types/ChatBoostSourcePremium.php @@ -0,0 +1,85 @@ + true, + 'user' => User::class + ]; + + /** + * Source of the boost, always “premium” + * + * @var string + */ + protected $source = 'premium'; + + /** + * User that boosted the chat + * + * @var User + */ + protected $user; + + public static function fromResponse($data) + { + self::validate($data); + /** @psalm-suppress UnsafeInstantiation */ + $instance = new static(); + $instance->map($data); + + return $instance; + } + + /** + * @return string + */ + public function getSource(): string + { + return $this->source; + } + + /** + * @param string $source + */ + public function setSource($source): void + { + $this->source = $source; + } + + /** + * @return User + */ + public function getUser(): User + { + return $this->user; + } + + /** + * @param User $user + */ + public function setUser($user): void + { + $this->user = $user; + } +} diff --git a/src/Types/ChatBoostUpdated.php b/src/Types/ChatBoostUpdated.php new file mode 100644 index 00000000..1298db0c --- /dev/null +++ b/src/Types/ChatBoostUpdated.php @@ -0,0 +1,78 @@ + Chat::class, + 'boost' => ChatBoost::class + ]; + + /** + * Chat which was boosted + * + * @var Chat + */ + protected $chat; + + /** + * Information about the chat boost + * + * @var ChatBoost + */ + protected $boost; + + /** + * @return Chat + */ + public function getChat() + { + return $this->chat; + } + + /** + * @param Chat $chat + */ + public function setChat($chat) + { + $this->chat = $chat; + } + + /** + * @return ChatBoost + */ + public function getBoost() + { + return $this->boost; + } + + /** + * @param ChatBoost $boost + */ + public function setBoost($boost) + { + $this->boost = $boost; + } +} diff --git a/src/Types/ChatFullInfo.php b/src/Types/ChatFullInfo.php new file mode 100644 index 00000000..b3a93cfa --- /dev/null +++ b/src/Types/ChatFullInfo.php @@ -0,0 +1,1069 @@ + true, + 'type' => true, + 'title' => true, + 'username' => true, + 'first_name' => true, + 'last_name' => true, + 'is_forum' => true, + 'accent_color_id' => true, + 'max_reaction_count' => true, + 'photo' => ChatPhoto::class, + 'active_usernames' => true, + 'birthdate' => true, + 'business_intro' => true, + 'business_location' => true, + 'business_opening_hours' => true, + 'personal_chat' => Chat::class, + 'available_reactions' => ArrayOfReactionType::class, + 'background_custom_emoji_id' => true, + 'profile_accent_color_id' => true, + 'profile_background_custom_emoji_id' => true, + 'emoji_status_custom_emoji_id' => true, + 'emoji_status_expiration_date' => true, + 'bio' => true, + 'has_private_forwards' => true, + 'has_restricted_voice_and_video_messages' => true, + 'join_to_send_messages' => true, + 'join_by_request' => true, + 'description' => true, + 'invite_link' => true, + 'pinned_message' => Message::class, + 'permissions' => ChatPermissions::class, + 'slow_mode_delay' => true, + 'unrestrict_boost_count' => true, + 'message_auto_delete_time' => true, + 'has_aggressive_anti_spam_enabled' => true, + 'has_hidden_members' => true, + 'has_protected_content' => true, + 'has_visible_history' => true, + 'sticker_set_name' => true, + 'can_set_sticker_set' => true, + 'custom_emoji_sticker_set_name' => true, + 'linked_chat_id' => true, + 'location' => ChatLocation::class, + ]; + + /** + * Unique identifier for this chat. + * + * @var int|float|string + */ + protected $id; + + /** + * Type of chat, can be either “private”, “group”, “supergroup” or “channel”. + * + * @var string + */ + protected $type; + + /** + * Optional. Title, for supergroups, channels and group chats. + * + * @var string|null + */ + protected $title; + + /** + * Optional. Username, for private chats, supergroups and channels if available. + * + * @var string|null + */ + protected $username; + + /** + * Optional. First name of the other party in a private chat. + * + * @var string|null + */ + protected $firstName; + + /** + * Optional. Last name of the other party in a private chat. + * + * @var string|null + */ + protected $lastName; + + /** + * Optional. True, if the supergroup chat is a forum (has topics enabled). + * + * @var bool|null + */ + protected $isForum; + + /** + * Optional. Identifier of the accent color for the chat name and backgrounds of the chat photo, reply header, and link preview. + * + * @var int|null + */ + protected $accentColorId; + + /** + * Optional. The maximum number of reactions that can be set on a message in the chat. + * + * @var int|null + */ + protected $maxReactionCount; + + /** + * Optional. Chat photo. Returned only in getChat. + * + * @var ChatPhoto|null + */ + protected $photo; + + /** + * Optional. If non-empty, the list of all active chat usernames; for private chats, supergroups and channels. Returned only in getChat. + * + * @var array|null + */ + protected $activeUsernames; + + /** + * Optional. For private chats, the date of birth of the user. + * + * @var string|null + */ + protected $birthdate; + + /** + * Optional. For private chats with business accounts, the intro of the business. + * + * @var string|null + */ + protected $businessIntro; + + /** + * Optional. For private chats with business accounts, the location of the business. + * + * @var string|null + */ + protected $businessLocation; + + /** + * Optional. For private chats with business accounts, the opening hours of the business. + * + * @var string|null + */ + protected $businessOpeningHours; + + /** + * Optional. For private chats, the personal channel of the user. + * + * @var Chat|null + */ + protected $personalChat; + + /** + * Optional. List of available reactions allowed in the chat. If omitted, then all emoji reactions are allowed. Returned only in getChat. + * + * @var array|null + */ + protected $availableReactions; + + /** + * Optional. Custom emoji identifier of emoji chosen by the chat for the reply header and link preview background. + * + * @var string|null + */ + protected $backgroundCustomEmojiId; + + /** + * Optional. Identifier of the accent color for the chat's profile background. + * + * @var int|null + */ + protected $profileAccentColorId; + + /** + * Optional. Custom emoji identifier of the emoji chosen by the chat for its profile background. + * + * @var string|null + */ + protected $profileBackgroundCustomEmojiId; + + /** + * Optional. Custom emoji identifier of the emoji status of the chat or the other party in a private chat. Returned only in getChat. + * + * @var string|null + */ + protected $emojiStatusCustomEmojiId; + + /** + * Optional. Expiration date of the emoji status of the chat or the other party in a private chat, in Unix time, if any. + * + * @var int|null + */ + protected $emojiStatusExpirationDate; + + /** + * Optional. Bio of the other party in a private chat. Returned only in getChat. + * + * @var string|null + */ + protected $bio; + + /** + * Optional. True, if privacy settings of the other party in the private chat allows to use tg://user?id= links only in chats with the user. + * + * @var bool|null + */ + protected $hasPrivateForwards; + + /** + * Optional. True, if the privacy settings of the other party restrict sending voice and video note messages in the private chat. Returned only in getChat. + * + * @var bool|null + */ + protected $hasRestrictedVoiceAndVideoMessages; + + /** + * Optional. True, if users need to join the supergroup before they can send messages. Returned only in getChat. + * + * @var bool|null + */ + protected $joinToSendMessages; + + /** + * Optional. True, if all users directly joining the supergroup need to be approved by supergroup administrators. Returned only in getChat. + * + * @var bool|null + */ + protected $joinByRequest; + + /** + * Optional. Description, for groups, supergroups and channel chats. Returned only in getChat. + * + * @var string|null + */ + protected $description; + + /** + * Optional. Primary invite link, for groups, supergroups and channel chats. Returned only in getChat. + * + * @var string|null + */ + protected $inviteLink; + + /** + * Optional. The most recent pinned message (by sending date). Returned only in getChat. + * + * @var Message|null + */ + protected $pinnedMessage; + + /** + * Optional. Default chat member permissions, for groups and supergroups. Returned only in getChat. + * + * @var ChatPermissions|null + */ + protected $permissions; + + /** + * Optional. For supergroups, the minimum allowed delay between consecutive messages sent by each unprivileged user; in seconds. Returned only in getChat. + * + * @var int|null + */ + protected $slowModeDelay; + + /** + * Optional. For supergroups, the minimum number of boosts that a non-administrator user needs to add in order to ignore slow mode and chat permissions. + * + * @var int|null + */ + protected $unrestrictBoostCount; + + /** + * Optional. The time after which all messages sent to the chat will be automatically deleted; in seconds. Returned only in getChat. + * + * @var int|null + */ + protected $messageAutoDeleteTime; + + /** + * Optional. True, if aggressive anti-spam checks are enabled in the supergroup. The field is only available to chat administrators. Returned only in getChat. + * + * @var bool|null + */ + protected $hasAggressiveAntiSpamEnabled; + + /** + * Optional. True, if non-administrators can only get the list of bots and administrators in the chat. Returned only in getChat. + * + * @var bool|null + */ + protected $hasHiddenMembers; + + /** + * Optional. True, if messages from the chat can't be forwarded to other chats. Returned only in getChat. + * + * @var bool|null + */ + protected $hasProtectedContent; + + /** + * Optional. True, if new chat members will have access to old messages; available only to chat administrators. Returned only in getChat. + * + * @var bool|null + */ + protected $hasVisibleHistory; + + /** + * Optional. For supergroups, name of the group sticker set. Returned only in getChat. + * + * @var string|null + */ + protected $stickerSetName; + + /** + * Optional. True, if the bot can change the group sticker set. Returned only in getChat. + * + * @var bool|null + */ + protected $canSetStickerSet; + + /** + * Optional. For supergroups, the name of the group's custom emoji sticker set. Custom emoji from this set can be used by all users and bots in the group. + * + * @var string|null + */ + protected $customEmojiStickerSetName; + + /** + * Optional. Unique identifier for the linked chat, i.e. the discussion group identifier for a channel and vice versa; for supergroups and channel chats. This identifier may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier. + * + * @var int|null + */ + protected $linkedChatId; + + /** + * Optional. For supergroups, the location to which the supergroup is connected. Returned only in getChat. + * + * @var ChatLocation|null + */ + protected $location; + + /** + * @return int|float|string + */ + public function getId() + { + return $this->id; + } + + /** + * @param mixed $id + * @return void + * @throws InvalidArgumentException + */ + public function setId($id) + { + if (is_integer($id) || is_float($id) || is_string($id)) { + $this->id = $id; + } else { + throw new InvalidArgumentException(); + } + } + + /** + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * @param string $type + */ + public function setType($type) + { + $this->type = $type; + } + + /** + * @return string|null + */ + public function getTitle() + { + return $this->title; + } + + /** + * @param string|null $title + */ + public function setTitle($title) + { + $this->title = $title; + } + + /** + * @return string|null + */ + public function getUsername() + { + return $this->username; + } + + /** + * @param string|null $username + */ + public function setUsername($username) + { + $this->username = $username; + } + + /** + * @return string|null + */ + public function getFirstName() + { + return $this->firstName; + } + + /** + * @param string|null $firstName + */ + public function setFirstName($firstName) + { + $this->firstName = $firstName; + } + + /** + * @return string|null + */ + public function getLastName() + { + return $this->lastName; + } + + /** + * @param string|null $lastName + */ + public function setLastName($lastName) + { + $this->lastName = $lastName; + } + + /** + * @return bool|null + */ + public function getIsForum() + { + return $this->isForum; + } + + /** + * @param bool|null $isForum + */ + public function setIsForum($isForum) + { + $this->isForum = $isForum; + } + + /** + * @return int|null + */ + public function getAccentColorId() + { + return $this->accentColorId; + } + + /** + * @param int|null $accentColorId + */ + public function setAccentColorId($accentColorId) + { + $this->accentColorId = $accentColorId; + } + + /** + * @return int|null + */ + public function getMaxReactionCount() + { + return $this->maxReactionCount; + } + + /** + * @param int|null $maxReactionCount + */ + public function setMaxReactionCount($maxReactionCount) + { + $this->maxReactionCount = $maxReactionCount; + } + + /** + * @return ChatPhoto|null + */ + public function getPhoto() + { + return $this->photo; + } + + /** + * @param ChatPhoto|null $photo + */ + public function setPhoto($photo) + { + $this->photo = $photo; + } + + /** + * @return array|null + */ + public function getActiveUsernames() + { + return $this->activeUsernames; + } + + /** + * @param array|null $activeUsernames + */ + public function setActiveUsernames($activeUsernames) + { + $this->activeUsernames = $activeUsernames; + } + + /** + * @return string|null + */ + public function getBirthdate() + { + return $this->birthdate; + } + + /** + * @param string|null $birthdate + */ + public function setBirthdate($birthdate) + { + $this->birthdate = $birthdate; + } + + /** + * @return string|null + */ + public function getBusinessIntro() + { + return $this->businessIntro; + } + + /** + * @param string|null $businessIntro + */ + public function setBusinessIntro($businessIntro) + { + $this->businessIntro = $businessIntro; + } + + /** + * @return string|null + */ + public function getBusinessLocation() + { + return $this->businessLocation; + } + + /** + * @param string|null $businessLocation + */ + public function setBusinessLocation($businessLocation) + { + $this->businessLocation = $businessLocation; + } + + /** + * @return string|null + */ + public function getBusinessOpeningHours() + { + return $this->businessOpeningHours; + } + + /** + * @param string|null $businessOpeningHours + */ + public function setBusinessOpeningHours($businessOpeningHours) + { + $this->businessOpeningHours = $businessOpeningHours; + } + + /** + * @return Chat|null + */ + public function getPersonalChat() + { + return $this->personalChat; + } + + /** + * @param Chat|null $personalChat + */ + public function setPersonalChat($personalChat) + { + $this->personalChat = $personalChat; + } + + /** + * @return array|null + */ + public function getAvailableReactions() + { + return $this->availableReactions; + } + + /** + * @param array|null $availableReactions + */ + public function setAvailableReactions($availableReactions) + { + $this->availableReactions = $availableReactions; + } + + /** + * @return string|null + */ + public function getBackgroundCustomEmojiId() + { + return $this->backgroundCustomEmojiId; + } + + /** + * @param string|null $backgroundCustomEmojiId + */ + public function setBackgroundCustomEmojiId($backgroundCustomEmojiId) + { + $this->backgroundCustomEmojiId = $backgroundCustomEmojiId; + } + + /** + * @return int|null + */ + public function getProfileAccentColorId() + { + return $this->profileAccentColorId; + } + + /** + * @param int|null $profileAccentColorId + */ + public function setProfileAccentColorId($profileAccentColorId) + { + $this->profileAccentColorId = $profileAccentColorId; + } + + /** + * @return string|null + */ + public function getProfileBackgroundCustomEmojiId() + { + return $this->profileBackgroundCustomEmojiId; + } + + /** + * @param string|null $profileBackgroundCustomEmojiId + */ + public function setProfileBackgroundCustomEmojiId($profileBackgroundCustomEmojiId) + { + $this->profileBackgroundCustomEmojiId = $profileBackgroundCustomEmojiId; + } + + /** + * @return string|null + */ + public function getEmojiStatusCustomEmojiId() + { + return $this->emojiStatusCustomEmojiId; + } + + /** + * @param string|null $emojiStatusCustomEmojiId + */ + public function setEmojiStatusCustomEmojiId($emojiStatusCustomEmojiId) + { + $this->emojiStatusCustomEmojiId = $emojiStatusCustomEmojiId; + } + + /** + * @return int|null + */ + public function getEmojiStatusExpirationDate() + { + return $this->emojiStatusExpirationDate; + } + + /** + * @param int|null $emojiStatusExpirationDate + */ + public function setEmojiStatusExpirationDate($emojiStatusExpirationDate) + { + $this->emojiStatusExpirationDate = $emojiStatusExpirationDate; + } + + /** + * @return string|null + */ + public function getBio() + { + return $this->bio; + } + + /** + * @param string|null $bio + */ + public function setBio($bio) + { + $this->bio = $bio; + } + + /** + * @return bool|null + */ + public function getHasPrivateForwards() + { + return $this->hasPrivateForwards; + } + + /** + * @param bool|null $hasPrivateForwards + */ + public function setHasPrivateForwards($hasPrivateForwards) + { + $this->hasPrivateForwards = $hasPrivateForwards; + } + + /** + * @return bool|null + */ + public function getHasRestrictedVoiceAndVideoMessages() + { + return $this->hasRestrictedVoiceAndVideoMessages; + } + + /** + * @param bool|null $hasRestrictedVoiceAndVideoMessages + */ + public function setHasRestrictedVoiceAndVideoMessages($hasRestrictedVoiceAndVideoMessages) + { + $this->hasRestrictedVoiceAndVideoMessages = $hasRestrictedVoiceAndVideoMessages; + } + + /** + * @return bool|null + */ + public function getJoinToSendMessages() + { + return $this->joinToSendMessages; + } + + /** + * @param bool|null $joinToSendMessages + */ + public function setJoinToSendMessages($joinToSendMessages) + { + $this->joinToSendMessages = $joinToSendMessages; + } + + /** + * @return bool|null + */ + public function getJoinByRequest() + { + return $this->joinByRequest; + } + + /** + * @param bool|null $joinByRequest + */ + public function setJoinByRequest($joinByRequest) + { + $this->joinByRequest = $joinByRequest; + } + + /** + * @return string|null + */ + public function getDescription() + { + return $this->description; + } + + /** + * @param string|null $description + */ + public function setDescription($description) + { + $this->description = $description; + } + + /** + * @return string|null + */ + public function getInviteLink() + { + return $this->inviteLink; + } + + /** + * @param string|null $inviteLink + */ + public function setInviteLink($inviteLink) + { + $this->inviteLink = $inviteLink; + } + + /** + * @return Message|null + */ + public function getPinnedMessage() + { + return $this->pinnedMessage; + } + + /** + * @param Message|null $pinnedMessage + */ + public function setPinnedMessage($pinnedMessage) + { + $this->pinnedMessage = $pinnedMessage; + } + + /** + * @return ChatPermissions|null + */ + public function getPermissions() + { + return $this->permissions; + } + + /** + * @param ChatPermissions|null $permissions + */ + public function setPermissions($permissions) + { + $this->permissions = $permissions; + } + + /** + * @return int|null + */ + public function getSlowModeDelay() + { + return $this->slowModeDelay; + } + + /** + * @param int|null $slowModeDelay + */ + public function setSlowModeDelay($slowModeDelay) + { + $this->slowModeDelay = $slowModeDelay; + } + + /** + * @return int|null + */ + public function getUnrestrictBoostCount() + { + return $this->unrestrictBoostCount; + } + + /** + * @param int|null $unrestrictBoostCount + */ + public function setUnrestrictBoostCount($unrestrictBoostCount) + { + $this->unrestrictBoostCount = $unrestrictBoostCount; + } + + /** + * @return int|null + */ + public function getMessageAutoDeleteTime() + { + return $this->messageAutoDeleteTime; + } + + /** + * @param int|null $messageAutoDeleteTime + */ + public function setMessageAutoDeleteTime($messageAutoDeleteTime) + { + $this->messageAutoDeleteTime = $messageAutoDeleteTime; + } + + /** + * @return bool|null + */ + public function getHasAggressiveAntiSpamEnabled() + { + return $this->hasAggressiveAntiSpamEnabled; + } + + /** + * @param bool|null $hasAggressiveAntiSpamEnabled + */ + public function setHasAggressiveAntiSpamEnabled($hasAggressiveAntiSpamEnabled) + { + $this->hasAggressiveAntiSpamEnabled = $hasAggressiveAntiSpamEnabled; + } + + /** + * @return bool|null + */ + public function getHasHiddenMembers() + { + return $this->hasHiddenMembers; + } + + /** + * @param bool|null $hasHiddenMembers + */ + public function setHasHiddenMembers($hasHiddenMembers) + { + $this->hasHiddenMembers = $hasHiddenMembers; + } + + /** + * @return bool|null + */ + public function getHasProtectedContent() + { + return $this->hasProtectedContent; + } + + /** + * @param bool|null $hasProtectedContent + */ + public function setHasProtectedContent($hasProtectedContent) + { + $this->hasProtectedContent = $hasProtectedContent; + } + + /** + * @return bool|null + */ + public function getHasVisibleHistory() + { + return $this->hasVisibleHistory; + } + + /** + * @param bool|null $hasVisibleHistory + */ + public function setHasVisibleHistory($hasVisibleHistory) + { + $this->hasVisibleHistory = $hasVisibleHistory; + } + + /** + * @return string|null + */ + public function getStickerSetName() + { + return $this->stickerSetName; + } + + /** + * @param string|null $stickerSetName + */ + public function setStickerSetName($stickerSetName) + { + $this->stickerSetName = $stickerSetName; + } + + /** + * @return bool|null + */ + public function getCanSetStickerSet() + { + return $this->canSetStickerSet; + } + + /** + * @param bool|null $canSetStickerSet + */ + public function setCanSetStickerSet($canSetStickerSet) + { + $this->canSetStickerSet = $canSetStickerSet; + } + + /** + * @return string|null + */ + public function getCustomEmojiStickerSetName() + { + return $this->customEmojiStickerSetName; + } + + /** + * @param string|null $customEmojiStickerSetName + */ + public function setCustomEmojiStickerSetName($customEmojiStickerSetName) + { + $this->customEmojiStickerSetName = $customEmojiStickerSetName; + } + + /** + * @return int|null + */ + public function getLinkedChatId() + { + return $this->linkedChatId; + } + + /** + * @param int|null $linkedChatId + */ + public function setLinkedChatId($linkedChatId) + { + $this->linkedChatId = $linkedChatId; + } + + /** + * @return ChatLocation|null + */ + public function getLocation() + { + return $this->location; + } + + /** + * @param ChatLocation|null $location + */ + public function setLocation($location) + { + $this->location = $location; + } +} diff --git a/src/Types/ChatMember.php b/src/Types/ChatMember.php index 808597e0..f8df0915 100644 --- a/src/Types/ChatMember.php +++ b/src/Types/ChatMember.php @@ -3,15 +3,47 @@ namespace TelegramBot\Api\Types; use TelegramBot\Api\BaseType; +use TelegramBot\Api\InvalidArgumentException; +use TelegramBot\Api\TypeInterface; -class ChatMember extends BaseType +abstract class ChatMember extends BaseType implements TypeInterface { /** * {@inheritdoc} * * @var array */ - protected static $requiredParams = ['user', 'status']; + protected static $requiredParams = ['status', 'user']; + + /** + * Factory method to create a concrete ChatMember instance + * + * @param array $data + * @return ChatMember + * @throws InvalidArgumentException + */ + public static function fromResponse($data) + { + self::validate($data); + $status = $data['status']; + + switch ($status) { + case 'creator': + return ChatMemberOwner::fromResponse($data); + case 'administrator': + return ChatMemberAdministrator::fromResponse($data); + case 'member': + return ChatMemberMember::fromResponse($data); + case 'restricted': + return ChatMemberRestricted::fromResponse($data); + case 'left': + return ChatMemberLeft::fromResponse($data); + case 'kicked': + return ChatMemberBanned::fromResponse($data); + default: + throw new InvalidArgumentException("Unknown chat member status: $status"); + } + } /** * {@inheritdoc} @@ -19,199 +51,23 @@ class ChatMember extends BaseType * @var array */ protected static $map = [ - 'user' => User::class, 'status' => true, - 'until_date' => true, - 'can_be_edited' => true, - 'can_change_info' => true, - 'can_post_messages' => true, - 'can_edit_messages' => true, - 'can_delete_messages' => true, - 'can_invite_users' => true, - 'can_restrict_members' => true, - 'can_pin_messages' => true, - 'can_promote_members' => true, - 'can_send_messages' => true, - 'can_send_media_messages' => true, - 'can_send_other_messages' => true, - 'can_add_web_page_previews' => true, - 'can_manage_topics' => true, - 'is_anonymous' => true, - 'custom_title' => true, - 'can_manage_chat' => true, - 'can_send_polls' => true, + 'user' => User::class, ]; /** - * Information about the user - * - * @var User - */ - protected $user; - - /** - * The member's status in the chat. Can be “creator”, “administrator”, “member”, “restricted”, “left” or “kicked” + * The member's status in the chat * * @var string */ protected $status; /** - * Optional. Restricted and kicked only. Date when restrictions will be lifted for this user, unix time - * - * @var integer|null - */ - protected $untilDate; - - /** - * Optional. Administrators only. True, if the bot is allowed to edit administrator privileges of that user - * - * @var bool|null - */ - protected $canBeEdited; - - /** - * Optional. Administrators only. True, if the administrator can change the chat title, photo and other settings - * - * @var bool|null - */ - protected $canChangeInfo; - - /** - * Optional. Administrators only. True, if the administrator can post in the channel, channels only - * - * @var bool|null - */ - protected $canPostMessages; - - /** - * Optional. Administrators only. True, if the administrator can edit messages of other users, channels only - * - * @var bool|null - */ - protected $canEditMessages; - - /** - * Optional. Administrators only. True, if the administrator can delete messages of other users - * - * @var bool|null - */ - protected $canDeleteMessages; - - /** - * Optional. Administrators only. True, if the administrator can invite new users to the chat - * - * @var bool|null - */ - protected $canInviteUsers; - - /** - * Optional. Administrators only. True, if the administrator can restrict, ban or unban chat members - * - * @var bool|null - */ - protected $canRestrictMembers; - - /** - * Optional. Administrators only. True, if the administrator can pin messages, supergroups only - * - * @var bool|null - */ - protected $canPinMessages; - - /** - * Optional. Administrators only. True, if the administrator can add new administrators with a subset of his own - * privileges or demote administrators that he has promoted, directly or indirectly - * (promoted by administrators that were appointed by the user) - * - * @var bool|null - */ - protected $canPromoteMembers; - - /** - * Optional. Restricted only. True, if the user can send text messages, contacts, locations and venues - * - * @var bool|null - */ - protected $canSendMessages; - - /** - * Optional. Restricted only. True, if the user can send audios, documents, photos, videos, video notes - * and voice notes, implies can_send_messages - * - * @var bool|null - */ - protected $canSendMediaMessages; - - /** - * Optional. Restricted only. True, if the user can send animations, games, stickers and use inline bots, - * implies can_send_media_messages - * - * @var bool|null - */ - protected $canSendOtherMessages; - - /** - * Optional. Restricted only. True, if user may add web page previews to his messages, - * implies can_send_media_messages - * - * @var bool|null - */ - protected $canAddWebPagePreviews; - - /** - * Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; supergroups only - * - * @var bool|null - */ - protected $canManageTopics; - - /** - * True, if the user's presence in the chat is hidden - * - * @var bool - */ - protected $isAnonymous; - - /** - * Optional. Custom title for this user - * - * @var string|null - */ - protected $customTitle; - - /** - * True, if the administrator can access the chat event log, chat statistics, message statistics in channels, - * see channel members, see anonymous administrators in supergroups and ignore slow mode. - * Implied by any other administrator privilege - * - * @var bool - */ - protected $canManageChat; - - /** - * True, if the user is allowed to send polls + * Information about the user * - * @var bool - */ - protected $canSendPolls; - - /** - * @return User - */ - public function getUser() - { - return $this->user; - } - - /** - * @param User $user - * @return void + * @var User */ - public function setUser($user) - { - $this->user = $user; - } + protected $user; /** * @return string @@ -231,325 +87,19 @@ public function setStatus($status) } /** - * @return int|null - */ - public function getUntilDate() - { - return $this->untilDate; - } - - /** - * @param int $untilDate - * @return void - */ - public function setUntilDate($untilDate) - { - $this->untilDate = $untilDate; - } - - /** - * @return bool|null - */ - public function getCanBeEdited() - { - return $this->canBeEdited; - } - - /** - * @param bool $canBeEdited - * @return void - */ - public function setCanBeEdited($canBeEdited) - { - $this->canBeEdited = $canBeEdited; - } - - /** - * @return bool|null - */ - public function getCanChangeInfo() - { - return $this->canChangeInfo; - } - - /** - * @param bool $canChangeInfo - * @return void - */ - public function setCanChangeInfo($canChangeInfo) - { - $this->canChangeInfo = $canChangeInfo; - } - - /** - * @return bool|null - */ - public function getCanPostMessages() - { - return $this->canPostMessages; - } - - /** - * @param bool $canPostMessages - * @return void - */ - public function setCanPostMessages($canPostMessages) - { - $this->canPostMessages = $canPostMessages; - } - - /** - * @return bool|null - */ - public function getCanEditMessages() - { - return $this->canEditMessages; - } - - /** - * @param bool $canEditMessages - * @return void - */ - public function setCanEditMessages($canEditMessages) - { - $this->canEditMessages = $canEditMessages; - } - - /** - * @return bool|null - */ - public function getCanDeleteMessages() - { - return $this->canDeleteMessages; - } - - /** - * @param bool $canDeleteMessages - * @return void - */ - public function setCanDeleteMessages($canDeleteMessages) - { - $this->canDeleteMessages = $canDeleteMessages; - } - - /** - * @return bool|null - */ - public function getCanInviteUsers() - { - return $this->canInviteUsers; - } - - /** - * @param bool $canInviteUsers - * @return void - */ - public function setCanInviteUsers($canInviteUsers) - { - $this->canInviteUsers = $canInviteUsers; - } - - /** - * @return bool|null - */ - public function getCanRestrictMembers() - { - return $this->canRestrictMembers; - } - - /** - * @param bool $canRestrictMembers - * @return void - */ - public function setCanRestrictMembers($canRestrictMembers) - { - $this->canRestrictMembers = $canRestrictMembers; - } - - /** - * @return bool|null - */ - public function getCanPinMessages() - { - return $this->canPinMessages; - } - - /** - * @param bool $canPinMessages - * @return void - */ - public function setCanPinMessages($canPinMessages) - { - $this->canPinMessages = $canPinMessages; - } - - /** - * @return bool|null - */ - public function getCanPromoteMembers() - { - return $this->canPromoteMembers; - } - - /** - * @param bool $canPromoteMembers - * @return void - */ - public function setCanPromoteMembers($canPromoteMembers) - { - $this->canPromoteMembers = $canPromoteMembers; - } - - /** - * @return bool|null - */ - public function getCanSendMessages() - { - return $this->canSendMessages; - } - - /** - * @param bool $canSendMessages - * @return void - */ - public function setCanSendMessages($canSendMessages) - { - $this->canSendMessages = $canSendMessages; - } - - /** - * @return bool|null - */ - public function getCanSendMediaMessages() - { - return $this->canSendMediaMessages; - } - - /** - * @param bool $canSendMediaMessages - * @return void - */ - public function setCanSendMediaMessages($canSendMediaMessages) - { - $this->canSendMediaMessages = $canSendMediaMessages; - } - - /** - * @return bool|null - */ - public function getCanSendOtherMessages() - { - return $this->canSendOtherMessages; - } - - /** - * @param bool $canSendOtherMessages - * @return void - */ - public function setCanSendOtherMessages($canSendOtherMessages) - { - $this->canSendOtherMessages = $canSendOtherMessages; - } - - /** - * @return bool|null - */ - public function getCanAddWebPagePreviews() - { - return $this->canAddWebPagePreviews; - } - - /** - * @param bool $canAddWebPagePreviews - * @return void - */ - public function setCanAddWebPagePreviews($canAddWebPagePreviews) - { - $this->canAddWebPagePreviews = $canAddWebPagePreviews; - } - - /** - * @return bool - */ - public function getCanManageChat() - { - return $this->canManageChat; - } - - /** - * @param bool $canManageChat - * @return void - */ - public function setCanManageChat($canManageChat) - { - $this->canManageChat = $canManageChat; - } - - /** - * @return bool - */ - public function getIsAnonymous() - { - return $this->isAnonymous; - } - - /** - * @param bool $isAnonymous - * @return void - */ - public function setIsAnonymous($isAnonymous) - { - $this->isAnonymous = $isAnonymous; - } - - /** - * @return bool - */ - public function getCanSendPolls() - { - return $this->canSendPolls; - } - - /** - * @param bool $canSendPolls - * @return void - */ - public function setCanSendPolls($canSendPolls) - { - $this->canSendPolls = $canSendPolls; - } - - /** - * @return bool|null - */ - public function getCanManageTopics() - { - return $this->canManageTopics; - } - - /** - * @param bool $canManageTopics - * @return void - */ - public function setCanManageTopics($canManageTopics) - { - $this->canManageTopics = $canManageTopics; - } - - /** - * @return null|string + * @return User */ - public function getCustomTitle() + public function getUser() { - return $this->customTitle; + return $this->user; } /** - * @param string $customTitle + * @param User $user * @return void */ - public function setCustomTitle($customTitle) + public function setUser($user) { - $this->customTitle = $customTitle; + $this->user = $user; } } diff --git a/src/Types/ChatMemberAdministrator.php b/src/Types/ChatMemberAdministrator.php new file mode 100644 index 00000000..0ee56bf7 --- /dev/null +++ b/src/Types/ChatMemberAdministrator.php @@ -0,0 +1,458 @@ + true, + 'user' => User::class, + 'can_be_edited' => true, + 'is_anonymous' => true, + 'can_manage_chat' => true, + 'can_delete_messages' => true, + 'can_manage_video_chats' => true, + 'can_restrict_members' => true, + 'can_promote_members' => true, + 'can_change_info' => true, + 'can_invite_users' => true, + 'can_post_stories' => true, + 'can_edit_stories' => true, + 'can_delete_stories' => true, + 'can_post_messages' => true, + 'can_edit_messages' => true, + 'can_pin_messages' => true, + 'can_manage_topics' => true, + 'custom_title' => true, + ]; + + /** + * True, if the bot is allowed to edit administrator privileges of that user + * + * @var bool + */ + protected $canBeEdited; + + /** + * True, if the user's presence in the chat is hidden + * + * @var bool + */ + protected $isAnonymous; + + /** + * True, if the administrator can access the chat event log, get boost list, see hidden supergroup and channel members, report spam messages and ignore slow mode + * + * @var bool + */ + protected $canManageChat; + + /** + * True, if the administrator can delete messages of other users + * + * @var bool + */ + protected $canDeleteMessages; + + /** + * True, if the administrator can manage video chats + * + * @var bool + */ + protected $canManageVideoChats; + + /** + * True, if the administrator can restrict, ban or unban chat members, or access supergroup statistics + * + * @var bool + */ + protected $canRestrictMembers; + + /** + * True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that they have promoted, directly or indirectly + * + * @var bool + */ + protected $canPromoteMembers; + + /** + * True, if the user is allowed to change the chat title, photo and other settings + * + * @var bool + */ + protected $canChangeInfo; + + /** + * True, if the user is allowed to invite new users to the chat + * + * @var bool + */ + protected $canInviteUsers; + + /** + * True, if the administrator can post stories to the chat + * + * @var bool|null + */ + protected $canPostStories; + + /** + * True, if the administrator can edit stories posted by other users, post stories to the chat page, pin chat stories, and access the chat's story archive + * + * @var bool|null + */ + protected $canEditStories; + + /** + * True, if the administrator can delete stories posted by other users + * + * @var bool|null + */ + protected $canDeleteStories; + + /** + * Optional. True, if the administrator can post messages in the channel, or access channel statistics; for channels only + * + * @var bool|null + */ + protected $canPostMessages; + + /** + * Optional. True, if the administrator can edit messages of other users and can pin messages; for channels only + * + * @var bool|null + */ + protected $canEditMessages; + + /** + * Optional. True, if the user is allowed to pin messages; for groups and supergroups only + * + * @var bool|null + */ + protected $canPinMessages; + + /** + * Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; for supergroups only + * + * @var bool|null + */ + protected $canManageTopics; + + /** + * Optional. Custom title for this user + * + * @var string|null + */ + protected $customTitle; + + public static function fromResponse($data) + { + self::validate($data); + /** @psalm-suppress UnsafeInstantiation */ + $instance = new static(); + $instance->map($data); + + return $instance; + } + + /** + * @return bool + */ + public function canBeEdited() + { + return $this->canBeEdited; + } + + /** + * @param bool $canBeEdited + * @return void + */ + public function setCanBeEdited($canBeEdited) + { + $this->canBeEdited = $canBeEdited; + } + + /** + * @return bool + */ + public function isAnonymous() + { + return $this->isAnonymous; + } + + /** + * @param bool $isAnonymous + * @return void + */ + public function setIsAnonymous($isAnonymous) + { + $this->isAnonymous = $isAnonymous; + } + + /** + * @return bool + */ + public function canManageChat() + { + return $this->canManageChat; + } + + /** + * @param bool $canManageChat + * @return void + */ + public function setCanManageChat($canManageChat) + { + $this->canManageChat = $canManageChat; + } + + /** + * @return bool + */ + public function canDeleteMessages() + { + return $this->canDeleteMessages; + } + + /** + * @param bool $canDeleteMessages + * @return void + */ + public function setCanDeleteMessages($canDeleteMessages) + { + $this->canDeleteMessages = $canDeleteMessages; + } + + /** + * @return bool + */ + public function canManageVideoChats() + { + return $this->canManageVideoChats; + } + + /** + * @param bool $canManageVideoChats + * @return void + */ + public function setCanManageVideoChats($canManageVideoChats) + { + $this->canManageVideoChats = $canManageVideoChats; + } + + /** + * @return bool + */ + public function canRestrictMembers() + { + return $this->canRestrictMembers; + } + + /** + * @param bool $canRestrictMembers + * @return void + */ + public function setCanRestrictMembers($canRestrictMembers) + { + $this->canRestrictMembers = $canRestrictMembers; + } + + /** + * @return bool + */ + public function canPromoteMembers() + { + return $this->canPromoteMembers; + } + + /** + * @param bool $canPromoteMembers + * @return void + */ + public function setCanPromoteMembers($canPromoteMembers) + { + $this->canPromoteMembers = $canPromoteMembers; + } + + /** + * @return bool + */ + public function canChangeInfo() + { + return $this->canChangeInfo; + } + + /** + * @param bool $canChangeInfo + * @return void + */ + public function setCanChangeInfo($canChangeInfo) + { + $this->canChangeInfo = $canChangeInfo; + } + + /** + * @return bool + */ + public function canInviteUsers() + { + return $this->canInviteUsers; + } + + /** + * @param bool $canInviteUsers + * @return void + */ + public function setCanInviteUsers($canInviteUsers) + { + $this->canInviteUsers = $canInviteUsers; + } + + /** + * @return bool|null + */ + public function canPostStories() + { + return $this->canPostStories; + } + + /** + * @param bool|null $canPostStories + * @return void + */ + public function setCanPostStories($canPostStories) + { + $this->canPostStories = $canPostStories; + } + + /** + * @return bool|null + */ + public function canEditStories() + { + return $this->canEditStories; + } + + /** + * @param bool|null $canEditStories + * @return void + */ + public function setCanEditStories($canEditStories) + { + $this->canEditStories = $canEditStories; + } + + /** + * @return bool|null + */ + public function canDeleteStories() + { + return $this->canDeleteStories; + } + + /** + * @param bool|null $canDeleteStories + * @return void + */ + public function setCanDeleteStories($canDeleteStories) + { + $this->canDeleteStories = $canDeleteStories; + } + + /** + * @return bool|null + */ + public function canPostMessages() + { + return $this->canPostMessages; + } + + /** + * @param bool|null $canPostMessages + * @return void + */ + public function setCanPostMessages($canPostMessages) + { + $this->canPostMessages = $canPostMessages; + } + + /** + * @return bool|null + */ + public function canEditMessages() + { + return $this->canEditMessages; + } + + /** + * @param bool|null $canEditMessages + * @return void + */ + public function setCanEditMessages($canEditMessages) + { + $this->canEditMessages = $canEditMessages; + } + + /** + * @return bool|null + */ + public function canPinMessages() + { + return $this->canPinMessages; + } + + /** + * @param bool|null $canPinMessages + * @return void + */ + public function setCanPinMessages($canPinMessages) + { + $this->canPinMessages = $canPinMessages; + } + + /** + * @return bool|null + */ + public function canManageTopics() + { + return $this->canManageTopics; + } + + /** + * @param bool|null $canManageTopics + * @return void + */ + public function setCanManageTopics($canManageTopics) + { + $this->canManageTopics = $canManageTopics; + } + + /** + * @return string|null + */ + public function getCustomTitle() + { + return $this->customTitle; + } + + /** + * @param string|null $customTitle + * @return void + */ + public function setCustomTitle($customTitle) + { + $this->customTitle = $customTitle; + } +} diff --git a/src/Types/ChatMemberBanned.php b/src/Types/ChatMemberBanned.php new file mode 100644 index 00000000..17647318 --- /dev/null +++ b/src/Types/ChatMemberBanned.php @@ -0,0 +1,58 @@ + true, + 'user' => User::class, + 'until_date' => true, + ]; + + /** + * Date when restrictions will be lifted for this user; Unix time. If 0, then the user is banned forever + * + * @var int + */ + protected $untilDate; + + public static function fromResponse($data) + { + self::validate($data); + /** @psalm-suppress UnsafeInstantiation */ + $instance = new static(); + $instance->map($data); + + return $instance; + } + + /** + * @return int + */ + public function getUntilDate() + { + return $this->untilDate; + } + + /** + * @param int $untilDate + * @return void + */ + public function setUntilDate($untilDate) + { + $this->untilDate = $untilDate; + } +} diff --git a/src/Types/ChatMemberLeft.php b/src/Types/ChatMemberLeft.php new file mode 100644 index 00000000..85c96feb --- /dev/null +++ b/src/Types/ChatMemberLeft.php @@ -0,0 +1,23 @@ +map($data); + + return $instance; + } +} diff --git a/src/Types/ChatMemberMember.php b/src/Types/ChatMemberMember.php new file mode 100644 index 00000000..ae1a8678 --- /dev/null +++ b/src/Types/ChatMemberMember.php @@ -0,0 +1,23 @@ +map($data); + + return $instance; + } +} diff --git a/src/Types/ChatMemberOwner.php b/src/Types/ChatMemberOwner.php new file mode 100644 index 00000000..e6c6520c --- /dev/null +++ b/src/Types/ChatMemberOwner.php @@ -0,0 +1,83 @@ + true, + 'user' => User::class, + 'is_anonymous' => true, + 'custom_title' => true, + ]; + + /** + * True, if the user's presence in the chat is hidden + * + * @var bool + */ + protected $isAnonymous; + + /** + * Optional. Custom title for this user + * + * @var string|null + */ + protected $customTitle; + + public static function fromResponse($data) + { + self::validate($data); + /** @psalm-suppress UnsafeInstantiation */ + $instance = new static(); + $instance->map($data); + + return $instance; + } + + /** + * @return bool + */ + public function isAnonymous() + { + return $this->isAnonymous; + } + + /** + * @param bool $isAnonymous + * @return void + */ + public function setIsAnonymous($isAnonymous) + { + $this->isAnonymous = $isAnonymous; + } + + /** + * @return string|null + */ + public function getCustomTitle() + { + return $this->customTitle; + } + + /** + * @param string|null $customTitle + * @return void + */ + public function setCustomTitle($customTitle) + { + $this->customTitle = $customTitle; + } +} diff --git a/src/Types/ChatMemberRestricted.php b/src/Types/ChatMemberRestricted.php new file mode 100644 index 00000000..386305b4 --- /dev/null +++ b/src/Types/ChatMemberRestricted.php @@ -0,0 +1,433 @@ + true, + 'user' => User::class, + 'is_member' => true, + 'can_send_messages' => true, + 'can_send_audios' => true, + 'can_send_documents' => true, + 'can_send_photos' => true, + 'can_send_videos' => true, + 'can_send_video_notes' => true, + 'can_send_voice_notes' => true, + 'can_send_polls' => true, + 'can_send_other_messages' => true, + 'can_add_web_page_previews' => true, + 'can_change_info' => true, + 'can_invite_users' => true, + 'can_pin_messages' => true, + 'can_manage_topics' => true, + 'until_date' => true, + ]; + + /** + * True, if the user is a member of the chat at the moment of the request + * + * @var bool + */ + protected $isMember; + + /** + * True, if the user is allowed to send text messages, contacts, giveaways, giveaway winners, invoices, locations and venues + * + * @var bool + */ + protected $canSendMessages; + + /** + * True, if the user is allowed to send audios + * + * @var bool + */ + protected $canSendAudios; + + /** + * True, if the user is allowed to send documents + * + * @var bool + */ + protected $canSendDocuments; + + /** + * True, if the user is allowed to send photos + * + * @var bool + */ + protected $canSendPhotos; + + /** + * True, if the user is allowed to send videos + * + * @var bool + */ + protected $canSendVideos; + + /** + * True, if the user is allowed to send video notes + * + * @var bool + */ + protected $canSendVideoNotes; + + /** + * True, if the user is allowed to send voice notes + * + * @var bool + */ + protected $canSendVoiceNotes; + + /** + * True, if the user is allowed to send polls + * + * @var bool + */ + protected $canSendPolls; + + /** + * True, if the user is allowed to send animations, games, stickers and use inline bots + * + * @var bool + */ + protected $canSendOtherMessages; + + /** + * True, if the user is allowed to add web page previews to their messages + * + * @var bool + */ + protected $canAddWebPagePreviews; + + /** + * True, if the user is allowed to change the chat title, photo and other settings + * + * @var bool + */ + protected $canChangeInfo; + + /** + * True, if the user is allowed to invite new users to the chat + * + * @var bool + */ + protected $canInviteUsers; + + /** + * True, if the user is allowed to pin messages + * + * @var bool + */ + protected $canPinMessages; + + /** + * True, if the user is allowed to create forum topics + * + * @var bool + */ + protected $canManageTopics; + + /** + * Date when restrictions will be lifted for this user; Unix time. If 0, then the user is restricted forever + * + * @var int + */ + protected $untilDate; + + public static function fromResponse($data) + { + self::validate($data); + /** @psalm-suppress UnsafeInstantiation */ + $instance = new static(); + $instance->map($data); + + return $instance; + } + + /** + * @return bool + */ + public function isMember() + { + return $this->isMember; + } + + /** + * @param bool $isMember + * @return void + */ + public function setIsMember($isMember) + { + $this->isMember = $isMember; + } + + /** + * @return bool + */ + public function canSendMessages() + { + return $this->canSendMessages; + } + + /** + * @param bool $canSendMessages + * @return void + */ + public function setCanSendMessages($canSendMessages) + { + $this->canSendMessages = $canSendMessages; + } + + /** + * @return bool + */ + public function canSendAudios() + { + return $this->canSendAudios; + } + + /** + * @param bool $canSendAudios + * @return void + */ + public function setCanSendAudios($canSendAudios) + { + $this->canSendAudios = $canSendAudios; + } + + /** + * @return bool + */ + public function canSendDocuments() + { + return $this->canSendDocuments; + } + + /** + * @param bool $canSendDocuments + * @return void + */ + public function setCanSendDocuments($canSendDocuments) + { + $this->canSendDocuments = $canSendDocuments; + } + + /** + * @return bool + */ + public function canSendPhotos() + { + return $this->canSendPhotos; + } + + /** + * @param bool $canSendPhotos + * @return void + */ + public function setCanSendPhotos($canSendPhotos) + { + $this->canSendPhotos = $canSendPhotos; + } + + /** + * @return bool + */ + public function canSendVideos() + { + return $this->canSendVideos; + } + + /** + * @param bool $canSendVideos + * @return void + */ + public function setCanSendVideos($canSendVideos) + { + $this->canSendVideos = $canSendVideos; + } + + /** + * @return bool + */ + public function canSendVideoNotes() + { + return $this->canSendVideoNotes; + } + + /** + * @param bool $canSendVideoNotes + * @return void + */ + public function setCanSendVideoNotes($canSendVideoNotes) + { + $this->canSendVideoNotes = $canSendVideoNotes; + } + + /** + * @return bool + */ + public function canSendVoiceNotes() + { + return $this->canSendVoiceNotes; + } + + /** + * @param bool $canSendVoiceNotes + * @return void + */ + public function setCanSendVoiceNotes($canSendVoiceNotes) + { + $this->canSendVoiceNotes = $canSendVoiceNotes; + } + + /** + * @return bool + */ + public function canSendPolls() + { + return $this->canSendPolls; + } + + /** + * @param bool $canSendPolls + * @return void + */ + public function setCanSendPolls($canSendPolls) + { + $this->canSendPolls = $canSendPolls; + } + + /** + * @return bool + */ + public function canSendOtherMessages() + { + return $this->canSendOtherMessages; + } + + /** + * @param bool $canSendOtherMessages + * @return void + */ + public function setCanSendOtherMessages($canSendOtherMessages) + { + $this->canSendOtherMessages = $canSendOtherMessages; + } + + /** + * @return bool + */ + public function canAddWebPagePreviews() + { + return $this->canAddWebPagePreviews; + } + + /** + * @param bool $canAddWebPagePreviews + * @return void + */ + public function setCanAddWebPagePreviews($canAddWebPagePreviews) + { + $this->canAddWebPagePreviews = $canAddWebPagePreviews; + } + + /** + * @return bool + */ + public function canChangeInfo() + { + return $this->canChangeInfo; + } + + /** + * @param bool $canChangeInfo + * @return void + */ + public function setCanChangeInfo($canChangeInfo) + { + $this->canChangeInfo = $canChangeInfo; + } + + /** + * @return bool + */ + public function canInviteUsers() + { + return $this->canInviteUsers; + } + + /** + * @param bool $canInviteUsers + * @return void + */ + public function setCanInviteUsers($canInviteUsers) + { + $this->canInviteUsers = $canInviteUsers; + } + + /** + * @return bool + */ + public function canPinMessages() + { + return $this->canPinMessages; + } + + /** + * @param bool $canPinMessages + * @return void + */ + public function setCanPinMessages($canPinMessages) + { + $this->canPinMessages = $canPinMessages; + } + + /** + * @return bool + */ + public function canManageTopics() + { + return $this->canManageTopics; + } + + /** + * @param bool $canManageTopics + * @return void + */ + public function setCanManageTopics($canManageTopics) + { + $this->canManageTopics = $canManageTopics; + } + + /** + * @return int + */ + public function getUntilDate() + { + return $this->untilDate; + } + + /** + * @param int $untilDate + * @return void + */ + public function setUntilDate($untilDate) + { + $this->untilDate = $untilDate; + } +} diff --git a/src/Types/ChatMemberUpdated.php b/src/Types/ChatMemberUpdated.php index 2c3ffb86..298f8169 100644 --- a/src/Types/ChatMemberUpdated.php +++ b/src/Types/ChatMemberUpdated.php @@ -26,9 +26,20 @@ class ChatMemberUpdated extends BaseType implements TypeInterface 'old_chat_member' => ChatMember::class, 'new_chat_member' => ChatMember::class, 'invite_link' => ChatInviteLink::class, + 'via_join_request' => true, 'via_chat_folder_invite_link' => true, ]; + public static function fromResponse($data) + { + self::validate($data); + /** @psalm-suppress UnsafeInstantiation */ + $instance = new static(); + $instance->map($data); + + return $instance; + } + /** * Chat the user belongs to * @@ -78,6 +89,13 @@ class ChatMemberUpdated extends BaseType implements TypeInterface */ protected $viaChatFolderInviteLink; + /** + * Optional. True, if the user joined the chat after sending a direct join request without using an invite link and being approved by an administrator + * + * @var bool|null + */ + protected $viaJoinRequest; + /** * @return Chat */ @@ -196,4 +214,21 @@ public function setViaChatFolderInviteLink($viaChatFolderInviteLink) { $this->viaChatFolderInviteLink = $viaChatFolderInviteLink; } + + /** + * @return bool|null + */ + public function getViaJoinRequest() + { + return $this->viaJoinRequest; + } + + /** + * @param bool|null $viaJoinRequest + * @return void + */ + public function setViaJoinRequest($viaJoinRequest) + { + $this->viaJoinRequest = $viaJoinRequest; + } } diff --git a/src/Types/ChatPhoto.php b/src/Types/ChatPhoto.php index acce238d..7fbabceb 100644 --- a/src/Types/ChatPhoto.php +++ b/src/Types/ChatPhoto.php @@ -20,7 +20,9 @@ class ChatPhoto extends BaseType */ protected static $map = [ 'small_file_id' => true, + 'small_file_unique_id' => true, 'big_file_id' => true, + 'big_file_unique_id' => true, ]; /** @@ -30,6 +32,13 @@ class ChatPhoto extends BaseType */ protected $smallFileId; + /** + * Unique file identifier of small (160x160) chat photo, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. + * + * @var string + */ + protected $smallFileUniqueId; + /** * Unique file identifier of big (640x640) chat photo. This file_id can be used only for photo download. * @@ -37,6 +46,13 @@ class ChatPhoto extends BaseType */ protected $bigFileId; + /** + * Unique file identifier of big (640x640) chat photo, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. + * + * @var string + */ + protected $bigFileUniqueId; + /** * @return string */ @@ -54,6 +70,23 @@ public function setSmallFileId($smallFileId) $this->smallFileId = $smallFileId; } + /** + * @return string + */ + public function getSmallFileUniqueId() + { + return $this->smallFileUniqueId; + } + + /** + * @param string $smallFileUniqueId + * @return void + */ + public function setSmallFileUniqueId($smallFileUniqueId) + { + $this->smallFileUniqueId = $smallFileUniqueId; + } + /** * @return string */ @@ -70,4 +103,21 @@ public function setBigFileId($bigFileId) { $this->bigFileId = $bigFileId; } + + /** + * @return string + */ + public function getBigFileUniqueId() + { + return $this->bigFileUniqueId; + } + + /** + * @param string $bigFileUniqueId + * @return void + */ + public function setBigFileUniqueId($bigFileUniqueId) + { + $this->bigFileUniqueId = $bigFileUniqueId; + } } diff --git a/src/Types/ChatShared.php b/src/Types/ChatShared.php new file mode 100644 index 00000000..fc28a422 --- /dev/null +++ b/src/Types/ChatShared.php @@ -0,0 +1,156 @@ + true, + 'chat_id' => true, + 'title' => true, + 'username' => true, + 'photo' => ArrayOfPhotoSize::class, + ]; + + /** + * Identifier of the request + * + * @var int + */ + protected $requestId; + + /** + * Identifier of the shared chat + * + * @var int + */ + protected $chatId; + + /** + * Optional. Title of the chat + * + * @var string|null + */ + protected $title; + + /** + * Optional. Username of the chat + * + * @var string|null + */ + protected $username; + + /** + * Optional. Available sizes of the chat photo + * Array of \TelegramBot\Api\Types\PhotoSize + * + * @var array|null + */ + protected $photo; + + /** + * @return int + */ + public function getRequestId() + { + return $this->requestId; + } + + /** + * @param int $requestId + * @return void + */ + public function setRequestId($requestId) + { + $this->requestId = $requestId; + } + + /** + * @return int + */ + public function getChatId() + { + return $this->chatId; + } + + /** + * @param int $chatId + * @return void + */ + public function setChatId($chatId) + { + $this->chatId = $chatId; + } + + /** + * @return string|null + */ + public function getTitle() + { + return $this->title; + } + + /** + * @param string|null $title + * @return void + */ + public function setTitle($title) + { + $this->title = $title; + } + + /** + * @return string|null + */ + public function getUsername() + { + return $this->username; + } + + /** + * @param string|null $username + * @return void + */ + public function setUsername($username) + { + $this->username = $username; + } + + /** + * @return array|null + */ + public function getPhoto() + { + return $this->photo; + } + + /** + * @param array|null $photo + * @return void + */ + public function setPhoto($photo) + { + $this->photo = $photo; + } +} diff --git a/src/Types/Dice.php b/src/Types/Dice.php index b2077418..7ebde544 100644 --- a/src/Types/Dice.php +++ b/src/Types/Dice.php @@ -8,6 +8,8 @@ /** * Class Dice * This object represents an animated emoji that displays a random value. + * + * @package TelegramBot\Api\Types */ class Dice extends BaseType implements TypeInterface { diff --git a/src/Types/Document.php b/src/Types/Document.php index e7b951bd..8b067f68 100644 --- a/src/Types/Document.php +++ b/src/Types/Document.php @@ -8,7 +8,7 @@ /** * Class Document - * This object represents a general file (as opposed to photos and audio files). + * This object represents a general file (as opposed to photos, voice messages and audio files). * Telegram users can send files of any type of up to 1.5 GB in size. * * @package TelegramBot\Api\Types @@ -44,9 +44,16 @@ class Document extends BaseType implements TypeInterface protected $fileId; /** - * Document thumbnail as defined by sender + * Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. + * + * @var string + */ + protected $fileUniqueId; + + /** + * Optional. Document thumbnail as defined by sender * - * @var PhotoSize + * @var PhotoSize|null */ protected $thumbnail; @@ -65,19 +72,12 @@ class Document extends BaseType implements TypeInterface protected $mimeType; /** - * Optional. File size + * Optional. File size in bytes. It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value. * * @var int|null */ protected $fileSize; - /** - * Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. - * - * @var string - */ - protected $fileUniqueId; - /** * @return string */ @@ -96,114 +96,114 @@ public function setFileId($fileId) } /** - * @return null|string + * @return string */ - public function getFileName() + public function getFileUniqueId() { - return $this->fileName; + return $this->fileUniqueId; } /** - * @param string $fileName + * @param string $fileUniqueId * @return void */ - public function setFileName($fileName) + public function setFileUniqueId($fileUniqueId) { - $this->fileName = $fileName; + $this->fileUniqueId = $fileUniqueId; } /** - * @return int|null + * @return PhotoSize|null */ - public function getFileSize() + public function getThumbnail() { - return $this->fileSize; + return $this->thumbnail; } /** - * @param mixed $fileSize + * @param PhotoSize|null $thumbnail * @return void - * @throws InvalidArgumentException */ - public function setFileSize($fileSize) + public function setThumbnail($thumbnail) { - if (is_integer($fileSize)) { - $this->fileSize = $fileSize; - } else { - throw new InvalidArgumentException(); - } + $this->thumbnail = $thumbnail; } /** - * @return null|string + * @deprecated use getThumbnail method + * + * @return PhotoSize|null */ - public function getMimeType() + public function getThumb() { - return $this->mimeType; + return $this->getThumbnail(); } /** - * @param string $mimeType + * @deprecated use setThumbnail method + * + * @param PhotoSize $thumb + * * @return void */ - public function setMimeType($mimeType) + public function setThumb($thumb) { - $this->mimeType = $mimeType; + $this->setThumbnail($thumb); } /** - * @return PhotoSize + * @return string|null */ - public function getThumbnail() + public function getFileName() { - return $this->thumbnail; + return $this->fileName; } /** - * @param PhotoSize $thumbnail + * @param string|null $fileName * @return void */ - public function setThumbnail(PhotoSize $thumbnail) + public function setFileName($fileName) { - $this->thumbnail = $thumbnail; + $this->fileName = $fileName; } /** - * @deprecated use getThumbnail method - * - * @return PhotoSize|null + * @return string|null */ - public function getThumb() + public function getMimeType() { - return $this->getThumbnail(); + return $this->mimeType; } /** - * @deprecated use setThumbnail method - * - * @param PhotoSize $thumb - * + * @param string|null $mimeType * @return void */ - public function setThumb($thumb) + public function setMimeType($mimeType) { - $this->setThumbnail($thumb); + $this->mimeType = $mimeType; } /** - * @return string + * @return int|null */ - public function getFileUniqueId() + public function getFileSize() { - return $this->fileUniqueId; + return $this->fileSize; } /** - * @param string $fileUniqueId + * @param int|null $fileSize * @return void + * @throws InvalidArgumentException */ - public function setFileUniqueId($fileUniqueId) + public function setFileSize($fileSize) { - $this->fileUniqueId = $fileUniqueId; + if (is_integer($fileSize) || is_null($fileSize)) { + $this->fileSize = $fileSize; + } else { + throw new InvalidArgumentException(); + } } } diff --git a/src/Types/ExternalReplyInfo.php b/src/Types/ExternalReplyInfo.php new file mode 100644 index 00000000..0a760c82 --- /dev/null +++ b/src/Types/ExternalReplyInfo.php @@ -0,0 +1,646 @@ + MessageOrigin::class, + 'chat' => Chat::class, + 'message_id' => true, + 'link_preview_options' => LinkPreviewOptions::class, + 'animation' => Animation::class, + 'audio' => Audio::class, + 'document' => Document::class, + 'photo' => ArrayOfPhotoSize::class, + 'sticker' => Sticker::class, + 'story' => Story::class, + 'video' => Video::class, + 'video_note' => VideoNote::class, + 'voice' => Voice::class, + 'has_media_spoiler' => true, + 'contact' => Contact::class, + 'dice' => Dice::class, + 'game' => Game::class, + 'giveaway' => Giveaway::class, + 'giveaway_winners' => GiveawayWinners::class, + 'invoice' => Invoice::class, + 'location' => Location::class, + 'poll' => Poll::class, + 'venue' => Venue::class, + ]; + + /** + * Origin of the message replied to by the given message + * + * @var MessageOrigin + */ + protected $origin; + + /** + * Optional. Chat the original message belongs to. Available only if the chat is a supergroup or a channel. + * + * @var Chat|null + */ + protected $chat; + + /** + * Optional. Unique message identifier inside the original chat. Available only if the original chat is a supergroup or a channel. + * + * @var int|null + */ + protected $messageId; + + /** + * Optional. Options used for link preview generation for the original message, if it is a text message + * + * @var LinkPreviewOptions|null + */ + protected $linkPreviewOptions; + + /** + * Optional. Message is an animation, information about the animation + * + * @var Animation|null + */ + protected $animation; + + /** + * Optional. Message is an audio file, information about the file + * + * @var Audio|null + */ + protected $audio; + + /** + * Optional. Message is a general file, information about the file + * + * @var Document|null + */ + protected $document; + + /** + * Optional. Message is a photo, available sizes of the photo + * + * @var array|null + */ + protected $photo; + + /** + * Optional. Message is a sticker, information about the sticker + * + * @var Sticker|null + */ + protected $sticker; + + /** + * Optional. Message is a forwarded story + * + * @var Story|null + */ + protected $story; + + /** + * Optional. Message is a video, information about the video + * + * @var Video|null + */ + protected $video; + + /** + * Optional. Message is a video note, information about the video message + * + * @var VideoNote|null + */ + protected $videoNote; + + /** + * Optional. Message is a voice message, information about the file + * + * @var Voice|null + */ + protected $voice; + + /** + * Optional. True, if the message media is covered by a spoiler animation + * + * @var bool|null + */ + protected $hasMediaSpoiler; + + /** + * Optional. Message is a shared contact, information about the contact + * + * @var Contact|null + */ + protected $contact; + + /** + * Optional. Message is a dice with random value + * + * @var Dice|null + */ + protected $dice; + + /** + * Optional. Message is a game, information about the game + * + * @var Game|null + */ + protected $game; + + /** + * Optional. Message is a scheduled giveaway, information about the giveaway + * + * @var Giveaway|null + */ + protected $giveaway; + + /** + * Optional. A giveaway with public winners was completed + * + * @var GiveawayWinners|null + */ + protected $giveawayWinners; + + /** + * Optional. Message is an invoice for a payment, information about the invoice + * + * @var Invoice|null + */ + protected $invoice; + + /** + * Optional. Message is a shared location, information about the location + * + * @var Location|null + */ + protected $location; + + /** + * Optional. Message is a native poll, information about the poll + * + * @var Poll|null + */ + protected $poll; + + /** + * Optional. Message is a venue, information about the venue + * + * @var Venue|null + */ + protected $venue; + + /** + * @return MessageOrigin + */ + public function getOrigin() + { + return $this->origin; + } + + /** + * @param MessageOrigin $origin + * @return void + */ + public function setOrigin(MessageOrigin $origin) + { + $this->origin = $origin; + } + + /** + * @return Chat|null + */ + public function getChat() + { + return $this->chat; + } + + /** + * @param Chat|null $chat + * @return void + */ + public function setChat($chat) + { + $this->chat = $chat; + } + + /** + * @return int|null + */ + public function getMessageId() + { + return $this->messageId; + } + + /** + * @param int|null $messageId + * @return void + */ + public function setMessageId($messageId) + { + $this->messageId = $messageId; + } + + /** + * @return LinkPreviewOptions|null + */ + public function getLinkPreviewOptions() + { + return $this->linkPreviewOptions; + } + + /** + * @param LinkPreviewOptions|null $linkPreviewOptions + * @return void + */ + public function setLinkPreviewOptions($linkPreviewOptions) + { + $this->linkPreviewOptions = $linkPreviewOptions; + } + + /** + * @return Animation|null + */ + public function getAnimation() + { + return $this->animation; + } + + /** + * @param Animation|null $animation + * @return void + */ + public function setAnimation($animation) + { + $this->animation = $animation; + } + + /** + * @return Audio|null + */ + public function getAudio() + { + return $this->audio; + } + + /** + * @param Audio|null $audio + * @return void + */ + public function setAudio($audio) + { + $this->audio = $audio; + } + + /** + * @return Document|null + */ + public function getDocument() + { + return $this->document; + } + + /** + * @param Document|null $document + * @return void + */ + public function setDocument($document) + { + $this->document = $document; + } + + /** + * @return array|null + */ + public function getPhoto() + { + return $this->photo; + } + + /** + * @param array|null $photo + * @return void + */ + public function setPhoto($photo) + { + $this->photo = $photo; + } + + /** + * @return Sticker|null + */ + public function getSticker() + { + return $this->sticker; + } + + /** + * @param Sticker|null $sticker + * @return void + */ + public function setSticker($sticker) + { + $this->sticker = $sticker; + } + + /** + * @return Story|null + */ + public function getStory() + { + return $this->story; + } + + /** + * @param Story|null $story + * @return void + */ + public function setStory($story) + { + $this->story = $story; + } + + /** + * @return Video|null + */ + public function getVideo() + { + return $this->video; + } + + /** + * @param Video|null $video + * @return void + */ + public function setVideo($video) + { + $this->video = $video; + } + + /** + * @return VideoNote|null + */ + public function getVideoNote() + { + return $this->videoNote; + } + + /** + * @param VideoNote|null $videoNote + * @return void + */ + public function setVideoNote($videoNote) + { + $this->videoNote = $videoNote; + } + + /** + * @return Voice|null + */ + public function getVoice() + { + return $this->voice; + } + + /** + * @param Voice|null $voice + * @return void + */ + public function setVoice($voice) + { + $this->voice = $voice; + } + + /** + * @return bool|null + */ + public function getHasMediaSpoiler() + { + return $this->hasMediaSpoiler; + } + + /** + * @param bool|null $hasMediaSpoiler + * @return void + */ + public function setHasMediaSpoiler($hasMediaSpoiler) + { + $this->hasMediaSpoiler = $hasMediaSpoiler; + } + + /** + * @return Contact|null + */ + public function getContact() + { + return $this->contact; + } + + /** + * @param Contact|null $contact + * @return void + */ + public function setContact($contact) + { + $this->contact = $contact; + } + + /** + * @return Dice|null + */ + public function getDice() + { + return $this->dice; + } + + /** + * @param Dice|null $dice + * @return void + */ + public function setDice($dice) + { + $this->dice = $dice; + } + + /** + * @return Game|null + */ + public function getGame() + { + return $this->game; + } + + /** + * @param Game|null $game + * @return void + */ + public function setGame($game) + { + $this->game = $game; + } + + /** + * @return Giveaway|null + */ + public function getGiveaway() + { + return $this->giveaway; + } + + /** + * @param Giveaway|null $giveaway + * @return void + */ + public function setGiveaway($giveaway) + { + $this->giveaway = $giveaway; + } + + /** + * @return GiveawayWinners|null + */ + public function getGiveawayWinners() + { + return $this->giveawayWinners; + } + + /** + * @param GiveawayWinners|null $giveawayWinners + * @return void + */ + public function setGiveawayWinners($giveawayWinners) + { + $this->giveawayWinners = $giveawayWinners; + } + + /** + * @return Invoice|null + */ + public function getInvoice() + { + return $this->invoice; + } + + /** + * @param Invoice|null $invoice + * @return void + */ + public function setInvoice($invoice) + { + $this->invoice = $invoice; + } + + /** + * @return Location|null + */ + public function getLocation() + { + return $this->location; + } + + /** + * @param Location|null $location + * @return void + */ + public function setLocation($location) + { + $this->location = $location; + } + + /** + * @return Poll|null + */ + public function getPoll() + { + return $this->poll; + } + + /** + * @param Poll|null $poll + * @return void + */ + public function setPoll($poll) + { + $this->poll = $poll; + } + + /** + * @return Venue|null + */ + public function getVenue() + { + return $this->venue; + } + + /** + * @param Venue|null $venue + * @return void + */ + public function setVenue($venue) + { + $this->venue = $venue; + } +} + +/** + * Class ArrayOfPhotoSize + * Represents an array of PhotoSize objects. + * + * @package TelegramBot\Api\Types + */ +class ArrayOfPhotoSize extends BaseType implements TypeInterface +{ + /** + * {@inheritdoc} + * + * @var array + */ + protected static $map = [ + 'photos' => PhotoSize::class, + ]; + + /** + * @var array + */ + protected $photos; + + /** + * @return array + */ + public function getPhotos() + { + return $this->photos; + } + + /** + * @param array $photos + * @return void + */ + public function setPhotos($photos) + { + $this->photos = $photos; + } +} diff --git a/src/Types/ForumTopicCreated.php b/src/Types/ForumTopicCreated.php index 30cc78fc..f1da401c 100644 --- a/src/Types/ForumTopicCreated.php +++ b/src/Types/ForumTopicCreated.php @@ -6,7 +6,7 @@ use TelegramBot\Api\TypeInterface; /** - * class ForumTopicCreated. + * Class ForumTopicCreated * This object represents a service message about a new forum topic created in the chat. * * @package TelegramBot\Api\Types @@ -42,14 +42,14 @@ class ForumTopicCreated extends BaseType implements TypeInterface /** * Color of the forum topic * - * @var string + * @var int */ protected $iconColor; /** - * Custom emoji of the forum topic + * Optional. Unique identifier of the custom emoji shown as the topic icon * - * @var string + * @var string|null */ protected $iconCustomEmojiId; @@ -71,7 +71,7 @@ public function setName($name) } /** - * @return string + * @return int */ public function getIconColor() { @@ -79,7 +79,7 @@ public function getIconColor() } /** - * @param string $iconColor + * @param int $iconColor * @return void */ public function setIconColor($iconColor) @@ -88,7 +88,7 @@ public function setIconColor($iconColor) } /** - * @return string + * @return string|null */ public function getIconCustomEmojiId() { @@ -96,7 +96,7 @@ public function getIconCustomEmojiId() } /** - * @param string $iconCustomEmojiId + * @param string|null $iconCustomEmojiId * @return void */ public function setIconCustomEmojiId($iconCustomEmojiId) diff --git a/src/Types/ForumTopicEdited.php b/src/Types/ForumTopicEdited.php new file mode 100644 index 00000000..c51a9c25 --- /dev/null +++ b/src/Types/ForumTopicEdited.php @@ -0,0 +1,73 @@ + true, + 'icon_custom_emoji_id' => true, + ]; + + /** + * Optional. New name of the topic, if it was edited + * + * @var string|null + */ + protected $name; + + /** + * Optional. New identifier of the custom emoji shown as the topic icon, if it was edited; an empty string if the icon was removed + * + * @var string|null + */ + protected $iconCustomEmojiId; + + /** + * @return string|null + */ + public function getName() + { + return $this->name; + } + + /** + * @param string|null $name + * @return void + */ + public function setName($name) + { + $this->name = $name; + } + + /** + * @return string|null + */ + public function getIconCustomEmojiId() + { + return $this->iconCustomEmojiId; + } + + /** + * @param string|null $iconCustomEmojiId + * @return void + */ + public function setIconCustomEmojiId($iconCustomEmojiId) + { + $this->iconCustomEmojiId = $iconCustomEmojiId; + } +} diff --git a/src/Types/Game.php b/src/Types/Game.php new file mode 100644 index 00000000..ae5c417f --- /dev/null +++ b/src/Types/Game.php @@ -0,0 +1,174 @@ + true, + 'description' => true, + 'photo' => ArrayOfPhotoSize::class, + 'text' => true, + 'text_entities' => ArrayOfMessageEntity::class, + 'animation' => Animation::class + ]; + + /** + * Title of the game + * + * @var string + */ + protected $title; + + /** + * Description of the game + * + * @var string + */ + protected $description; + + /** + * Photo that will be displayed in the game message in chats + * + * @var PhotoSize[] + */ + protected $photo; + + /** + * Optional. Brief description of the game or high scores included in the game message + * + * @var string|null + */ + protected $text; + + /** + * Optional. Special entities that appear in text, such as usernames, URLs, bot commands, etc. + * + * @var MessageEntity[]|null + */ + protected $textEntities; + + /** + * Optional. Animation that will be displayed in the game message in chats + * + * @var Animation|null + */ + protected $animation; + + /** + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * @param string $title + */ + public function setTitle($title) + { + $this->title = $title; + } + + /** + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * @param string $description + */ + public function setDescription($description) + { + $this->description = $description; + } + + /** + * @return PhotoSize[] + */ + public function getPhoto() + { + return $this->photo; + } + + /** + * @param PhotoSize[] $photo + */ + public function setPhoto(array $photo) + { + $this->photo = $photo; + } + + /** + * @return string|null + */ + public function getText() + { + return $this->text; + } + + /** + * @param string|null $text + */ + public function setText($text) + { + $this->text = $text; + } + + /** + * @return MessageEntity[]|null + */ + public function getTextEntities() + { + return $this->textEntities; + } + + /** + * @param MessageEntity[]|null $textEntities + */ + public function setTextEntities($textEntities) + { + $this->textEntities = $textEntities; + } + + /** + * @return Animation|null + */ + public function getAnimation() + { + return $this->animation; + } + + /** + * @param Animation|null $animation + */ + public function setAnimation($animation) + { + $this->animation = $animation; + } +} diff --git a/src/Types/GeneralForumTopicHidden.php b/src/Types/GeneralForumTopicHidden.php new file mode 100644 index 00000000..3bbd25c2 --- /dev/null +++ b/src/Types/GeneralForumTopicHidden.php @@ -0,0 +1,10 @@ + ArrayOfChat::class, + 'winners_selection_date' => true, + 'winner_count' => true, + 'only_new_members' => true, + 'has_public_winners' => true, + 'prize_description' => true, + 'country_codes' => true, + 'premium_subscription_month_count' => true, + ]; + + /** + * The list of chats which the user must join to participate in the giveaway + * + * @var array + */ + protected $chats; + + /** + * Point in time (Unix timestamp) when winners of the giveaway will be selected + * + * @var int + */ + protected $winnersSelectionDate; + + /** + * The number of users which are supposed to be selected as winners of the giveaway + * + * @var int + */ + protected $winnerCount; + + /** + * Optional. True, if only users who join the chats after the giveaway started should be eligible to win + * + * @var bool|null + */ + protected $onlyNewMembers; + + /** + * Optional. True, if the list of giveaway winners will be visible to everyone + * + * @var bool|null + */ + protected $hasPublicWinners; + + /** + * Optional. Description of additional giveaway prize + * + * @var string|null + */ + protected $prizeDescription; + + /** + * Optional. A list of two-letter ISO 3166-1 alpha-2 country codes indicating the countries from which eligible users for the giveaway must come. If empty, then all users can participate in the giveaway. Users with a phone number that was bought on Fragment can always participate in giveaways. + * + * @var array|null + */ + protected $countryCodes; + + /** + * Optional. The number of months the Telegram Premium subscription won from the giveaway will be active for + * + * @var int|null + */ + protected $premiumSubscriptionMonthCount; + + /** + * @return array + */ + public function getChats() + { + return $this->chats; + } + + /** + * @param array $chats + * @return void + */ + public function setChats($chats) + { + $this->chats = $chats; + } + + /** + * @return int + */ + public function getWinnersSelectionDate() + { + return $this->winnersSelectionDate; + } + + /** + * @param int $winnersSelectionDate + * @return void + */ + public function setWinnersSelectionDate($winnersSelectionDate) + { + $this->winnersSelectionDate = $winnersSelectionDate; + } + + /** + * @return int + */ + public function getWinnerCount() + { + return $this->winnerCount; + } + + /** + * @param int $winnerCount + * @return void + */ + public function setWinnerCount($winnerCount) + { + $this->winnerCount = $winnerCount; + } + + /** + * @return bool|null + */ + public function getOnlyNewMembers() + { + return $this->onlyNewMembers; + } + + /** + * @param bool|null $onlyNewMembers + * @return void + */ + public function setOnlyNewMembers($onlyNewMembers) + { + $this->onlyNewMembers = $onlyNewMembers; + } + + /** + * @return bool|null + */ + public function getHasPublicWinners() + { + return $this->hasPublicWinners; + } + + /** + * @param bool|null $hasPublicWinners + * @return void + */ + public function setHasPublicWinners($hasPublicWinners) + { + $this->hasPublicWinners = $hasPublicWinners; + } + + /** + * @return string|null + */ + public function getPrizeDescription() + { + return $this->prizeDescription; + } + + /** + * @param string|null $prizeDescription + * @return void + */ + public function setPrizeDescription($prizeDescription) + { + $this->prizeDescription = $prizeDescription; + } + + /** + * @return array|null + */ + public function getCountryCodes() + { + return $this->countryCodes; + } + + /** + * @param array|null $countryCodes + * @return void + */ + public function setCountryCodes($countryCodes) + { + $this->countryCodes = $countryCodes; + } + + /** + * @return int|null + */ + public function getPremiumSubscriptionMonthCount() + { + return $this->premiumSubscriptionMonthCount; + } + + /** + * @param int|null $premiumSubscriptionMonthCount + * @return void + */ + public function setPremiumSubscriptionMonthCount($premiumSubscriptionMonthCount) + { + $this->premiumSubscriptionMonthCount = $premiumSubscriptionMonthCount; + } +} diff --git a/src/Types/GiveawayCompleted.php b/src/Types/GiveawayCompleted.php new file mode 100644 index 00000000..28ac6b92 --- /dev/null +++ b/src/Types/GiveawayCompleted.php @@ -0,0 +1,105 @@ + true, + 'unclaimed_prize_count' => true, + 'giveaway_message' => MaybeInaccessibleMessage::class, + ]; + + /** + * Number of winners in the giveaway + * + * @var int + */ + protected $winnerCount; + + /** + * Optional. Number of undistributed prizes + * + * @var int|null + */ + protected $unclaimedPrizeCount; + + /** + * Optional. Message with the giveaway that was completed, if it wasn't deleted + * + * @var MaybeInaccessibleMessage|null + */ + protected $giveawayMessage; + + /** + * @return int + */ + public function getWinnerCount() + { + return $this->winnerCount; + } + + /** + * @param int $winnerCount + * @return void + */ + public function setWinnerCount($winnerCount) + { + $this->winnerCount = $winnerCount; + } + + /** + * @return int|null + */ + public function getUnclaimedPrizeCount() + { + return $this->unclaimedPrizeCount; + } + + /** + * @param int|null $unclaimedPrizeCount + * @return void + */ + public function setUnclaimedPrizeCount($unclaimedPrizeCount) + { + $this->unclaimedPrizeCount = $unclaimedPrizeCount; + } + + /** + * @return MaybeInaccessibleMessage|null + */ + public function getGiveawayMessage() + { + return $this->giveawayMessage; + } + + /** + * @param MaybeInaccessibleMessage|null $giveawayMessage + * @return void + */ + public function setGiveawayMessage($giveawayMessage) + { + $this->giveawayMessage = $giveawayMessage; + } +} diff --git a/src/Types/GiveawayCreated.php b/src/Types/GiveawayCreated.php new file mode 100644 index 00000000..61bb8cf8 --- /dev/null +++ b/src/Types/GiveawayCreated.php @@ -0,0 +1,10 @@ + Chat::class, + 'giveaway_message_id' => true, + 'winners_selection_date' => true, + 'winner_count' => true, + 'winners' => ArrayOfUser::class, + 'additional_chat_count' => true, + 'premium_subscription_month_count' => true, + 'unclaimed_prize_count' => true, + 'only_new_members' => true, + 'was_refunded' => true, + 'prize_description' => true, + ]; + + /** + * The chat that created the giveaway + * + * @var Chat + */ + protected $chat; + + /** + * Identifier of the message with the giveaway in the chat + * + * @var int + */ + protected $giveawayMessageId; + + /** + * Point in time (Unix timestamp) when winners of the giveaway were selected + * + * @var int + */ + protected $winnersSelectionDate; + + /** + * Total number of winners in the giveaway + * + * @var int + */ + protected $winnerCount; + + /** + * List of up to 100 winners of the giveaway + * + * @var array + */ + protected $winners; + + /** + * Optional. The number of other chats the user had to join in order to be eligible for the giveaway + * + * @var int|null + */ + protected $additionalChatCount; + + /** + * Optional. The number of months the Telegram Premium subscription won from the giveaway will be active for + * + * @var int|null + */ + protected $premiumSubscriptionMonthCount; + + /** + * Optional. Number of undistributed prizes + * + * @var int|null + */ + protected $unclaimedPrizeCount; + + /** + * Optional. True, if only users who had joined the chats after the giveaway started were eligible to win + * + * @var bool|null + */ + protected $onlyNewMembers; + + /** + * Optional. True, if the giveaway was canceled because the payment for it was refunded + * + * @var bool|null + */ + protected $wasRefunded; + + /** + * Optional. Description of additional giveaway prize + * + * @var string|null + */ + protected $prizeDescription; + + /** + * @return Chat + */ + public function getChat() + { + return $this->chat; + } + + /** + * @param Chat $chat + * @return void + */ + public function setChat($chat) + { + $this->chat = $chat; + } + + /** + * @return int + */ + public function getGiveawayMessageId() + { + return $this->giveawayMessageId; + } + + /** + * @param int $giveawayMessageId + * @return void + */ + public function setGiveawayMessageId($giveawayMessageId) + { + $this->giveawayMessageId = $giveawayMessageId; + } + + /** + * @return int + */ + public function getWinnersSelectionDate() + { + return $this->winnersSelectionDate; + } + + /** + * @param int $winnersSelectionDate + * @return void + */ + public function setWinnersSelectionDate($winnersSelectionDate) + { + $this->winnersSelectionDate = $winnersSelectionDate; + } + + /** + * @return int + */ + public function getWinnerCount() + { + return $this->winnerCount; + } + + /** + * @param int $winnerCount + * @return void + */ + public function setWinnerCount($winnerCount) + { + $this->winnerCount = $winnerCount; + } + + /** + * @return array + */ + public function getWinners() + { + return $this->winners; + } + + /** + * @param array $winners + * @return void + */ + public function setWinners($winners) + { + $this->winners = $winners; + } + + /** + * @return int|null + */ + public function getAdditionalChatCount() + { + return $this->additionalChatCount; + } + + /** + * @param int|null $additionalChatCount + * @return void + */ + public function setAdditionalChatCount($additionalChatCount) + { + $this->additionalChatCount = $additionalChatCount; + } + + /** + * @return int|null + */ + public function getPremiumSubscriptionMonthCount() + { + return $this->premiumSubscriptionMonthCount; + } + + /** + * @param int|null $premiumSubscriptionMonthCount + * @return void + */ + public function setPremiumSubscriptionMonthCount($premiumSubscriptionMonthCount) + { + $this->premiumSubscriptionMonthCount = $premiumSubscriptionMonthCount; + } + + /** + * @return int|null + */ + public function getUnclaimedPrizeCount() + { + return $this->unclaimedPrizeCount; + } + + /** + * @param int|null $unclaimedPrizeCount + * @return void + */ + public function setUnclaimedPrizeCount($unclaimedPrizeCount) + { + $this->unclaimedPrizeCount = $unclaimedPrizeCount; + } + + /** + * @return bool|null + */ + public function getOnlyNewMembers() + { + return $this->onlyNewMembers; + } + + /** + * @param bool|null $onlyNewMembers + * @return void + */ + public function setOnlyNewMembers($onlyNewMembers) + { + $this->onlyNewMembers = $onlyNewMembers; + } + + /** + * @return bool|null + */ + public function getWasRefunded() + { + return $this->wasRefunded; + } + + /** + * @param bool|null $wasRefunded + * @return void + */ + public function setWasRefunded($wasRefunded) + { + $this->wasRefunded = $wasRefunded; + } + + /** + * @return string|null + */ + public function getPrizeDescription() + { + return $this->prizeDescription; + } + + /** + * @param string|null $prizeDescription + * @return void + */ + public function setPrizeDescription($prizeDescription) + { + $this->prizeDescription = $prizeDescription; + } +} diff --git a/src/Types/InaccessibleMessage.php b/src/Types/InaccessibleMessage.php new file mode 100644 index 00000000..1f41e04e --- /dev/null +++ b/src/Types/InaccessibleMessage.php @@ -0,0 +1,131 @@ + Chat::class, + 'message_id' => true, + 'date' => true, + ]; + + /** + * Chat the message belonged to + * + * @var Chat + */ + protected $chat; + + /** + * Unique message identifier inside the chat + * + * @var int + */ + protected $messageId; + + /** + * Always 0. The field can be used to differentiate regular and inaccessible messages. + * + * @var int + */ + protected $date; + + public static function fromResponse($data) + { + self::validate($data); + /** @psalm-suppress UnsafeInstantiation */ + $instance = new static(); + $instance->map($data); + + return $instance; + } + + /** + * @return Chat + */ + public function getChat() + { + return $this->chat; + } + + /** + * @param Chat $chat + * @return void + */ + public function setChat(Chat $chat) + { + $this->chat = $chat; + } + + /** + * @return int + */ + public function getMessageId() + { + return $this->messageId; + } + + /** + * @param int $messageId + * @return void + * @throws InvalidArgumentException + */ + public function setMessageId($messageId) + { + if (!is_int($messageId)) { + throw new InvalidArgumentException('MessageId must be an integer'); + } + $this->messageId = $messageId; + } + + /** + * @return int + */ + public function getDate() + { + return $this->date; + } + + /** + * @param int $date + * @return void + * @throws InvalidArgumentException + */ + public function setDate($date) + { + if (!is_int($date)) { + throw new InvalidArgumentException('Date must be an integer'); + } + $this->date = $date; + } +} diff --git a/src/Types/Inline/InlineKeyboardButton.php b/src/Types/Inline/InlineKeyboardButton.php new file mode 100644 index 00000000..afdf17ed --- /dev/null +++ b/src/Types/Inline/InlineKeyboardButton.php @@ -0,0 +1,283 @@ + true, + 'url' => true, + 'callback_data' => true, + 'web_app' => WebAppInfo::class, + 'login_url' => LoginUrl::class, + 'switch_inline_query' => true, + 'switch_inline_query_current_chat' => true, + 'switch_inline_query_chosen_chat' => SwitchInlineQueryChosenChat::class, + 'callback_game' => CallbackGame::class, + 'pay' => true, + ]; + + /** + * Label text on the button + * + * @var string + */ + protected $text; + + /** + * Optional. HTTP or tg:// URL to be opened when the button is pressed + * + * @var string|null + */ + protected $url; + + /** + * Optional. Data to be sent in a callback query to the bot when button is pressed, 1-64 bytes + * + * @var string|null + */ + protected $callbackData; + + /** + * Optional. Description of the Web App that will be launched when the user presses the button + * + * @var WebAppInfo|null + */ + protected $webApp; + + /** + * Optional. An HTTPS URL used to automatically authorize the user + * + * @var LoginUrl|null + */ + protected $loginUrl; + + /** + * Optional. If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field + * + * @var string|null + */ + protected $switchInlineQuery; + + /** + * Optional. If set, pressing the button will insert the bot's username and the specified inline query in the current chat's input field + * + * @var string|null + */ + protected $switchInlineQueryCurrentChat; + + /** + * Optional. If set, pressing the button will prompt the user to select one of their chats of the specified type, open that chat and insert the bot's username and the specified inline query in the input field + * + * @var SwitchInlineQueryChosenChat|null + */ + protected $switchInlineQueryChosenChat; + + /** + * Optional. Description of the game that will be launched when the user presses the button + * + * @var CallbackGame|null + */ + protected $callbackGame; + + /** + * Optional. Specify True to send a Pay button + * + * @var bool|null + */ + protected $pay; + + /** + * @return string + */ + public function getText() + { + return $this->text; + } + + /** + * @param string $text + * @return void + */ + public function setText($text) + { + $this->text = $text; + } + + /** + * @return string|null + */ + public function getUrl() + { + return $this->url; + } + + /** + * @param string|null $url + * @return void + */ + public function setUrl($url) + { + $this->url = $url; + } + + /** + * @return string|null + */ + public function getCallbackData() + { + return $this->callbackData; + } + + /** + * @param string|null $callbackData + * @return void + */ + public function setCallbackData($callbackData) + { + $this->callbackData = $callbackData; + } + + /** + * @return WebAppInfo|null + */ + public function getWebApp() + { + return $this->webApp; + } + + /** + * @param WebAppInfo|null $webApp + * @return void + */ + public function setWebApp($webApp) + { + $this->webApp = $webApp; + } + + /** + * @return LoginUrl|null + */ + public function getLoginUrl() + { + return $this->loginUrl; + } + + /** + * @param LoginUrl|null $loginUrl + * @return void + */ + public function setLoginUrl($loginUrl) + { + $this->loginUrl = $loginUrl; + } + + /** + * @return string|null + */ + public function getSwitchInlineQuery() + { + return $this->switchInlineQuery; + } + + /** + * @param string|null $switchInlineQuery + * @return void + */ + public function setSwitchInlineQuery($switchInlineQuery) + { + $this->switchInlineQuery = $switchInlineQuery; + } + + /** + * @return string|null + */ + public function getSwitchInlineQueryCurrentChat() + { + return $this->switchInlineQueryCurrentChat; + } + + /** + * @param string|null $switchInlineQueryCurrentChat + * @return void + */ + public function setSwitchInlineQueryCurrentChat($switchInlineQueryCurrentChat) + { + $this->switchInlineQueryCurrentChat = $switchInlineQueryCurrentChat; + } + + /** + * @return SwitchInlineQueryChosenChat|null + */ + public function getSwitchInlineQueryChosenChat() + { + return $this->switchInlineQueryChosenChat; + } + + /** + * @param SwitchInlineQueryChosenChat|null $switchInlineQueryChosenChat + * @return void + */ + public function setSwitchInlineQueryChosenChat($switchInlineQueryChosenChat) + { + $this->switchInlineQueryChosenChat = $switchInlineQueryChosenChat; + } + + /** + * @return CallbackGame|null + */ + public function getCallbackGame() + { + return $this->callbackGame; + } + + /** + * @param CallbackGame|null $callbackGame + * @return void + */ + public function setCallbackGame($callbackGame) + { + $this->callbackGame = $callbackGame; + } + + /** + * @return bool|null + */ + public function isPay() + { + return $this->pay; + } + + /** + * @param bool|null $pay + * @return void + */ + public function setPay($pay) + { + $this->pay = $pay; + } +} diff --git a/src/Types/Inline/InlineKeyboardMarkup.php b/src/Types/Inline/InlineKeyboardMarkup.php index 08e1f647..5868e725 100644 --- a/src/Types/Inline/InlineKeyboardMarkup.php +++ b/src/Types/Inline/InlineKeyboardMarkup.php @@ -1,10 +1,4 @@ true, + 'allow_user_chats' => true, + 'allow_bot_chats' => true, + 'allow_group_chats' => true, + 'allow_channel_chats' => true + ]; + + /** + * Optional. The default inline query to be inserted in the input field. If left empty, only the bot's username will be inserted. + * + * @var string|null + */ + protected $query; + + /** + * Optional. True, if private chats with users can be chosen. + * + * @var bool|null + */ + protected $allowUserChats; + + /** + * Optional. True, if private chats with bots can be chosen. + * + * @var bool|null + */ + protected $allowBotChats; + + /** + * Optional. True, if group and supergroup chats can be chosen. + * + * @var bool|null + */ + protected $allowGroupChats; + + /** + * Optional. True, if channel chats can be chosen. + * + * @var bool|null + */ + protected $allowChannelChats; + + /** + * @return string|null + */ + public function getQuery() + { + return $this->query; + } + + /** + * @param string|null $query + * @return void + */ + public function setQuery($query) + { + $this->query = $query; + } + + /** + * @return bool|null + */ + public function getAllowUserChats() + { + return $this->allowUserChats; + } + + /** + * @param bool|null $allowUserChats + * @return void + */ + public function setAllowUserChats($allowUserChats) + { + $this->allowUserChats = $allowUserChats; + } + + /** + * @return bool|null + */ + public function getAllowBotChats() + { + return $this->allowBotChats; + } + + /** + * @param bool|null $allowBotChats + * @return void + */ + public function setAllowBotChats($allowBotChats) + { + $this->allowBotChats = $allowBotChats; + } + + /** + * @return bool|null + */ + public function getAllowGroupChats() + { + return $this->allowGroupChats; + } + + /** + * @param bool|null $allowGroupChats + * @return void + */ + public function setAllowGroupChats($allowGroupChats) + { + $this->allowGroupChats = $allowGroupChats; + } + + /** + * @return bool|null + */ + public function getAllowChannelChats() + { + return $this->allowChannelChats; + } + + /** + * @param bool|null $allowChannelChats + * @return void + */ + public function setAllowChannelChats($allowChannelChats) + { + $this->allowChannelChats = $allowChannelChats; + } +} diff --git a/src/Types/InputMedia/InputMedia.php b/src/Types/InputMedia/InputMedia.php index 97b520ae..e3f5bb75 100644 --- a/src/Types/InputMedia/InputMedia.php +++ b/src/Types/InputMedia/InputMedia.php @@ -4,134 +4,43 @@ use TelegramBot\Api\BaseType; use TelegramBot\Api\Collection\CollectionItemInterface; +use TelegramBot\Api\TypeInterface; +use TelegramBot\Api\InvalidArgumentException; /** * Class InputMedia * This object represents the content of a media message to be sent. + * It should be one of InputMediaAnimation, InputMediaDocument, InputMediaAudio, InputMediaPhoto, InputMediaVideo. * - * @package TelegramBot\Api + * @package TelegramBot\Api\Types */ -class InputMedia extends BaseType implements CollectionItemInterface +class InputMedia extends BaseType implements TypeInterface, CollectionItemInterface { /** - * {@inheritdoc} - * - * @var array - */ - protected static $requiredParams = ['type', 'media']; - - /** - * {@inheritdoc} - * - * @var array - */ - protected static $map = [ - 'type' => true, - 'media' => true, - 'caption' => true, - 'parse_mode' => true, - ]; - - /** - * Type of the result. - * - * @var string - */ - protected $type; - - /** - * File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), - * pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://" - * to upload a new one using multipart/form-data under name. - * - * @var string - */ - protected $media; - - /** - * Optional. Caption of the photo to be sent, 0-200 characters. - * - * @var string|null - */ - protected $caption; - - /** - * Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, - * fixed-width text or inline URLs in the media caption. - * - * @var string|null - */ - protected $parseMode; - - /** - * @return string - */ - public function getType() - { - return $this->type; - } - - /** - * @param string $type - * - * @return void - */ - public function setType($type) - { - $this->type = $type; - } - - /** - * @return string - */ - public function getMedia() - { - return $this->media; - } - - /** - * @param string $media - * - * @return void - */ - public function setMedia($media) - { - $this->media = $media; - } - - /** - * @return string|null - */ - public function getCaption() - { - return $this->caption; - } - - /** - * @param string|null $caption - * - * @return void - */ - public function setCaption($caption) - { - $this->caption = $caption; - } - - /** - * @return string|null - */ - public function getParseMode() - { - return $this->parseMode; - } - - /** - * @param string|null $parseMode - * - * @return void - */ - public function setParseMode($parseMode) - { - $this->parseMode = $parseMode; + * Factory method to create an instance of the appropriate InputMedia subclass based on the type. + * + * @param array $data + * @return InputMediaAnimation|InputMediaDocument|InputMediaAudio|InputMediaPhoto|InputMediaVideo + * @throws InvalidArgumentException + */ + public static function fromResponse($data) + { + self::validate($data); + $type = $data['type']; + + switch ($type) { + case 'animation': + return InputMediaAnimation::fromResponse($data); + case 'document': + return InputMediaDocument::fromResponse($data); + case 'audio': + return InputMediaAudio::fromResponse($data); + case 'photo': + return InputMediaPhoto::fromResponse($data); + case 'video': + return InputMediaVideo::fromResponse($data); + default: + throw new InvalidArgumentException('Unknown media type: ' . $data['type']); + } } } diff --git a/src/Types/InputMedia/InputMediaAnimation.php b/src/Types/InputMedia/InputMediaAnimation.php new file mode 100644 index 00000000..94a6bd78 --- /dev/null +++ b/src/Types/InputMedia/InputMediaAnimation.php @@ -0,0 +1,308 @@ + true, + 'media' => true, + 'thumbnail' => true, + 'caption' => true, + 'parse_mode' => true, + 'caption_entities' => true, + 'show_caption_above_media' => true, + 'width' => true, + 'height' => true, + 'duration' => true, + 'has_spoiler' => true + ]; + + /** + * Type of the result, must be animation + * + * @var string + */ + protected $type = 'animation'; + + /** + * File to send + * + * @var string + */ + protected $media; + + /** + * Optional. Thumbnail of the file sent + * + * @var string|null + */ + protected $thumbnail; + + /** + * Optional. Caption of the animation to be sent, 0-1024 characters after entities parsing + * + * @var string|null + */ + protected $caption; + + /** + * Optional. Mode for parsing entities in the animation caption + * + * @var string|null + */ + protected $parseMode; + + /** + * Optional. List of special entities that appear in the caption + * + * @var array|null + */ + protected $captionEntities; + + /** + * Optional. Pass True, if the caption must be shown above the message media + * + * @var bool|null + */ + protected $showCaptionAboveMedia; + + /** + * Optional. Animation width + * + * @var int|null + */ + protected $width; + + /** + * Optional. Animation height + * + * @var int|null + */ + protected $height; + + /** + * Optional. Animation duration in seconds + * + * @var int|null + */ + protected $duration; + + /** + * Optional. Pass True if the animation needs to be covered with a spoiler animation + * + * @var bool|null + */ + protected $hasSpoiler; + + /** + * @param array $data + * @return static + * @throws InvalidArgumentException + */ + public static function fromResponse($data) + { + self::validate($data); + /** @psalm-suppress UnsafeInstantiation */ + $instance = new static(); + $instance->map($data); + + return $instance; + } + + /** + * @return string + */ + public function getType(): string + { + return $this->type; + } + + /** + * @param string $type + */ + public function setType(string $type): void + { + $this->type = $type; + } + + /** + * @return string + */ + public function getMedia(): string + { + return $this->media; + } + + /** + * @param string $media + */ + public function setMedia(string $media): void + { + $this->media = $media; + } + + /** + * @return string|null + */ + public function getThumbnail(): ?string + { + return $this->thumbnail; + } + + /** + * @param string|null $thumbnail + */ + public function setThumbnail(?string $thumbnail): void + { + $this->thumbnail = $thumbnail; + } + + /** + * @return string|null + */ + public function getCaption(): ?string + { + return $this->caption; + } + + /** + * @param string|null $caption + */ + public function setCaption(?string $caption): void + { + $this->caption = $caption; + } + + /** + * @return string|null + */ + public function getParseMode(): ?string + { + return $this->parseMode; + } + + /** + * @param string|null $parseMode + */ + public function setParseMode(?string $parseMode): void + { + $this->parseMode = $parseMode; + } + + /** + * @return array|null + */ + public function getCaptionEntities(): ?array + { + return $this->captionEntities; + } + + /** + * @param array|null $captionEntities + */ + public function setCaptionEntities(?array $captionEntities): void + { + $this->captionEntities = $captionEntities; + } + + /** + * @return bool|null + */ + public function getShowCaptionAboveMedia(): ?bool + { + return $this->showCaptionAboveMedia; + } + + /** + * @param bool|null $showCaptionAboveMedia + */ + public function setShowCaptionAboveMedia(?bool $showCaptionAboveMedia): void + { + $this->showCaptionAboveMedia = $showCaptionAboveMedia; + } + + /** + * @return int|null + */ + public function getWidth(): ?int + { + return $this->width; + } + + /** + * @param int|null $width + */ + public function setWidth(?int $width): void + { + $this->width = $width; + } + + /** + * @return int|null + */ + public function getHeight(): ?int + { + return $this->height; + } + + /** + * @param int|null $height + */ + public function setHeight(?int $height): void + { + $this->height = $height; + } + + /** + * @return int|null + */ + public function getDuration(): ?int + { + return $this->duration; + } + + /** + * @param int|null $duration + */ + public function setDuration(?int $duration): void + { + $this->duration = $duration; + } + + /** + * @return bool|null + */ + public function getHasSpoiler(): ?bool + { + return $this->hasSpoiler; + } + + /** + * @param bool|null $hasSpoiler + */ + public function setHasSpoiler(?bool $hasSpoiler): void + { + $this->hasSpoiler = $hasSpoiler; + } +} diff --git a/src/Types/InputMedia/InputMediaAudio.php b/src/Types/InputMedia/InputMediaAudio.php new file mode 100644 index 00000000..8bd555d3 --- /dev/null +++ b/src/Types/InputMedia/InputMediaAudio.php @@ -0,0 +1,260 @@ + true, + 'media' => true, + 'thumbnail' => true, + 'caption' => true, + 'parse_mode' => true, + 'caption_entities' => true, + 'duration' => true, + 'performer' => true, + 'title' => true + ]; + + /** + * Type of the result, must be audio + * + * @var string + */ + protected $type = 'audio'; + + /** + * File to send + * + * @var string + */ + protected $media; + + /** + * Optional. Thumbnail of the file sent + * + * @var string|null + */ + protected $thumbnail; + + /** + * Optional. Caption of the audio to be sent, 0-1024 characters after entities parsing + * + * @var string|null + */ + protected $caption; + + /** + * Optional. Mode for parsing entities in the audio caption + * + * @var string|null + */ + protected $parseMode; + + /** + * Optional. List of special entities that appear in the caption + * + * @var array|null + */ + protected $captionEntities; + + /** + * Optional. Duration of the audio in seconds + * + * @var int|null + */ + protected $duration; + + /** + * Optional. Performer of the audio + * + * @var string|null + */ + protected $performer; + + /** + * Optional. Title of the audio + * + * @var string|null + */ + protected $title; + + /** + * @param array $data + * @return static + * @throws InvalidArgumentException + */ + public static function fromResponse($data) + { + self::validate($data); + /** @psalm-suppress UnsafeInstantiation */ + $instance = new static(); + $instance->map($data); + + return $instance; + } + + /** + * @return string + */ + public function getType(): string + { + return $this->type; + } + + /** + * @param string $type + */ + public function setType(string $type): void + { + $this->type = $type; + } + + /** + * @return string + */ + public function getMedia(): string + { + return $this->media; + } + + /** + * @param string $media + */ + public function setMedia(string $media): void + { + $this->media = $media; + } + + /** + * @return string|null + */ + public function getThumbnail(): ?string + { + return $this->thumbnail; + } + + /** + * @param string|null $thumbnail + */ + public function setThumbnail(?string $thumbnail): void + { + $this->thumbnail = $thumbnail; + } + + /** + * @return string|null + */ + public function getCaption(): ?string + { + return $this->caption; + } + + /** + * @param string|null $caption + */ + public function setCaption(?string $caption): void + { + $this->caption = $caption; + } + + /** + * @return string|null + */ + public function getParseMode(): ?string + { + return $this->parseMode; + } + + /** + * @param string|null $parseMode + */ + public function setParseMode(?string $parseMode): void + { + $this->parseMode = $parseMode; + } + + /** + * @return array|null + */ + public function getCaptionEntities(): ?array + { + return $this->captionEntities; + } + + /** + * @param array|null $captionEntities + */ + public function setCaptionEntities(?array $captionEntities): void + { + $this->captionEntities = $captionEntities; + } + + /** + * @return int|null + */ + public function getDuration(): ?int + { + return $this->duration; + } + + /** + * @param int|null $duration + */ + public function setDuration(?int $duration): void + { + $this->duration = $duration; + } + + /** + * @return string|null + */ + public function getPerformer(): ?string + { + return $this->performer; + } + + /** + * @param string|null $performer + */ + public function setPerformer(?string $performer): void + { + $this->performer = $performer; + } + + /** + * @return string|null + */ + public function getTitle(): ?string + { + return $this->title; + } + + /** + * @param string|null $title + */ + public function setTitle(?string $title): void + { + $this->title = $title; + } +} diff --git a/src/Types/InputMedia/InputMediaDocument.php b/src/Types/InputMedia/InputMediaDocument.php new file mode 100644 index 00000000..3012e232 --- /dev/null +++ b/src/Types/InputMedia/InputMediaDocument.php @@ -0,0 +1,212 @@ + true, + 'media' => true, + 'thumbnail' => true, + 'caption' => true, + 'parse_mode' => true, + 'caption_entities' => true, + 'disable_content_type_detection' => true + ]; + + /** + * Type of the result, must be document + * + * @var string + */ + protected $type = 'document'; + + /** + * File to send + * + * @var string + */ + protected $media; + + /** + * Optional. Thumbnail of the file sent + * + * @var string|null + */ + protected $thumbnail; + + /** + * Optional. Caption of the document to be sent, 0-1024 characters after entities parsing + * + * @var string|null + */ + protected $caption; + + /** + * Optional. Mode for parsing entities in the document caption + * + * @var string|null + */ + protected $parseMode; + + /** + * Optional. List of special entities that appear in the caption + * + * @var array|null + */ + protected $captionEntities; + + /** + * Optional. Disables automatic server-side content type detection for files uploaded using multipart/form-data. Always True, if the document is sent as part of an album. + * + * @var bool|null + */ + protected $disableContentTypeDetection; + + /** + * @param array $data + * @return static + * @throws InvalidArgumentException + */ + public static function fromResponse($data) + { + self::validate($data); + /** @psalm-suppress UnsafeInstantiation */ + $instance = new static(); + $instance->map($data); + + return $instance; + } + + /** + * @return string + */ + public function getType(): string + { + return $this->type; + } + + /** + * @param string $type + */ + public function setType(string $type): void + { + $this->type = $type; + } + + /** + * @return string + */ + public function getMedia(): string + { + return $this->media; + } + + /** + * @param string $media + */ + public function setMedia(string $media): void + { + $this->media = $media; + } + + /** + * @return string|null + */ + public function getThumbnail(): ?string + { + return $this->thumbnail; + } + + /** + * @param string|null $thumbnail + */ + public function setThumbnail(?string $thumbnail): void + { + $this->thumbnail = $thumbnail; + } + + /** + * @return string|null + */ + public function getCaption(): ?string + { + return $this->caption; + } + + /** + * @param string|null $caption + */ + public function setCaption(?string $caption): void + { + $this->caption = $caption; + } + + /** + * @return string|null + */ + public function getParseMode(): ?string + { + return $this->parseMode; + } + + /** + * @param string|null $parseMode + */ + public function setParseMode(?string $parseMode): void + { + $this->parseMode = $parseMode; + } + + /** + * @return array|null + */ + public function getCaptionEntities(): ?array + { + return $this->captionEntities; + } + + /** + * @param array|null $captionEntities + */ + public function setCaptionEntities(?array $captionEntities): void + { + $this->captionEntities = $captionEntities; + } + + /** + * @return bool|null + */ + public function getDisableContentTypeDetection(): ?bool + { + return $this->disableContentTypeDetection; + } + + /** + * @param bool|null $disableContentTypeDetection + */ + public function setDisableContentTypeDetection(?bool $disableContentTypeDetection): void + { + $this->disableContentTypeDetection = $disableContentTypeDetection; + } +} diff --git a/src/Types/InputMedia/InputMediaPhoto.php b/src/Types/InputMedia/InputMediaPhoto.php index 1bf0b2b2..891e2327 100644 --- a/src/Types/InputMedia/InputMediaPhoto.php +++ b/src/Types/InputMedia/InputMediaPhoto.php @@ -2,26 +2,211 @@ namespace TelegramBot\Api\Types\InputMedia; +use TelegramBot\Api\InvalidArgumentException; + /** * Class InputMediaPhoto * Represents a photo to be sent. * - * @package TelegramBot\Api + * @package TelegramBot\Api\Types */ class InputMediaPhoto extends InputMedia { /** - * InputMediaPhoto constructor. + * {@inheritdoc} + * + * @var array + */ + protected static $requiredParams = ['type', 'media']; + + /** + * {@inheritdoc} + * + * @var array + */ + protected static $map = [ + 'type' => true, + 'media' => true, + 'caption' => true, + 'parse_mode' => true, + 'caption_entities' => true, + 'show_caption_above_media' => true, + 'has_spoiler' => true + ]; + + /** + * Type of the result, must be photo + * + * @var string + */ + protected $type; + + /** + * File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://” to upload a new one using multipart/form-data under name. + * + * @var string + */ + protected $media; + + /** + * Optional. Caption of the photo to be sent, 0-1024 characters after entities parsing + * + * @var string|null + */ + protected $caption; + + /** + * Optional. Mode for parsing entities in the photo caption. See formatting options for more details. + * + * @var string|null + */ + protected $parseMode; + + /** + * Optional. List of special entities that appear in the caption, which can be specified instead of parse_mode + * + * @var array|null + */ + protected $captionEntities; + + /** + * Optional. Pass True, if the caption must be shown above the message media * + * @var bool|null + */ + protected $showCaptionAboveMedia; + + /** + * Optional. Pass True if the photo needs to be covered with a spoiler animation + * + * @var bool|null + */ + protected $hasSpoiler; + + /** + * @param array $data + * @return static + * @throws InvalidArgumentException + */ + public static function fromResponse($data) + { + self::validate($data); + /** @psalm-suppress UnsafeInstantiation */ + $instance = new static(); + $instance->map($data); + + return $instance; + } + + /** + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * @param string $type + */ + public function setType($type) + { + $this->type = $type; + } + + /** + * @return string + */ + public function getMedia() + { + return $this->media; + } + + /** * @param string $media - * @param string|null $caption - * @param string|null $parseMode */ - public function __construct($media, $caption = null, $parseMode = null) + public function setMedia($media) { - $this->type = 'photo'; $this->media = $media; + } + + /** + * @return string|null + */ + public function getCaption() + { + return $this->caption; + } + + /** + * @param string|null $caption + */ + public function setCaption($caption) + { $this->caption = $caption; + } + + /** + * @return string|null + */ + public function getParseMode() + { + return $this->parseMode; + } + + /** + * @param string|null $parseMode + */ + public function setParseMode($parseMode) + { $this->parseMode = $parseMode; } + + /** + * @return array|null + */ + public function getCaptionEntities() + { + return $this->captionEntities; + } + + /** + * @param array|null $captionEntities + */ + public function setCaptionEntities($captionEntities) + { + $this->captionEntities = $captionEntities; + } + + /** + * @return bool|null + */ + public function getShowCaptionAboveMedia() + { + return $this->showCaptionAboveMedia; + } + + /** + * @param bool|null $showCaptionAboveMedia + */ + public function setShowCaptionAboveMedia($showCaptionAboveMedia) + { + $this->showCaptionAboveMedia = $showCaptionAboveMedia; + } + + /** + * @return bool|null + */ + public function getHasSpoiler() + { + return $this->hasSpoiler; + } + + /** + * @param bool|null $hasSpoiler + */ + public function setHasSpoiler($hasSpoiler) + { + $this->hasSpoiler = $hasSpoiler; + } } diff --git a/src/Types/InputMedia/InputMediaVideo.php b/src/Types/InputMedia/InputMediaVideo.php index f6836a44..b51b32bb 100644 --- a/src/Types/InputMedia/InputMediaVideo.php +++ b/src/Types/InputMedia/InputMediaVideo.php @@ -2,14 +2,23 @@ namespace TelegramBot\Api\Types\InputMedia; +use TelegramBot\Api\InvalidArgumentException; + /** * Class InputMediaVideo * Represents a video to be sent. * - * @package TelegramBot\Api + * @package TelegramBot\Api\Types */ class InputMediaVideo extends InputMedia { + /** + * {@inheritdoc} + * + * @var array + */ + protected static $requiredParams = ['type', 'media']; + /** * {@inheritdoc} * @@ -18,86 +27,241 @@ class InputMediaVideo extends InputMedia protected static $map = [ 'type' => true, 'media' => true, + 'thumbnail' => true, 'caption' => true, 'parse_mode' => true, + 'caption_entities' => true, + 'show_caption_above_media' => true, 'width' => true, 'height' => true, 'duration' => true, - 'supports_streaming' => true + 'supports_streaming' => true, + 'has_spoiler' => true ]; /** - * Optional. Video width. + * Type of the result, must be video + * + * @var string + */ + protected $type = 'video'; + + /** + * File to send + * + * @var string + */ + protected $media; + + /** + * Optional. Thumbnail of the file sent + * + * @var string|null + */ + protected $thumbnail; + + /** + * Optional. Caption of the video to be sent, 0-1024 characters after entities parsing + * + * @var string|null + */ + protected $caption; + + /** + * Optional. Mode for parsing entities in the video caption + * + * @var string|null + */ + protected $parseMode; + + /** + * Optional. List of special entities that appear in the caption + * + * @var array|null + */ + protected $captionEntities; + + /** + * Optional. Pass True, if the caption must be shown above the message media + * + * @var bool|null + */ + protected $showCaptionAboveMedia; + + /** + * Optional. Video width * * @var int|null */ protected $width; /** - * Optional. Video height. + * Optional. Video height * * @var int|null */ protected $height; /** - * Optional. Video duration. + * Optional. Video duration in seconds * * @var int|null */ protected $duration; /** - * Optional. Pass True, if the uploaded video is suitable for streaming. + * Optional. Pass True if the uploaded video is suitable for streaming * * @var bool|null */ protected $supportsStreaming; /** - * InputMediaVideo constructor. + * Optional. Pass True if the video needs to be covered with a spoiler animation * + * @var bool|null + */ + protected $hasSpoiler; + + /** + * @param array $data + * @return static + * @throws InvalidArgumentException + */ + public static function fromResponse($data) + { + self::validate($data); + /** @psalm-suppress UnsafeInstantiation */ + $instance = new static(); + $instance->map($data); + + return $instance; + } + + /** + * @return string + */ + public function getType(): string + { + return $this->type; + } + + /** + * @param string $type + */ + public function setType(string $type): void + { + $this->type = $type; + } + + /** + * @return string + */ + public function getMedia(): string + { + return $this->media; + } + + /** * @param string $media - * @param string|null $caption - * @param string|null $parseMode - * @param int|null $width - * @param int|null $height - * @param int|null $duration - * @param bool $supportsStreaming - */ - public function __construct( - $media, - $caption = null, - $parseMode = null, - $width = null, - $height = null, - $duration = null, - $supportsStreaming = false - ) { - $this->type = 'video'; + */ + public function setMedia(string $media): void + { $this->media = $media; + } + + /** + * @return string|null + */ + public function getThumbnail(): ?string + { + return $this->thumbnail; + } + + /** + * @param string|null $thumbnail + */ + public function setThumbnail(?string $thumbnail): void + { + $this->thumbnail = $thumbnail; + } + + /** + * @return string|null + */ + public function getCaption(): ?string + { + return $this->caption; + } + + /** + * @param string|null $caption + */ + public function setCaption(?string $caption): void + { $this->caption = $caption; + } + + /** + * @return string|null + */ + public function getParseMode(): ?string + { + return $this->parseMode; + } + + /** + * @param string|null $parseMode + */ + public function setParseMode(?string $parseMode): void + { $this->parseMode = $parseMode; - $this->width = $width; - $this->height = $height; - $this->duration = $duration; - $this->supportsStreaming = $supportsStreaming; + } + + /** + * @return array|null + */ + public function getCaptionEntities(): ?array + { + return $this->captionEntities; + } + + /** + * @param array|null $captionEntities + */ + public function setCaptionEntities(?array $captionEntities): void + { + $this->captionEntities = $captionEntities; + } + + /** + * @return bool|null + */ + public function getShowCaptionAboveMedia(): ?bool + { + return $this->showCaptionAboveMedia; + } + + /** + * @param bool|null $showCaptionAboveMedia + */ + public function setShowCaptionAboveMedia(?bool $showCaptionAboveMedia): void + { + $this->showCaptionAboveMedia = $showCaptionAboveMedia; } /** * @return int|null */ - public function getWidth() + public function getWidth(): ?int { return $this->width; } /** * @param int|null $width - * - * @return void */ - public function setWidth($width) + public function setWidth(?int $width): void { $this->width = $width; } @@ -105,17 +269,15 @@ public function setWidth($width) /** * @return int|null */ - public function getHeight() + public function getHeight(): ?int { return $this->height; } /** * @param int|null $height - * - * @return void */ - public function setHeight($height) + public function setHeight(?int $height): void { $this->height = $height; } @@ -123,17 +285,15 @@ public function setHeight($height) /** * @return int|null */ - public function getDuration() + public function getDuration(): ?int { return $this->duration; } /** * @param int|null $duration - * - * @return void */ - public function setDuration($duration) + public function setDuration(?int $duration): void { $this->duration = $duration; } @@ -141,18 +301,33 @@ public function setDuration($duration) /** * @return bool|null */ - public function getSupportsStreaming() + public function getSupportsStreaming(): ?bool { return $this->supportsStreaming; } /** * @param bool|null $supportsStreaming - * - * @return void */ - public function setSupportsStreaming($supportsStreaming) + public function setSupportsStreaming(?bool $supportsStreaming): void { $this->supportsStreaming = $supportsStreaming; } + + /** + * @return bool|null + */ + public function getHasSpoiler(): ?bool + { + return $this->hasSpoiler; + } + + /** + * @param bool|null $hasSpoiler + */ + public function setHasSpoiler(?bool $hasSpoiler): void + { + $this->hasSpoiler = $hasSpoiler; + } + } diff --git a/src/Types/InputPollOption.php b/src/Types/InputPollOption.php new file mode 100644 index 00000000..f6791a23 --- /dev/null +++ b/src/Types/InputPollOption.php @@ -0,0 +1,105 @@ + true, + 'text_parse_mode' => true, + 'text_entities' => ArrayOfMessageEntity::class + ]; + + /** + * Option text, 1-100 characters + * + * @var string + */ + protected $text; + + /** + * Optional. Mode for parsing entities in the text. Currently, only custom emoji entities are allowed + * + * @var string|null + */ + protected $textParseMode; + + /** + * Optional. A JSON-serialized list of special entities that appear in the poll option text + * + * @var array|null + */ + protected $textEntities; + + /** + * @return string + */ + public function getText() + { + return $this->text; + } + + /** + * @param string $text + * @return void + */ + public function setText($text) + { + $this->text = $text; + } + + /** + * @return string|null + */ + public function getTextParseMode() + { + return $this->textParseMode; + } + + /** + * @param string|null $textParseMode + * @return void + */ + public function setTextParseMode($textParseMode) + { + $this->textParseMode = $textParseMode; + } + + /** + * @return array|null + */ + public function getTextEntities() + { + return $this->textEntities; + } + + /** + * @param array|null $textEntities + * @return void + */ + public function setTextEntities($textEntities) + { + $this->textEntities = $textEntities; + } +} diff --git a/src/Types/KeyboardButton.php b/src/Types/KeyboardButton.php new file mode 100644 index 00000000..9db786a9 --- /dev/null +++ b/src/Types/KeyboardButton.php @@ -0,0 +1,213 @@ + true, + 'request_users' => KeyboardButtonRequestUsers::class, + 'request_chat' => KeyboardButtonRequestChat::class, + 'request_contact' => true, + 'request_location' => true, + 'request_poll' => KeyboardButtonPollType::class, + 'web_app' => WebAppInfo::class, + ]; + + /** + * Text of the button. If none of the optional fields are used, it will be sent as a message when the button is pressed + * + * @var string + */ + protected $text; + + /** + * Optional. If specified, pressing the button will open a list of suitable users. + * Identifiers of selected users will be sent to the bot in a “users_shared” service message. + * Available in private chats only. + * + * @var KeyboardButtonRequestUsers|null + */ + protected $requestUsers; + + /** + * Optional. If specified, pressing the button will open a list of suitable chats. + * Tapping on a chat will send its identifier to the bot in a “chat_shared” service message. + * Available in private chats only. + * + * @var KeyboardButtonRequestChat|null + */ + protected $requestChat; + + /** + * Optional. If True, the user's phone number will be sent as a contact when the button is pressed. + * Available in private chats only. + * + * @var bool|null + */ + protected $requestContact; + + /** + * Optional. If True, the user's current location will be sent when the button is pressed. + * Available in private chats only. + * + * @var bool|null + */ + protected $requestLocation; + + /** + * Optional. If specified, the user will be asked to create a poll and send it to the bot when the button is pressed. + * Available in private chats only. + * + * @var KeyboardButtonPollType|null + */ + protected $requestPoll; + + /** + * Optional. If specified, the described Web App will be launched when the button is pressed. + * The Web App will be able to send a “web_app_data” service message. Available in private chats only. + * + * @var WebAppInfo|null + */ + protected $webApp; + + /** + * @return string + */ + public function getText() + { + return $this->text; + } + + /** + * @param string $text + * @return void + */ + public function setText($text) + { + $this->text = $text; + } + + /** + * @return KeyboardButtonRequestUsers|null + */ + public function getRequestUsers() + { + return $this->requestUsers; + } + + /** + * @param KeyboardButtonRequestUsers|null $requestUsers + * @return void + */ + public function setRequestUsers($requestUsers) + { + $this->requestUsers = $requestUsers; + } + + /** + * @return KeyboardButtonRequestChat|null + */ + public function getRequestChat() + { + return $this->requestChat; + } + + /** + * @param KeyboardButtonRequestChat|null $requestChat + * @return void + */ + public function setRequestChat($requestChat) + { + $this->requestChat = $requestChat; + } + + /** + * @return bool|null + */ + public function getRequestContact() + { + return $this->requestContact; + } + + /** + * @param bool|null $requestContact + * @return void + */ + public function setRequestContact($requestContact) + { + $this->requestContact = $requestContact; + } + + /** + * @return bool|null + */ + public function getRequestLocation() + { + return $this->requestLocation; + } + + /** + * @param bool|null $requestLocation + * @return void + */ + public function setRequestLocation($requestLocation) + { + $this->requestLocation = $requestLocation; + } + + /** + * @return KeyboardButtonPollType|null + */ + public function getRequestPoll() + { + return $this->requestPoll; + } + + /** + * @param KeyboardButtonPollType|null $requestPoll + * @return void + */ + public function setRequestPoll($requestPoll) + { + $this->requestPoll = $requestPoll; + } + + /** + * @return WebAppInfo|null + */ + public function getWebApp() + { + return $this->webApp; + } + + /** + * @param WebAppInfo|null $webApp + * @return void + */ + public function setWebApp($webApp) + { + $this->webApp = $webApp; + } +} diff --git a/src/Types/KeyboardButtonPollType.php b/src/Types/KeyboardButtonPollType.php new file mode 100644 index 00000000..2fa8c507 --- /dev/null +++ b/src/Types/KeyboardButtonPollType.php @@ -0,0 +1,50 @@ + true, + ]; + + /** + * Optional. If quiz is passed, the user will be allowed to create only polls in the quiz mode. + * If regular is passed, only regular polls will be allowed. + * Otherwise, the user will be allowed to create a poll of any type. + * + * @var string|null + */ + protected $type; + + /** + * @return string|null + */ + public function getType() + { + return $this->type; + } + + /** + * @param string|null $type + * @return void + */ + public function setType($type) + { + $this->type = $type; + } +} diff --git a/src/Types/KeyboardButtonRequestChat.php b/src/Types/KeyboardButtonRequestChat.php new file mode 100644 index 00000000..6e77522f --- /dev/null +++ b/src/Types/KeyboardButtonRequestChat.php @@ -0,0 +1,307 @@ + true, + 'chat_is_channel' => true, + 'chat_is_forum' => true, + 'chat_has_username' => true, + 'chat_is_created' => true, + 'user_administrator_rights' => ChatAdministratorRights::class, + 'bot_administrator_rights' => ChatAdministratorRights::class, + 'bot_is_member' => true, + 'request_title' => true, + 'request_username' => true, + 'request_photo' => true, + ]; + + /** + * Signed 32-bit identifier of the request, which will be received back in the ChatShared object. Must be unique within the message + * + * @var int + */ + protected $requestId; + + /** + * Pass True to request a channel chat, pass False to request a group or a supergroup chat. + * + * @var bool + */ + protected $chatIsChannel; + + /** + * Optional. Pass True to request a forum supergroup, pass False to request a non-forum chat. If not specified, no additional restrictions are applied. + * + * @var bool|null + */ + protected $chatIsForum; + + /** + * Optional. Pass True to request a supergroup or a channel with a username, pass False to request a chat without a username. If not specified, no additional restrictions are applied. + * + * @var bool|null + */ + protected $chatHasUsername; + + /** + * Optional. Pass True to request a chat owned by the user. Otherwise, no additional restrictions are applied. + * + * @var bool|null + */ + protected $chatIsCreated; + + /** + * Optional. A JSON-serialized object listing the required administrator rights of the user in the chat. The rights must be a superset of bot_administrator_rights. If not specified, no additional restrictions are applied. + * + * @var ChatAdministratorRights|null + */ + protected $userAdministratorRights; + + /** + * Optional. A JSON-serialized object listing the required administrator rights of the bot in the chat. The rights must be a subset of user_administrator_rights. If not specified, no additional restrictions are applied. + * + * @var ChatAdministratorRights|null + */ + protected $botAdministratorRights; + + /** + * Optional. Pass True to request a chat with the bot as a member. Otherwise, no additional restrictions are applied. + * + * @var bool|null + */ + protected $botIsMember; + + /** + * Optional. Pass True to request the chat's title. + * + * @var bool|null + */ + protected $requestTitle; + + /** + * Optional. Pass True to request the chat's username. + * + * @var bool|null + */ + protected $requestUsername; + + /** + * Optional. Pass True to request the chat's photo. + * + * @var bool|null + */ + protected $requestPhoto; + + /** + * @return int + */ + public function getRequestId() + { + return $this->requestId; + } + + /** + * @param int $requestId + * @return void + */ + public function setRequestId($requestId) + { + $this->requestId = $requestId; + } + + /** + * @return bool + */ + public function getChatIsChannel() + { + return $this->chatIsChannel; + } + + /** + * @param bool $chatIsChannel + * @return void + */ + public function setChatIsChannel($chatIsChannel) + { + $this->chatIsChannel = $chatIsChannel; + } + + /** + * @return bool|null + */ + public function getChatIsForum() + { + return $this->chatIsForum; + } + + /** + * @param bool|null $chatIsForum + * @return void + */ + public function setChatIsForum($chatIsForum) + { + $this->chatIsForum = $chatIsForum; + } + + /** + * @return bool|null + */ + public function getChatHasUsername() + { + return $this->chatHasUsername; + } + + /** + * @param bool|null $chatHasUsername + * @return void + */ + public function setChatHasUsername($chatHasUsername) + { + $this->chatHasUsername = $chatHasUsername; + } + + /** + * @return bool|null + */ + public function getChatIsCreated() + { + return $this->chatIsCreated; + } + + /** + * @param bool|null $chatIsCreated + * @return void + */ + public function setChatIsCreated($chatIsCreated) + { + $this->chatIsCreated = $chatIsCreated; + } + + /** + * @return ChatAdministratorRights|null + */ + public function getUserAdministratorRights() + { + return $this->userAdministratorRights; + } + + /** + * @param ChatAdministratorRights|null $userAdministratorRights + * @return void + */ + public function setUserAdministratorRights($userAdministratorRights) + { + $this->userAdministratorRights = $userAdministratorRights; + } + + /** + * @return ChatAdministratorRights|null + */ + public function getBotAdministratorRights() + { + return $this->botAdministratorRights; + } + + /** + * @param ChatAdministratorRights|null $botAdministratorRights + * @return void + */ + public function setBotAdministratorRights($botAdministratorRights) + { + $this->botAdministratorRights = $botAdministratorRights; + } + + /** + * @return bool|null + */ + public function getBotIsMember() + { + return $this->botIsMember; + } + + /** + * @param bool|null $botIsMember + * @return void + */ + public function setBotIsMember($botIsMember) + { + $this->botIsMember = $botIsMember; + } + + /** + * @return bool|null + */ + public function getRequestTitle() + { + return $this->requestTitle; + } + + /** + * @param bool|null $requestTitle + * @return void + */ + public function setRequestTitle($requestTitle) + { + $this->requestTitle = $requestTitle; + } + + /** + * @return bool|null + */ + public function getRequestUsername() + { + return $this->requestUsername; + } + + /** + * @param bool|null $requestUsername + * @return void + */ + public function setRequestUsername($requestUsername) + { + $this->requestUsername = $requestUsername; + } + + /** + * @return bool|null + */ + public function getRequestPhoto() + { + return $this->requestPhoto; + } + + /** + * @param bool|null $requestPhoto + * @return void + */ + public function setRequestPhoto($requestPhoto) + { + $this->requestPhoto = $requestPhoto; + } +} diff --git a/src/Types/KeyboardButtonRequestUsers.php b/src/Types/KeyboardButtonRequestUsers.php new file mode 100644 index 00000000..4cf02c76 --- /dev/null +++ b/src/Types/KeyboardButtonRequestUsers.php @@ -0,0 +1,206 @@ + true, + 'user_is_bot' => true, + 'user_is_premium' => true, + 'max_quantity' => true, + 'request_name' => true, + 'request_username' => true, + 'request_photo' => true, + ]; + + /** + * Signed 32-bit identifier of the request that will be received back in the UsersShared object. Must be unique within the message + * + * @var int + */ + protected $requestId; + + /** + * Optional. Pass True to request bots, pass False to request regular users. If not specified, no additional restrictions are applied. + * + * @var bool|null + */ + protected $userIsBot; + + /** + * Optional. Pass True to request premium users, pass False to request non-premium users. If not specified, no additional restrictions are applied. + * + * @var bool|null + */ + protected $userIsPremium; + + /** + * Optional. The maximum number of users to be selected; 1-10. Defaults to 1. + * + * @var int|null + */ + protected $maxQuantity; + + /** + * Optional. Pass True to request the users' first and last names. + * + * @var bool|null + */ + protected $requestName; + + /** + * Optional. Pass True to request the users' usernames. + * + * @var bool|null + */ + protected $requestUsername; + + /** + * Optional. Pass True to request the users' photos. + * + * @var bool|null + */ + protected $requestPhoto; + + /** + * @return int + */ + public function getRequestId() + { + return $this->requestId; + } + + /** + * @param int $requestId + * @return void + */ + public function setRequestId($requestId) + { + $this->requestId = $requestId; + } + + /** + * @return bool|null + */ + public function getUserIsBot() + { + return $this->userIsBot; + } + + /** + * @param bool|null $userIsBot + * @return void + */ + public function setUserIsBot($userIsBot) + { + $this->userIsBot = $userIsBot; + } + + /** + * @return bool|null + */ + public function getUserIsPremium() + { + return $this->userIsPremium; + } + + /** + * @param bool|null $userIsPremium + * @return void + */ + public function setUserIsPremium($userIsPremium) + { + $this->userIsPremium = $userIsPremium; + } + + /** + * @return int|null + */ + public function getMaxQuantity() + { + return $this->maxQuantity; + } + + /** + * @param int|null $maxQuantity + * @return void + */ + public function setMaxQuantity($maxQuantity) + { + $this->maxQuantity = $maxQuantity; + } + + /** + * @return bool|null + */ + public function getRequestName() + { + return $this->requestName; + } + + /** + * @param bool|null $requestName + * @return void + */ + public function setRequestName($requestName) + { + $this->requestName = $requestName; + } + + /** + * @return bool|null + */ + public function getRequestUsername() + { + return $this->requestUsername; + } + + /** + * @param bool|null $requestUsername + * @return void + */ + public function setRequestUsername($requestUsername) + { + $this->requestUsername = $requestUsername; + } + + /** + * @return bool|null + */ + public function getRequestPhoto() + { + return $this->requestPhoto; + } + + /** + * @param bool|null $requestPhoto + * @return void + */ + public function setRequestPhoto($requestPhoto) + { + $this->requestPhoto = $requestPhoto; + } +} diff --git a/src/Types/LinkPreviewOptions.php b/src/Types/LinkPreviewOptions.php new file mode 100644 index 00000000..e12175c6 --- /dev/null +++ b/src/Types/LinkPreviewOptions.php @@ -0,0 +1,148 @@ + true, + 'url' => true, + 'prefer_small_media' => true, + 'prefer_large_media' => true, + 'show_above_text' => true, + ]; + + /** + * Optional. True, if the link preview is disabled + * + * @var bool|null + */ + protected $isDisabled; + + /** + * Optional. URL to use for the link preview. If empty, then the first URL found in the message text will be used + * + * @var string|null + */ + protected $url; + + /** + * Optional. True, if the media in the link preview is supposed to be shrunk; ignored if the URL isn't explicitly specified or media size change isn't supported for the preview + * + * @var bool|null + */ + protected $preferSmallMedia; + + /** + * Optional. True, if the media in the link preview is supposed to be enlarged; ignored if the URL isn't explicitly specified or media size change isn't supported for the preview + * + * @var bool|null + */ + protected $preferLargeMedia; + + /** + * Optional. True, if the link preview must be shown above the message text; otherwise, the link preview will be shown below the message text + * + * @var bool|null + */ + protected $showAboveText; + + /** + * @return bool|null + */ + public function getIsDisabled() + { + return $this->isDisabled; + } + + /** + * @param bool|null $isDisabled + * @return void + */ + public function setIsDisabled($isDisabled) + { + $this->isDisabled = $isDisabled; + } + + /** + * @return string|null + */ + public function getUrl() + { + return $this->url; + } + + /** + * @param string|null $url + * @return void + */ + public function setUrl($url) + { + $this->url = $url; + } + + /** + * @return bool|null + */ + public function getPreferSmallMedia() + { + return $this->preferSmallMedia; + } + + /** + * @param bool|null $preferSmallMedia + * @return void + */ + public function setPreferSmallMedia($preferSmallMedia) + { + $this->preferSmallMedia = $preferSmallMedia; + } + + /** + * @return bool|null + */ + public function getPreferLargeMedia() + { + return $this->preferLargeMedia; + } + + /** + * @param bool|null $preferLargeMedia + * @return void + */ + public function setPreferLargeMedia($preferLargeMedia) + { + $this->preferLargeMedia = $preferLargeMedia; + } + + /** + * @return bool|null + */ + public function getShowAboveText() + { + return $this->showAboveText; + } + + /** + * @param bool|null $showAboveText + * @return void + */ + public function setShowAboveText($showAboveText) + { + $this->showAboveText = $showAboveText; + } +} diff --git a/src/Types/Location.php b/src/Types/Location.php index 19a17f8f..9237858a 100644 --- a/src/Types/Location.php +++ b/src/Types/Location.php @@ -57,8 +57,7 @@ class Location extends BaseType implements TypeInterface protected $horizontalAccuracy; /** - * Optional. Time relative to the message sending date, during which the location can be updated, in seconds. For - * active live locations only. + * Optional. Time relative to the message sending date, during which the location can be updated, in seconds. For active live locations only. * * @var int|null */ @@ -72,8 +71,7 @@ class Location extends BaseType implements TypeInterface protected $heading; /** - * Optional. Maximum distance for proximity alerts about approaching another chat member, in meters. For sent live - * locations only. + * Optional. Maximum distance for proximity alerts about approaching another chat member, in meters. For sent live locations only. * * @var int|null */ @@ -88,7 +86,7 @@ public function getLatitude() } /** - * @param mixed $latitude + * @param float $latitude * @return void * @throws InvalidArgumentException */ @@ -110,7 +108,7 @@ public function getLongitude() } /** - * @param mixed $longitude + * @param float $longitude * @return void * @throws InvalidArgumentException */ @@ -132,7 +130,7 @@ public function getHorizontalAccuracy() } /** - * @param mixed $horizontalAccuracy + * @param float|null $horizontalAccuracy * @return void * @throws InvalidArgumentException */ @@ -154,7 +152,7 @@ public function getLivePeriod() } /** - * @param int $livePeriod + * @param int|null $livePeriod * @return void */ public function setLivePeriod($livePeriod) @@ -171,7 +169,7 @@ public function getHeading() } /** - * @param int $heading + * @param int|null $heading * @return void */ public function setHeading($heading) @@ -188,7 +186,7 @@ public function getProximityAlertRadius() } /** - * @param int $proximityAlertRadius + * @param int|null $proximityAlertRadius * @return void */ public function setProximityAlertRadius($proximityAlertRadius) diff --git a/src/Types/MaybeInaccessibleMessage.php b/src/Types/MaybeInaccessibleMessage.php new file mode 100644 index 00000000..505b07d7 --- /dev/null +++ b/src/Types/MaybeInaccessibleMessage.php @@ -0,0 +1,26 @@ + true, + 'message_thread_id' => true, 'from' => User::class, + 'sender_chat' => Chat::class, + 'sender_boost_count' => true, + 'sender_business_bot' => User::class, 'date' => true, + 'business_connection_id' => true, 'chat' => Chat::class, - 'forward_from' => User::class, - 'forward_from_chat' => Chat::class, - 'forward_from_message_id' => true, - 'forward_date' => true, - 'forward_signature' => true, - 'forward_sender_name' => true, - 'reply_to_message' => Message::class, + 'forward_origin' => MessageOrigin::class, + 'is_topic_message' => true, + 'is_automatic_forward' => true, + 'reply_to_message' => self::class, + 'external_reply' => ExternalReplyInfo::class, + 'quote' => TextQuote::class, + 'reply_to_story' => Story::class, 'via_bot' => User::class, 'edit_date' => true, + 'has_protected_content' => true, + 'is_from_offline' => true, 'media_group_id' => true, 'author_signature' => true, 'text' => true, 'entities' => ArrayOfMessageEntity::class, - 'caption_entities' => ArrayOfMessageEntity::class, + 'link_preview_options' => LinkPreviewOptions::class, + 'effect_id' => true, + 'animation' => Animation::class, 'audio' => Audio::class, 'document' => Document::class, - 'animation' => Animation::class, 'photo' => ArrayOfPhotoSize::class, 'sticker' => Sticker::class, + 'story' => Story::class, 'video' => Video::class, 'video_note' => VideoNote::class, 'voice' => Voice::class, 'caption' => true, + 'caption_entities' => ArrayOfMessageEntity::class, + 'show_caption_above_media' => true, + 'has_media_spoiler' => true, 'contact' => Contact::class, - 'location' => Location::class, - 'venue' => Venue::class, - 'poll' => Poll::class, 'dice' => Dice::class, + 'game' => Game::class, + 'poll' => Poll::class, + 'venue' => Venue::class, + 'location' => Location::class, 'new_chat_members' => ArrayOfUser::class, 'left_chat_member' => User::class, 'new_chat_title' => true, @@ -64,104 +83,159 @@ class Message extends BaseType implements TypeInterface 'group_chat_created' => true, 'supergroup_chat_created' => true, 'channel_chat_created' => true, + 'message_auto_delete_timer_changed' => MessageAutoDeleteTimerChanged::class, 'migrate_to_chat_id' => true, 'migrate_from_chat_id' => true, - 'pinned_message' => Message::class, + 'pinned_message' => MaybeInaccessibleMessage::class, 'invoice' => Invoice::class, 'successful_payment' => SuccessfulPayment::class, + 'users_shared' => UsersShared::class, + 'chat_shared' => ChatShared::class, 'connected_website' => true, + 'write_access_allowed' => WriteAccessAllowed::class, + // 'passport_data' => PassportData::class, + 'proximity_alert_triggered' => ProximityAlertTriggered::class, + 'boost_added' => ChatBoostAdded::class, + 'chat_background_set' => ChatBackground::class, 'forum_topic_created' => ForumTopicCreated::class, + 'forum_topic_edited' => ForumTopicEdited::class, 'forum_topic_closed' => ForumTopicClosed::class, 'forum_topic_reopened' => ForumTopicReopened::class, - 'is_topic_message' => true, - 'message_thread_id' => true, + 'general_forum_topic_hidden' => GeneralForumTopicHidden::class, + 'general_forum_topic_unhidden' => GeneralForumTopicUnhidden::class, + 'giveaway_created' => GiveawayCreated::class, + 'giveaway' => Giveaway::class, + 'giveaway_winners' => GiveawayWinners::class, + 'giveaway_completed' => GiveawayCompleted::class, + 'video_chat_scheduled' => VideoChatScheduled::class, + 'video_chat_started' => VideoChatStarted::class, + 'video_chat_ended' => VideoChatEnded::class, + 'video_chat_participants_invited' => VideoChatParticipantsInvited::class, 'web_app_data' => WebAppData::class, 'reply_markup' => InlineKeyboardMarkup::class, ]; /** - * Unique message identifier + * Unique message identifier inside this chat * - * @var int|float + * @var int */ protected $messageId; /** - * Optional. Sender name. Can be empty for messages sent to channels + * Optional. Unique identifier of a message thread to which the message belongs; for supergroups only + * + * @var int|null + */ + protected $messageThreadId; + + /** + * Optional. Sender of the message; empty for messages sent to channels. For backward compatibility, + * the field contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat. * * @var \TelegramBot\Api\Types\User|null */ protected $from; /** - * Date the message was sent in Unix time + * Optional. Sender of the message, sent on behalf of a chat. For example, the channel itself for channel posts, + * the supergroup itself for messages from anonymous group administrators, the linked channel for messages automatically forwarded to the discussion group. + * For backward compatibility, the field from contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat. + * + * @var \TelegramBot\Api\Types\Chat|null + */ + protected $senderChat; + + /** + * Optional. If the sender of the message boosted the chat, the number of boosts added by the user + * + * @var int|null + */ + protected $senderBoostCount; + + /** + * Optional. The bot that actually sent the message on behalf of the business account. + * Available only for outgoing messages sent on behalf of the connected business account. + * + * @var \TelegramBot\Api\Types\User|null + */ + protected $senderBusinessBot; + + /** + * Date the message was sent in Unix time. It is always a positive number, representing a valid date. * * @var int */ protected $date; /** - * Conversation the message belongs to — user in case of a private message, GroupChat in case of a group + * Optional. Unique identifier of the business connection from which the message was received. + * If non-empty, the message belongs to a chat of the corresponding business account that is independent + * from any potential bot chat which might share the same identifier. + * + * @var string|null + */ + protected $businessConnectionId; + + /** + * Chat the message belongs to * * @var \TelegramBot\Api\Types\Chat */ protected $chat; /** - * Optional. For forwarded messages, sender of the original message + * Optional. Information about the original message for forwarded messages * - * @var \TelegramBot\Api\Types\User|null + * @var \TelegramBot\Api\Types\MessageOrigin|null */ - protected $forwardFrom; + protected $forwardOrigin; /** - * Optional. For messages forwarded from channels, information about - * the original channel + * Optional. True, if the message is sent to a forum topic * - * @var \TelegramBot\Api\Types\Chat|null + * @var bool|null */ - protected $forwardFromChat; + protected $isTopicMessage; /** - * Optional. For messages forwarded from channels, identifier of - * the original message in the channel + * Optional. True, if the message is a channel post that was automatically forwarded to the connected discussion group * - * @var int|null + * @var bool|null */ - protected $forwardFromMessageId; + protected $isAutomaticForward; /** - * Optional. For messages forwarded from channels, signature of the post author if present + * Optional. For replies in the same chat and message thread, the original message. + * Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply. * - * @var string|null + * @var \TelegramBot\Api\Types\Message|null */ - protected $forwardSignature; + protected $replyToMessage; /** - * Optional. Sender's name for messages forwarded from users who disallow adding a link to their account - * in forwarded messages + * Optional. Information about the message that is being replied to, which may come from another chat or forum topic * - * @var string|null + * @var \TelegramBot\Api\Types\ExternalReplyInfo|null */ - protected $forwardSenderName; + protected $externalReply; /** - * Optional. For forwarded messages, date the original message was sent in Unix time + * Optional. For replies that quote part of the original message, the quoted part of the message * - * @var int|null + * @var \TelegramBot\Api\Types\TextQuote|null */ - protected $forwardDate; + protected $quote; /** - * Optional. For replies, the original message. Note that the Message object in this field will not contain further - * reply_to_message fields even if it itself is a reply. + * Optional. For replies to a story, the original story * - * @var \TelegramBot\Api\Types\Message|null + * @var \TelegramBot\Api\Types\Story|null */ - protected $replyToMessage; + protected $replyToStory; /** - * Optional. Bot through which the message was sent. + * Optional. Bot through which the message was sent * * @var \TelegramBot\Api\Types\User|null */ @@ -175,15 +249,29 @@ class Message extends BaseType implements TypeInterface protected $editDate; /** - * Optional. The unique identifier of a media message group - * this message belongs to + * Optional. True, if the message can't be forwarded * - * @var int|null + * @var bool|null + */ + protected $hasProtectedContent; + + /** + * Optional. True, if the message was sent by an implicit action, for example, as an away or a greeting business message, + * or as a scheduled message + * + * @var bool|null + */ + protected $isFromOffline; + + /** + * Optional. The unique identifier of a media message group this message belongs to + * + * @var string|null */ protected $mediaGroupId; /** - * Optional. Signature of the post author for messages in channels + * Optional. Signature of the post author for messages in channels, or the custom title of an anonymous group administrator * * @var string|null */ @@ -197,20 +285,33 @@ class Message extends BaseType implements TypeInterface protected $text; /** - * Optional. For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text. - * array of \TelegramBot\Api\Types\MessageEntity + * Optional. For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text * - * @var array|null + * @var \TelegramBot\Api\Types\ArrayOfMessageEntity|null */ protected $entities; /** - * Optional. For messages with a caption, special entities like usernames, - * URLs, bot commands, etc. that appear in the caption + * Optional. Options used for link preview generation for the message, if it is a text message and link preview options were changed * - * @var ArrayOfMessageEntity|null + * @var \TelegramBot\Api\Types\LinkPreviewOptions|null */ - protected $captionEntities; + protected $linkPreviewOptions; + + /** + * Optional. Unique identifier of the message effect added to the message + * + * @var string|null + */ + protected $effectId; + + /** + * Optional. Message is an animation, information about the animation. + * For backward compatibility, when this field is set, the document field will also be set + * + * @var \TelegramBot\Api\Types\Animation|null + */ + protected $animation; /** * Optional. Message is an audio file, information about the file @@ -226,18 +327,10 @@ class Message extends BaseType implements TypeInterface */ protected $document; - /** - * Optional. Message is a animation, information about the animation - * - * @var \TelegramBot\Api\Types\Animation|null - */ - protected $animation; - /** * Optional. Message is a photo, available sizes of the photo - * array of \TelegramBot\Api\Types\Photo * - * @var array|null + * @var \TelegramBot\Api\Types\ArrayOfPhotoSize|null */ protected $photo; @@ -248,6 +341,13 @@ class Message extends BaseType implements TypeInterface */ protected $sticker; + /** + * Optional. Message is a forwarded story + * + * @var \TelegramBot\Api\Types\Story|null + */ + protected $story; + /** * Optional. Message is a video, information about the video * @@ -270,12 +370,33 @@ class Message extends BaseType implements TypeInterface protected $voice; /** - * Optional. Text description of the video (usually empty) + * Optional. Caption for the animation, audio, document, photo, video or voice * * @var string|null */ protected $caption; + /** + * Optional. For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption + * + * @var \TelegramBot\Api\Types\ArrayOfMessageEntity|null + */ + protected $captionEntities; + + /** + * Optional. True, if the caption must be shown above the message media + * + * @var bool|null + */ + protected $showCaptionAboveMedia; + + /** + * Optional. True, if the message media is covered by a spoiler animation + * + * @var bool|null + */ + protected $hasMediaSpoiler; + /** * Optional. Message is a shared contact, information about the contact * @@ -284,18 +405,18 @@ class Message extends BaseType implements TypeInterface protected $contact; /** - * Optional. Message is a shared location, information about the location + * Optional. Message is a dice with random value * - * @var \TelegramBot\Api\Types\Location|null + * @var \TelegramBot\Api\Types\Dice|null */ - protected $location; + protected $dice; /** - * Optional. Message is a venue, information about the venue + * Optional. Message is a game, information about the game * - * @var \TelegramBot\Api\Types\Venue|null + * @var \TelegramBot\Api\Types\Game|null */ - protected $venue; + protected $game; /** * Optional. Message is a native poll, information about the poll @@ -305,166 +426,300 @@ class Message extends BaseType implements TypeInterface protected $poll; /** - * Optional. Message is a dice with random value from 1 to 6 + * Optional. Message is a venue, information about the venue. + * For backward compatibility, when this field is set, the location field will also be set * - * @var \TelegramBot\Api\Types\Dice|null + * @var \TelegramBot\Api\Types\Venue|null */ - protected $dice; + protected $venue; + + /** + * Optional. Message is a shared location, information about the location + * + * @var \TelegramBot\Api\Types\Location|null + */ + protected $location; /** * Optional. New members that were added to the group or supergroup and information about them * (the bot itself may be one of these members) - * array of \TelegramBot\Api\Types\User * - * @var \TelegramBot\Api\Types\User[]|null + * @var \TelegramBot\Api\Types\ArrayOfUser|null */ protected $newChatMembers; /** - * Optional. A member was removed from the group, information about them (this member may be bot itself) + * Optional. A member was removed from the group, information about them (this member may be the bot itself) * * @var \TelegramBot\Api\Types\User|null */ protected $leftChatMember; /** - * Optional. A group title was changed to this value + * Optional. A chat title was changed to this value * * @var string|null */ protected $newChatTitle; /** - * Optional. A group photo was change to this value + * Optional. A chat photo was change to this value * - * @var PhotoSize[]|null + * @var \TelegramBot\Api\Types\ArrayOfPhotoSize|null */ protected $newChatPhoto; /** - * Optional. Informs that the group photo was deleted + * Optional. Service message: the chat photo was deleted * * @var bool|null */ protected $deleteChatPhoto; /** - * Optional. Informs that the group has been created + * Optional. Service message: the group has been created * * @var bool|null */ protected $groupChatCreated; /** - * Optional. Service message: the supergroup has been created + * Optional. Service message: the supergroup has been created. + * This field can't be received in a message coming through updates, + * because bot can't be a member of a supergroup when it is created. + * It can only be found in reply_to_message if someone replies to a very first message in a directly created supergroup. * * @var bool|null */ protected $supergroupChatCreated; /** - * Optional. Service message: the channel has been created + * Optional. Service message: the channel has been created. + * This field can't be received in a message coming through updates, + * because bot can't be a member of a channel when it is created. + * It can only be found in reply_to_message if someone replies to a very first message in a channel. * * @var bool|null */ protected $channelChatCreated; /** - * Optional. The group has been migrated to a supergroup with the specified identifier, - * not exceeding 1e13 by absolute value + * Optional. Service message: auto-delete timer settings changed in the chat + * + * @var \TelegramBot\Api\Types\MessageAutoDeleteTimerChanged|null + */ + protected $messageAutoDeleteTimerChanged; + + /** + * Optional. The group has been migrated to a supergroup with the specified identifier. + * This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. + * But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier. * * @var int|null */ protected $migrateToChatId; /** - * Optional. The supergroup has been migrated from a group with the specified identifier, - * not exceeding 1e13 by absolute value + * Optional. The supergroup has been migrated from a group with the specified identifier. + * This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. + * But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier. * * @var int|null */ protected $migrateFromChatId; /** - * Optional. Specified message was pinned.Note that the Message object in this field - * will not contain further reply_to_message fields even if it is itself a reply. + * Optional. Specified message was pinned. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply. * - * @var Message|null + * @var \TelegramBot\Api\Types\MaybeInaccessibleMessage|null */ protected $pinnedMessage; /** - * Optional. Message is an invoice for a payment, information about the invoice. + * Optional. Message is an invoice for a payment, information about the invoice * - * @var Invoice|null + * @var Invoice */ protected $invoice; /** - * Optional. Message is a service message about a successful payment, information about the payment. + * Optional. Message is a service message about a successful payment, information about the payment * - * @var SuccessfulPayment|null + * @var SuccessfulPayment */ protected $successfulPayment; /** - * Optional. The domain name of the website on which the user has logged in. + * Optional. Service message: users were shared with the bot + * + * @var \TelegramBot\Api\Types\UsersShared|null + */ + protected $usersShared; + + /** + * Optional. Service message: a chat was shared with the bot + * + * @var \TelegramBot\Api\Types\ChatShared|null + */ + protected $chatShared; + + /** + * Optional. The domain name of the website on which the user has logged in * * @var string|null */ protected $connectedWebsite; /** - * Optional. Service message: data sent by a Web App + * Optional. Service message: the user allowed the bot to write messages after adding it to the attachment or side menu, + * launching a Web App from a link, or accepting an explicit request from a Web App sent by the method requestWriteAccess * - * @var WebAppData|null + * @var \TelegramBot\Api\Types\WriteAccessAllowed|null */ - protected $webAppData; + protected $writeAccessAllowed; /** - * Optional. Inline keyboard attached to the message. login_url buttons are represented as ordinary url buttons. + * Optional. Telegram Passport data * - * @var InlineKeyboardMarkup|null + * @var \TelegramBot\Api\Types\PassportData|null */ - protected $replyMarkup; + protected $passportData; + + /** + * Optional. Service message. A user in the chat triggered another user's proximity alert while sharing Live Location + * + * @var \TelegramBot\Api\Types\ProximityAlertTriggered|null + */ + protected $proximityAlertTriggered; + + /** + * Optional. Service message: user boosted the chat + * + * @var \TelegramBot\Api\Types\ChatBoostAdded|null + */ + protected $boostAdded; + + /** + * Optional. Service message: chat background set + * + * @var \TelegramBot\Api\Types\ChatBackground|null + */ + protected $chatBackgroundSet; /** * Optional. Service message: forum topic created * - * @var ForumTopicCreated|null + * @var \TelegramBot\Api\Types\ForumTopicCreated|null */ protected $forumTopicCreated; + /** + * Optional. Service message: forum topic edited + * + * @var \TelegramBot\Api\Types\ForumTopicEdited|null + */ + protected $forumTopicEdited; + /** * Optional. Service message: forum topic closed * - * @var ForumTopicReopened|null + * @var \TelegramBot\Api\Types\ForumTopicClosed|null */ - protected $forumTopicReopened; + protected $forumTopicClosed; /** * Optional. Service message: forum topic reopened * - * @var ForumTopicClosed|null + * @var \TelegramBot\Api\Types\ForumTopicReopened|null */ - protected $forumTopicClosed; + protected $forumTopicReopened; /** - * Optional. True, if the message is sent to a forum topic + * Optional. Service message: the 'General' forum topic hidden * - * @var bool|null + * @var \TelegramBot\Api\Types\GeneralForumTopicHidden|null */ - protected $isTopicMessage; + protected $generalForumTopicHidden; /** - * Optional. Unique identifier of a message thread to which the message belongs; for supergroups only + * Optional. Service message: the 'General' forum topic unhidden * - * @var int|null + * @var \TelegramBot\Api\Types\GeneralForumTopicUnhidden|null */ - protected $messageThreadId; + protected $generalForumTopicUnhidden; + + /** + * Optional. Service message: a scheduled giveaway was created + * + * @var \TelegramBot\Api\Types\GiveawayCreated|null + */ + protected $giveawayCreated; + + /** + * Optional. The message is a scheduled giveaway message + * + * @var \TelegramBot\Api\Types\Giveaway|null + */ + protected $giveaway; + + /** + * Optional. A giveaway with public winners was completed + * + * @var \TelegramBot\Api\Types\GiveawayWinners|null + */ + protected $giveawayWinners; + + /** + * Optional. Service message: a giveaway without public winners was completed + * + * @var \TelegramBot\Api\Types\GiveawayCompleted|null + */ + protected $giveawayCompleted; + + /** + * Optional. Service message: video chat scheduled + * + * @var \TelegramBot\Api\Types\VideoChatScheduled|null + */ + protected $videoChatScheduled; + + /** + * Optional. Service message: video chat started + * + * @var \TelegramBot\Api\Types\VideoChatStarted|null + */ + protected $videoChatStarted; + + /** + * Optional. Service message: video chat ended + * + * @var \TelegramBot\Api\Types\VideoChatEnded|null + */ + protected $videoChatEnded; + + /** + * Optional. Service message: new participants invited to a video chat + * + * @var \TelegramBot\Api\Types\VideoChatParticipantsInvited|null + */ + protected $videoChatParticipantsInvited; + + /** + * Optional. Service message: data sent by a Web App + * + * @var \TelegramBot\Api\Types\WebAppData|null + */ + protected $webAppData; + + /** + * Optional. Inline keyboard attached to the message. login_url buttons are represented as ordinary url buttons + * + * @var \TelegramBot\Api\Types\Inline\InlineKeyboardMarkup|null + */ + protected $replyMarkup; /** - * @return int|float + * @return int */ public function getMessageId() { @@ -485,6 +740,23 @@ public function setMessageId($messageId) } } + /** + * @return int|null + */ + public function getMessageThreadId() + { + return $this->messageThreadId; + } + + /** + * @param int|null $messageThreadId + * @return void + */ + public function setMessageThreadId($messageThreadId) + { + $this->messageThreadId = $messageThreadId; + } + /** * @return User|null */ @@ -503,20 +775,52 @@ public function setFrom(User $from) } /** - * @return Chat + * @return Chat|null */ - public function getChat() + public function getSenderChat() { - return $this->chat; + return $this->senderChat; } /** - * @param Chat $chat + * @param Chat $senderChat * @return void */ - public function setChat(Chat $chat) + public function setSenderChat(Chat $senderChat) { - $this->chat = $chat; + $this->senderChat = $senderChat; + } + + /** + * @return int|null + */ + public function getSenderBoostCount() + { + return $this->senderBoostCount; + } + + /** + * @param int|null $senderBoostCount + */ + public function setSenderBoostCount($senderBoostCount) + { + $this->senderBoostCount = $senderBoostCount; + } + + /** + * @return User|null + */ + public function getSenderBusinessBot() + { + return $this->senderBusinessBot; + } + + /** + * @param User|null $senderBusinessBot + */ + public function setSenderBusinessBot($senderBusinessBot) + { + $this->senderBusinessBot = $senderBusinessBot; } /** @@ -530,139 +834,160 @@ public function getDate() /** * @param mixed $date * @return void - * @throws InvalidArgumentException + * @throws InvalidArgumentException + */ + public function setDate($date) + { + if (is_int($date)) { + $this->date = $date; + } else { + throw new InvalidArgumentException(); + } + } + + /** + * @return string|null + */ + public function getBusinessConnectionId() + { + return $this->businessConnectionId; + } + + /** + * @param string|null $businessConnectionId + */ + public function setBusinessConnectionId($businessConnectionId) + { + $this->businessConnectionId = $businessConnectionId; + } + + /** + * @return Chat + */ + public function getChat() + { + return $this->chat; + } + + /** + * @param Chat $chat + * @return void */ - public function setDate($date) + public function setChat(Chat $chat) { - if (is_int($date)) { - $this->date = $date; - } else { - throw new InvalidArgumentException(); - } + $this->chat = $chat; } /** - * @return User|null + * @return MessageOrigin|null */ - public function getForwardFrom() + public function getForwardOrigin() { - return $this->forwardFrom; + return $this->forwardOrigin; } /** - * @param User $forwardFrom - * @return void + * @param MessageOrigin|null $forwardOrigin */ - public function setForwardFrom(User $forwardFrom) + public function setForwardOrigin($forwardOrigin) { - $this->forwardFrom = $forwardFrom; + $this->forwardOrigin = $forwardOrigin; } /** - * @return Chat|null + * @return bool|null */ - public function getForwardFromChat() + public function getIsTopicMessage() { - return $this->forwardFromChat; + return $this->isTopicMessage; } /** - * @param Chat $forwardFromChat - * @return void + * @param bool|null $isTopicMessage */ - public function setForwardFromChat(Chat $forwardFromChat) + public function setIsTopicMessage($isTopicMessage) { - $this->forwardFromChat = $forwardFromChat; + $this->isTopicMessage = $isTopicMessage; } /** - * @return int|null + * @return bool|null */ - public function getForwardFromMessageId() + public function getIsAutomaticForward() { - return $this->forwardFromMessageId; + return $this->isAutomaticForward; } /** - * @param int $forwardFromMessageId - * @return void + * @param bool|null $isAutomaticForward */ - public function setForwardFromMessageId($forwardFromMessageId) + public function setIsAutomaticForward($isAutomaticForward) { - $this->forwardFromMessageId = $forwardFromMessageId; + $this->isAutomaticForward = $isAutomaticForward; } /** - * @return null|string + * @return Message|null */ - public function getForwardSignature() + public function getReplyToMessage() { - return $this->forwardSignature; + return $this->replyToMessage; } /** - * @param string $forwardSignature - * @return void + * @param Message|null $replyToMessage */ - public function setForwardSignature($forwardSignature) + public function setReplyToMessage($replyToMessage) { - $this->forwardSignature = $forwardSignature; + $this->replyToMessage = $replyToMessage; } /** - * @return null|string + * @return ExternalReplyInfo|null */ - public function getForwardSenderName() + public function getExternalReply() { - return $this->forwardSenderName; + return $this->externalReply; } /** - * @param string $forwardSenderName - * @return void + * @param ExternalReplyInfo|null $externalReply */ - public function setForwardSenderName($forwardSenderName) + public function setExternalReply($externalReply) { - $this->forwardSenderName = $forwardSenderName; + $this->externalReply = $externalReply; } /** - * @return int|null + * @return TextQuote|null */ - public function getForwardDate() + public function getQuote() { - return $this->forwardDate; + return $this->quote; } /** - * @param mixed $forwardDate - * @return void - * @throws InvalidArgumentException + * @param TextQuote|null $quote */ - public function setForwardDate($forwardDate) + public function setQuote($quote) { - if (is_int($forwardDate)) { - $this->forwardDate = $forwardDate; - } else { - throw new InvalidArgumentException(); - } + $this->quote = $quote; } /** - * @return null|self + * @return Story|null */ - public function getReplyToMessage() + public function getReplyToStory() { - return $this->replyToMessage; + return $this->replyToStory; } /** - * @param Message $replyToMessage - * @return void + * @param Story|null $replyToStory */ - public function setReplyToMessage(Message $replyToMessage) + public function setReplyToStory($replyToStory) { - $this->replyToMessage = $replyToMessage; + $this->replyToStory = $replyToStory; } /** @@ -674,10 +999,9 @@ public function getViaBot() } /** - * @param User $viaBot - * @return void + * @param User|null $viaBot */ - public function setViaBot(User $viaBot) + public function setViaBot($viaBot) { $this->viaBot = $viaBot; } @@ -705,7 +1029,39 @@ public function setEditDate($editDate) } /** - * @return int|null + * @return bool|null + */ + public function getHasProtectedContent() + { + return $this->hasProtectedContent; + } + + /** + * @param bool|null $hasProtectedContent + */ + public function setHasProtectedContent($hasProtectedContent) + { + $this->hasProtectedContent = $hasProtectedContent; + } + + /** + * @return bool|null + */ + public function getIsFromOffline() + { + return $this->isFromOffline; + } + + /** + * @param bool|null $isFromOffline + */ + public function setIsFromOffline($isFromOffline) + { + $this->isFromOffline = $isFromOffline; + } + + /** + * @return string|null */ public function getMediaGroupId() { @@ -713,8 +1069,7 @@ public function getMediaGroupId() } /** - * @param int $mediaGroupId - * @return void + * @param string|null $mediaGroupId */ public function setMediaGroupId($mediaGroupId) { @@ -722,7 +1077,7 @@ public function setMediaGroupId($mediaGroupId) } /** - * @return null|string + * @return string|null */ public function getAuthorSignature() { @@ -730,8 +1085,7 @@ public function getAuthorSignature() } /** - * @param string $authorSignature - * @return void + * @param string|null $authorSignature */ public function setAuthorSignature($authorSignature) { @@ -739,7 +1093,7 @@ public function setAuthorSignature($authorSignature) } /** - * @return null|string + * @return string|null */ public function getText() { @@ -747,25 +1101,20 @@ public function getText() } /** - * @param string $text - * @return void + * @param string|null $text */ public function setText($text) { $this->text = $text; } - /** - * @return array|null - */ public function getEntities() { return $this->entities; } /** - * @param array $entities - * @return void + * @param array|null $entities */ public function setEntities($entities) { @@ -773,86 +1122,94 @@ public function setEntities($entities) } /** - * @return ArrayOfMessageEntity|null + * @return LinkPreviewOptions|null */ - public function getCaptionEntities() + public function getLinkPreviewOptions() { - return $this->captionEntities; + return $this->linkPreviewOptions; } /** - * @param ArrayOfMessageEntity $captionEntities - * @return void + * @param LinkPreviewOptions|null $linkPreviewOptions */ - public function setCaptionEntities($captionEntities) + public function setLinkPreviewOptions($linkPreviewOptions) { - $this->captionEntities = $captionEntities; + $this->linkPreviewOptions = $linkPreviewOptions; } /** - * @return Audio|null + * @return string|null */ - public function getAudio() + public function getEffectId() { - return $this->audio; + return $this->effectId; } /** - * @param Audio $audio - * @return void + * @param string|null $effectId */ - public function setAudio(Audio $audio) + public function setEffectId($effectId) { - $this->audio = $audio; + $this->effectId = $effectId; } /** - * @return Document|null + * @return Animation|null */ - public function getDocument() + public function getAnimation() { - return $this->document; + return $this->animation; } /** - * @param Document $document - * @return void + * @param Animation|null $animation */ - public function setDocument($document) + public function setAnimation($animation) { - $this->document = $document; + $this->animation = $animation; } /** - * @return Animation|null + * @return Audio|null */ - public function getAnimation() + public function getAudio() { - return $this->animation; + return $this->audio; } /** - * @param Animation $animation - * @return void + * @param Audio|null $audio */ - public function setAnimation(Animation $animation) + public function setAudio($audio) { - $this->animation = $animation; + $this->audio = $audio; + } + + /** + * @return Document|null + */ + public function getDocument() + { + return $this->document; } /** - * @return array|null + * @param Document|null $document */ + public function setDocument($document) + { + $this->document = $document; + } + public function getPhoto() { return $this->photo; } /** - * @param array $photo - * @return void + * @param array|null $photo */ - public function setPhoto(array $photo) + public function setPhoto($photo) { $this->photo = $photo; } @@ -866,14 +1223,29 @@ public function getSticker() } /** - * @param Sticker $sticker - * @return void + * @param Sticker|null $sticker */ - public function setSticker(Sticker $sticker) + public function setSticker($sticker) { $this->sticker = $sticker; } + /** + * @return Story|null + */ + public function getStory() + { + return $this->story; + } + + /** + * @param Story|null $story + */ + public function setStory($story) + { + $this->story = $story; + } + /** * @return Video|null */ @@ -882,6 +1254,14 @@ public function getVideo() return $this->video; } + /** + * @param Video|null $video + */ + public function setVideo($video) + { + $this->video = $video; + } + /** * @return VideoNote|null */ @@ -892,22 +1272,12 @@ public function getVideoNote() /** * @param VideoNote|null $videoNote - * @return void */ public function setVideoNote($videoNote) { $this->videoNote = $videoNote; } - /** - * @param Video $video - * @return void - */ - public function setVideo(Video $video) - { - $this->video = $video; - } - /** * @return Voice|null */ @@ -917,8 +1287,7 @@ public function getVoice() } /** - * @param Voice $voice - * @return void + * @param Voice|null $voice */ public function setVoice($voice) { @@ -934,14 +1303,61 @@ public function getCaption() } /** - * @param string $caption - * @return void + * @param string|null $caption */ public function setCaption($caption) { $this->caption = $caption; } + /** + * @return ArrayOfMessageEntity|null + */ + public function getCaptionEntities() + { + return $this->captionEntities; + } + + /** + * @param ArrayOfMessageEntity|null $captionEntities + */ + public function setCaptionEntities($captionEntities) + { + $this->captionEntities = $captionEntities; + } + + /** + * @return bool|null + */ + public function getShowCaptionAboveMedia() + { + return $this->showCaptionAboveMedia; + } + + /** + * @param bool|null $showCaptionAboveMedia + */ + public function setShowCaptionAboveMedia($showCaptionAboveMedia) + { + $this->showCaptionAboveMedia = $showCaptionAboveMedia; + } + + /** + * @return bool|null + */ + public function getHasMediaSpoiler() + { + return $this->hasMediaSpoiler; + } + + /** + * @param bool|null $hasMediaSpoiler + */ + public function setHasMediaSpoiler($hasMediaSpoiler) + { + $this->hasMediaSpoiler = $hasMediaSpoiler; + } + /** * @return Contact|null */ @@ -951,46 +1367,43 @@ public function getContact() } /** - * @param Contact $contact - * @return void + * @param Contact|null $contact */ - public function setContact(Contact $contact) + public function setContact($contact) { $this->contact = $contact; } /** - * @return Location|null + * @return Dice|null */ - public function getLocation() + public function getDice() { - return $this->location; + return $this->dice; } /** - * @param Location $location - * @return void + * @param Dice|null $dice */ - public function setLocation(Location $location) + public function setDice($dice) { - $this->location = $location; + $this->dice = $dice; } /** - * @return Venue|null + * @return Game|null */ - public function getVenue() + public function getGame() { - return $this->venue; + return $this->game; } /** - * @param Venue $venue - * @return void + * @param Game|null $game */ - public function setVenue($venue) + public function setGame($game) { - $this->venue = $venue; + $this->game = $game; } /** @@ -1002,8 +1415,7 @@ public function getPoll() } /** - * @param Poll $poll - * @return void + * @param Poll|null $poll */ public function setPoll($poll) { @@ -1011,25 +1423,37 @@ public function setPoll($poll) } /** - * @return Dice|null + * @return Venue|null */ - public function getDice() + public function getVenue() { - return $this->dice; + return $this->venue; } /** - * @param Dice $dice - * @return void + * @param Venue|null $venue */ - public function setDice(Dice $dice) + public function setVenue($venue) { - $this->dice = $dice; + $this->venue = $venue; + } + + /** + * @return Location|null + */ + public function getLocation() + { + return $this->location; } /** - * @return \TelegramBot\Api\Types\User[]|null + * @param Location|null $location */ + public function setLocation($location) + { + $this->location = $location; + } + public function getNewChatMembers() { return $this->newChatMembers; @@ -1078,9 +1502,6 @@ public function setNewChatTitle($newChatTitle) $this->newChatTitle = $newChatTitle; } - /** - * @return PhotoSize[]|null - */ public function getNewChatPhoto() { return $this->newChatPhoto; @@ -1197,9 +1618,6 @@ public function setMigrateFromChatId($migrateFromChatId) $this->migrateFromChatId = $migrateFromChatId; } - /** - * @return null|self - */ public function getPinnedMessage() { return $this->pinnedMessage; @@ -1215,8 +1633,6 @@ public function setPinnedMessage($pinnedMessage) } /** - * @author MY - * * @return Invoice|null */ public function getInvoice() @@ -1225,7 +1641,6 @@ public function getInvoice() } /** - * @author MY * @param Invoice $invoice * @return void */ @@ -1235,8 +1650,6 @@ public function setInvoice($invoice) } /** - * @author MY - * * @return SuccessfulPayment|null */ public function getSuccessfulPayment() @@ -1245,7 +1658,6 @@ public function getSuccessfulPayment() } /** - * @author MY * @param SuccessfulPayment $successfulPayment * @return void */ @@ -1355,38 +1767,4 @@ public function setForumTopicReopened($forumTopicReopened) { $this->forumTopicReopened = $forumTopicReopened; } - - /** - * @return bool|null - */ - public function getIsTopicMessage() - { - return $this->isTopicMessage; - } - - /** - * @param bool $isTopicMessage - * @return void - */ - public function setIsTopicMessage($isTopicMessage) - { - $this->isTopicMessage = $isTopicMessage; - } - - /** - * @return int|null - */ - public function getMessageThreadId() - { - return $this->messageThreadId; - } - - /** - * @param int|null $messageThreadId - * @return void - */ - public function setMessageThreadId($messageThreadId) - { - $this->messageThreadId = $messageThreadId; - } } diff --git a/src/Types/MessageAutoDeleteTimerChanged.php b/src/Types/MessageAutoDeleteTimerChanged.php new file mode 100644 index 00000000..9e662d94 --- /dev/null +++ b/src/Types/MessageAutoDeleteTimerChanged.php @@ -0,0 +1,55 @@ + true, + ]; + + /** + * New auto-delete time for messages in the chat; in seconds + * + * @var int + */ + protected $messageAutoDeleteTime; + + /** + * @return int + */ + public function getMessageAutoDeleteTime() + { + return $this->messageAutoDeleteTime; + } + + /** + * @param int $messageAutoDeleteTime + * @return void + */ + public function setMessageAutoDeleteTime($messageAutoDeleteTime) + { + $this->messageAutoDeleteTime = $messageAutoDeleteTime; + } +} diff --git a/src/Types/MessageEntity.php b/src/Types/MessageEntity.php index 54eb90db..a1499da1 100644 --- a/src/Types/MessageEntity.php +++ b/src/Types/MessageEntity.php @@ -1,10 +1,4 @@ messageId = $messageId; } } diff --git a/src/Types/MessageOrigin.php b/src/Types/MessageOrigin.php new file mode 100644 index 00000000..394bfce3 --- /dev/null +++ b/src/Types/MessageOrigin.php @@ -0,0 +1,45 @@ + true, + 'date' => true, + ]; + + protected $type; + protected $date; + + public function getType() + { + return $this->type; + } + + public function setType($type) + { + $this->type = $type; + } + + public function getDate() + { + return $this->date; + } + + public function setDate($date) + { + $this->date = $date; + } +} diff --git a/src/Types/MessageOriginChannel.php b/src/Types/MessageOriginChannel.php new file mode 100644 index 00000000..2e78834f --- /dev/null +++ b/src/Types/MessageOriginChannel.php @@ -0,0 +1,56 @@ + true, + 'date' => true, + 'chat' => Chat::class, + 'message_id' => true, + 'author_signature' => true, + ]; + + protected $chat; + protected $messageId; + protected $authorSignature; + + public function getChat(): ?Chat + { + return $this->chat; + } + + public function setChat($chat): void + { + $this->chat = $chat; + } + + public function getMessageId(): ?int + { + return $this->messageId; + } + + public function setMessageId($messageId): void + { + $this->messageId = $messageId; + } + + public function getAuthorSignature(): ?string + { + return $this->authorSignature; + } + + public function setAuthorSignature($authorSignature): void + { + $this->authorSignature = $authorSignature; + } +} diff --git a/src/Types/MessageOriginChat.php b/src/Types/MessageOriginChat.php new file mode 100644 index 00000000..3027b6f6 --- /dev/null +++ b/src/Types/MessageOriginChat.php @@ -0,0 +1,44 @@ + true, + 'date' => true, + 'sender_chat' => Chat::class, + 'author_signature' => true, + ]; + + protected $senderChat; + protected $authorSignature; + + public function getSenderChat() + { + return $this->senderChat; + } + + public function setSenderChat(Chat $senderChat) + { + $this->senderChat = $senderChat; + } + + public function getAuthorSignature() + { + return $this->authorSignature; + } + + public function setAuthorSignature($authorSignature) + { + $this->authorSignature = $authorSignature; + } +} diff --git a/src/Types/MessageOriginHiddenUser.php b/src/Types/MessageOriginHiddenUser.php new file mode 100644 index 00000000..3e37b750 --- /dev/null +++ b/src/Types/MessageOriginHiddenUser.php @@ -0,0 +1,32 @@ + true, + 'date' => true, + 'sender_user_name' => true, + ]; + + protected $senderUserName; + + public function getSenderUserName() + { + return $this->senderUserName; + } + + public function setSenderUserName(User $senderUserName) + { + $this->senderUserName = $senderUserName; + } +} diff --git a/src/Types/MessageOriginUser.php b/src/Types/MessageOriginUser.php new file mode 100644 index 00000000..d68aaa7d --- /dev/null +++ b/src/Types/MessageOriginUser.php @@ -0,0 +1,32 @@ + true, + 'date' => true, + 'sender_user' => User::class, + ]; + + protected $senderUser; + + public function getSenderUser() + { + return $this->senderUser; + } + + public function setSenderUser(User $senderUser) + { + $this->senderUser = $senderUser; + } +} diff --git a/src/Types/MessageReactionCountUpdated.php b/src/Types/MessageReactionCountUpdated.php new file mode 100644 index 00000000..b768a919 --- /dev/null +++ b/src/Types/MessageReactionCountUpdated.php @@ -0,0 +1,124 @@ + Chat::class, + 'message_id' => true, + 'date' => true, + 'reactions' => ArrayOfReactionType::class, + ]; + + /** + * The chat containing the message + * + * @var Chat + */ + protected $chat; + + /** + * Unique message identifier inside the chat + * + * @var int + */ + protected $messageId; + + /** + * Date of the change in Unix time + * + * @var int + */ + protected $date; + + /** + * List of reactions that are present on the message + * + * @var array + */ + protected $reactions; + + /** + * @return Chat + */ + public function getChat() + { + return $this->chat; + } + + /** + * @param Chat $chat + * @return void + */ + public function setChat($chat) + { + $this->chat = $chat; + } + + /** + * @return int + */ + public function getMessageId() + { + return $this->messageId; + } + + /** + * @param int $messageId + * @return void + */ + public function setMessageId($messageId) + { + $this->messageId = $messageId; + } + + /** + * @return int + */ + public function getDate() + { + return $this->date; + } + + /** + * @param int $date + * @return void + */ + public function setDate($date) + { + $this->date = $date; + } + + /** + * @return array + */ + public function getReactions() + { + return $this->reactions; + } + + /** + * @param array $reactions + * @return void + */ + public function setReactions($reactions) + { + $this->reactions = $reactions; + } +} diff --git a/src/Types/MessageReactionUpdated.php b/src/Types/MessageReactionUpdated.php new file mode 100644 index 00000000..350ae560 --- /dev/null +++ b/src/Types/MessageReactionUpdated.php @@ -0,0 +1,199 @@ + Chat::class, + 'message_id' => true, + 'user' => User::class, + 'actor_chat' => Chat::class, + 'date' => true, + 'old_reaction' => ArrayOfReactionType::class, + 'new_reaction' => ArrayOfReactionType::class, + ]; + + /** + * The chat containing the message the user reacted to + * + * @var Chat + */ + protected $chat; + + /** + * Unique identifier of the message inside the chat + * + * @var int + */ + protected $messageId; + + /** + * Optional. The user that changed the reaction, if the user isn't anonymous + * + * @var User|null + */ + protected $user; + + /** + * Optional. The chat on behalf of which the reaction was changed, if the user is anonymous + * + * @var Chat|null + */ + protected $actorChat; + + /** + * Date of the change in Unix time + * + * @var int + */ + protected $date; + + /** + * Previous list of reaction types that were set by the user + * + * @var array + */ + protected $oldReaction; + + /** + * New list of reaction types that have been set by the user + * + * @var array + */ + protected $newReaction; + + /** + * @return Chat + */ + public function getChat() + { + return $this->chat; + } + + /** + * @param Chat $chat + * @return void + */ + public function setChat($chat) + { + $this->chat = $chat; + } + + /** + * @return int + */ + public function getMessageId() + { + return $this->messageId; + } + + /** + * @param int $messageId + * @return void + */ + public function setMessageId($messageId) + { + $this->messageId = $messageId; + } + + /** + * @return User|null + */ + public function getUser() + { + return $this->user; + } + + /** + * @param User|null $user + * @return void + */ + public function setUser($user) + { + $this->user = $user; + } + + /** + * @return Chat|null + */ + public function getActorChat() + { + return $this->actorChat; + } + + /** + * @param Chat|null $actorChat + * @return void + */ + public function setActorChat($actorChat) + { + $this->actorChat = $actorChat; + } + + /** + * @return int + */ + public function getDate() + { + return $this->date; + } + + /** + * @param int $date + * @return void + */ + public function setDate($date) + { + $this->date = $date; + } + + /** + * @return array + */ + public function getOldReaction() + { + return $this->oldReaction; + } + + /** + * @param array $oldReaction + * @return void + */ + public function setOldReaction($oldReaction) + { + $this->oldReaction = $oldReaction; + } + + /** + * @return array + */ + public function getNewReaction() + { + return $this->newReaction; + } + + /** + * @param array $newReaction + * @return void + */ + public function setNewReaction($newReaction) + { + $this->newReaction = $newReaction; + } +} diff --git a/src/Types/PhotoSize.php b/src/Types/PhotoSize.php index 50c69063..07144621 100644 --- a/src/Types/PhotoSize.php +++ b/src/Types/PhotoSize.php @@ -35,12 +35,19 @@ class PhotoSize extends BaseType implements TypeInterface ]; /** - * Unique identifier for this file + * Identifier for this file, which can be used to download or reuse the file * * @var string */ protected $fileId; + /** + * Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. + * + * @var string + */ + protected $fileUniqueId; + /** * Photo width * @@ -56,19 +63,12 @@ class PhotoSize extends BaseType implements TypeInterface protected $height; /** - * Optional. File size + * Optional. File size in bytes * * @var int|null */ protected $fileSize; - /** - * Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. - * - * @var string - */ - protected $fileUniqueId; - /** * @return string */ @@ -87,44 +87,39 @@ public function setFileId($fileId) } /** - * @return int|null + * @return string */ - public function getFileSize() + public function getFileUniqueId() { - return $this->fileSize; + return $this->fileUniqueId; } /** - * @param mixed $fileSize + * @param string $fileUniqueId * @return void - * @throws InvalidArgumentException */ - public function setFileSize($fileSize) + public function setFileUniqueId($fileUniqueId) { - if (is_integer($fileSize)) { - $this->fileSize = $fileSize; - } else { - throw new InvalidArgumentException(); - } + $this->fileUniqueId = $fileUniqueId; } /** * @return int */ - public function getHeight() + public function getWidth() { - return $this->height; + return $this->width; } /** - * @param mixed $height + * @param int $width * @return void * @throws InvalidArgumentException */ - public function setHeight($height) + public function setWidth($width) { - if (is_integer($height)) { - $this->height = $height; + if (is_integer($width)) { + $this->width = $width; } else { throw new InvalidArgumentException(); } @@ -133,39 +128,44 @@ public function setHeight($height) /** * @return int */ - public function getWidth() + public function getHeight() { - return $this->width; + return $this->height; } /** - * @param mixed $width + * @param int $height * @return void * @throws InvalidArgumentException */ - public function setWidth($width) + public function setHeight($height) { - if (is_integer($width)) { - $this->width = $width; + if (is_integer($height)) { + $this->height = $height; } else { throw new InvalidArgumentException(); } } /** - * @return string + * @return int|null */ - public function getFileUniqueId() + public function getFileSize() { - return $this->fileUniqueId; + return $this->fileSize; } /** - * @param string $fileUniqueId + * @param int|null $fileSize * @return void + * @throws InvalidArgumentException */ - public function setFileUniqueId($fileUniqueId) + public function setFileSize($fileSize) { - $this->fileUniqueId = $fileUniqueId; + if (is_integer($fileSize) || is_null($fileSize)) { + $this->fileSize = $fileSize; + } else { + throw new InvalidArgumentException(); + } } } diff --git a/src/Types/Poll.php b/src/Types/Poll.php index 2f59f611..b8bbb90b 100644 --- a/src/Types/Poll.php +++ b/src/Types/Poll.php @@ -37,6 +37,7 @@ class Poll extends BaseType implements TypeInterface protected static $map = [ 'id' => true, 'question' => true, + 'question_entities' => ArrayOfMessageEntity::class, 'options' => ArrayOfPollOption::class, 'total_voter_count' => true, 'is_closed' => true, @@ -44,6 +45,10 @@ class Poll extends BaseType implements TypeInterface 'type' => true, 'allows_multiple_answers' => true, 'correct_option_id' => true, + 'explanation' => true, + 'explanation_entities' => ArrayOfMessageEntity::class, + 'open_period' => true, + 'close_date' => true, ]; /** @@ -54,12 +59,19 @@ class Poll extends BaseType implements TypeInterface protected $id; /** - * Poll question, 1-255 characters + * Poll question, 1-300 characters * * @var string */ protected $question; + /** + * Optional. Special entities that appear in the question. Currently, only custom emoji entities are allowed in poll questions. + * + * @var array|null + */ + protected $questionEntities; + /** * List of poll options * Array of \TelegramBot\Api\Types\PollOption @@ -112,6 +124,34 @@ class Poll extends BaseType implements TypeInterface */ protected $correctOptionId; + /** + * Optional. Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters + * + * @var string|null + */ + protected $explanation; + + /** + * Optional. Special entities like usernames, URLs, bot commands, etc. that appear in the explanation + * + * @var array|null + */ + protected $explanationEntities; + + /** + * Optional. Amount of time in seconds the poll will be active after creation + * + * @var int|null + */ + protected $openPeriod; + + /** + * Optional. Point in time (Unix timestamp) when the poll will be automatically closed + * + * @var int|null + */ + protected $closeDate; + /** * @return string */ @@ -146,6 +186,23 @@ public function setQuestion($question) $this->question = $question; } + /** + * @return array|null + */ + public function getQuestionEntities() + { + return $this->questionEntities; + } + + /** + * @param array|null $questionEntities + * @return void + */ + public function setQuestionEntities($questionEntities) + { + $this->questionEntities = $questionEntities; + } + /** * @return array */ @@ -264,4 +321,72 @@ public function setCorrectOptionId($correctOptionId) { $this->correctOptionId = $correctOptionId; } + + /** + * @return string|null + */ + public function getExplanation() + { + return $this->explanation; + } + + /** + * @param string|null $explanation + * @return void + */ + public function setExplanation($explanation) + { + $this->explanation = $explanation; + } + + /** + * @return array|null + */ + public function getExplanationEntities() + { + return $this->explanationEntities; + } + + /** + * @param array|null $explanationEntities + * @return void + */ + public function setExplanationEntities($explanationEntities) + { + $this->explanationEntities = $explanationEntities; + } + + /** + * @return int|null + */ + public function getOpenPeriod() + { + return $this->openPeriod; + } + + /** + * @param int|null $openPeriod + * @return void + */ + public function setOpenPeriod($openPeriod) + { + $this->openPeriod = $openPeriod; + } + + /** + * @return int|null + */ + public function getCloseDate() + { + return $this->closeDate; + } + + /** + * @param int|null $closeDate + * @return void + */ + public function setCloseDate($closeDate) + { + $this->closeDate = $closeDate; + } } diff --git a/src/Types/PollAnswer.php b/src/Types/PollAnswer.php index 5ae68123..69f19c52 100644 --- a/src/Types/PollAnswer.php +++ b/src/Types/PollAnswer.php @@ -11,7 +11,6 @@ * * This object represents an answer of a user in a non-anonymous poll. * - * * @package TelegramBot\Api\Types */ class PollAnswer extends BaseType @@ -21,7 +20,7 @@ class PollAnswer extends BaseType * * @var array */ - protected static $requiredParams = ['poll_id', 'option_ids', 'user']; + protected static $requiredParams = ['poll_id', 'option_ids']; /** * {@inheritdoc} @@ -29,22 +28,36 @@ class PollAnswer extends BaseType * @var array */ protected static $map = [ - 'option_ids' => true, - 'user' => User::class, 'poll_id' => true, + 'voter_chat' => Chat::class, + 'user' => User::class, + 'option_ids' => true, ]; /** - * @var \TelegramBot\Api\Types\User + * Unique poll identifier + * + * @var string */ - protected $user; + protected $pollId; /** - * @var string + * Optional. The chat that changed the answer to the poll, if the voter is anonymous + * + * @var Chat|null */ - protected $pollId; + protected $voterChat; + + /** + * Optional. The user that changed the answer to the poll, if the voter isn't anonymous + * + * @var User|null + */ + protected $user; /** + * 0-based identifiers of chosen answer options. May be empty if the vote was retracted + * * @var int[] */ protected $optionIds; @@ -58,41 +71,46 @@ public function getPollId() } /** - * @param string $id + * @param string $pollId * @return void */ - public function setPollId($id) + public function setPollId($pollId) { - $this->pollId = $id; + $this->pollId = $pollId; } /** - * @return User + * @return Chat|null */ - public function getUser() + public function getVoterChat() { - return $this->user; + return $this->voterChat; } /** - * @param User $from + * @param Chat|null $voterChat * @return void */ - public function setUser(User $from) + public function setVoterChat($voterChat) { - $this->user = $from; + $this->voterChat = $voterChat; } /** - * @deprecated - * - * @return User + * @return User|null */ - public function getFrom() + public function getUser() { - @trigger_error(sprintf('Access user with %s is deprecated, use "%s::getUser" method', __METHOD__, __CLASS__), \E_USER_DEPRECATED); + return $this->user; + } - return $this->getUser(); + /** + * @param User|null $user + * @return void + */ + public function setUser($user) + { + $this->user = $user; } /** @@ -107,7 +125,7 @@ public function getOptionIds() * @param int[] $optionIds * @return void */ - public function setOptionIds($optionIds) + public function setOptionIds(array $optionIds) { $this->optionIds = $optionIds; } diff --git a/src/Types/PollOption.php b/src/Types/PollOption.php index 45beabb6..f9b70304 100644 --- a/src/Types/PollOption.php +++ b/src/Types/PollOption.php @@ -27,7 +27,8 @@ class PollOption extends BaseType implements TypeInterface */ protected static $map = [ 'text' => true, - 'voter_count' => true + 'voter_count' => true, + 'text_entities' => ArrayOfMessageEntity::class ]; /** @@ -44,6 +45,13 @@ class PollOption extends BaseType implements TypeInterface */ protected $voterCount; + /** + * Optional. Special entities that appear in the option text. Currently, only custom emoji entities are allowed in poll option texts + * + * @var array|null + */ + protected $textEntities; + /** * @return string */ @@ -77,4 +85,21 @@ public function setVoterCount($voterCount) { $this->voterCount = $voterCount; } + + /** + * @return array|null + */ + public function getTextEntities() + { + return $this->textEntities; + } + + /** + * @param array|null $textEntities + * @return void + */ + public function setTextEntities($textEntities) + { + $this->textEntities = $textEntities; + } } diff --git a/src/Types/ProximityAlertTriggered.php b/src/Types/ProximityAlertTriggered.php new file mode 100644 index 00000000..837c4d50 --- /dev/null +++ b/src/Types/ProximityAlertTriggered.php @@ -0,0 +1,105 @@ + User::class, + 'watcher' => User::class, + 'distance' => true, + ]; + + /** + * User that triggered the alert + * + * @var User + */ + protected $traveler; + + /** + * User that set the alert + * + * @var User + */ + protected $watcher; + + /** + * The distance between the users + * + * @var int + */ + protected $distance; + + /** + * @return User + */ + public function getTraveler() + { + return $this->traveler; + } + + /** + * @param User $traveler + * @return void + */ + public function setTraveler(User $traveler) + { + $this->traveler = $traveler; + } + + /** + * @return User + */ + public function getWatcher() + { + return $this->watcher; + } + + /** + * @param User $watcher + * @return void + */ + public function setWatcher(User $watcher) + { + $this->watcher = $watcher; + } + + /** + * @return int + */ + public function getDistance() + { + return $this->distance; + } + + /** + * @param int $distance + * @return void + */ + public function setDistance($distance) + { + $this->distance = $distance; + } +} diff --git a/src/Types/ReactionCount.php b/src/Types/ReactionCount.php new file mode 100644 index 00000000..be6f62b9 --- /dev/null +++ b/src/Types/ReactionCount.php @@ -0,0 +1,74 @@ + ReactionType::class, + 'total_count' => true, + ]; + + /** + * Type of the reaction + * + * @var ReactionType + */ + protected $type; + + /** + * Number of times the reaction was added + * + * @var int + */ + protected $totalCount; + + /** + * @return ReactionType + */ + public function getType() + { + return $this->type; + } + + /** + * @param ReactionType $type + * @return void + */ + public function setType($type) + { + $this->type = $type; + } + + /** + * @return int + */ + public function getTotalCount() + { + return $this->totalCount; + } + + /** + * @param int $totalCount + * @return void + */ + public function setTotalCount($totalCount) + { + $this->totalCount = $totalCount; + } +} diff --git a/src/Types/ReactionType.php b/src/Types/ReactionType.php new file mode 100644 index 00000000..983473e7 --- /dev/null +++ b/src/Types/ReactionType.php @@ -0,0 +1,36 @@ +type; + } + + /** + * Set the type of the reaction. + * + * @param string $type + */ + protected function setType($type) + { + $this->type = $type; + } +} diff --git a/src/Types/ReactionTypeCustomEmoji.php b/src/Types/ReactionTypeCustomEmoji.php new file mode 100644 index 00000000..6e7c7b74 --- /dev/null +++ b/src/Types/ReactionTypeCustomEmoji.php @@ -0,0 +1,56 @@ + true, + 'custom_emoji_id' => true, + ]; + + /** + * {@inheritdoc} + * + * @var array + */ + protected static $requiredParams = ['type', 'custom_emoji_id']; + + /** + * Custom emoji identifier + * + * @var string + */ + protected $customEmojiId; + + /** + * Get the custom emoji identifier. + * + * @return string + */ + public function getCustomEmojiId() + { + return $this->customEmojiId; + } + + /** + * Set the custom emoji identifier. + * + * @param string $customEmojiId + */ + protected function setCustomEmojiId($customEmojiId) + { + $this->customEmojiId = $customEmojiId; + } +} diff --git a/src/Types/ReactionTypeEmoji.php b/src/Types/ReactionTypeEmoji.php new file mode 100644 index 00000000..9fec8892 --- /dev/null +++ b/src/Types/ReactionTypeEmoji.php @@ -0,0 +1,55 @@ + true, + 'emoji' => true, + ]; + + /** + * {@inheritdoc} + * + * @var array + */ + protected static $requiredParams = ['type', 'emoji']; + /** + * Reaction emoji + * + * @var string + */ + protected $emoji; + + /** + * Get the reaction emoji. + * + * @return string + */ + public function getEmoji() + { + return $this->emoji; + } + + /** + * Set the reaction emoji. + * + * @param string $emoji + */ + protected function setEmoji($emoji) + { + $this->emoji = $emoji; + } +} diff --git a/src/Types/ReplyParameters.php b/src/Types/ReplyParameters.php new file mode 100644 index 00000000..5275bb33 --- /dev/null +++ b/src/Types/ReplyParameters.php @@ -0,0 +1,205 @@ + true, + 'chat_id' => true, + 'allow_sending_without_reply' => true, + 'quote' => true, + 'quote_parse_mode' => true, + 'quote_entities' => ArrayOfMessageEntity::class, + 'quote_position' => true, + ]; + + /** + * Identifier of the message that will be replied to in the current chat, or in the chat chat_id if it is specified + * + * @var int + */ + protected $messageId; + + /** + * Optional. If the message to be replied to is from a different chat, unique identifier for the chat or username of the channel (in the format @channelusername). Not supported for messages sent on behalf of a business account. + * + * @var int|string|null + */ + protected $chatId; + + /** + * Optional. Pass True if the message should be sent even if the specified message to be replied to is not found. Always False for replies in another chat or forum topic. Always True for messages sent on behalf of a business account. + * + * @var bool|null + */ + protected $allowSendingWithoutReply; + + /** + * Optional. Quoted part of the message to be replied to; 0-1024 characters after entities parsing. The quote must be an exact substring of the message to be replied to, including bold, italic, underline, strikethrough, spoiler, and custom_emoji entities. The message will fail to send if the quote isn't found in the original message. + * + * @var string|null + */ + protected $quote; + + /** + * Optional. Mode for parsing entities in the quote. See formatting options for more details. + * + * @var string|null + */ + protected $quoteParseMode; + + /** + * Optional. A JSON-serialized list of special entities that appear in the quote. It can be specified instead of quote_parse_mode. + * + * @var ArrayOfMessageEntity|null + */ + protected $quoteEntities; + + /** + * Optional. Position of the quote in the original message in UTF-16 code units + * + * @var int|null + */ + protected $quotePosition; + + /** + * @return int + */ + public function getMessageId() + { + return $this->messageId; + } + + /** + * @param int $messageId + * @return void + */ + public function setMessageId($messageId) + { + $this->messageId = $messageId; + } + + /** + * @return int|string|null + */ + public function getChatId() + { + return $this->chatId; + } + + /** + * @param int|string|null $chatId + * @return void + */ + public function setChatId($chatId) + { + $this->chatId = $chatId; + } + + /** + * @return bool|null + */ + public function getAllowSendingWithoutReply() + { + return $this->allowSendingWithoutReply; + } + + /** + * @param bool|null $allowSendingWithoutReply + * @return void + */ + public function setAllowSendingWithoutReply($allowSendingWithoutReply) + { + $this->allowSendingWithoutReply = $allowSendingWithoutReply; + } + + /** + * @return string|null + */ + public function getQuote() + { + return $this->quote; + } + + /** + * @param string|null $quote + * @return void + */ + public function setQuote($quote) + { + $this->quote = $quote; + } + + /** + * @return string|null + */ + public function getQuoteParseMode() + { + return $this->quoteParseMode; + } + + /** + * @param string|null $quoteParseMode + * @return void + */ + public function setQuoteParseMode($quoteParseMode) + { + $this->quoteParseMode = $quoteParseMode; + } + + /** + * @return ArrayOfMessageEntity|null + */ + public function getQuoteEntities() + { + return $this->quoteEntities; + } + + /** + * @param ArrayOfMessageEntity|null $quoteEntities + * @return void + */ + public function setQuoteEntities($quoteEntities) + { + $this->quoteEntities = $quoteEntities; + } + + /** + * @return int|null + */ + public function getQuotePosition() + { + return $this->quotePosition; + } + + /** + * @param int|null $quotePosition + * @return void + */ + public function setQuotePosition($quotePosition) + { + $this->quotePosition = $quotePosition; + } +} diff --git a/src/Types/ResponseParameters.php b/src/Types/ResponseParameters.php new file mode 100644 index 00000000..7cc3bf24 --- /dev/null +++ b/src/Types/ResponseParameters.php @@ -0,0 +1,78 @@ + true, + 'retry_after' => true + ]; + + /** + * The group has been migrated to a supergroup with the specified identifier + * + * @var int|null + */ + protected $migrateToChatId; + + /** + * In case of exceeding flood control, the number of seconds left to wait before the request can be repeated + * + * @var int|null + */ + protected $retryAfter; + + /** + * @return int|null + */ + public function getMigrateToChatId() + { + return $this->migrateToChatId; + } + + /** + * @param int|null $migrateToChatId + */ + public function setMigrateToChatId($migrateToChatId) + { + $this->migrateToChatId = $migrateToChatId; + } + + /** + * @return int|null + */ + public function getRetryAfter() + { + return $this->retryAfter; + } + + /** + * @param int|null $retryAfter + */ + public function setRetryAfter($retryAfter) + { + $this->retryAfter = $retryAfter; + } +} diff --git a/src/Types/SharedUser.php b/src/Types/SharedUser.php new file mode 100644 index 00000000..21f9a1fd --- /dev/null +++ b/src/Types/SharedUser.php @@ -0,0 +1,155 @@ + true, + 'first_name' => true, + 'last_name' => true, + 'username' => true, + 'photo' => ArrayOfPhotoSize::class + ]; + + /** + * Identifier of the shared user + * + * @var int + */ + protected $userId; + + /** + * Optional. First name of the user, if the name was requested by the bot + * + * @var string|null + */ + protected $firstName; + + /** + * Optional. Last name of the user, if the name was requested by the bot + * + * @var string|null + */ + protected $lastName; + + /** + * Optional. Username of the user, if the username was requested by the bot + * + * @var string|null + */ + protected $username; + + /** + * Optional. Available sizes of the chat photo, if the photo was requested by the bot + * + * @var array|null + */ + protected $photo; + + /** + * @return int + */ + public function getUserId() + { + return $this->userId; + } + + /** + * @param int $userId + * @return void + */ + public function setUserId($userId) + { + $this->userId = $userId; + } + + /** + * @return string|null + */ + public function getFirstName() + { + return $this->firstName; + } + + /** + * @param string|null $firstName + * @return void + */ + public function setFirstName($firstName) + { + $this->firstName = $firstName; + } + + /** + * @return string|null + */ + public function getLastName() + { + return $this->lastName; + } + + /** + * @param string|null $lastName + * @return void + */ + public function setLastName($lastName) + { + $this->lastName = $lastName; + } + + /** + * @return string|null + */ + public function getUsername() + { + return $this->username; + } + + /** + * @param string|null $username + * @return void + */ + public function setUsername($username) + { + $this->username = $username; + } + + /** + * @return array|null + */ + public function getPhoto() + { + return $this->photo; + } + + /** + * @param array|null $photo + * @return void + */ + public function setPhoto($photo) + { + $this->photo = $photo; + } +} diff --git a/src/Types/Story.php b/src/Types/Story.php new file mode 100644 index 00000000..42683884 --- /dev/null +++ b/src/Types/Story.php @@ -0,0 +1,85 @@ + Chat::class, + 'id' => true, + ]; + + /** + * Chat that posted the story + * + * @var Chat + */ + protected $chat; + + /** + * Unique identifier for the story in the chat + * + * @var int + */ + protected $id; + + /** + * @return Chat + */ + public function getChat() + { + return $this->chat; + } + + /** + * @param Chat $chat + * @return void + */ + public function setChat(Chat $chat) + { + $this->chat = $chat; + } + + /** + * @return int + */ + public function getId() + { + return $this->id; + } + + /** + * @param int $id + * @return void + */ + public function setId($id) + { + if (is_integer($id)) { + $this->id = $id; + } else { + throw new InvalidArgumentException(); + } + } +} diff --git a/src/Types/TextQuote.php b/src/Types/TextQuote.php new file mode 100644 index 00000000..d7202bfa --- /dev/null +++ b/src/Types/TextQuote.php @@ -0,0 +1,131 @@ + true, + 'entities' => ArrayOfMessageEntity::class, + 'position' => true, + 'is_manual' => true, + ]; + + /** + * Text of the quoted part of a message that is replied to by the given message + * + * @var string + */ + protected $text; + + /** + * Optional. Special entities that appear in the quote. Currently, only bold, italic, underline, strikethrough, + * spoiler, and custom_emoji entities are kept in quotes. + * + * @var array|null + */ + protected $entities; + + /** + * Approximate quote position in the original message in UTF-16 code units as specified by the sender + * + * @var int + */ + protected $position; + + /** + * Optional. True, if the quote was chosen manually by the message sender. Otherwise, the quote was added automatically by the server. + * + * @var bool|null + */ + protected $isManual; + + /** + * @return string + */ + public function getText() + { + return $this->text; + } + + /** + * @param string $text + * @return void + */ + public function setText($text) + { + $this->text = $text; + } + + /** + * @return array|null + */ + public function getEntities() + { + return $this->entities; + } + + /** + * @param array|null $entities + * @return void + */ + public function setEntities($entities) + { + $this->entities = $entities; + } + + /** + * @return int + */ + public function getPosition() + { + return $this->position; + } + + /** + * @param int $position + * @return void + */ + public function setPosition($position) + { + $this->position = $position; + } + + /** + * @return bool|null + */ + public function getIsManual() + { + return $this->isManual; + } + + /** + * @param bool|null $isManual + * @return void + */ + public function setIsManual($isManual) + { + $this->isManual = $isManual; + } +} diff --git a/src/Types/User.php b/src/Types/User.php index 34a8be78..cd8faa72 100644 --- a/src/Types/User.php +++ b/src/Types/User.php @@ -32,12 +32,13 @@ class User extends BaseType implements TypeInterface 'last_name' => true, 'username' => true, 'language_code' => true, + 'is_bot' => true, 'is_premium' => true, 'added_to_attachment_menu' => true, 'can_join_groups' => true, 'can_read_all_group_messages' => true, 'supports_inline_queries' => true, - 'is_bot' => true + 'can_connect_to_business' => true ]; /** @@ -118,207 +119,132 @@ class User extends BaseType implements TypeInterface protected $supportsInlineQueries; /** - * @return string + * Optional. True, if the bot can be connected to a Telegram Business account to receive its messages. Returned only in getMe. + * + * @var bool|null */ - public function getFirstName() + protected $canConnectToBusiness; + + public function getId(): int { - return $this->firstName; + return $this->id; } - /** - * @param string $firstName - * - * @return void - */ - public function setFirstName($firstName) + public function setId($id): void { - $this->firstName = $firstName; + if (!is_int($id) && !is_float($id)) { + throw new InvalidArgumentException('ID must be an integer or float'); + } + $this->id = $id; } - /** - * @return int|float - */ - public function getId() + public function getFirstName(): string { - return $this->id; + return $this->firstName; } - /** - * @param mixed $id - * - * @throws InvalidArgumentException - * - * @return void - */ - public function setId($id) + public function setFirstName($firstName): void { - if (is_integer($id) || is_float($id)) { - $this->id = $id; - } else { - throw new InvalidArgumentException(); - } + $this->firstName = $firstName; } - /** - * @return null|string - */ - public function getLastName() + public function getLastName(): ?string { return $this->lastName; } - /** - * @param string $lastName - * - * @return void - */ - public function setLastName($lastName) + public function setLastName($lastName): void { $this->lastName = $lastName; } - /** - * @return null|string - */ - public function getUsername() + public function getUsername(): ?string { return $this->username; } - /** - * @param string $username - * - * @return void - */ - public function setUsername($username) + public function setUsername($username): void { $this->username = $username; } - /** - * @return null|string - */ public function getLanguageCode() { return $this->languageCode; } - /** - * @param string $languageCode - * - * @return void - */ - public function setLanguageCode($languageCode) + public function setLanguageCode($languageCode): void { $this->languageCode = $languageCode; } - /** - * @return bool - */ - public function isBot() + public function isBot(): bool { return $this->isBot; } - /** - * @param bool $isBot - * - * @return void - */ - public function setIsBot($isBot) + public function setIsBot($isBot): void { $this->isBot = $isBot; } - /** - * @param bool $isPremium - * - * @return void - */ - public function setIsPremium($isPremium) + public function getIsPremium(): ?bool + { + return $this->isPremium; + } + + public function setIsPremium($isPremium): void { $this->isPremium = $isPremium; } - /** - * @return bool|null - */ - public function getIsPremium() + public function getAddedToAttachmentMenu(): ?bool { - return $this->isPremium; + return $this->addedToAttachmentMenu; } - /** - * @param bool $addedToAttachmentMenu - * - * @return void - */ - public function setAddedToAttachmentMenu($addedToAttachmentMenu) + public function setAddedToAttachmentMenu($addedToAttachmentMenu): void { $this->addedToAttachmentMenu = $addedToAttachmentMenu; } - /** - * @return bool|null - */ - public function getAddedToAttachmentMenu() + public function getCanJoinGroups(): ?bool { - return $this->addedToAttachmentMenu; + return $this->canJoinGroups; } - /** - * @param bool $canJoinGroups - * - * @return void - */ - public function setCanJoinGroups($canJoinGroups) + public function setCanJoinGroups($canJoinGroups): void { $this->canJoinGroups = $canJoinGroups; } - /** - * @return bool|null - */ - public function getCanJoinGroups() + public function getCanReadAllGroupMessages(): ?bool { - return $this->canJoinGroups; + return $this->canReadAllGroupMessages; } - /** - * @param bool $canReadAllGroupMessages - * - * @return void - */ - public function setCanReadAllGroupMessages($canReadAllGroupMessages) + public function setCanReadAllGroupMessages($canReadAllGroupMessages): void { $this->canReadAllGroupMessages = $canReadAllGroupMessages; } - /** - * @return bool|null - */ - public function getCanReadAllGroupMessages() + public function getSupportsInlineQueries(): ?bool { - return $this->canReadAllGroupMessages; + return $this->supportsInlineQueries; } - /** - * @param bool $supportsInlineQueries - * - * @return void - */ - public function setSupportsInlineQueries($supportsInlineQueries) + public function setSupportsInlineQueries($supportsInlineQueries): void { $this->supportsInlineQueries = $supportsInlineQueries; } - /** - * @return bool|null - */ - public function getSupportsInlineQueries() + public function getCanConnectToBusiness(): ?bool { - return $this->supportsInlineQueries; + return $this->canConnectToBusiness; } + public function setCanConnectToBusiness($canConnectToBusiness): void + { + $this->canConnectToBusiness = $canConnectToBusiness; + } } diff --git a/src/Types/UserChatBoosts.php b/src/Types/UserChatBoosts.php new file mode 100644 index 00000000..5543b587 --- /dev/null +++ b/src/Types/UserChatBoosts.php @@ -0,0 +1,54 @@ + ArrayOfChatBoost::class + ]; + + /** + * The list of boosts added to the chat by the user + * + * @var ArrayOfChatBoost + */ + protected $boosts; + + /** + * @return ArrayOfChatBoost + */ + public function getBoosts() + { + return $this->boosts; + } + + /** + * @param ArrayOfChatBoost $boosts + */ + public function setBoosts($boosts): void + { + $this->boosts = $boosts; + } +} diff --git a/src/Types/UsersShared.php b/src/Types/UsersShared.php new file mode 100644 index 00000000..818b5950 --- /dev/null +++ b/src/Types/UsersShared.php @@ -0,0 +1,81 @@ + true, + 'users' => ArrayOfSharedUser::class + ]; + + /** + * Identifier of the request + * + * @var int + */ + protected $requestId; + + /** + * Information about users shared with the bot + * Array of \TelegramBot\Api\Types\SharedUser + * + * @var array + */ + protected $users; + + /** + * @return int + */ + public function getRequestId() + { + return $this->requestId; + } + + /** + * @param int $requestId + * @return void + */ + public function setRequestId($requestId) + { + $this->requestId = $requestId; + } + + /** + * @return array + */ + public function getUsers() + { + return $this->users; + } + + /** + * @param array $users + * @return void + */ + public function setUsers($users) + { + $this->users = $users; + } +} diff --git a/src/Types/Venue.php b/src/Types/Venue.php index 38718f64..2ffd125c 100644 --- a/src/Types/Venue.php +++ b/src/Types/Venue.php @@ -1,10 +1,4 @@ true, + ]; + + /** + * Video chat duration in seconds + * + * @var int + */ + protected $duration; + + /** + * @return int + */ + public function getDuration() + { + return $this->duration; + } + + /** + * @param int $duration + * @return void + */ + public function setDuration($duration) + { + $this->duration = $duration; + } +} diff --git a/src/Types/VideoChatParticipantsInvited.php b/src/Types/VideoChatParticipantsInvited.php new file mode 100644 index 00000000..934b3ad5 --- /dev/null +++ b/src/Types/VideoChatParticipantsInvited.php @@ -0,0 +1,55 @@ + ArrayOfUser::class, + ]; + + /** + * New members that were invited to the video chat + * + * @var array + */ + protected $users; + + /** + * @return array + */ + public function getUsers() + { + return $this->users; + } + + /** + * @param array $users + * @return void + */ + public function setUsers($users) + { + $this->users = $users; + } +} diff --git a/src/Types/VideoChatScheduled.php b/src/Types/VideoChatScheduled.php new file mode 100644 index 00000000..d329f52f --- /dev/null +++ b/src/Types/VideoChatScheduled.php @@ -0,0 +1,55 @@ + true, + ]; + + /** + * Point in time (Unix timestamp) when the video chat is supposed to be started by a chat administrator + * + * @var int + */ + protected $startDate; + + /** + * @return int + */ + public function getStartDate() + { + return $this->startDate; + } + + /** + * @param int $startDate + * @return void + */ + public function setStartDate($startDate) + { + $this->startDate = $startDate; + } +} diff --git a/src/Types/VideoChatStarted.php b/src/Types/VideoChatStarted.php new file mode 100644 index 00000000..f67914c7 --- /dev/null +++ b/src/Types/VideoChatStarted.php @@ -0,0 +1,10 @@ + true, 'file_unique_id' => true, diff --git a/src/Types/WebAppInfo.php b/src/Types/WebAppInfo.php new file mode 100644 index 00000000..d33ea0a5 --- /dev/null +++ b/src/Types/WebAppInfo.php @@ -0,0 +1,55 @@ + true, + ]; + + /** + * An HTTPS URL of a Web App to be opened with additional data as specified in Initializing Web Apps + * + * @var string + */ + protected $url; + + /** + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * @param string $url + * @return void + */ + public function setUrl($url) + { + $this->url = $url; + } +} diff --git a/src/Types/WriteAccessAllowed.php b/src/Types/WriteAccessAllowed.php new file mode 100644 index 00000000..243de7b1 --- /dev/null +++ b/src/Types/WriteAccessAllowed.php @@ -0,0 +1,98 @@ + true, + 'web_app_name' => true, + 'from_attachment_menu' => true, + ]; + + /** + * Optional. True, if the access was granted after the user accepted an explicit request from a Web App sent by the method requestWriteAccess + * + * @var bool|null + */ + protected $fromRequest; + + /** + * Optional. Name of the Web App, if the access was granted when the Web App was launched from a link + * + * @var string|null + */ + protected $webAppName; + + /** + * Optional. True, if the access was granted when the bot was added to the attachment or side menu + * + * @var bool|null + */ + protected $fromAttachmentMenu; + + /** + * @return bool|null + */ + public function isFromRequest() + { + return $this->fromRequest; + } + + /** + * @param bool|null $fromRequest + * @return void + */ + public function setFromRequest($fromRequest) + { + $this->fromRequest = $fromRequest; + } + + /** + * @return string|null + */ + public function getWebAppName() + { + return $this->webAppName; + } + + /** + * @param string|null $webAppName + * @return void + */ + public function setWebAppName($webAppName) + { + $this->webAppName = $webAppName; + } + + /** + * @return bool|null + */ + public function isFromAttachmentMenu() + { + return $this->fromAttachmentMenu; + } + + /** + * @param bool|null $fromAttachmentMenu + * @return void + */ + public function setFromAttachmentMenu($fromAttachmentMenu) + { + $this->fromAttachmentMenu = $fromAttachmentMenu; + } +} diff --git a/tests/BotApiTest.php b/tests/BotApiTest.php index 823292d3..43e351bf 100644 --- a/tests/BotApiTest.php +++ b/tests/BotApiTest.php @@ -143,6 +143,6 @@ private function createHttpClient() private function createBotApi(HttpClientInterface $httpClient) { - return new BotApi('token', null, $httpClient); + return new BotApi('token', $httpClient); } } diff --git a/tests/ClientTest.php b/tests/ClientTest.php index bc0737e5..14a70371 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -136,10 +136,9 @@ public function testGetInlineQueryChecker($update) public function testBadMethodCallException() { $this->expectException(BadMethodCallException::class); - $this->expectErrorMessage('Method testMethod not exists'); + $this->expectExceptionMessage('Method testMethod not exists'); $item = new Client('testToken'); - $item->testMethod(); } diff --git a/tests/Collection/CollectionTest.php b/tests/Collection/CollectionTest.php index c8aceb99..48994aab 100644 --- a/tests/Collection/CollectionTest.php +++ b/tests/Collection/CollectionTest.php @@ -88,20 +88,4 @@ public function testCantAddMoreThenMaxLimit() $media->addItem(new InputMediaPhoto('link')); $media->addItem(new InputMediaPhoto('link')); } - - public function testCanOutputItemsAsArray() - { - $media = new ArrayOfInputMedia(); - $media->addItem(new InputMediaPhoto('link')); - - $this->assertSame($this->itemsOutput, $media->toJson(true)); - } - - public function testCanOutputItemsAsJson() - { - $media = new ArrayOfInputMedia(); - $media->addItem(new InputMediaPhoto('link')); - - $this->assertSame(json_encode($this->itemsOutput), $media->toJson()); - } } diff --git a/tests/Events/EventCollectionTest.php b/tests/Events/EventCollectionTest.php index a66ac5d9..a5e18d8b 100644 --- a/tests/Events/EventCollectionTest.php +++ b/tests/Events/EventCollectionTest.php @@ -3,7 +3,6 @@ namespace TelegramBot\Api\Test\Events; use PHPUnit\Framework\TestCase; -use TelegramBot\Api\Botan; use TelegramBot\Api\Events\Event; use TelegramBot\Api\Events\EventCollection; use TelegramBot\Api\Types\Update; @@ -92,38 +91,6 @@ public function testAdd2($action) } } - /** - * @param \Closure $action - * @param \Closure $checker - * @param Update $update - * - * @dataProvider data - */ - public function testHandle1($action, $checker, $update) - { - $item = new EventCollection('testToken'); - $name = 'test'; - $item->add($action, function ($update) use ($name) { - return true; - }); - - $mockedTracker = $this->getMockBuilder(Botan::class) - ->disableOriginalConstructor() - ->getMock(); - - // Configure the stub. - - $mockedTracker->expects($this->once())->method('track')->willReturn(null); - - $reflection = new \ReflectionClass($item); - $reflectionProperty = $reflection->getProperty('tracker'); - $reflectionProperty->setAccessible(true); - $reflectionProperty->setValue($item, $mockedTracker); - $reflectionProperty->setAccessible(false); - - $item->handle($update); - } - /** * @param \Closure $action * @param \Closure $checker @@ -139,16 +106,11 @@ public function testHandle2($action, $checker, $update) return true; }); - $mockedTracker = $this->getMockBuilder(Botan::class) - ->disableOriginalConstructor() - ->getMock(); - $mockedEvent = $this->getMockBuilder(Event::class) ->disableOriginalConstructor() ->getMock(); // Configure the stub. - $mockedTracker->expects($this->exactly(0))->method('track')->willReturn(null); $mockedEvent->expects($this->once())->method('executeChecker')->willReturn(true); $mockedEvent->expects($this->once())->method('executeAction')->willReturn(true); diff --git a/tests/Types/ChatMemberTest.php b/tests/Types/ChatMemberTest.php deleted file mode 100644 index 6fd4018d..00000000 --- a/tests/Types/ChatMemberTest.php +++ /dev/null @@ -1,105 +0,0 @@ - UserTest::getMinResponse(), - 'status' => 'member', - ]; - } - - public static function getFullResponse() - { - return [ - 'user' => UserTest::getMinResponse(), - 'status' => 'member', - 'until_date' => 1682343644, - 'can_be_edited' => true, - 'can_change_info' => true, - 'can_post_messages' => true, - 'can_edit_messages' => true, - 'can_delete_messages' => true, - 'can_invite_users' => true, - 'can_restrict_members' => true, - 'can_pin_messages' => true, - 'can_promote_members' => true, - 'can_send_messages' => true, - 'can_send_media_messages' => true, - 'can_send_other_messages' => true, - 'can_add_web_page_previews' => true, - 'can_manage_topics' => true, - 'is_anonymous' => true, - 'custom_title' => 'custom_title', - 'can_manage_chat' => true, - 'can_send_polls' => true, - ]; - } - - /** - * @param ChatMember $item - * @return void - */ - protected function assertMinItem($item) - { - $this->assertEquals(UserTest::createMinInstance(), $item->getUser()); - $this->assertEquals('member', $item->getStatus()); - $this->assertNull($item->getUntilDate()); - $this->assertNull($item->getCanBeEdited()); - $this->assertNull($item->getCanChangeInfo()); - $this->assertNull($item->getCanPostMessages()); - $this->assertNull($item->getCanEditMessages()); - $this->assertNull($item->getCanDeleteMessages()); - $this->assertNull($item->getCanInviteUsers()); - $this->assertNull($item->getCanRestrictMembers()); - $this->assertNull($item->getCanPinMessages()); - $this->assertNull($item->getCanPromoteMembers()); - $this->assertNull($item->getCanSendMessages()); - $this->assertNull($item->getCanSendMediaMessages()); - $this->assertNull($item->getCanSendOtherMessages()); - $this->assertNull($item->getCanAddWebPagePreviews()); - $this->assertNull($item->getCanManageTopics()); - $this->assertNull($item->getIsAnonymous()); - $this->assertNull($item->getCustomTitle()); - $this->assertNull($item->getCanManageChat()); - $this->assertNull($item->getCanSendPolls()); - } - - /** - * @param ChatMember $item - * @return void - */ - protected function assertFullItem($item) - { - $this->assertEquals(1682343644, $item->getUntilDate()); - $this->assertTrue($item->getCanBeEdited()); - $this->assertTrue($item->getCanChangeInfo()); - $this->assertTrue($item->getCanPostMessages()); - $this->assertTrue($item->getCanEditMessages()); - $this->assertTrue($item->getCanDeleteMessages()); - $this->assertTrue($item->getCanInviteUsers()); - $this->assertTrue($item->getCanRestrictMembers()); - $this->assertTrue($item->getCanPinMessages()); - $this->assertTrue($item->getCanPromoteMembers()); - $this->assertTrue($item->getCanSendMessages()); - $this->assertTrue($item->getCanSendMediaMessages()); - $this->assertTrue($item->getCanSendOtherMessages()); - $this->assertTrue($item->getCanAddWebPagePreviews()); - $this->assertTrue($item->getCanManageTopics()); - $this->assertTrue($item->getIsAnonymous()); - $this->assertEquals('custom_title', $item->getCustomTitle()); - $this->assertTrue($item->getCanManageChat()); - $this->assertTrue($item->getCanSendPolls()); - } -} diff --git a/tests/Types/ChatMemberUpdatedTest.php b/tests/Types/ChatMemberUpdatedTest.php deleted file mode 100644 index 8f80f995..00000000 --- a/tests/Types/ChatMemberUpdatedTest.php +++ /dev/null @@ -1,68 +0,0 @@ - ChatTest::getMinResponse(), - 'from' => UserTest::getMinResponse(), - 'date' => 100500, - 'old_chat_member' => ChatMemberTest::getMinResponse(), - 'new_chat_member' => ChatMemberTest::getMinResponse(), - ]; - } - - public static function getFullResponse() - { - return [ - 'chat' => ChatTest::getMinResponse(), - 'from' => UserTest::getMinResponse(), - 'date' => 100500, - 'old_chat_member' => ChatMemberTest::getMinResponse(), - 'new_chat_member' => ChatMemberTest::getMinResponse(), - 'invite_link' => ChatInviteLinkTest::getMinResponse(), - 'via_chat_folder_invite_link' => true, - ]; - } - - /** - * @param ChatMemberUpdated $item - * @return void - */ - protected function assertMinItem($item) - { - $this->assertEquals(ChatTest::createMinInstance(), $item->getChat()); - $this->assertEquals(UserTest::createMinInstance(), $item->getFrom()); - $this->assertEquals(100500, $item->getDate()); - $this->assertEquals(ChatMemberTest::createMinInstance(), $item->getOldChatMember()); - $this->assertEquals(ChatMemberTest::createMinInstance(), $item->getNewChatMember()); - $this->assertNull($item->getInviteLink()); - $this->assertNull($item->getViaChatFolderInviteLink()); - } - - /** - * @param ChatMemberUpdated $item - * @return void - */ - protected function assertFullItem($item) - { - $this->assertEquals(ChatTest::createMinInstance(), $item->getChat()); - $this->assertEquals(UserTest::createMinInstance(), $item->getFrom()); - $this->assertEquals(100500, $item->getDate()); - $this->assertEquals(ChatMemberTest::createMinInstance(), $item->getOldChatMember()); - $this->assertEquals(ChatMemberTest::createMinInstance(), $item->getNewChatMember()); - $this->assertEquals(ChatInviteLinkTest::createMinInstance(), $item->getInviteLink()); - $this->assertTrue($item->getViaChatFolderInviteLink()); - } -} diff --git a/tests/Types/ChatTest.php b/tests/Types/ChatTest.php index 1ea4634d..54ab521c 100644 --- a/tests/Types/ChatTest.php +++ b/tests/Types/ChatTest.php @@ -65,29 +65,10 @@ protected function assertMinItem($item) $this->assertEquals('private', $item->getType()); $this->assertNull($item->getTitle()); - $this->assertNull($item->getInviteLink()); $this->assertNull($item->getFirstName()); $this->assertNull($item->getLastName()); $this->assertNull($item->getUsername()); - $this->assertNull($item->getBio()); - $this->assertNull($item->getDescription()); - $this->assertNull($item->getSlowModeDelay()); - $this->assertNull($item->getStickerSetName()); - $this->assertNull($item->getCanSetStickerSet()); - $this->assertNull($item->getLinkedChatId()); - $this->assertNull($item->getJoinToSendMessages()); - $this->assertNull($item->getJoinByRequest()); - $this->assertNull($item->getMessageAutoDeleteTime()); - $this->assertNull($item->getHasProtectedContent()); $this->assertNull($item->getIsForum()); - $this->assertNull($item->getActiveUsernames()); - $this->assertNull($item->getEmojiStatusCustomEmojiId()); - $this->assertNull($item->getHasPrivateForwards()); - $this->assertNull($item->getHasRestrictedVoiceAndVideoMessages()); - $this->assertNull($item->getPhoto()); - $this->assertNull($item->getPinnedMessage()); - $this->assertNull($item->getPermissions()); - $this->assertNull($item->getLocation()); } /** @@ -99,29 +80,9 @@ protected function assertFullItem($item) $this->assertEquals(123456, $item->getId()); $this->assertEquals('private', $item->getType()); $this->assertEquals('title', $item->getTitle()); - $this->assertEquals('invite_link', $item->getInviteLink()); $this->assertEquals('Ilya', $item->getFirstName()); $this->assertEquals('Gusev', $item->getLastName()); $this->assertEquals('iGusev', $item->getUsername()); - $this->assertEquals('PHP Telegram Bot API', $item->getBio()); - $this->assertEquals('description', $item->getDescription()); - $this->assertEquals(10, $item->getSlowModeDelay()); - $this->assertEquals('sticker_set_name', $item->getStickerSetName()); - $this->assertEquals(true, $item->getCanSetStickerSet()); - $this->assertEquals(2, $item->getLinkedChatId()); - $this->assertEquals(true, $item->getJoinToSendMessages()); - $this->assertEquals(true, $item->getJoinByRequest()); - $this->assertEquals(10000, $item->getMessageAutoDeleteTime()); - $this->assertEquals(true, $item->getHasProtectedContent()); - $this->assertEquals(true, $item->getIsForum()); - $this->assertEquals(['username'], $item->getActiveUsernames()); - $this->assertEquals('emoji_status_custom_emoji_id', $item->getEmojiStatusCustomEmojiId()); - $this->assertEquals(true, $item->getHasPrivateForwards()); - $this->assertEquals(true, $item->getHasRestrictedVoiceAndVideoMessages()); - $this->assertEquals(ChatPhotoTest::createMinInstance(), $item->getPhoto()); - $this->assertEquals(MessageTest::createMinInstance(), $item->getPinnedMessage()); - $this->assertEquals(ChatPermissionsTest::createFullInstance(), $item->getPermissions()); - $this->assertEquals(ChatLocationTest::createMinInstance(), $item->getLocation()); } public function testSet64bitId() diff --git a/tests/Types/MessageOriginChannelTest.php b/tests/Types/MessageOriginChannelTest.php new file mode 100644 index 00000000..c6c0db3b --- /dev/null +++ b/tests/Types/MessageOriginChannelTest.php @@ -0,0 +1,74 @@ + 'channel', + 'date' => 1640908800, + 'chat' => [ + 'id' => 123456, + 'type' => 'private', + ], + 'message_id' => 12345, + ]; + } + + public static function getFullResponse() + { + return [ + 'type' => 'channel', + 'date' => 1640908800, + 'chat' => [ + 'id' => 123456, + 'type' => 'private', + ], + 'message_id' => 12345, + 'author_signature' => 'John Doe', + ]; + } + + /** + * @param MessageOriginChannel $item + */ + protected function assertMinItem($item) + { + $this->assertEquals('channel', $item->getType()); + $this->assertEquals(1640908800, $item->getDate()); + $this->assertEquals(12345, $item->getMessageId()); + $this->assertNull($item->getAuthorSignature()); + + $chat = $item->getChat(); + $this->assertInstanceOf(Chat::class, $chat); + $this->assertEquals(123456, $chat->getId()); + $this->assertEquals('private', $chat->getType()); + } + + /** + * @param MessageOriginChannel $item + */ + protected function assertFullItem($item) + { + $this->assertEquals('channel', $item->getType()); + $this->assertEquals(1640908800, $item->getDate()); + $this->assertEquals(12345, $item->getMessageId()); + $this->assertEquals('John Doe', $item->getAuthorSignature()); + + $chat = $item->getChat(); + $this->assertInstanceOf(Chat::class, $chat); + $this->assertEquals(123456, $chat->getId()); + $this->assertEquals('private', $chat->getType()); + } +} diff --git a/tests/Types/MessageTest.php b/tests/Types/MessageTest.php index b15472d4..ae4f470c 100644 --- a/tests/Types/MessageTest.php +++ b/tests/Types/MessageTest.php @@ -106,12 +106,6 @@ protected function assertMinItem($item) $this->assertEquals(ChatTest::createMinInstance(), $item->getChat()); $this->assertNull($item->getFrom()); - $this->assertNull($item->getForwardFrom()); - $this->assertNull($item->getForwardFromChat()); - $this->assertNull($item->getForwardFromMessageId()); - $this->assertNull($item->getForwardDate()); - $this->assertNull($item->getForwardSignature()); - $this->assertNull($item->getForwardSenderName()); $this->assertNull($item->getReplyToMessage()); $this->assertNull($item->getViaBot()); $this->assertNull($item->getEditDate()); @@ -168,12 +162,6 @@ protected function assertFullItem($item) $this->assertEquals(ChatTest::createMinInstance(), $item->getChat()); $this->assertEquals(UserTest::createMinInstance(), $item->getFrom()); - $this->assertEquals(UserTest::createMinInstance(), $item->getForwardFrom()); - $this->assertEquals(ChatTest::createMinInstance(), $item->getForwardFromChat()); - $this->assertEquals(2, $item->getForwardFromMessageId()); - $this->assertEquals(1682343645, $item->getForwardDate()); - $this->assertEquals('forward_signature', $item->getForwardSignature()); - $this->assertEquals('forward_sender_name', $item->getForwardSenderName()); $this->assertEquals(MessageTest::createMinInstance(), $item->getReplyToMessage()); $this->assertEquals(UserTest::createMinInstance(), $item->getViaBot()); $this->assertEquals(1682343643, $item->getEditDate()); @@ -250,14 +238,6 @@ public function testSetEditDateException() $item->setEditDate('s'); } - public function testSetForwardDateException() - { - $this->expectException(InvalidArgumentException::class); - - $item = new Message(); - $item->setForwardDate('s'); - } - public function testToJson1() { $data = [ diff --git a/tests/Types/PollAnswerTest.php b/tests/Types/PollAnswerTest.php index 4c3b0ce1..ed08dbd4 100644 --- a/tests/Types/PollAnswerTest.php +++ b/tests/Types/PollAnswerTest.php @@ -34,7 +34,6 @@ protected function assertMinItem($item) { $this->assertEquals(123456789, $item->getPollId()); $this->assertEquals(UserTest::createMinInstance(), $item->getUser()); - $this->assertEquals(UserTest::createMinInstance(), $item->getFrom()); $this->assertEquals([1,2,3,4,5,6], $item->getOptionIds()); } diff --git a/tests/Types/ReactionTypeCustomEmojiTest.php b/tests/Types/ReactionTypeCustomEmojiTest.php new file mode 100644 index 00000000..bab97bd5 --- /dev/null +++ b/tests/Types/ReactionTypeCustomEmojiTest.php @@ -0,0 +1,46 @@ + 'custom_emoji', + 'custom_emoji_id' => 'custom_emoji_123' + ]; + } + + public static function getFullResponse() + { + return static::getMinResponse(); + } + + /** + * @param ReactionTypeCustomEmoji $item + * @return void + */ + protected function assertMinItem($item) + { + $this->assertEquals('custom_emoji', $item->getType()); + $this->assertEquals('custom_emoji_123', $item->getCustomEmojiId()); + } + + /** + * @param ReactionTypeCustomEmoji $item + * @return void + */ + protected function assertFullItem($item) + { + $this->assertMinItem($item); + } +} diff --git a/tests/Types/MessageIdTest.php b/tests/Types/ReactionTypeEmojiTest.php similarity index 58% rename from tests/Types/MessageIdTest.php rename to tests/Types/ReactionTypeEmojiTest.php index 65f1f590..6c192f8e 100644 --- a/tests/Types/MessageIdTest.php +++ b/tests/Types/ReactionTypeEmojiTest.php @@ -3,19 +3,20 @@ namespace TelegramBot\Api\Test\Types; use TelegramBot\Api\Test\AbstractTypeTest; -use TelegramBot\Api\Types\MessageId; +use TelegramBot\Api\Types\ReactionTypeEmoji; -class MessageIdTest extends AbstractTypeTest +class ReactionTypeEmojiTest extends AbstractTypeTest { protected static function getType() { - return MessageId::class; + return ReactionTypeEmoji::class; } public static function getMinResponse() { return [ - 'message_id' => 100, + 'type' => 'emoji', + 'emoji' => '👍' ]; } @@ -25,16 +26,17 @@ public static function getFullResponse() } /** - * @param MessageId $item + * @param ReactionTypeEmoji $item * @return void */ protected function assertMinItem($item) { - $this->assertEquals(100, $item->getMessageId()); + $this->assertEquals('emoji', $item->getType()); + $this->assertEquals('👍', $item->getEmoji()); } /** - * @param MessageId $item + * @param ReactionTypeEmoji $item * @return void */ protected function assertFullItem($item) diff --git a/tests/Types/UpdateTest.php b/tests/Types/UpdateTest.php index 73852b3d..0af8523a 100644 --- a/tests/Types/UpdateTest.php +++ b/tests/Types/UpdateTest.php @@ -38,8 +38,6 @@ public static function getFullResponse() 'pre_checkout_query' => PreCheckoutQueryTest::getMinResponse(), 'poll_answer' => PollAnswerTest::getMinResponse(), 'poll' => PollTest::getMinResponse(), - 'my_chat_member' => ChatMemberUpdatedTest::getMinResponse(), - 'chat_member' => ChatMemberUpdatedTest::getMinResponse(), 'chat_join_request' => ChatJoinRequestTest::getMinResponse(), ]; } @@ -85,8 +83,6 @@ protected function assertFullItem($item) $this->assertEquals(PreCheckoutQueryTest::createMinInstance(), $item->getPreCheckoutQuery()); $this->assertEquals(PollAnswerTest::createMinInstance(), $item->getPollAnswer()); $this->assertEquals(PollTest::createMinInstance(), $item->getPoll()); - $this->assertEquals(ChatMemberUpdatedTest::createMinInstance(), $item->getMyChatMember()); - $this->assertEquals(ChatMemberUpdatedTest::createMinInstance(), $item->getChatMember()); $this->assertEquals(ChatJoinRequestTest::createMinInstance(), $item->getChatJoinRequest()); } } diff --git a/tests/Types/UserTest.php b/tests/Types/UserTest.php index de3b485c..61a29f00 100644 --- a/tests/Types/UserTest.php +++ b/tests/Types/UserTest.php @@ -114,4 +114,74 @@ public function testFromResponseException2() ]); } + public function testSetAndGetFirstName() + { + $item = new User(); + $item->setFirstName('John'); + $this->assertEquals('John', $item->getFirstName()); + } + + public function testSetAndGetLastName() + { + $item = new User(); + $item->setLastName('Doe'); + $this->assertEquals('Doe', $item->getLastName()); + } + + public function testSetAndGetUsername() + { + $item = new User(); + $item->setUsername('johndoe'); + $this->assertEquals('johndoe', $item->getUsername()); + } + + public function testSetAndGetLanguageCode() + { + $item = new User(); + $item->setLanguageCode('en'); + $this->assertEquals('en', $item->getLanguageCode()); + } + + public function testSetAndGetIsBot() + { + $item = new User(); + $item->setIsBot(true); + $this->assertTrue($item->isBot()); + } + + public function testSetAndGetIsPremium() + { + $item = new User(); + $item->setIsPremium(true); + $this->assertTrue($item->getIsPremium()); + } + + public function testSetAndGetAddedToAttachmentMenu() + { + $item = new User(); + $item->setAddedToAttachmentMenu(true); + $this->assertTrue($item->getAddedToAttachmentMenu()); + } + + public function testSetAndGetCanJoinGroups() + { + $item = new User(); + $item->setCanJoinGroups(true); + $this->assertTrue($item->getCanJoinGroups()); + } + + public function testSetAndGetCanReadAllGroupMessages() + { + $item = new User(); + $item->setCanReadAllGroupMessages(true); + $this->assertTrue($item->getCanReadAllGroupMessages()); + } + + public function testSetAndGetSupportsInlineQueries() + { + $item = new User(); + $item->setSupportsInlineQueries(true); + $this->assertTrue($item->getSupportsInlineQueries()); + } + }