Commit 4e284cd8 authored by Armando Lüscher's avatar Armando Lüscher Committed by GitHub

Merge pull request #604 from noplanman/bot_api_3.2

Bot API 3.2
parents 309421d7 e6ffc037
...@@ -6,6 +6,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c ...@@ -6,6 +6,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
## [Unreleased] ## [Unreleased]
### Added ### Added
- New entities, methods, update types and inline keyboard button for Payments (Bot API 3.0). - New entities, methods, update types and inline keyboard button for Payments (Bot API 3.0).
- Add new methods, fields and objects for working with stickers (Bot API 3.2).
### Changed ### Changed
- [:exclamation:][unreleased-correct-printerror] Corrected `ServerResponse->printError` method to print by default and return by setting `$return` parameter. - [:exclamation:][unreleased-correct-printerror] Corrected `ServerResponse->printError` method to print by default and return by setting `$return` parameter.
- Ensure command names are handled as lower case. - Ensure command names are handled as lower case.
......
<?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;
}
}
...@@ -60,6 +60,12 @@ use Longman\TelegramBot\Exception\TelegramException; ...@@ -60,6 +60,12 @@ use Longman\TelegramBot\Exception\TelegramException;
* @method static ServerResponse editMessageCaption(array $data) Use this method to edit captions of messages sent by the bot or via the bot (for inline bots). On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned. * @method static ServerResponse editMessageCaption(array $data) Use this method to edit captions of messages sent by the bot or via the bot (for inline bots). On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
* @method static ServerResponse editMessageReplyMarkup(array $data) Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots). On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned. * @method static ServerResponse editMessageReplyMarkup(array $data) Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots). On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
* @method static ServerResponse deleteMessage(array $data) Use this method to delete a message, including service messages, with certain limitations. Returns True on success. * @method static ServerResponse deleteMessage(array $data) Use this method to delete a message, including service messages, with certain limitations. Returns True on success.
* @method static ServerResponse getStickerSet(array $data) Use this method to get a sticker set. On success, a StickerSet object is returned.
* @method static ServerResponse uploadStickerFile(array $data) Use this method to upload a .png file with a sticker for later use in createNewStickerSet and addStickerToSet methods (can be used multiple times). Returns the uploaded File on success.
* @method static ServerResponse createNewStickerSet(array $data) Use this method to create new sticker set owned by a user. The bot will be able to edit the created sticker set. Returns True on success.
* @method static ServerResponse addStickerToSet(array $data) Use this method to add a new sticker to a set created by the bot. Returns True on success.
* @method static ServerResponse setStickerPositionInSet(array $data) Use this method to move a sticker in a set created by the bot to a specific position. Returns True on success.
* @method static ServerResponse deleteStickerFromSet(array $data) Use this method to delete a sticker from a set created by the bot. Returns True on success.
*/ */
class Request class Request
{ {
...@@ -160,6 +166,12 @@ class Request ...@@ -160,6 +166,12 @@ class Request
'editMessageCaption', 'editMessageCaption',
'editMessageReplyMarkup', 'editMessageReplyMarkup',
'deleteMessage', 'deleteMessage',
'getStickerSet',
'uploadStickerFile',
'createNewStickerSet',
'addStickerToSet',
'setStickerPositionInSet',
'deleteStickerFromSet',
]; ];
/** /**
......
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