Add new fields to the Sticker object, plus two new objects, StickerSet, and MaskPosition.

parent 309421d7
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities;
/**
* Class MaskPosition
*
* @link https://core.telegram.org/bots/api#maskposition
*
* @method string getPoint() The part of the face relative to which the mask should be placed. One of “forehead”, “eyes”, “mouth”, or “chin”.
* @method float getXShift() Shift by X-axis measured in widths of the mask scaled to the face size, from left to right. For example, choosing -1.0 will place mask just to the left of the default mask position.
* @method float getYShift() Shift by Y-axis measured in heights of the mask scaled to the face size, from top to bottom. For example, 1.0 will place the mask just below the default mask position.
* @method float getScale() Mask scaling coefficient. For example, 2.0 means double size.
*/
class MaskPosition extends Entity
{
}
...@@ -20,6 +20,8 @@ namespace Longman\TelegramBot\Entities; ...@@ -20,6 +20,8 @@ namespace Longman\TelegramBot\Entities;
* @method int getHeight() Sticker height * @method int getHeight() Sticker height
* @method PhotoSize getThumb() Optional. Sticker thumbnail in .webp or .jpg format * @method PhotoSize getThumb() Optional. Sticker thumbnail in .webp or .jpg format
* @method string getEmoji() Optional. Emoji associated with the sticker * @method string getEmoji() Optional. Emoji associated with the sticker
* @method string getSetName() Optional. Name of the sticker set to which the sticker belongs
* @method MaskPosition getMaskPosition() Optional. For mask stickers, the position where the mask should be placed
* @method int getFileSize() Optional. File size * @method int getFileSize() Optional. File size
*/ */
class Sticker extends Entity class Sticker extends Entity
...@@ -31,6 +33,7 @@ class Sticker extends Entity ...@@ -31,6 +33,7 @@ class Sticker extends Entity
{ {
return [ return [
'thumb' => PhotoSize::class, 'thumb' => PhotoSize::class,
'mask_position' => MaskPosition::class,
]; ];
} }
} }
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Entities;
/**
* Class StickerSet
*
* @link https://core.telegram.org/bots/api#stickerset
*
* @method string getName() Sticker set name
* @method string getTitle() Sticker set title
* @method bool getContainsMasks() True, if the sticker set contains masks
*/
class StickerSet extends Entity
{
/**
* List of all set stickers
*
* This method overrides the default getStickers method and returns a nice array
*
* @return Sticker[]
*/
public function getStickers()
{
$all_stickers = [];
if ($these_stickers = $this->getProperty('stickers')) {
foreach ($these_stickers as $stickers) {
$new_stickers = [];
foreach ($stickers as $sticker) {
$new_stickers[] = new Sticker($sticker);
}
$all_stickers[] = $new_stickers;
}
}
return $all_stickers;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment