-
Notifications
You must be signed in to change notification settings - Fork 325
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
1 parent
6d0d893
commit cfde76a
Showing
5 changed files
with
243 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
namespace TelegramBot\Api; | ||
|
||
use TelegramBot\Api\Types\InputSticker; | ||
use TelegramBot\Api\Http\CurlHttpClient; | ||
use TelegramBot\Api\Types\UserChatBoosts; | ||
use TelegramBot\Api\Types\ReplyParameters; | ||
|
@@ -3248,6 +3249,33 @@ public function getBusinessConnection($businessConnectionId) | |
])); | ||
} | ||
|
||
/** | ||
* Use this method to replace an existing sticker in a sticker set with a new one. | ||
* The method is equivalent to calling deleteStickerFromSet, then addStickerToSet, then setStickerPositionInSet. | ||
* Returns True on success. | ||
* | ||
* @param int $userId User identifier of the sticker set owner | ||
* @param string $name Sticker set name | ||
* @param string $oldSticker File identifier of the replaced sticker | ||
* @param InputSticker $sticker A JSON-serialized object with information about the added sticker. | ||
* If exactly the same sticker had already been added to the set, then the set remains unchanged. | ||
* | ||
* @return bool | ||
* @throws Exception | ||
* | ||
* @since Bot API 7.2 | ||
* @auther bernard-ng <[email protected]> | ||
*/ | ||
public function replaceStickerInSet($userId, $name, $oldSticker, $sticker) | ||
{ | ||
return $this->call('replaceStickerInSet', [ | ||
'user_id' => $userId, | ||
'name' => $name, | ||
'old_sticker' => $oldSticker, | ||
'sticker' => $sticker | ||
]); | ||
} | ||
|
||
/** | ||
* Set an option for a cURL transfer | ||
* | ||
|
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,164 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace TelegramBot\Api\Types; | ||
|
||
use TelegramBot\Api\BaseType; | ||
use TelegramBot\Api\TypeInterface; | ||
|
||
/** | ||
* Class InputSticker. | ||
* This object describes a sticker to be added to a sticker set. | ||
* | ||
* @author bernard-ng <[email protected]> | ||
*/ | ||
class InputSticker extends BaseType implements TypeInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
* | ||
* @var array | ||
*/ | ||
protected static $requiredParams = ['sticker', 'format', 'emoji_list']; | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @var array | ||
*/ | ||
protected static $map = [ | ||
'sticker' => true, | ||
'format' => true, | ||
'emoji_list' => true, | ||
'mask_position' => MaskPosition::class, | ||
'keywords' => true, | ||
]; | ||
|
||
/** | ||
* The added sticker. | ||
* Pass a file_id as a String to send a file that already exists on the Telegram servers, | ||
* pass an HTTP URL as a String for Telegram to get a file from the Internet, | ||
* upload a new one using multipart/form-data, or pass βattach://<file_attach_name>β to upload a new one using multipart/form-data under <file_attach_name> name. | ||
* Animated and video stickers can't be uploaded via HTTP URL. | ||
* | ||
* @var string | ||
* @see https://core.telegram.org/bots/api#sending-files | ||
*/ | ||
protected string $sticker; | ||
|
||
/** | ||
* Format of the added sticker, must be one of βstaticβ | ||
* for a .WEBP or .PNG image, βanimatedβ for a .TGS animation, βvideoβ for a WEBM video | ||
* | ||
* @var string | ||
*/ | ||
protected string $format; | ||
|
||
/** | ||
* List of 1-20 emoji associated with the sticker | ||
* | ||
* @var string[] | ||
*/ | ||
protected array $emojiList; | ||
|
||
/** | ||
* Optional. Position where the mask should be placed on faces. For βmaskβ stickers only. | ||
* | ||
* @var MaskPosition|null | ||
*/ | ||
protected $maskPosition; | ||
|
||
/** | ||
* Optional. List of 0-20 search keywords for the sticker with total length of up to 64 characters. | ||
* For βregularβ and βcustom_emojiβ stickers only. | ||
* | ||
* @var string[] | ||
*/ | ||
protected $keywords; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getSticker() | ||
{ | ||
return $this->sticker; | ||
} | ||
|
||
/** | ||
* @param string $sticker | ||
* @return void | ||
*/ | ||
public function setSticker(string $sticker) | ||
{ | ||
$this->sticker = $sticker; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getFormat() | ||
{ | ||
return $this->format; | ||
} | ||
|
||
/** | ||
* @param string $format | ||
* @return void | ||
*/ | ||
public function setFormat(string $format) | ||
{ | ||
$this->format = $format; | ||
} | ||
|
||
/** | ||
* @return string[] | ||
*/ | ||
public function getEmojiList() | ||
{ | ||
return $this->emojiList; | ||
} | ||
|
||
/** | ||
* @param string[] $emojiList | ||
* @return void | ||
*/ | ||
public function setEmojiList(array $emojiList) | ||
{ | ||
$this->emojiList = $emojiList; | ||
} | ||
|
||
/** | ||
* @return MaskPosition|null | ||
*/ | ||
public function getMaskPosition() | ||
{ | ||
return $this->maskPosition; | ||
} | ||
|
||
/** | ||
* @param MaskPosition|null $maskPosition | ||
* @return void | ||
*/ | ||
public function setMaskPosition($maskPosition) | ||
{ | ||
$this->maskPosition = $maskPosition; | ||
} | ||
|
||
/** | ||
* @return string[] | ||
*/ | ||
public function getKeywords() | ||
{ | ||
return $this->keywords; | ||
} | ||
|
||
/** | ||
* @param string[] $keywords | ||
* @return void | ||
*/ | ||
public function setKeywords(array $keywords) | ||
{ | ||
$this->keywords = $keywords; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,7 +1,5 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace TelegramBot\Api\Test\Types; | ||
|
||
use TelegramBot\Api\Test\AbstractTypeTest; | ||
|
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,50 @@ | ||
<?php | ||
|
||
namespace TelegramBot\Api\Test\Types; | ||
|
||
use TelegramBot\Api\Types\InputSticker; | ||
use TelegramBot\Api\Test\AbstractTypeTest; | ||
|
||
class InputStickerTest extends AbstractTypeTest | ||
{ | ||
protected static function getType() | ||
{ | ||
return InputSticker::class; | ||
} | ||
|
||
public static function getMinResponse() | ||
{ | ||
return [ | ||
'sticker' => 'file', | ||
'format' => 'static', | ||
'emoji_list' => ['π'] | ||
]; | ||
} | ||
|
||
public static function getFullResponse() | ||
{ | ||
return [ | ||
'sticker' => 'file', | ||
'format' => 'static', | ||
'emoji_list' => ['π'], | ||
'mask_position' => MaskPositionTest::getMinResponse(), | ||
'keywords' => ['keywords'] | ||
]; | ||
} | ||
|
||
protected function assertMinItem($item) | ||
{ | ||
$this->assertEquals('file', $item->getSticker()); | ||
$this->assertEquals('static', $item->getFormat()); | ||
$this->assertEquals(['π'], $item->getEmojiList()); | ||
} | ||
|
||
protected function assertFullItem($item) | ||
{ | ||
$this->assertEquals('file', $item->getSticker()); | ||
$this->assertEquals('static', $item->getFormat()); | ||
$this->assertEquals(['π'], $item->getEmojiList()); | ||
$this->assertEquals(MaskPositionTest::createMinInstance(), $item->getMaskPosition()); | ||
$this->assertEquals(['keywords'], $item->getKeywords()); | ||
} | ||
} |