forked from TelegramBot/Api
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
672 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Luzrain\TelegramBotApi\Type; | ||
|
||
use Luzrain\TelegramBotApi\Type; | ||
|
||
/** | ||
* This object describes the way a background is filled based on the selected colors. Currently, it can be one of | ||
* | ||
* @see BackgroundFillSolid | ||
* @see BackgroundFillGradient | ||
* @see BackgroundFillFreeformGradient | ||
*/ | ||
readonly class BackgroundFill extends Type | ||
{ | ||
protected function __construct( | ||
/** | ||
* Type of the background | ||
*/ | ||
public string $type, | ||
) { | ||
} | ||
|
||
/** | ||
* @psalm-suppress LessSpecificReturnStatement | ||
* @psalm-suppress MoreSpecificReturnType | ||
*/ | ||
public static function fromArray(array $data): static | ||
{ | ||
/** @var self $instance */ | ||
$instance = parent::fromArray($data); | ||
|
||
return self::class !== static::class ? $instance : match ($instance->type) { | ||
BackgroundFillSolid::TYPE => BackgroundFillSolid::fromArray($data), | ||
BackgroundFillGradient::TYPE => BackgroundFillGradient::fromArray($data), | ||
BackgroundFillFreeformGradient::TYPE => BackgroundFillFreeformGradient::fromArray($data), | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Luzrain\TelegramBotApi\Type; | ||
|
||
/** | ||
* The background is a freeform gradient that rotates after every message in the chat. | ||
*/ | ||
final readonly class BackgroundFillFreeformGradient extends BackgroundFill | ||
{ | ||
public const TYPE = 'freeform_gradient'; | ||
|
||
public function __construct( | ||
/** | ||
* A list of the 3 or 4 base colors that are used to generate the freeform gradient in the RGB24 format | ||
* | ||
* @var list<int> | ||
*/ | ||
public array $colors, | ||
) { | ||
parent::__construct(self::TYPE); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Luzrain\TelegramBotApi\Type; | ||
|
||
/** | ||
* The background is a gradient fill. | ||
*/ | ||
final readonly class BackgroundFillGradient extends BackgroundFill | ||
{ | ||
public const TYPE = 'gradient'; | ||
|
||
public function __construct( | ||
/** | ||
* Top color of the gradient in the RGB24 format | ||
*/ | ||
public int $topColor, | ||
|
||
/** | ||
* Bottom color of the gradient in the RGB24 format | ||
*/ | ||
public int $bottomColor, | ||
|
||
/** | ||
* Clockwise rotation angle of the background fill in degrees; 0-359 | ||
*/ | ||
public int $rotationAngle, | ||
) { | ||
parent::__construct(self::TYPE); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Luzrain\TelegramBotApi\Type; | ||
|
||
/** | ||
* The background is filled using the selected color. | ||
*/ | ||
final readonly class BackgroundFillSolid extends BackgroundFill | ||
{ | ||
public const TYPE = 'solid'; | ||
|
||
public function __construct( | ||
/** | ||
* The color of the background fill in the RGB24 format | ||
*/ | ||
public int $color, | ||
) { | ||
parent::__construct(self::TYPE); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Luzrain\TelegramBotApi\Type; | ||
|
||
use Luzrain\TelegramBotApi\Type; | ||
|
||
/** | ||
* This object describes the type of a background. Currently, it can be one of | ||
* | ||
* @see BackgroundTypeFill | ||
* @see BackgroundTypeWallpaper | ||
* @see BackgroundTypePattern | ||
* @see BackgroundTypeChatTheme | ||
*/ | ||
readonly class BackgroundType extends Type | ||
{ | ||
protected function __construct( | ||
/** | ||
* Type of the background | ||
*/ | ||
public string $type, | ||
) { | ||
} | ||
|
||
/** | ||
* @psalm-suppress LessSpecificReturnStatement | ||
* @psalm-suppress MoreSpecificReturnType | ||
*/ | ||
public static function fromArray(array $data): static | ||
{ | ||
/** @var self $instance */ | ||
$instance = parent::fromArray($data); | ||
|
||
return self::class !== static::class ? $instance : match ($instance->type) { | ||
BackgroundTypeFill::TYPE => BackgroundTypeFill::fromArray($data), | ||
BackgroundTypeWallpaper::TYPE => BackgroundTypeWallpaper::fromArray($data), | ||
BackgroundTypePattern::TYPE => BackgroundTypePattern::fromArray($data), | ||
BackgroundTypeChatTheme::TYPE => BackgroundTypeChatTheme::fromArray($data), | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Luzrain\TelegramBotApi\Type; | ||
|
||
/** | ||
* The background is taken directly from a built-in chat theme. | ||
*/ | ||
final readonly class BackgroundTypeChatTheme extends BackgroundType | ||
{ | ||
public const TYPE = 'chat_theme'; | ||
|
||
public function __construct( | ||
/** | ||
* Document with the pattern | ||
*/ | ||
public Document $document, | ||
|
||
/** | ||
* Name of the chat theme, which is usually an emoji | ||
*/ | ||
public string $themeName, | ||
) { | ||
parent::__construct(self::TYPE); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Luzrain\TelegramBotApi\Type; | ||
|
||
/** | ||
* The background is automatically filled based on the selected colors. | ||
*/ | ||
final readonly class BackgroundTypeFill extends BackgroundType | ||
{ | ||
public const TYPE = 'fill'; | ||
|
||
public function __construct( | ||
/** | ||
* The background fill | ||
*/ | ||
public BackgroundFill $fill, | ||
|
||
/** | ||
* Dimming of the background in dark themes, as a percentage; 0-100 | ||
*/ | ||
public int $darkThemeDimming, | ||
) { | ||
parent::__construct(self::TYPE); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Luzrain\TelegramBotApi\Type; | ||
|
||
/** | ||
* The background is a PNG or TGV (gzipped subset of SVG with MIME type "application/x-tgwallpattern") | ||
* pattern to be combined with the background fill chosen by the user. | ||
*/ | ||
final readonly class BackgroundTypePattern extends BackgroundType | ||
{ | ||
public const TYPE = 'pattern'; | ||
|
||
public function __construct( | ||
/** | ||
* Document with the pattern | ||
*/ | ||
public Document $document, | ||
|
||
/** | ||
* The background fill that is combined with the pattern | ||
*/ | ||
public BackgroundFill $fill, | ||
|
||
/** | ||
* Intensity of the pattern when it is shown above the filled background; 0-100 | ||
*/ | ||
public int $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 | ||
*/ | ||
public true|null $isInverted = null, | ||
|
||
/** | ||
* Optional. True, if the background moves slightly when the device is tilted | ||
*/ | ||
public true|null $isMoving = null, | ||
) { | ||
parent::__construct(self::TYPE); | ||
} | ||
} |
Oops, something went wrong.