1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types = 1); |
4
|
|
|
|
5
|
|
|
namespace unreal4u\TelegramAPI\Telegram\Methods; |
6
|
|
|
|
7
|
|
|
use Generator; |
8
|
|
|
use Psr\Log\LoggerInterface; |
9
|
|
|
use unreal4u\TelegramAPI\Abstracts\TelegramMethods; |
10
|
|
|
use unreal4u\TelegramAPI\Abstracts\TelegramTypes; |
11
|
|
|
use unreal4u\TelegramAPI\InternalFunctionality\TelegramResponse; |
12
|
|
|
use unreal4u\TelegramAPI\Telegram\Types\Custom\InputFile; |
13
|
|
|
use unreal4u\TelegramAPI\Telegram\Types\Custom\ResultBoolean; |
14
|
|
|
use unreal4u\TelegramAPI\Telegram\Types\MaskPosition; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Use this method to add a new sticker to a set created by the bot. Returns True on success |
18
|
|
|
* |
19
|
|
|
* Objects defined as-is july 2017 |
20
|
|
|
* |
21
|
|
|
* @see https://core.telegram.org/bots/api#addstickertoset |
22
|
|
|
*/ |
23
|
|
|
class AddStickerToSet extends TelegramMethods |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* User identifier of created sticker set owner |
27
|
|
|
* @var int |
28
|
|
|
*/ |
29
|
|
|
public $user_id = 0; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only english |
33
|
|
|
* letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in |
34
|
|
|
* "_by_<bot username>". <bot_username> is case insensitive. 1-64 characters |
35
|
|
|
* @var string |
36
|
|
|
*/ |
37
|
|
|
public $name = ''; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either |
41
|
|
|
* width or height must be exactly 512px. Pass a file_id as a String to send a file that already exists on the |
42
|
|
|
* Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one |
43
|
|
|
* using multipart/form-data |
44
|
|
|
* @var string|InputFile |
45
|
|
|
*/ |
46
|
|
|
public $png_sticker; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* One or more emoji corresponding to the sticker |
50
|
|
|
* @var string |
51
|
|
|
*/ |
52
|
|
|
public $emojis = ''; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Position where the mask should be placed on faces |
56
|
|
|
* @var MaskPosition |
57
|
|
|
*/ |
58
|
|
|
public $mask_position; |
59
|
|
|
|
60
|
|
|
public static function bindToObject(TelegramResponse $data, LoggerInterface $logger): TelegramTypes |
61
|
|
|
{ |
62
|
|
|
return new ResultBoolean($data->getResultBoolean(), $logger); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function getMandatoryFields(): array |
66
|
|
|
{ |
67
|
|
|
return [ |
68
|
|
|
'user_id', |
69
|
|
|
'name', |
70
|
|
|
'png_sticker', |
71
|
|
|
'emojis', |
72
|
|
|
]; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function hasLocalFiles(): bool |
76
|
|
|
{ |
77
|
|
|
return $this->png_sticker instanceof InputFile; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public function getLocalFiles(): Generator |
81
|
|
|
{ |
82
|
|
|
yield 'png_sticker' => $this->png_sticker; |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|