1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace TgBotApi\BotApiBase\Method; |
6
|
|
|
|
7
|
|
|
use TgBotApi\BotApiBase\Method\Interfaces\AddMethodAliasInterface; |
8
|
|
|
use TgBotApi\BotApiBase\Method\Traits\EmojisVariableTrait; |
9
|
|
|
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait; |
10
|
|
|
use TgBotApi\BotApiBase\Type\InputFileType; |
11
|
|
|
use TgBotApi\BotApiBase\Type\MaskPositionType; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Class AddStickerToSetMethod. |
15
|
|
|
* |
16
|
|
|
* @see https://core.telegram.org/bots/api#addstickertoset |
17
|
|
|
*/ |
18
|
|
|
class AddStickerToSetMethod implements AddMethodAliasInterface |
19
|
|
|
{ |
20
|
|
|
use FillFromArrayTrait; |
21
|
|
|
use EmojisVariableTrait; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* User identifier of sticker set owner. |
25
|
|
|
* |
26
|
|
|
* @var int |
27
|
|
|
*/ |
28
|
|
|
public $userId; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Sticker set name. |
32
|
|
|
* |
33
|
|
|
* @var string |
34
|
|
|
*/ |
35
|
|
|
public $name; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Optional. Png image with the sticker, must be up to 512 kilobytes in size, |
39
|
|
|
* dimensions must not exceed 512px, and either width or height must be exactly 512px. |
40
|
|
|
* Pass a file_id as a String to send a file that already exists on the Telegram servers, |
41
|
|
|
* pass an HTTP URL as a String for Telegram to get a file from the Internet, |
42
|
|
|
* or upload a new one using multipart/form-data. |
43
|
|
|
* |
44
|
|
|
* @var InputFileType|string|null |
45
|
|
|
*/ |
46
|
|
|
public $pngSticker; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Optional. TGS animation with the sticker, uploaded using multipart/form-data. |
50
|
|
|
* See https://core.telegram.org/animated_stickers#technical-requirements for technical requirements. |
51
|
|
|
* |
52
|
|
|
* @var InputFileType|null |
53
|
|
|
*/ |
54
|
|
|
public $tgsSticker; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Optional. A JSON-serialized object for position where the mask should be placed on faces. |
58
|
|
|
* |
59
|
|
|
* @var MaskPositionType|null |
60
|
|
|
*/ |
61
|
|
|
public $maskPosition; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @param InputFileType|string $pngSticker |
65
|
|
|
* |
66
|
|
|
* @throws \TgBotApi\BotApiBase\Exception\BadArgumentException |
67
|
|
|
* |
68
|
|
|
* @deprecated |
69
|
|
|
* @see AddStickerToSetMethod::createStatic() |
70
|
|
|
*/ |
71
|
1 |
|
public static function create( |
72
|
|
|
int $userId, |
73
|
|
|
string $name, |
74
|
|
|
$pngSticker, |
75
|
|
|
string $emojis, |
76
|
|
|
array $data = null |
77
|
|
|
): AddStickerToSetMethod { |
78
|
1 |
|
return static::createStatic($userId, $name, $pngSticker, $emojis, $data); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @param InputFileType|string $pngSticker |
83
|
|
|
* |
84
|
|
|
* @throws \TgBotApi\BotApiBase\Exception\BadArgumentException |
85
|
|
|
*/ |
86
|
1 |
|
public static function createStatic( |
87
|
|
|
int $userId, |
88
|
|
|
string $name, |
89
|
|
|
$pngSticker, |
90
|
|
|
string $emojis, |
91
|
|
|
array $data = null |
92
|
|
|
): AddStickerToSetMethod { |
93
|
1 |
|
$instance = static::createBase($userId, $name, $emojis, $data); |
94
|
1 |
|
$instance->pngSticker = $pngSticker; |
95
|
|
|
|
96
|
1 |
|
return $instance; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @throws \TgBotApi\BotApiBase\Exception\BadArgumentException |
101
|
|
|
*/ |
102
|
1 |
|
public static function createAnimated( |
103
|
|
|
int $userId, |
104
|
|
|
string $name, |
105
|
|
|
InputFileType $tgsSticker, |
106
|
|
|
string $emojis, |
107
|
|
|
array $data = null |
108
|
|
|
): AddStickerToSetMethod { |
109
|
1 |
|
$instance = static::createBase($userId, $name, $emojis, $data); |
110
|
1 |
|
$instance->tgsSticker = $tgsSticker; |
111
|
|
|
|
112
|
1 |
|
return $instance; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @throws \TgBotApi\BotApiBase\Exception\BadArgumentException |
117
|
|
|
*/ |
118
|
2 |
|
private static function createBase( |
119
|
|
|
int $userId, |
120
|
|
|
string $name, |
121
|
|
|
string $emojis, |
122
|
|
|
array $data = null |
123
|
|
|
): AddStickerToSetMethod { |
124
|
2 |
|
$instance = new static(); |
125
|
2 |
|
$instance->userId = $userId; |
126
|
2 |
|
$instance->name = $name; |
127
|
2 |
|
$instance->emojis = $emojis; |
128
|
2 |
|
if ($data) { |
129
|
2 |
|
$instance->fill($data); |
130
|
|
|
} |
131
|
|
|
|
132
|
2 |
|
return $instance; |
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
|