|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace TelegramBot\Api\Types\Inline\QueryResult; |
|
4
|
|
|
|
|
5
|
|
|
use TelegramBot\Api\Types\Inline\InlineKeyboardMarkup; |
|
6
|
|
|
use TelegramBot\Api\Types\Inline\InputMessageContent; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Class InlineQueryResultGif |
|
10
|
|
|
* Represents a link to an animated GIF file. |
|
11
|
|
|
* By default, this animated GIF file will be sent by the user with optional caption. |
|
12
|
|
|
* Alternatively, you can provide InputMessageContent to send it instead of the animation. |
|
13
|
|
|
* |
|
14
|
|
|
* @package TelegramBot\Api\Types\Inline |
|
15
|
|
|
*/ |
|
16
|
|
|
class Gif extends AbstractInlineQueryResult |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* {@inheritdoc} |
|
20
|
|
|
* |
|
21
|
|
|
* @var array |
|
22
|
|
|
*/ |
|
23
|
|
|
protected static $requiredParams = ['type', 'id', 'gif_url', 'thumbnail_url']; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* {@inheritdoc} |
|
27
|
|
|
* |
|
28
|
|
|
* @var array |
|
29
|
|
|
*/ |
|
30
|
|
|
protected static $map = [ |
|
31
|
|
|
'type' => true, |
|
32
|
|
|
'id' => true, |
|
33
|
|
|
'gif_url' => true, |
|
34
|
|
|
'gif_width' => true, |
|
35
|
|
|
'gif_height' => true, |
|
36
|
|
|
'thumbnail_url' => true, |
|
37
|
|
|
'title' => true, |
|
38
|
|
|
'caption' => true, |
|
39
|
|
|
'reply_markup' => InlineKeyboardMarkup::class, |
|
40
|
|
|
'input_message_content' => InputMessageContent::class, |
|
41
|
|
|
]; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* {@inheritdoc} |
|
45
|
|
|
* |
|
46
|
|
|
* @var string |
|
47
|
|
|
*/ |
|
48
|
|
|
protected $type = 'gif'; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* A valid URL for the GIF file. File size must not exceed 1MB |
|
52
|
|
|
* |
|
53
|
|
|
* @var string |
|
54
|
|
|
*/ |
|
55
|
|
|
protected $gifUrl; |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Optional. Width of the GIF |
|
59
|
|
|
* |
|
60
|
|
|
* @var int|null |
|
61
|
|
|
*/ |
|
62
|
|
|
protected $gifWidth; |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Optional. Height of the GIF |
|
66
|
|
|
* |
|
67
|
|
|
* @var int|null |
|
68
|
|
|
*/ |
|
69
|
|
|
protected $gifHeight; |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* URL of the static thumbnail for the result (jpeg or gif) |
|
73
|
|
|
* |
|
74
|
|
|
* @var string |
|
75
|
|
|
*/ |
|
76
|
|
|
protected $thumbnailUrl; |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* Optional. Caption of the GIF file to be sent, 0-200 characters |
|
80
|
|
|
* |
|
81
|
|
|
* @var string|null |
|
82
|
|
|
*/ |
|
83
|
|
|
protected $caption; |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* InlineQueryResultGif constructor. |
|
87
|
|
|
* |
|
88
|
|
|
* @param string $id |
|
89
|
|
|
* @param string $gifUrl |
|
90
|
|
|
* @param string|null $thumbnailUrl |
|
91
|
|
|
* @param int|null $gifWidth |
|
92
|
|
|
* @param int|null $gifHeight |
|
93
|
|
|
* @param string|null $title |
|
94
|
|
|
* @param string|null $caption |
|
95
|
|
|
* @param InputMessageContent $inputMessageContent |
|
96
|
|
|
* @param InlineKeyboardMarkup|null $inlineKeyboardMarkup |
|
97
|
|
|
*/ |
|
98
|
|
|
public function __construct( |
|
99
|
|
|
$id, |
|
100
|
|
|
$gifUrl, |
|
101
|
|
|
$thumbnailUrl = null, |
|
102
|
|
|
$title = null, |
|
103
|
|
|
$caption = null, |
|
104
|
|
|
$gifWidth = null, |
|
105
|
|
|
$gifHeight = null, |
|
106
|
|
|
$inputMessageContent = null, |
|
107
|
|
|
$inlineKeyboardMarkup = null |
|
108
|
|
|
) { |
|
109
|
|
|
parent::__construct($id, $title, $inputMessageContent, $inlineKeyboardMarkup); |
|
110
|
|
|
|
|
111
|
|
|
$this->gifUrl = $gifUrl; |
|
112
|
|
|
$this->thumbnailUrl = is_null($thumbnailUrl) ? $gifUrl : $thumbnailUrl; |
|
113
|
|
|
$this->gifWidth = $gifWidth; |
|
114
|
|
|
$this->gifHeight = $gifHeight; |
|
115
|
|
|
$this->caption = $caption; |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
/** |
|
119
|
|
|
* @return string |
|
120
|
|
|
*/ |
|
121
|
|
|
public function getGifUrl() |
|
122
|
|
|
{ |
|
123
|
|
|
return $this->gifUrl; |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
/** |
|
127
|
|
|
* @param string $gifUrl |
|
128
|
|
|
* |
|
129
|
|
|
* @return void |
|
130
|
|
|
*/ |
|
131
|
|
|
public function setGifUrl($gifUrl) |
|
132
|
|
|
{ |
|
133
|
|
|
$this->gifUrl = $gifUrl; |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
/** |
|
137
|
|
|
* @return int|null |
|
138
|
|
|
*/ |
|
139
|
|
|
public function getGifWidth() |
|
140
|
|
|
{ |
|
141
|
|
|
return $this->gifWidth; |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
/** |
|
145
|
|
|
* @param int|null $gifWidth |
|
146
|
|
|
* |
|
147
|
|
|
* @return void |
|
148
|
|
|
*/ |
|
149
|
|
|
public function setGifWidth($gifWidth) |
|
150
|
|
|
{ |
|
151
|
|
|
$this->gifWidth = $gifWidth; |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
/** |
|
155
|
|
|
* @return int|null |
|
156
|
|
|
*/ |
|
157
|
|
|
public function getGifHeight() |
|
158
|
|
|
{ |
|
159
|
|
|
return $this->gifHeight; |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
/** |
|
163
|
|
|
* @param int|null $gifHeight |
|
164
|
|
|
* |
|
165
|
|
|
* @return void |
|
166
|
|
|
*/ |
|
167
|
|
|
public function setGifHeight($gifHeight) |
|
168
|
|
|
{ |
|
169
|
|
|
$this->gifHeight = $gifHeight; |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
|
|
/** |
|
173
|
|
|
* @return string |
|
174
|
|
|
*/ |
|
175
|
|
|
public function getThumbnailUrl() |
|
176
|
|
|
{ |
|
177
|
|
|
return $this->thumbnailUrl; |
|
178
|
|
|
} |
|
179
|
|
|
|
|
180
|
|
|
/** |
|
181
|
|
|
* @param string $thumbnailUrl |
|
182
|
|
|
* |
|
183
|
|
|
* @return void |
|
184
|
|
|
*/ |
|
185
|
|
|
public function setThumbnailUrl($thumbnailUrl) |
|
186
|
|
|
{ |
|
187
|
|
|
$this->thumbnailUrl = $thumbnailUrl; |
|
188
|
|
|
} |
|
189
|
|
|
|
|
190
|
|
|
/** |
|
191
|
|
|
* @deprecated Use getThumbnailUrl |
|
192
|
|
|
* |
|
193
|
|
|
* @return string |
|
194
|
|
|
*/ |
|
195
|
|
|
public function getThumbUrl() |
|
196
|
|
|
{ |
|
197
|
|
|
return $this->getThumbnailUrl(); |
|
198
|
|
|
} |
|
199
|
|
|
|
|
200
|
|
|
/** |
|
201
|
|
|
* @deprecated Use setThumbnailUrl |
|
202
|
|
|
* |
|
203
|
|
|
* @param string $thumbUrl |
|
204
|
|
|
* |
|
205
|
|
|
* @return void |
|
206
|
|
|
*/ |
|
207
|
|
|
public function setThumbUrl($thumbUrl) |
|
208
|
|
|
{ |
|
209
|
|
|
$this->setThumbnailUrl($thumbUrl); |
|
210
|
|
|
} |
|
211
|
|
|
|
|
212
|
|
|
/** |
|
213
|
|
|
* @return string|null |
|
214
|
|
|
*/ |
|
215
|
|
|
public function getCaption() |
|
216
|
|
|
{ |
|
217
|
|
|
return $this->caption; |
|
218
|
|
|
} |
|
219
|
|
|
|
|
220
|
|
|
/** |
|
221
|
|
|
* @param string|null $caption |
|
222
|
|
|
* |
|
223
|
|
|
* @return void |
|
224
|
|
|
*/ |
|
225
|
|
|
public function setCaption($caption) |
|
226
|
|
|
{ |
|
227
|
|
|
$this->caption = $caption; |
|
228
|
|
|
} |
|
229
|
|
|
} |
|
230
|
|
|
|