-
Notifications
You must be signed in to change notification settings - Fork 44
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
29 changed files
with
385 additions
and
96 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
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,33 @@ | ||
<?php | ||
|
||
namespace WeStacks\TeleBot\Objects; | ||
|
||
use WeStacks\TeleBot\Contracts\TelegramObject; | ||
use WeStacks\TeleBot\Exceptions\TeleBotException; | ||
|
||
/** | ||
* This object describes the way a background is filled based on the selected colors. Currently, it can be one of | ||
* | ||
* - [BackgroundFillSolid](https://core.telegram.org/bots/api#backgroundfillsolid) | ||
* - [BackgroundFillGradient](https://core.telegram.org/bots/api#backgroundfillgradient) | ||
* - [BackgroundFillFreeformGradient](https://core.telegram.org/bots/api#backgroundfillfreeformgradient) | ||
*/ | ||
abstract class BackgroundFill extends TelegramObject | ||
{ | ||
protected static $types = [ | ||
'solid' => BackgroundFillSolid::class, | ||
'gradient' => BackgroundFillGradient::class, | ||
'freeform_gradient' => BackgroundFillFreeformGradient::class, | ||
]; | ||
|
||
public static function create($object) | ||
{ | ||
$object = (array) $object; | ||
|
||
if ($class = static::$types[$object['type'] ?? null] ?? null) { | ||
return new $class($object); | ||
} | ||
|
||
throw new TeleBotException('Cannot cast value of type '.gettype($object).' to type '.static::class); | ||
} | ||
} |
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,17 @@ | ||
<?php | ||
|
||
namespace WeStacks\TeleBot\Objects; | ||
|
||
/** | ||
* The background is a freeform gradient that rotates after every message in the chat. | ||
* | ||
* @property string $type Type of the background fill, always “freeform_gradient” | ||
* @property int[] $colors A list of the 3 or 4 base colors that are used to generate the freeform gradient in the RGB24 format | ||
*/ | ||
class BackgroundFillFreeformGradient extends BackgroundFill | ||
{ | ||
protected $attributes = [ | ||
'type' => 'string', | ||
'colors' => 'integer[]', | ||
]; | ||
} |
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,21 @@ | ||
<?php | ||
|
||
namespace WeStacks\TeleBot\Objects; | ||
|
||
/** | ||
* The background is a gradient fill. | ||
* | ||
* @property string $type Type of the background fill, always “gradient” | ||
* @property int $top_color Top color of the gradient in the RGB24 format | ||
* @property int $bottom_color Bottom color of the gradient in the RGB24 format | ||
* @property int $rotation_angle Clockwise rotation angle of the background fill in degrees; 0-359 | ||
*/ | ||
class BackgroundFillGradient extends BackgroundFill | ||
{ | ||
protected $attributes = [ | ||
'type' => 'string', | ||
'top_color' => 'integer', | ||
'bottom_color' => 'integer', | ||
'rotation_angle' => 'integer', | ||
]; | ||
} |
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,17 @@ | ||
<?php | ||
|
||
namespace WeStacks\TeleBot\Objects; | ||
|
||
/** | ||
* The background is filled using the selected color. | ||
* | ||
* @property string $type Type of the background, always “chat_theme” | ||
* @property int $color The color of the background fill in the RGB24 format | ||
*/ | ||
class BackgroundFillSolid extends BackgroundFill | ||
{ | ||
protected $attributes = [ | ||
'type' => 'string', | ||
'color' => 'integer', | ||
]; | ||
} |
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,35 @@ | ||
<?php | ||
|
||
namespace WeStacks\TeleBot\Objects; | ||
|
||
use WeStacks\TeleBot\Contracts\TelegramObject; | ||
use WeStacks\TeleBot\Exceptions\TeleBotException; | ||
|
||
/** | ||
* This object describes the type of a background. Currently, it can be one of | ||
* | ||
* - [BackgroundTypeFill](https://core.telegram.org/bots/api#backgroundtypefill) | ||
* - [BackgroundTypeWallpaper](https://core.telegram.org/bots/api#backgroundtypewallpaper) | ||
* - [BackgroundTypePattern](https://core.telegram.org/bots/api#backgroundtypepattern) | ||
* - [BackgroundTypeChatTheme](https://core.telegram.org/bots/api#backgroundtypechattheme) | ||
*/ | ||
abstract class BackgroundType extends TelegramObject | ||
{ | ||
protected static $types = [ | ||
'fill' => BackgroundTypeFill::class, | ||
'wallpaper' => BackgroundTypeWallpaper::class, | ||
'pattern' => BackgroundTypePattern::class, | ||
'chat_theme' => BackgroundTypeChatTheme::class, | ||
]; | ||
|
||
public static function create($object) | ||
{ | ||
$object = (array) $object; | ||
|
||
if ($class = static::$types[$object['type'] ?? null] ?? null) { | ||
return new $class($object); | ||
} | ||
|
||
throw new TeleBotException('Cannot cast value of type '.gettype($object).' to type '.static::class); | ||
} | ||
} |
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,17 @@ | ||
<?php | ||
|
||
namespace WeStacks\TeleBot\Objects; | ||
|
||
/** | ||
* The background is taken directly from a built-in chat theme. | ||
* | ||
* @property string $type Type of the background, always “chat_theme” | ||
* @property string $theme_name Name of the chat theme, which is usually an emoji | ||
*/ | ||
class BackgroundTypeChatTheme extends BackgroundType | ||
{ | ||
protected $attributes = [ | ||
'type' => 'string', | ||
'theme_name' => 'string', | ||
]; | ||
} |
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,19 @@ | ||
<?php | ||
|
||
namespace WeStacks\TeleBot\Objects; | ||
|
||
/** | ||
* The background is automatically filled based on the selected colors. | ||
* | ||
* @property string $type The type of the background | ||
* @property BackgroundFillSolid|BackgroundFillGradient|BackgroundFillFreeformGradient $fill The background fill | ||
* @property int $dark_theme_dimming Dimming of the background in dark themes, as a percentage; 0-100 | ||
*/ | ||
class BackgroundTypeFill extends BackgroundType | ||
{ | ||
protected $attributes = [ | ||
'type' => 'string', | ||
'fill' => 'BackgroundFill', | ||
'dark_theme_dimming' => 'integer', | ||
]; | ||
} |
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,25 @@ | ||
<?php | ||
|
||
namespace WeStacks\TeleBot\Objects; | ||
|
||
/** | ||
* 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. | ||
* | ||
* @property string $type Type of the background, always “pattern” | ||
* @property Document $document Document with the pattern | ||
* @property BackgroundFillSolid|BackgroundFillGradient|BackgroundFillFreeformGradient $fill The background fill that is combined with the pattern | ||
* @property int $intensity Intensity of the pattern when it is shown above the filled background; 0-100 | ||
* @property bool $is_inverted 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 | ||
* @property bool $is_moving Optional. True, if the background moves slightly when the device is tilted | ||
*/ | ||
class BackgroundTypePattern extends BackgroundType | ||
{ | ||
protected $attributes = [ | ||
'type' => 'string', | ||
'document' => 'Document', | ||
'fill' => 'BackgroundFill', | ||
'intensity' => 'integer', | ||
'is_inverted' => 'bool', | ||
'is_moving' => 'bool', | ||
]; | ||
} |
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,23 @@ | ||
<?php | ||
|
||
namespace WeStacks\TeleBot\Objects; | ||
|
||
/** | ||
* The background is a wallpaper in the JPEG format. | ||
* | ||
* @property string $type Type of the background, always “wallpaper” | ||
* @property Document $document Document with the wallpaper | ||
* @property int $dark_theme_dimming Dimming of the background in dark themes, as a percentage; 0-100 | ||
* @property bool $is_blurred Optional. True, if the wallpaper is downscaled to fit in a 450x450 square and then box-blurred with radius 12 | ||
* @property bool $is_moving Optional. True, if the background moves slightly when the device is tilted | ||
*/ | ||
class BackgroundTypeWallpaper extends BackgroundType | ||
{ | ||
protected $attributes = [ | ||
'type' => 'string', | ||
'document' => 'Document', | ||
'dark_theme_dimming' => 'integer', | ||
'is_blurred' => 'boolean', | ||
'is_moving' => 'boolean', | ||
]; | ||
} |
Oops, something went wrong.