1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace TelegramBot\Api; |
4
|
|
|
|
5
|
|
|
use TelegramBot\Api\Http\CurlHttpClient; |
6
|
|
|
use TelegramBot\Api\Http\HttpClientInterface; |
7
|
|
|
use TelegramBot\Api\Types\ArrayOfBotCommand; |
8
|
|
|
use TelegramBot\Api\Types\ArrayOfChatMemberEntity; |
9
|
|
|
use TelegramBot\Api\Types\ArrayOfMessageEntity; |
10
|
|
|
use TelegramBot\Api\Types\ArrayOfMessages; |
11
|
|
|
use TelegramBot\Api\Types\ArrayOfSticker; |
12
|
|
|
use TelegramBot\Api\Types\ArrayOfUpdates; |
13
|
|
|
use TelegramBot\Api\Types\BotCommand; |
14
|
|
|
use TelegramBot\Api\Types\Chat; |
15
|
|
|
use TelegramBot\Api\Types\ChatInviteLink; |
16
|
|
|
use TelegramBot\Api\Types\ChatMember; |
17
|
|
|
use TelegramBot\Api\Types\File; |
18
|
|
|
use TelegramBot\Api\Types\ForceReply; |
19
|
|
|
use TelegramBot\Api\Types\ForumTopic; |
20
|
|
|
use TelegramBot\Api\Types\Inline\InlineKeyboardMarkup; |
21
|
|
|
use TelegramBot\Api\Types\Inline\QueryResult\AbstractInlineQueryResult; |
22
|
|
|
use TelegramBot\Api\Types\InputMedia\ArrayOfInputMedia; |
23
|
|
|
use TelegramBot\Api\Types\InputMedia\InputMedia; |
24
|
|
|
use TelegramBot\Api\Types\MaskPosition; |
25
|
|
|
use TelegramBot\Api\Types\Message; |
26
|
|
|
use TelegramBot\Api\Types\MessageId; |
27
|
|
|
use TelegramBot\Api\Types\Poll; |
28
|
|
|
use TelegramBot\Api\Types\ReplyKeyboardMarkup; |
29
|
|
|
use TelegramBot\Api\Types\ReplyKeyboardRemove; |
30
|
|
|
use TelegramBot\Api\Types\SentWebAppMessage; |
31
|
|
|
use TelegramBot\Api\Types\Sticker; |
32
|
|
|
use TelegramBot\Api\Types\StickerSet; |
33
|
|
|
use TelegramBot\Api\Types\Update; |
34
|
|
|
use TelegramBot\Api\Types\User; |
35
|
|
|
use TelegramBot\Api\Types\UserProfilePhotos; |
36
|
|
|
use TelegramBot\Api\Types\WebhookInfo; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Class BotApi |
40
|
|
|
* |
41
|
|
|
* @package TelegramBot\Api |
42
|
|
|
*/ |
43
|
|
|
class BotApi |
44
|
|
|
{ |
45
|
|
|
/** |
46
|
|
|
* @deprecated |
47
|
|
|
* |
48
|
|
|
* HTTP codes |
49
|
|
|
* |
50
|
|
|
* @var array |
51
|
|
|
*/ |
52
|
|
|
public static $codes = [ |
53
|
|
|
// Informational 1xx |
54
|
|
|
100 => 'Continue', |
55
|
|
|
101 => 'Switching Protocols', |
56
|
|
|
102 => 'Processing', // RFC2518 |
57
|
|
|
// Success 2xx |
58
|
|
|
200 => 'OK', |
59
|
|
|
201 => 'Created', |
60
|
|
|
202 => 'Accepted', |
61
|
|
|
203 => 'Non-Authoritative Information', |
62
|
|
|
204 => 'No Content', |
63
|
|
|
205 => 'Reset Content', |
64
|
|
|
206 => 'Partial Content', |
65
|
|
|
207 => 'Multi-Status', // RFC4918 |
66
|
|
|
208 => 'Already Reported', // RFC5842 |
67
|
|
|
226 => 'IM Used', // RFC3229 |
68
|
|
|
// Redirection 3xx |
69
|
|
|
300 => 'Multiple Choices', |
70
|
|
|
301 => 'Moved Permanently', |
71
|
|
|
302 => 'Found', // 1.1 |
72
|
|
|
303 => 'See Other', |
73
|
|
|
304 => 'Not Modified', |
74
|
|
|
305 => 'Use Proxy', |
75
|
|
|
// 306 is deprecated but reserved |
76
|
|
|
307 => 'Temporary Redirect', |
77
|
|
|
308 => 'Permanent Redirect', // RFC7238 |
78
|
|
|
// Client Error 4xx |
79
|
|
|
400 => 'Bad Request', |
80
|
|
|
401 => 'Unauthorized', |
81
|
|
|
402 => 'Payment Required', |
82
|
|
|
403 => 'Forbidden', |
83
|
|
|
404 => 'Not Found', |
84
|
|
|
405 => 'Method Not Allowed', |
85
|
|
|
406 => 'Not Acceptable', |
86
|
|
|
407 => 'Proxy Authentication Required', |
87
|
|
|
408 => 'Request Timeout', |
88
|
|
|
409 => 'Conflict', |
89
|
|
|
410 => 'Gone', |
90
|
|
|
411 => 'Length Required', |
91
|
|
|
412 => 'Precondition Failed', |
92
|
|
|
413 => 'Payload Too Large', |
93
|
|
|
414 => 'URI Too Long', |
94
|
|
|
415 => 'Unsupported Media Type', |
95
|
|
|
416 => 'Range Not Satisfiable', |
96
|
|
|
417 => 'Expectation Failed', |
97
|
|
|
422 => 'Unprocessable Entity', // RFC4918 |
98
|
|
|
423 => 'Locked', // RFC4918 |
99
|
|
|
424 => 'Failed Dependency', // RFC4918 |
100
|
|
|
425 => 'Reserved for WebDAV advanced collections expired proposal', // RFC2817 |
101
|
|
|
426 => 'Upgrade Required', // RFC2817 |
102
|
|
|
428 => 'Precondition Required', // RFC6585 |
103
|
|
|
429 => 'Too Many Requests', // RFC6585 |
104
|
|
|
431 => 'Request Header Fields Too Large', // RFC6585 |
105
|
|
|
// Server Error 5xx |
106
|
|
|
500 => 'Internal Server Error', |
107
|
|
|
501 => 'Not Implemented', |
108
|
|
|
502 => 'Bad Gateway', |
109
|
|
|
503 => 'Service Unavailable', |
110
|
|
|
504 => 'Gateway Timeout', |
111
|
|
|
505 => 'HTTP Version Not Supported', |
112
|
|
|
506 => 'Variant Also Negotiates (Experimental)', // RFC2295 |
113
|
|
|
507 => 'Insufficient Storage', // RFC4918 |
114
|
|
|
508 => 'Loop Detected', // RFC5842 |
115
|
|
|
510 => 'Not Extended', // RFC2774 |
116
|
|
|
511 => 'Network Authentication Required', // RFC6585 |
117
|
|
|
]; |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* Url prefixes |
121
|
|
|
*/ |
122
|
|
|
const URL_PREFIX = 'https://api.telegram.org/bot'; |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* Url prefix for files |
126
|
|
|
*/ |
127
|
|
|
const FILE_URL_PREFIX = 'https://api.telegram.org/file/bot'; |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @deprecated |
131
|
|
|
* |
132
|
|
|
* Default http status code |
133
|
|
|
*/ |
134
|
|
|
const DEFAULT_STATUS_CODE = 200; |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @deprecated |
138
|
|
|
* |
139
|
|
|
* Not Modified http status code |
140
|
|
|
*/ |
141
|
|
|
const NOT_MODIFIED_STATUS_CODE = 304; |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* @deprecated |
145
|
|
|
* |
146
|
|
|
* Limits for tracked ids |
147
|
|
|
*/ |
148
|
|
|
const MAX_TRACKED_EVENTS = 200; |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* @var HttpClientInterface |
152
|
|
|
*/ |
153
|
|
|
private $httpClient; |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* @var string |
157
|
|
|
*/ |
158
|
|
|
private $token; |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* @var string |
162
|
|
|
*/ |
163
|
|
|
private $endpoint; |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* @var string|null |
167
|
|
|
*/ |
168
|
|
|
private $fileEndpoint; |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* @deprecated |
172
|
|
|
* |
173
|
|
|
* Botan tracker |
174
|
|
|
* |
175
|
|
|
* @var Botan|null |
176
|
|
|
*/ |
177
|
|
|
protected $tracker; |
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* @deprecated |
181
|
|
|
* |
182
|
|
|
* list of event ids |
183
|
|
|
* |
184
|
|
|
* @var array |
185
|
|
|
*/ |
186
|
|
|
protected $trackedEvents = []; |
187
|
|
|
|
188
|
9 |
|
/** |
189
|
|
|
* @param string $token Telegram Bot API token |
190
|
9 |
|
* @param string|null $trackerToken Yandex AppMetrica application api_key |
191
|
9 |
|
* @param HttpClientInterface|null $httpClient |
192
|
|
|
* @param string|null $endpoint |
193
|
9 |
|
*/ |
194
|
|
|
public function __construct($token, $trackerToken = null, HttpClientInterface $httpClient = null, $endpoint = null) |
195
|
|
|
{ |
196
|
9 |
|
$this->token = $token; |
197
|
|
|
$this->endpoint = ($endpoint ?: self::URL_PREFIX) . $token; |
198
|
|
|
$this->fileEndpoint = $endpoint ? null : (self::FILE_URL_PREFIX . $token); |
199
|
|
|
|
200
|
|
|
$this->httpClient = $httpClient ?: new CurlHttpClient(); |
201
|
|
|
|
202
|
|
|
if ($trackerToken) { |
203
|
|
|
@trigger_error(sprintf('Passing $trackerToken to %s is deprecated', self::class), \E_USER_DEPRECATED); |
204
|
|
|
$this->tracker = new Botan($trackerToken); |
|
|
|
|
205
|
|
|
} |
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
/** |
209
|
|
|
* @param string $rawData |
210
|
|
|
* @param int|null $authDateDiff |
211
|
|
|
* @return bool |
212
|
|
|
*/ |
213
|
|
|
public function validateWebAppData($rawData, $authDateDiff = null) |
214
|
|
|
{ |
215
|
|
|
parse_str($rawData, $data); |
216
|
|
|
|
217
|
|
|
$sign = $data['hash']; |
218
|
|
|
unset($data['hash']); |
219
|
|
|
|
220
|
|
|
if ($authDateDiff && (time() - $data['auth_date'] > $authDateDiff)) { |
|
|
|
|
221
|
|
|
return false; |
222
|
|
|
} |
223
|
|
|
|
224
|
|
|
ksort($data); |
225
|
|
|
$checkString = ''; |
226
|
|
|
foreach ($data as $k => $v) { |
227
|
|
|
$checkString .= "$k=$v\n"; |
228
|
|
|
} |
229
|
|
|
$checkString = trim($checkString); |
230
|
|
|
|
231
|
|
|
$secret = hash_hmac('sha256', $this->token, 'WebAppData', true); |
232
|
|
|
|
233
|
|
|
return bin2hex(hash_hmac('sha256', $checkString, $secret, true)) === $sign; |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
/** |
237
|
|
|
* @deprecated |
238
|
|
|
* |
239
|
|
|
* Set return array |
240
|
|
|
* |
241
|
|
|
* @param bool $mode |
242
|
|
|
* |
243
|
|
|
* @return $this |
244
|
|
|
*/ |
245
|
|
|
public function setModeObject($mode = true) |
246
|
|
|
{ |
247
|
|
|
@trigger_error(sprintf('Method "%s::%s" is deprecated', __CLASS__, __METHOD__), \E_USER_DEPRECATED); |
248
|
|
|
|
249
|
|
|
return $this; |
250
|
|
|
} |
251
|
|
|
|
252
|
|
|
/** |
253
|
|
|
* @deprecated |
254
|
|
|
* |
255
|
|
|
* Call method |
256
|
|
|
* |
257
|
|
|
* @param string $method |
258
|
|
|
* @param array|null $data |
259
|
|
|
* @param int|null $timeout |
260
|
|
|
* |
261
|
|
|
* @return mixed |
262
|
|
|
* @throws Exception |
263
|
|
|
* @throws HttpException |
264
|
|
|
* @throws InvalidJsonException |
265
|
|
|
*/ |
266
|
|
|
public function call($method, array $data = null, $timeout = null) |
267
|
|
|
{ |
268
|
|
|
if ($timeout !== null) { |
269
|
|
|
@trigger_error(sprintf('Passing $timeout parameter in %s::%s is deprecated. Use http client options', __CLASS__, __METHOD__), \E_USER_DEPRECATED); |
270
|
|
|
} |
271
|
|
|
|
272
|
|
|
$endpoint = $this->endpoint . '/' . $method; |
273
|
|
|
|
274
|
|
|
return $this->httpClient->request($endpoint, $data); |
275
|
|
|
} |
276
|
|
|
|
277
|
|
|
/** |
278
|
|
|
* Get file contents via cURL |
279
|
|
|
* |
280
|
|
|
* @param string $fileId |
281
|
|
|
* |
282
|
|
|
* @return string |
283
|
|
|
* |
284
|
|
|
* @throws HttpException |
285
|
|
|
* @throws Exception |
286
|
|
|
*/ |
287
|
|
|
public function downloadFile($fileId) |
288
|
|
|
{ |
289
|
|
|
$file = $this->getFile($fileId); |
290
|
|
|
if (!$path = $file->getFilePath()) { |
291
|
|
|
throw new Exception('Empty file_path property'); |
292
|
|
|
} |
293
|
|
|
if (!$this->fileEndpoint) { |
294
|
|
|
return file_get_contents($path); |
295
|
|
|
} |
296
|
|
|
|
297
|
|
|
return $this->httpClient->download($this->fileEndpoint . '/' . $path); |
298
|
|
|
} |
299
|
|
|
|
300
|
|
|
/** |
301
|
|
|
* @deprecated |
302
|
|
|
* |
303
|
|
|
* Response validation |
304
|
|
|
* |
305
|
|
|
* @param resource $curl |
306
|
|
|
* @param string|false|null $response |
307
|
|
|
* |
308
|
|
|
* @throws HttpException |
309
|
|
|
* |
310
|
|
|
* @return void |
311
|
|
|
*/ |
312
|
|
|
public static function curlValidate($curl, $response = null) |
313
|
|
|
{ |
314
|
|
|
@trigger_error(sprintf('Method "%s::%s" is deprecated', __CLASS__, __METHOD__), \E_USER_DEPRECATED); |
315
|
|
|
|
316
|
|
|
if ($response) { |
317
|
|
|
$json = json_decode($response, true) ?: []; |
318
|
|
|
} else { |
319
|
|
|
$json = []; |
320
|
|
|
} |
321
|
|
|
if (($httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE)) |
322
|
|
|
&& !in_array($httpCode, [self::DEFAULT_STATUS_CODE, self::NOT_MODIFIED_STATUS_CODE]) |
|
|
|
|
323
|
|
|
) { |
324
|
|
|
$errorDescription = array_key_exists('description', $json) ? $json['description'] : self::$codes[$httpCode]; |
325
|
|
|
$errorParameters = array_key_exists('parameters', $json) ? $json['parameters'] : []; |
326
|
|
|
throw new HttpException($errorDescription, $httpCode, null, $errorParameters); |
327
|
|
|
} |
328
|
|
|
} |
329
|
|
|
|
330
|
|
|
/** |
331
|
|
|
* JSON validation |
332
|
|
|
* |
333
|
|
|
* @param string $jsonString |
334
|
|
|
* @param bool $asArray |
335
|
|
|
* |
336
|
|
|
* @return object|array |
337
|
|
|
* @throws InvalidJsonException |
338
|
|
|
*/ |
339
|
|
|
public static function jsonValidate($jsonString, $asArray) |
340
|
|
|
{ |
341
|
|
|
$json = json_decode($jsonString, $asArray); |
342
|
|
|
|
343
|
|
|
if (json_last_error() != JSON_ERROR_NONE) { |
344
|
|
|
throw new InvalidJsonException(json_last_error_msg(), json_last_error()); |
345
|
|
|
} |
346
|
|
|
|
347
|
|
|
return $json; |
348
|
|
|
} |
349
|
|
|
|
350
|
|
|
/** |
351
|
|
|
* Use this method to send text messages. On success, the sent \TelegramBot\Api\Types\Message is returned. |
352
|
|
|
* |
353
|
|
|
* @param int|float|string $chatId |
354
|
|
|
* @param string $text |
355
|
|
|
* @param string|null $parseMode |
356
|
|
|
* @param bool $disablePreview |
357
|
|
|
* @param int|null $replyToMessageId |
358
|
|
|
* @param InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $replyMarkup |
359
|
|
|
* @param bool $disableNotification |
360
|
|
|
* @param int|null $messageThreadId |
361
|
|
|
* @param bool|null $protectContent |
362
|
|
|
* @param bool|null $allowSendingWithoutReply |
363
|
|
|
* |
364
|
|
|
* @return Message |
365
|
|
|
* @throws InvalidArgumentException |
366
|
|
|
* @throws Exception |
367
|
|
|
*/ |
368
|
|
|
public function sendMessage( |
369
|
|
|
$chatId, |
370
|
|
|
$text, |
371
|
|
|
$parseMode = null, |
372
|
|
|
$disablePreview = false, |
373
|
|
|
$replyToMessageId = null, |
374
|
|
|
$replyMarkup = null, |
375
|
|
|
$disableNotification = false, |
376
|
|
|
$messageThreadId = null, |
377
|
|
|
$protectContent = null, |
378
|
|
|
$allowSendingWithoutReply = null |
379
|
|
|
) { |
380
|
|
|
return Message::fromResponse($this->call('sendMessage', [ |
|
|
|
|
381
|
|
|
'chat_id' => $chatId, |
382
|
|
|
'text' => $text, |
383
|
|
|
'message_thread_id' => $messageThreadId, |
384
|
|
|
'parse_mode' => $parseMode, |
385
|
|
|
'disable_web_page_preview' => $disablePreview, |
386
|
|
|
'reply_to_message_id' => (int) $replyToMessageId, |
387
|
|
|
'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(), |
388
|
|
|
'disable_notification' => (bool) $disableNotification, |
389
|
|
|
'protect_content' => (bool) $protectContent, |
390
|
|
|
'allow_sending_without_reply' => (bool) $allowSendingWithoutReply, |
391
|
|
|
])); |
392
|
|
|
} |
393
|
|
|
|
394
|
|
|
/** |
395
|
|
|
* @param int|string $chatId |
396
|
|
|
* @param int|string $fromChatId |
397
|
|
|
* @param int $messageId |
398
|
|
|
* @param string|null $caption |
399
|
|
|
* @param string|null $parseMode |
400
|
|
|
* @param ArrayOfMessageEntity|null $captionEntities |
401
|
|
|
* @param bool $disableNotification |
402
|
|
|
* @param int|null $replyToMessageId |
403
|
|
|
* @param bool $allowSendingWithoutReply |
404
|
|
|
* @param InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $replyMarkup |
405
|
|
|
* @param int|null $messageThreadId |
406
|
|
|
* @param bool|null $protectContent |
407
|
|
|
* |
408
|
|
|
* @return MessageId |
409
|
|
|
* @throws Exception |
410
|
|
|
* @throws HttpException |
411
|
|
|
* @throws InvalidJsonException |
412
|
|
|
*/ |
413
|
|
|
public function copyMessage( |
414
|
|
|
$chatId, |
415
|
|
|
$fromChatId, |
416
|
|
|
$messageId, |
417
|
|
|
$caption = null, |
418
|
|
|
$parseMode = null, |
419
|
|
|
$captionEntities = null, |
420
|
|
|
$disableNotification = false, |
421
|
|
|
$replyToMessageId = null, |
422
|
|
|
$allowSendingWithoutReply = false, |
423
|
|
|
$replyMarkup = null, |
424
|
|
|
$messageThreadId = null, |
425
|
|
|
$protectContent = null |
426
|
|
|
) { |
427
|
|
|
return MessageId::fromResponse($this->call('copyMessage', [ |
|
|
|
|
428
|
|
|
'chat_id' => $chatId, |
429
|
|
|
'from_chat_id' => $fromChatId, |
430
|
|
|
'message_id' => (int) $messageId, |
431
|
|
|
'caption' => $caption, |
432
|
|
|
'parse_mode' => $parseMode, |
433
|
|
|
'caption_entities' => $captionEntities, |
434
|
|
|
'disable_notification' => (bool) $disableNotification, |
435
|
|
|
'message_thread_id' => $messageThreadId, |
436
|
|
|
'reply_to_message_id' => (int) $replyToMessageId, |
437
|
|
|
'allow_sending_without_reply' => (bool) $allowSendingWithoutReply, |
438
|
|
|
'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(), |
439
|
|
|
'protect_content' => (bool) $protectContent, |
440
|
|
|
])); |
441
|
|
|
} |
442
|
|
|
|
443
|
|
|
/** |
444
|
|
|
* Use this method to send phone contacts |
445
|
|
|
* |
446
|
|
|
* @param int|string $chatId chat_id or @channel_name |
447
|
|
|
* @param string $phoneNumber |
448
|
|
|
* @param string $firstName |
449
|
|
|
* @param string $lastName |
450
|
|
|
* @param int|null $replyToMessageId |
451
|
|
|
* @param InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $replyMarkup |
452
|
|
|
* @param bool $disableNotification |
453
|
|
|
* @param int|null $messageThreadId |
454
|
|
|
* @param bool|null $protectContent |
455
|
|
|
* @param bool|null $allowSendingWithoutReply |
456
|
|
|
* |
457
|
|
|
* @return Message |
458
|
|
|
* @throws Exception |
459
|
|
|
*/ |
460
|
|
|
public function sendContact( |
461
|
|
|
$chatId, |
462
|
|
|
$phoneNumber, |
463
|
|
|
$firstName, |
464
|
|
|
$lastName = null, |
465
|
|
|
$replyToMessageId = null, |
466
|
|
|
$replyMarkup = null, |
467
|
|
|
$disableNotification = false, |
468
|
|
|
$messageThreadId = null, |
469
|
|
|
$protectContent = null, |
470
|
|
|
$allowSendingWithoutReply = null |
471
|
|
|
) { |
472
|
|
|
return Message::fromResponse($this->call('sendContact', [ |
|
|
|
|
473
|
|
|
'chat_id' => $chatId, |
474
|
|
|
'phone_number' => $phoneNumber, |
475
|
|
|
'first_name' => $firstName, |
476
|
|
|
'last_name' => $lastName, |
477
|
|
|
'message_thread_id' => $messageThreadId, |
478
|
|
|
'reply_to_message_id' => $replyToMessageId, |
479
|
|
|
'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(), |
480
|
|
|
'disable_notification' => (bool) $disableNotification, |
481
|
|
|
'protect_content' => (bool) $protectContent, |
482
|
|
|
'allow_sending_without_reply' => (bool) $allowSendingWithoutReply, |
483
|
|
|
])); |
484
|
|
|
} |
485
|
|
|
|
486
|
|
|
/** |
487
|
|
|
* Use this method when you need to tell the user that something is happening on the bot's side. |
488
|
|
|
* The status is set for 5 seconds or less (when a message arrives from your bot, |
489
|
|
|
* Telegram clients clear its typing status). |
490
|
|
|
* |
491
|
|
|
* We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive. |
492
|
|
|
* |
493
|
|
|
* Type of action to broadcast. Choose one, depending on what the user is about to receive: |
494
|
|
|
* `typing` for text messages, `upload_photo` for photos, `record_video` or `upload_video` for videos, |
495
|
|
|
* `record_audio` or upload_audio for audio files, `upload_document` for general files, |
496
|
|
|
* `find_location` for location data. |
497
|
|
|
* |
498
|
|
|
* @param int $chatId |
499
|
|
|
* @param string $action |
500
|
|
|
* |
501
|
|
|
* @return bool |
502
|
|
|
* @throws Exception |
503
|
|
|
*/ |
504
|
|
|
public function sendChatAction($chatId, $action) |
505
|
|
|
{ |
506
|
|
|
return $this->call('sendChatAction', [ |
|
|
|
|
507
|
|
|
'chat_id' => $chatId, |
508
|
|
|
'action' => $action, |
509
|
|
|
]); |
510
|
|
|
} |
511
|
|
|
|
512
|
|
|
/** |
513
|
|
|
* Use this method to get a list of profile pictures for a user. |
514
|
|
|
* |
515
|
|
|
* @param int $userId |
516
|
|
|
* @param int $offset |
517
|
|
|
* @param int $limit |
518
|
|
|
* |
519
|
|
|
* @return UserProfilePhotos |
520
|
|
|
* @throws Exception |
521
|
|
|
*/ |
522
|
|
|
public function getUserProfilePhotos($userId, $offset = 0, $limit = 100) |
523
|
|
|
{ |
524
|
|
|
return UserProfilePhotos::fromResponse($this->call('getUserProfilePhotos', [ |
|
|
|
|
525
|
|
|
'user_id' => (int) $userId, |
526
|
|
|
'offset' => (int) $offset, |
527
|
|
|
'limit' => (int) $limit, |
528
|
|
|
])); |
529
|
|
|
} |
530
|
|
|
|
531
|
|
|
/** |
532
|
|
|
* Use this method to specify a url and receive incoming updates via an outgoing webhook. |
533
|
|
|
* Whenever there is an update for the bot, we will send an HTTPS POST request to the specified url, |
534
|
|
|
* containing a JSON-serialized Update. |
535
|
|
|
* In case of an unsuccessful request, we will give up after a reasonable amount of attempts. |
536
|
|
|
* |
537
|
|
|
* @param string $url HTTPS url to send updates to. Use an empty string to remove webhook integration |
538
|
|
|
* @param \CURLFile|string $certificate Upload your public key certificate |
539
|
|
|
* so that the root certificate in use can be checked |
540
|
|
|
* @param string|null $ipAddress The fixed IP address which will be used to send webhook requests |
541
|
|
|
* instead of the IP address resolved through DNS |
542
|
|
|
* @param int|null $maxConnections The maximum allowed number of simultaneous HTTPS connections to the webhook |
543
|
|
|
* for update delivery, 1-100. Defaults to 40. Use lower values to limit |
544
|
|
|
* the load on your bot's server, and higher values to increase your bot's throughput. |
545
|
|
|
* @param array|string|null $allowedUpdates A JSON-serialized list of the update types you want your bot to receive. |
546
|
|
|
* For example, specify [“message”, “edited_channel_post”, “callback_query”] |
547
|
|
|
* to only receive updates of these types. See Update for a complete list of available update types. |
548
|
|
|
* Specify an empty list to receive all update types except chat_member (default). |
549
|
|
|
* If not specified, the previous setting will be used. |
550
|
|
|
* Please note that this parameter doesn't affect updates created before the call to the setWebhook, |
551
|
|
|
* so unwanted updates may be received for a short period of time. |
552
|
|
|
* @param bool|null $dropPendingUpdates Pass True to drop all pending updates |
553
|
|
|
* @param string|null $secretToken A secret token to be sent in a header “X-Telegram-Bot-Api-Secret-Token” in every webhook request, |
554
|
|
|
* 1-256 characters. Only characters A-Z, a-z, 0-9, _ and - are allowed. |
555
|
|
|
* The header is useful to ensure that the request comes from a webhook set by you. |
556
|
|
|
* |
557
|
|
|
* @return string |
558
|
|
|
* |
559
|
|
|
* @throws Exception |
560
|
|
|
*/ |
561
|
|
|
public function setWebhook( |
562
|
|
|
$url = '', |
563
|
|
|
$certificate = null, |
564
|
|
|
$ipAddress = null, |
565
|
|
|
$maxConnections = 40, |
566
|
|
|
$allowedUpdates = null, |
567
|
|
|
$dropPendingUpdates = false, |
568
|
|
|
$secretToken = null |
569
|
|
|
) { |
570
|
|
|
return $this->call('setWebhook', [ |
|
|
|
|
571
|
|
|
'url' => $url, |
572
|
|
|
'certificate' => $certificate, |
573
|
|
|
'ip_address' => $ipAddress, |
574
|
|
|
'max_connections' => $maxConnections, |
575
|
|
|
'allowed_updates' => \is_array($allowedUpdates) ? json_encode($allowedUpdates) : $allowedUpdates, |
576
|
|
|
'drop_pending_updates' => $dropPendingUpdates, |
577
|
|
|
'secret_token' => $secretToken |
578
|
|
|
]); |
579
|
|
|
} |
580
|
|
|
|
581
|
|
|
/** |
582
|
|
|
* Use this method to clear webhook and use getUpdates again! |
583
|
|
|
* |
584
|
|
|
* @param bool $dropPendingUpdates Pass True to drop all pending updates |
585
|
|
|
* |
586
|
|
|
* @return mixed |
587
|
|
|
* |
588
|
|
|
* @throws Exception |
589
|
|
|
*/ |
590
|
|
|
public function deleteWebhook($dropPendingUpdates = false) |
591
|
|
|
{ |
592
|
|
|
return $this->call('deleteWebhook', ['drop_pending_updates' => $dropPendingUpdates]); |
|
|
|
|
593
|
|
|
} |
594
|
|
|
|
595
|
2 |
|
/** |
596
|
|
|
* Use this method to get current webhook status. Requires no parameters. |
597
|
2 |
|
* On success, returns a WebhookInfo object. If the bot is using getUpdates, |
598
|
2 |
|
* will return an object with the url field empty. |
599
|
2 |
|
* |
600
|
2 |
|
* @return WebhookInfo |
601
|
2 |
|
* @throws Exception |
602
|
|
|
* @throws InvalidArgumentException |
603
|
2 |
|
*/ |
604
|
|
|
public function getWebhookInfo() |
605
|
|
|
{ |
606
|
|
|
return WebhookInfo::fromResponse($this->call('getWebhookInfo')); |
|
|
|
|
607
|
|
|
} |
608
|
|
|
|
609
|
2 |
|
/** |
610
|
|
|
* A simple method for testing your bot's auth token.Requires no parameters. |
611
|
|
|
* Returns basic information about the bot in form of a User object. |
612
|
|
|
* |
613
|
|
|
* @return User |
614
|
|
|
* @throws Exception |
615
|
|
|
* @throws InvalidArgumentException |
616
|
|
|
*/ |
617
|
|
|
public function getMe() |
618
|
|
|
{ |
619
|
|
|
return User::fromResponse($this->call('getMe')); |
|
|
|
|
620
|
|
|
} |
621
|
|
|
|
622
|
|
|
/** |
623
|
|
|
* Use this method to receive incoming updates using long polling. |
624
|
|
|
* An Array of Update objects is returned. |
625
|
|
|
* |
626
|
|
|
* Notes |
627
|
|
|
* 1. This method will not work if an outgoing webhook is set up. |
628
|
|
|
* 2. In order to avoid getting duplicate updates, recalculate offset after each server response. |
629
|
|
|
* |
630
|
|
|
* @param int $offset |
631
|
|
|
* @param int $limit |
632
|
|
|
* @param int $timeout |
633
|
|
|
* |
634
|
|
|
* @return Update[] |
635
|
|
|
* @throws Exception |
636
|
|
|
* @throws InvalidArgumentException |
637
|
|
|
*/ |
638
|
|
|
public function getUpdates($offset = 0, $limit = 100, $timeout = 0) |
639
|
|
|
{ |
640
|
|
|
$updates = ArrayOfUpdates::fromResponse($this->call('getUpdates', [ |
|
|
|
|
641
|
|
|
'offset' => $offset, |
642
|
|
|
'limit' => $limit, |
643
|
|
|
'timeout' => $timeout, |
644
|
|
|
])); |
645
|
|
|
|
646
|
|
|
if ($this->tracker instanceof Botan) { |
|
|
|
|
647
|
|
|
foreach ($updates as $update) { |
648
|
|
|
$this->trackUpdate($update); |
|
|
|
|
649
|
|
|
} |
650
|
|
|
} |
651
|
|
|
|
652
|
|
|
return $updates; |
653
|
|
|
} |
654
|
|
|
|
655
|
|
|
/** |
656
|
|
|
* Use this method to send point on the map. On success, the sent Message is returned. |
657
|
|
|
* |
658
|
|
|
* @param int|string $chatId |
659
|
|
|
* @param float $latitude |
660
|
|
|
* @param float $longitude |
661
|
|
|
* @param int|null $replyToMessageId |
662
|
|
|
* @param InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $replyMarkup |
663
|
|
|
* @param bool $disableNotification |
664
|
|
|
* @param null|int $livePeriod |
665
|
|
|
* @param int|null $messageThreadId |
666
|
|
|
* @param bool|null $protectContent |
667
|
|
|
* @param bool|null $allowSendingWithoutReply |
668
|
|
|
* |
669
|
|
|
* @return Message |
670
|
|
|
* |
671
|
|
|
* @throws Exception |
672
|
|
|
*/ |
673
|
|
|
public function sendLocation( |
674
|
|
|
$chatId, |
675
|
|
|
$latitude, |
676
|
|
|
$longitude, |
677
|
|
|
$replyToMessageId = null, |
678
|
|
|
$replyMarkup = null, |
679
|
|
|
$disableNotification = false, |
680
|
|
|
$livePeriod = null, |
681
|
|
|
$messageThreadId = null, |
682
|
|
|
$protectContent = null, |
683
|
|
|
$allowSendingWithoutReply = null |
684
|
|
|
) { |
685
|
|
|
return Message::fromResponse($this->call('sendLocation', [ |
|
|
|
|
686
|
|
|
'chat_id' => $chatId, |
687
|
|
|
'latitude' => $latitude, |
688
|
|
|
'longitude' => $longitude, |
689
|
|
|
'live_period' => $livePeriod, |
690
|
|
|
'message_thread_id' => $messageThreadId, |
691
|
|
|
'reply_to_message_id' => $replyToMessageId, |
692
|
|
|
'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(), |
693
|
|
|
'disable_notification' => (bool) $disableNotification, |
694
|
|
|
'protect_content' => (bool) $protectContent, |
695
|
|
|
'allow_sending_without_reply' => (bool) $allowSendingWithoutReply, |
696
|
|
|
])); |
697
|
|
|
} |
698
|
|
|
|
699
|
|
|
/** |
700
|
|
|
* Use this method to edit live location messages sent by the bot or via the bot (for inline bots). |
701
|
|
|
* On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. |
702
|
|
|
* |
703
|
|
|
* @param int|string $chatId |
704
|
|
|
* @param int $messageId |
705
|
|
|
* @param string $inlineMessageId |
706
|
|
|
* @param float $latitude |
707
|
|
|
* @param float $longitude |
708
|
|
|
* @param InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $replyMarkup |
709
|
|
|
* |
710
|
|
|
* @return Message|true |
711
|
|
|
* |
712
|
|
|
* @throws Exception |
713
|
|
|
*/ |
714
|
|
|
public function editMessageLiveLocation( |
715
|
|
|
$chatId, |
716
|
|
|
$messageId, |
717
|
|
|
$inlineMessageId, |
718
|
|
|
$latitude, |
719
|
|
|
$longitude, |
720
|
|
|
$replyMarkup = null |
721
|
|
|
) { |
722
|
|
|
$response = $this->call('editMessageLiveLocation', [ |
|
|
|
|
723
|
|
|
'chat_id' => $chatId, |
724
|
|
|
'message_id' => $messageId, |
725
|
|
|
'inline_message_id' => $inlineMessageId, |
726
|
|
|
'latitude' => $latitude, |
727
|
|
|
'longitude' => $longitude, |
728
|
|
|
'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(), |
729
|
|
|
]); |
730
|
|
|
if ($response === true) { |
731
|
|
|
return true; |
732
|
|
|
} |
733
|
|
|
|
734
|
|
|
return Message::fromResponse($response); |
735
|
|
|
} |
736
|
|
|
|
737
|
|
|
/** |
738
|
|
|
* Use this method to stop updating a live location message sent by the bot or via the bot (for inline bots) before |
739
|
|
|
* live_period expires. |
740
|
|
|
* On success, if the message is not an inline message, the edited Message is returned, otherwise True is returned. |
741
|
|
|
* |
742
|
|
|
* @param int|string $chatId |
743
|
|
|
* @param int $messageId |
744
|
|
|
* @param string $inlineMessageId |
745
|
|
|
* @param InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $replyMarkup |
746
|
|
|
* |
747
|
|
|
* @return Message|true |
748
|
|
|
* |
749
|
|
|
* @throws Exception |
750
|
|
|
*/ |
751
|
|
|
public function stopMessageLiveLocation( |
752
|
|
|
$chatId, |
753
|
|
|
$messageId, |
754
|
|
|
$inlineMessageId, |
755
|
|
|
$replyMarkup = null |
756
|
|
|
) { |
757
|
|
|
$response = $this->call('stopMessageLiveLocation', [ |
|
|
|
|
758
|
|
|
'chat_id' => $chatId, |
759
|
|
|
'message_id' => $messageId, |
760
|
|
|
'inline_message_id' => $inlineMessageId, |
761
|
|
|
'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(), |
762
|
|
|
]); |
763
|
|
|
if ($response === true) { |
764
|
|
|
return true; |
765
|
|
|
} |
766
|
|
|
|
767
|
|
|
return Message::fromResponse($response); |
768
|
|
|
} |
769
|
|
|
|
770
|
|
|
/** |
771
|
|
|
* Use this method to send information about a venue. On success, the sent Message is returned. |
772
|
|
|
* |
773
|
|
|
* @param int|string $chatId chat_id or @channel_name |
774
|
|
|
* @param float $latitude |
775
|
|
|
* @param float $longitude |
776
|
|
|
* @param string $title |
777
|
|
|
* @param string $address |
778
|
|
|
* @param string|null $foursquareId |
779
|
|
|
* @param int|null $replyToMessageId |
780
|
|
|
* @param InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $replyMarkup |
781
|
|
|
* @param bool $disableNotification |
782
|
|
|
* @param int|null $messageThreadId |
783
|
|
|
* @param bool|null $protectContent |
784
|
|
|
* @param bool|null $allowSendingWithoutReply |
785
|
|
|
* |
786
|
|
|
* @return Message |
787
|
|
|
* @throws Exception |
788
|
|
|
*/ |
789
|
|
|
public function sendVenue( |
790
|
|
|
$chatId, |
791
|
|
|
$latitude, |
792
|
|
|
$longitude, |
793
|
|
|
$title, |
794
|
|
|
$address, |
795
|
|
|
$foursquareId = null, |
796
|
|
|
$replyToMessageId = null, |
797
|
|
|
$replyMarkup = null, |
798
|
|
|
$disableNotification = false, |
799
|
|
|
$messageThreadId = null, |
800
|
|
|
$protectContent = null, |
801
|
|
|
$allowSendingWithoutReply = null |
802
|
|
|
) { |
803
|
|
|
return Message::fromResponse($this->call('sendVenue', [ |
|
|
|
|
804
|
|
|
'chat_id' => $chatId, |
805
|
|
|
'latitude' => $latitude, |
806
|
|
|
'longitude' => $longitude, |
807
|
|
|
'title' => $title, |
808
|
|
|
'address' => $address, |
809
|
|
|
'foursquare_id' => $foursquareId, |
810
|
|
|
'message_thread_id' => $messageThreadId, |
811
|
|
|
'reply_to_message_id' => $replyToMessageId, |
812
|
|
|
'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(), |
813
|
|
|
'disable_notification' => (bool) $disableNotification, |
814
|
|
|
'protect_content' => (bool) $protectContent, |
815
|
|
|
'allow_sending_without_reply' => (bool) $allowSendingWithoutReply, |
816
|
|
|
])); |
817
|
|
|
} |
818
|
|
|
|
819
|
|
|
/** |
820
|
|
|
* Use this method to send .webp stickers. On success, the sent Message is returned. |
821
|
|
|
* |
822
|
|
|
* @param int|string $chatId chat_id or @channel_name |
823
|
|
|
* @param \CURLFile|string $sticker |
824
|
|
|
* @param int|null $replyToMessageId |
825
|
|
|
* @param InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $replyMarkup |
826
|
|
|
* @param bool $disableNotification Sends the message silently. Users will receive a notification with no sound. |
827
|
|
|
* @param bool $protectContent Protects the contents of the sent message from forwarding and saving |
828
|
|
|
* @param bool $allowSendingWithoutReply Pass True if the message should be sent even if the specified replied-to message is not found |
829
|
|
|
* @param string|null $messageThreadId |
830
|
|
|
* |
831
|
|
|
* @return Message |
832
|
|
|
* @throws InvalidArgumentException |
833
|
|
|
* @throws Exception |
834
|
|
|
*/ |
835
|
|
|
public function sendSticker( |
836
|
|
|
$chatId, |
837
|
|
|
$sticker, |
838
|
|
|
$replyToMessageId = null, |
839
|
|
|
$replyMarkup = null, |
840
|
|
|
$disableNotification = false, |
841
|
|
|
$protectContent = false, |
842
|
|
|
$allowSendingWithoutReply = false, |
843
|
|
|
$messageThreadId = null |
844
|
|
|
) { |
845
|
|
|
return Message::fromResponse($this->call('sendSticker', [ |
|
|
|
|
846
|
|
|
'chat_id' => $chatId, |
847
|
|
|
'sticker' => $sticker, |
848
|
|
|
'message_thread_id' => $messageThreadId, |
849
|
|
|
'reply_to_message_id' => $replyToMessageId, |
850
|
|
|
'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(), |
851
|
|
|
'disable_notification' => (bool) $disableNotification, |
852
|
|
|
'protect_content' => (bool) $protectContent, |
853
|
|
|
'allow_sending_without_reply' => (bool) $allowSendingWithoutReply, |
854
|
|
|
])); |
855
|
|
|
} |
856
|
|
|
|
857
|
|
|
/** |
858
|
|
|
* @param string $name Name of the sticker set |
859
|
|
|
* @return StickerSet |
860
|
|
|
* @throws InvalidArgumentException |
861
|
|
|
* @throws Exception |
862
|
|
|
*/ |
863
|
|
|
public function getStickerSet($name) |
864
|
|
|
{ |
865
|
|
|
return StickerSet::fromResponse($this->call('getStickerSet', [ |
|
|
|
|
866
|
|
|
'name' => $name, |
867
|
|
|
])); |
868
|
|
|
} |
869
|
|
|
|
870
|
|
|
/** |
871
|
|
|
* @param array[] $customEmojiIds List of custom emoji identifiers. |
872
|
|
|
* At most 200 custom emoji identifiers can be specified. |
873
|
|
|
* @return StickerSet |
874
|
|
|
* @throws InvalidArgumentException |
875
|
|
|
* @throws Exception |
876
|
|
|
* |
877
|
|
|
* @author bernard-ng <[email protected]> |
878
|
|
|
*/ |
879
|
|
|
public function getCustomEmojiStickers($customEmojiIds = []) |
880
|
|
|
{ |
881
|
|
|
return StickerSet::fromResponse($this->call('getCustomEmojiStickers', [ |
|
|
|
|
882
|
|
|
'custom_emoji_ids' => $customEmojiIds, |
883
|
|
|
])); |
884
|
|
|
} |
885
|
|
|
|
886
|
|
|
/** |
887
|
|
|
* Use this method to create a new sticker set owned by a user. |
888
|
|
|
* The bot will be able to edit the sticker set thus created. |
889
|
|
|
* You must use exactly one of the fields png_sticker, tgs_sticker, or webm_sticker. |
890
|
|
|
* Returns True on success. |
891
|
|
|
* |
892
|
|
|
* @param int $userId User identifier of created sticker set owner |
893
|
|
|
* @param string $pngSticker PNG image with the sticker, must be up to 512 kilobytes in size, |
894
|
|
|
* dimensions must not exceed 512px, and either width or height must be exactly 512px. |
895
|
|
|
* |
896
|
|
|
* @return File |
897
|
|
|
* |
898
|
|
|
* @throws InvalidArgumentException |
899
|
|
|
* @throws Exception |
900
|
|
|
*/ |
901
|
|
|
public function uploadStickerFile($userId, $pngSticker) |
902
|
|
|
{ |
903
|
|
|
return File::fromResponse($this->call('uploadStickerFile', [ |
|
|
|
|
904
|
|
|
'user_id' => $userId, |
905
|
|
|
'png_sticker' => $pngSticker, |
906
|
|
|
])); |
907
|
|
|
} |
908
|
|
|
|
909
|
|
|
/** |
910
|
|
|
* Use this method to create a new sticker set owned by a user. |
911
|
|
|
* The bot will be able to edit the sticker set thus created. |
912
|
|
|
* You must use exactly one of the fields png_sticker, tgs_sticker, or webm_sticker. Returns True on success. |
913
|
|
|
* |
914
|
|
|
* @param int $userId User identifier of created sticker set owner |
915
|
|
|
* @param string $name Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). |
916
|
|
|
* Can contain only english letters, digits and underscores. Must begin with a letter, |
917
|
|
|
* can't contain consecutive underscores and must end in “_by_<bot username>”. |
918
|
|
|
* <bot_username> is case insensitive. 1-64 characters. |
919
|
|
|
* @param string $title Sticker set title, 1-64 characters |
920
|
|
|
* @param string $pngSticker PNG image with the sticker, must be up to 512 kilobytes in size, |
921
|
|
|
* dimensions must not exceed 512px, and either width or height must be exactly 512px. |
922
|
|
|
* Pass a file_id as a String to send a file that already exists on the Telegram servers, |
923
|
|
|
* pass an HTTP URL as a String for Telegram to get a file from the Internet, |
924
|
|
|
* or upload a new one using multipart/form-data. |
925
|
|
|
* @param string $tgsSticker TGS animation with the sticker, uploaded using multipart/form-data. |
926
|
|
|
* See https://core.telegram.org/animated_stickers#technical-requirements for technical requirements |
927
|
|
|
* @param string $webmSticker WebP animation with the sticker, uploaded using multipart/form-data. |
928
|
|
|
* See https://core.telegram.org/animated_stickers#technical-requirements for technical requirements |
929
|
|
|
* @param string $stickerType Sticker type, one of “png”, “tgs”, or “webp” |
930
|
|
|
* @param string $emojis One or more emoji corresponding to the sticker |
931
|
|
|
* @param MaskPosition|null $maskPosition A JSON-serialized object for position where the mask should be placed on faces |
932
|
|
|
* @param array<string, \CURLFile|\CURLStringFile> $attachments Attachments to use in attach://<attachment> |
933
|
|
|
* |
934
|
|
|
* @throws InvalidArgumentException |
935
|
|
|
* @throws Exception |
936
|
|
|
* |
937
|
|
|
* @return bool |
938
|
|
|
* |
939
|
|
|
* @author bernard-ng <[email protected]> |
940
|
|
|
*/ |
941
|
|
|
public function createNewStickerSet( |
942
|
|
|
$userId, |
943
|
|
|
$name, |
944
|
|
|
$title, |
945
|
|
|
$emojis, |
946
|
|
|
$pngSticker, |
947
|
|
|
$tgsSticker = null, |
948
|
|
|
$webmSticker = null, |
949
|
|
|
$stickerType = null, |
950
|
|
|
$maskPosition = null, |
951
|
|
|
$attachments = [] |
952
|
|
|
) { |
953
|
|
|
return $this->call('createNewStickerSet', [ |
|
|
|
|
954
|
|
|
'user_id' => $userId, |
955
|
|
|
'name' => $name, |
956
|
|
|
'title' => $title, |
957
|
|
|
'png_sticker' => $pngSticker, |
958
|
|
|
'tgs_sticker' => $tgsSticker, |
959
|
|
|
'webm_sticker' => $webmSticker, |
960
|
|
|
'sticker_type' => $stickerType, |
961
|
|
|
'emojis' => $emojis, |
962
|
|
|
'mask_position' => is_null($maskPosition) ? $maskPosition : $maskPosition->toJson(), |
963
|
|
|
] + $attachments); |
964
|
|
|
} |
965
|
|
|
|
966
|
|
|
/** |
967
|
|
|
* Use this method to add a new sticker to a set created by the bot. |
968
|
|
|
* You must use exactly one of the fields png_sticker, tgs_sticker, or webm_sticker. |
969
|
|
|
* Animated stickers can be added to animated sticker sets and only to them. |
970
|
|
|
* Animated sticker sets can have up to 50 stickers. |
971
|
|
|
* Static sticker sets can have up to 120 stickers. Returns True on success. |
972
|
|
|
* |
973
|
|
|
* @param string $userId |
974
|
|
|
* @param string $name |
975
|
|
|
* @param string $emojis |
976
|
|
|
* @param string $pngSticker |
977
|
|
|
* @param string|null $tgsSticker |
978
|
|
|
* @param string|null $webmSticker |
979
|
|
|
* @param MaskPosition|null $maskPosition |
980
|
|
|
* @param array<string, \CURLFile|\CURLStringFile> $attachments Attachments to use in attach://<attachment> |
981
|
|
|
* |
982
|
|
|
* @return bool |
983
|
|
|
* @throws Exception |
984
|
|
|
* @throws HttpException |
985
|
|
|
* @throws InvalidJsonException |
986
|
|
|
*/ |
987
|
|
|
public function addStickerToSet( |
988
|
|
|
$userId, |
989
|
|
|
$name, |
990
|
|
|
$emojis, |
991
|
|
|
$pngSticker, |
992
|
|
|
$tgsSticker = null, |
993
|
|
|
$webmSticker = null, |
994
|
|
|
$maskPosition = null, |
995
|
|
|
$attachments = [] |
996
|
|
|
) { |
997
|
|
|
return $this->call('addStickerToSet', [ |
|
|
|
|
998
|
|
|
'user_id' => $userId, |
999
|
|
|
'name' => $name, |
1000
|
|
|
'png_sticker' => $pngSticker, |
1001
|
|
|
'tgs_sticker' => $tgsSticker, |
1002
|
|
|
'webm_sticker' => $webmSticker, |
1003
|
|
|
'emojis' => $emojis, |
1004
|
|
|
'mask_position' => is_null($maskPosition) ? $maskPosition : $maskPosition->toJson(), |
1005
|
|
|
] + $attachments); |
1006
|
|
|
} |
1007
|
|
|
|
1008
|
|
|
/** |
1009
|
|
|
* Use this method to move a sticker in a set created by the bot to a specific position. |
1010
|
|
|
* Returns True on success. |
1011
|
|
|
* |
1012
|
|
|
* @param string $sticker File identifier of the sticker |
1013
|
|
|
* @param int $position New sticker position in the set, zero-based |
1014
|
|
|
* |
1015
|
|
|
* @return bool |
1016
|
|
|
* |
1017
|
|
|
* @throws InvalidArgumentException |
1018
|
|
|
* @throws Exception |
1019
|
|
|
*/ |
1020
|
|
|
public function setStickerPositionInSet($sticker, $position) |
1021
|
|
|
{ |
1022
|
|
|
return $this->call('setStickerPositionInSet', [ |
|
|
|
|
1023
|
|
|
'sticker' => $sticker, |
1024
|
|
|
'position' => $position, |
1025
|
|
|
]); |
1026
|
|
|
} |
1027
|
|
|
|
1028
|
|
|
/** |
1029
|
|
|
* Use this method to delete a sticker from a set created by the bot. |
1030
|
|
|
* Returns True on success. |
1031
|
|
|
* |
1032
|
|
|
* @param string $name Sticker set name |
1033
|
|
|
* @param string $userId User identifier of sticker set owner |
1034
|
|
|
* @param File|null $thumbnail A PNG image with the thumbnail, |
1035
|
|
|
* must be up to 128 kilobytes in size and have width and height exactly 100px, |
1036
|
|
|
* or a TGS animation with the thumbnail up to 32 kilobytes in size |
1037
|
|
|
* |
1038
|
|
|
* @return bool |
1039
|
|
|
* |
1040
|
|
|
* @throws InvalidArgumentException |
1041
|
|
|
* @throws Exception |
1042
|
|
|
*/ |
1043
|
|
|
public function setStickerSetThumbnail($name, $userId, $thumbnail = null) |
1044
|
|
|
{ |
1045
|
|
|
return $this->call('setStickerSetThumb', [ |
|
|
|
|
1046
|
|
|
'name' => $name, |
1047
|
|
|
'user_id' => $userId, |
1048
|
|
|
'thumbnail' => $thumbnail, |
1049
|
|
|
]); |
1050
|
|
|
} |
1051
|
|
|
|
1052
|
|
|
/** |
1053
|
|
|
* @deprecated Use setStickerSetThumbnail |
1054
|
|
|
* |
1055
|
|
|
* Use this method to delete a sticker from a set created by the bot. |
1056
|
|
|
* Returns True on success. |
1057
|
|
|
* |
1058
|
|
|
* @param string $name Sticker set name |
1059
|
|
|
* @param string $userId User identifier of sticker set owner |
1060
|
|
|
* @param File|null $thumb A PNG image with the thumbnail, |
1061
|
|
|
* must be up to 128 kilobytes in size and have width and height exactly 100px, |
1062
|
|
|
* or a TGS animation with the thumbnail up to 32 kilobytes in size |
1063
|
|
|
* |
1064
|
|
|
* @return bool |
1065
|
|
|
* |
1066
|
|
|
* @throws InvalidArgumentException |
1067
|
|
|
* @throws Exception |
1068
|
|
|
*/ |
1069
|
|
|
public function setStickerSetThumb($name, $userId, $thumb = null) |
1070
|
|
|
{ |
1071
|
|
|
return $this->setStickerSetThumbnail($name, $userId, $thumb); |
1072
|
|
|
} |
1073
|
|
|
|
1074
|
|
|
/** |
1075
|
|
|
* Use this method to send video files, |
1076
|
|
|
* Telegram clients support mp4 videos (other formats may be sent as Document). |
1077
|
|
|
* On success, the sent Message is returned. |
1078
|
|
|
* |
1079
|
|
|
* @param int|string $chatId chat_id or @channel_name |
1080
|
|
|
* @param \CURLFile|string $video |
1081
|
|
|
* @param int|null $duration |
1082
|
|
|
* @param string|null $caption |
1083
|
|
|
* @param int|null $replyToMessageId |
1084
|
|
|
* @param InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $replyMarkup |
1085
|
|
|
* @param bool $disableNotification |
1086
|
|
|
* @param bool $supportsStreaming Pass True, if the uploaded video is suitable for streaming |
1087
|
|
|
* @param string|null $parseMode |
1088
|
|
|
* @param int|null $messageThreadId |
1089
|
|
|
* @param bool|null $protectContent |
1090
|
|
|
* @param bool|null $allowSendingWithoutReply |
1091
|
|
|
* @param \CURLFile|\CURLStringFile|string|null $thumbnail |
|
|
|
|
1092
|
|
|
* |
1093
|
|
|
* @return Message |
1094
|
|
|
* @throws InvalidArgumentException |
1095
|
|
|
* @throws Exception |
1096
|
|
|
*/ |
1097
|
|
|
public function sendVideo( |
1098
|
|
|
$chatId, |
1099
|
|
|
$video, |
1100
|
|
|
$duration = null, |
1101
|
|
|
$caption = null, |
1102
|
|
|
$replyToMessageId = null, |
1103
|
|
|
$replyMarkup = null, |
1104
|
|
|
$disableNotification = false, |
1105
|
|
|
$supportsStreaming = false, |
1106
|
|
|
$parseMode = null, |
1107
|
|
|
$messageThreadId = null, |
1108
|
|
|
$protectContent = null, |
1109
|
|
|
$allowSendingWithoutReply = null, |
1110
|
|
|
$thumbnail = null |
1111
|
|
|
) { |
1112
|
|
|
return Message::fromResponse($this->call('sendVideo', [ |
|
|
|
|
1113
|
|
|
'chat_id' => $chatId, |
1114
|
|
|
'video' => $video, |
1115
|
|
|
'duration' => $duration, |
1116
|
|
|
'caption' => $caption, |
1117
|
|
|
'message_thread_id' => $messageThreadId, |
1118
|
|
|
'reply_to_message_id' => $replyToMessageId, |
1119
|
|
|
'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(), |
1120
|
|
|
'disable_notification' => (bool) $disableNotification, |
1121
|
|
|
'supports_streaming' => (bool) $supportsStreaming, |
1122
|
|
|
'parse_mode' => $parseMode, |
1123
|
|
|
'protect_content' => (bool) $protectContent, |
1124
|
|
|
'allow_sending_without_reply' => (bool) $allowSendingWithoutReply, |
1125
|
|
|
'thumbnail' => $thumbnail, |
1126
|
|
|
])); |
1127
|
|
|
} |
1128
|
|
|
|
1129
|
|
|
/** |
1130
|
|
|
* Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound), |
1131
|
|
|
* On success, the sent Message is returned. |
1132
|
|
|
* Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future. |
1133
|
|
|
* |
1134
|
|
|
* @param int|string $chatId chat_id or @channel_name |
1135
|
|
|
* @param \CURLFile|string $animation |
1136
|
|
|
* @param int|null $duration |
1137
|
|
|
* @param string|null $caption |
1138
|
|
|
* @param int|null $replyToMessageId |
1139
|
|
|
* @param InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $replyMarkup |
1140
|
|
|
* @param bool $disableNotification |
1141
|
|
|
* @param string|null $parseMode, |
1142
|
|
|
* @param int|null $messageThreadId |
1143
|
|
|
* @param bool|null $protectContent |
1144
|
|
|
* @param bool|null $allowSendingWithoutReply |
1145
|
|
|
* @param \CURLFile|\CURLStringFile|string|null $thumbnail |
1146
|
|
|
* |
1147
|
|
|
* @return Message |
1148
|
|
|
* @throws InvalidArgumentException |
1149
|
|
|
* @throws Exception |
1150
|
|
|
*/ |
1151
|
|
|
public function sendAnimation( |
1152
|
|
|
$chatId, |
1153
|
|
|
$animation, |
1154
|
|
|
$duration = null, |
1155
|
|
|
$caption = null, |
1156
|
|
|
$replyToMessageId = null, |
1157
|
|
|
$replyMarkup = null, |
1158
|
|
|
$disableNotification = false, |
1159
|
|
|
$parseMode = null, |
1160
|
|
|
$messageThreadId = null, |
1161
|
|
|
$protectContent = null, |
1162
|
|
|
$allowSendingWithoutReply = null, |
1163
|
|
|
$thumbnail = null |
1164
|
|
|
) { |
1165
|
|
|
return Message::fromResponse($this->call('sendAnimation', [ |
|
|
|
|
1166
|
|
|
'chat_id' => $chatId, |
1167
|
|
|
'animation' => $animation, |
1168
|
|
|
'duration' => $duration, |
1169
|
|
|
'caption' => $caption, |
1170
|
|
|
'message_thread_id' => $messageThreadId, |
1171
|
|
|
'reply_to_message_id' => $replyToMessageId, |
1172
|
|
|
'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(), |
1173
|
|
|
'disable_notification' => (bool) $disableNotification, |
1174
|
|
|
'parse_mode' => $parseMode, |
1175
|
|
|
'protect_content' => (bool) $protectContent, |
1176
|
|
|
'allow_sending_without_reply' => (bool) $allowSendingWithoutReply, |
1177
|
|
|
'thumbnail' => $thumbnail, |
1178
|
|
|
])); |
1179
|
|
|
} |
1180
|
|
|
|
1181
|
|
|
/** |
1182
|
|
|
* Use this method to send audio files, |
1183
|
|
|
* if you want Telegram clients to display the file as a playable voice message. |
1184
|
|
|
* For this to work, your audio must be in an .ogg file encoded with OPUS |
1185
|
|
|
* (other formats may be sent as Audio or Document). |
1186
|
|
|
* On success, the sent Message is returned. |
1187
|
|
|
* Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future. |
1188
|
|
|
* |
1189
|
|
|
* @param int|string $chatId chat_id or @channel_name |
1190
|
|
|
* @param \CURLFile|string $voice |
1191
|
|
|
* @param string $caption Voice message caption, 0-1024 characters after entities parsing |
1192
|
|
|
* @param int|null $duration |
1193
|
|
|
* @param int|null $replyToMessageId |
1194
|
|
|
* @param InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $replyMarkup |
1195
|
|
|
* @param bool $disableNotification |
1196
|
|
|
* @param bool $allowSendingWithoutReply Pass True, if the message should be sent even if the specified |
1197
|
|
|
* replied-to message is not found |
1198
|
|
|
* @param string|null $parseMode |
1199
|
|
|
* @param int|null $messageThreadId |
1200
|
|
|
* @param bool|null $protectContent |
1201
|
|
|
* |
1202
|
|
|
* @return Message |
1203
|
|
|
* @throws InvalidArgumentException |
1204
|
|
|
* @throws Exception |
1205
|
|
|
*/ |
1206
|
|
|
public function sendVoice( |
1207
|
|
|
$chatId, |
1208
|
|
|
$voice, |
1209
|
|
|
$caption = null, |
1210
|
|
|
$duration = null, |
1211
|
|
|
$replyToMessageId = null, |
1212
|
|
|
$replyMarkup = null, |
1213
|
|
|
$disableNotification = false, |
1214
|
|
|
$allowSendingWithoutReply = false, |
1215
|
|
|
$parseMode = null, |
1216
|
|
|
$messageThreadId = null, |
1217
|
|
|
$protectContent = null |
1218
|
|
|
) { |
1219
|
|
|
return Message::fromResponse($this->call('sendVoice', [ |
|
|
|
|
1220
|
|
|
'chat_id' => $chatId, |
1221
|
|
|
'voice' => $voice, |
1222
|
|
|
'caption' => $caption, |
1223
|
|
|
'duration' => $duration, |
1224
|
|
|
'message_thread_id' => $messageThreadId, |
1225
|
|
|
'reply_to_message_id' => $replyToMessageId, |
1226
|
|
|
'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(), |
1227
|
|
|
'disable_notification' => (bool) $disableNotification, |
1228
|
|
|
'allow_sending_without_reply' => $allowSendingWithoutReply, |
1229
|
|
|
'parse_mode' => $parseMode, |
1230
|
|
|
'protect_content' => (bool) $protectContent, |
1231
|
|
|
])); |
1232
|
|
|
} |
1233
|
|
|
|
1234
|
|
|
/** |
1235
|
|
|
* Use this method to forward messages of any kind. Service messages can't be forwarded. |
1236
|
|
|
* On success, the sent Message is returned. |
1237
|
|
|
* |
1238
|
|
|
* @param int|string $chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
1239
|
|
|
* @param int $fromChatId Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername) |
1240
|
|
|
* @param string $messageId Message identifier in the chat specified in from_chat_id |
1241
|
|
|
* @param bool $protectContent Protects the contents of the forwarded message from forwarding and saving |
1242
|
|
|
* @param bool $disableNotification Sends the message silently. Users will receive a notification with no sound. |
1243
|
|
|
* @param int|null $messageThreadId Unique identifier for the target message thread (topic) of the forum; for forum supergroups only |
1244
|
|
|
* |
1245
|
|
|
* @return Message |
1246
|
|
|
* @throws Exception |
1247
|
|
|
* @throws HttpException |
1248
|
|
|
* @throws InvalidJsonException |
1249
|
|
|
*/ |
1250
|
|
|
public function forwardMessage( |
1251
|
|
|
$chatId, |
1252
|
|
|
$fromChatId, |
1253
|
|
|
$messageId, |
1254
|
|
|
$protectContent = false, |
1255
|
|
|
$disableNotification = false, |
1256
|
|
|
$messageThreadId = null |
1257
|
|
|
) { |
1258
|
|
|
return Message::fromResponse($this->call('forwardMessage', [ |
|
|
|
|
1259
|
|
|
'chat_id' => $chatId, |
1260
|
|
|
'from_chat_id' => $fromChatId, |
1261
|
|
|
'message_id' => $messageId, |
1262
|
|
|
'message_thread_id' => $messageThreadId, |
1263
|
|
|
'protect_content' => $protectContent, |
1264
|
|
|
'disable_notification' => (bool) $disableNotification, |
1265
|
|
|
])); |
1266
|
|
|
} |
1267
|
|
|
|
1268
|
|
|
/** |
1269
|
|
|
* Use this method to send audio files, |
1270
|
|
|
* if you want Telegram clients to display them in the music player. |
1271
|
|
|
* Your audio must be in the .mp3 format. |
1272
|
|
|
* On success, the sent Message is returned. |
1273
|
|
|
* Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future. |
1274
|
|
|
* |
1275
|
|
|
* For backward compatibility, when the fields title and performer are both empty |
1276
|
|
|
* and the mime-type of the file to be sent is not audio/mpeg, the file will be sent as a playable voice message. |
1277
|
|
|
* For this to work, the audio must be in an .ogg file encoded with OPUS. |
1278
|
|
|
* This behavior will be phased out in the future. For sending voice messages, use the sendVoice method instead. |
1279
|
|
|
* |
1280
|
|
|
* @param int|string $chatId chat_id or @channel_name |
1281
|
|
|
* @param \CURLFile|string $audio |
1282
|
|
|
* @param int|null $duration |
1283
|
|
|
* @param string|null $performer |
1284
|
|
|
* @param string|null $title |
1285
|
|
|
* @param int|null $replyToMessageId |
1286
|
|
|
* @param InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $replyMarkup |
1287
|
|
|
* @param bool $disableNotification |
1288
|
|
|
* @param string|null $parseMode |
1289
|
|
|
* @param bool|null $protectContent |
1290
|
|
|
* @param bool|null $allowSendingWithoutReply |
1291
|
|
|
* @param \CURLFile|\CURLStringFile|string|null $thumbnail |
1292
|
|
|
* |
1293
|
|
|
* @return Message |
1294
|
|
|
* @throws InvalidArgumentException |
1295
|
|
|
* @throws Exception |
1296
|
|
|
* @deprecated since 20th February. Removed backward compatibility from the method sendAudio. |
1297
|
|
|
* Voice messages now must be sent using the method sendVoice. |
1298
|
|
|
* There is no more need to specify a non-empty title or performer while sending the audio by file_id. |
1299
|
|
|
* |
1300
|
|
|
*/ |
1301
|
|
|
public function sendAudio( |
1302
|
|
|
$chatId, |
1303
|
|
|
$audio, |
1304
|
|
|
$duration = null, |
1305
|
|
|
$performer = null, |
1306
|
|
|
$title = null, |
1307
|
|
|
$replyToMessageId = null, |
1308
|
|
|
$replyMarkup = null, |
1309
|
|
|
$disableNotification = false, |
1310
|
|
|
$parseMode = null, |
1311
|
|
|
$protectContent = null, |
1312
|
|
|
$allowSendingWithoutReply = null, |
1313
|
|
|
$thumbnail = null |
1314
|
|
|
) { |
1315
|
|
|
return Message::fromResponse($this->call('sendAudio', [ |
|
|
|
|
1316
|
|
|
'chat_id' => $chatId, |
1317
|
|
|
'audio' => $audio, |
1318
|
|
|
'duration' => $duration, |
1319
|
|
|
'performer' => $performer, |
1320
|
|
|
'title' => $title, |
1321
|
|
|
'reply_to_message_id' => $replyToMessageId, |
1322
|
|
|
'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(), |
1323
|
|
|
'disable_notification' => (bool) $disableNotification, |
1324
|
|
|
'parse_mode' => $parseMode, |
1325
|
|
|
'protect_content' => (bool) $protectContent, |
1326
|
|
|
'allow_sending_without_reply' => (bool) $allowSendingWithoutReply, |
1327
|
|
|
'thumbnail' => $thumbnail, |
1328
|
|
|
])); |
1329
|
|
|
} |
1330
|
|
|
|
1331
|
|
|
/** |
1332
|
|
|
* Use this method to send photos. On success, the sent Message is returned. |
1333
|
|
|
* |
1334
|
|
|
* @param int|string $chatId chat_id or @channel_name |
1335
|
|
|
* @param \CURLFile|string $photo |
1336
|
|
|
* @param string|null $caption |
1337
|
|
|
* @param int|null $replyToMessageId |
1338
|
|
|
* @param InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $replyMarkup |
1339
|
|
|
* @param bool $disableNotification |
1340
|
|
|
* @param string|null $parseMode |
1341
|
|
|
* @param int|null $messageThreadId |
1342
|
|
|
* @param bool|null $protectContent |
1343
|
|
|
* @param bool|null $allowSendingWithoutReply |
1344
|
|
|
* |
1345
|
|
|
* @return Message |
1346
|
|
|
* @throws InvalidArgumentException |
1347
|
|
|
* @throws Exception |
1348
|
|
|
*/ |
1349
|
|
|
public function sendPhoto( |
1350
|
|
|
$chatId, |
1351
|
|
|
$photo, |
1352
|
|
|
$caption = null, |
1353
|
|
|
$replyToMessageId = null, |
1354
|
|
|
$replyMarkup = null, |
1355
|
|
|
$disableNotification = false, |
1356
|
|
|
$parseMode = null, |
1357
|
|
|
$messageThreadId = null, |
1358
|
|
|
$protectContent = null, |
1359
|
|
|
$allowSendingWithoutReply = null |
1360
|
|
|
) { |
1361
|
|
|
return Message::fromResponse($this->call('sendPhoto', [ |
|
|
|
|
1362
|
|
|
'chat_id' => $chatId, |
1363
|
|
|
'photo' => $photo, |
1364
|
|
|
'caption' => $caption, |
1365
|
|
|
'message_thread_id' => $messageThreadId, |
1366
|
|
|
'reply_to_message_id' => $replyToMessageId, |
1367
|
|
|
'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(), |
1368
|
|
|
'disable_notification' => (bool) $disableNotification, |
1369
|
|
|
'parse_mode' => $parseMode, |
1370
|
|
|
'protect_content' => (bool) $protectContent, |
1371
|
|
|
'allow_sending_without_reply' => (bool) $allowSendingWithoutReply, |
1372
|
|
|
])); |
1373
|
|
|
} |
1374
|
|
|
|
1375
|
|
|
/** |
1376
|
|
|
* Use this method to send general files. On success, the sent Message is returned. |
1377
|
|
|
* Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future. |
1378
|
|
|
* |
1379
|
|
|
* @param int|string $chatId chat_id or @channel_name |
1380
|
|
|
* @param \CURLFile|\CURLStringFile|string $document |
1381
|
|
|
* @param string|null $caption |
1382
|
|
|
* @param int|null $replyToMessageId |
1383
|
|
|
* @param InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $replyMarkup |
1384
|
|
|
* @param bool $disableNotification |
1385
|
|
|
* @param string|null $parseMode |
1386
|
|
|
* @param int|null $messageThreadId |
1387
|
|
|
* @param bool|null $protectContent |
1388
|
|
|
* @param bool|null $allowSendingWithoutReply |
1389
|
|
|
* @param \CURLFile|\CURLStringFile|string|null $thumbnail |
1390
|
|
|
* |
1391
|
|
|
* @return Message |
1392
|
|
|
* @throws InvalidArgumentException |
1393
|
|
|
* @throws Exception |
1394
|
|
|
*/ |
1395
|
|
|
public function sendDocument( |
1396
|
|
|
$chatId, |
1397
|
|
|
$document, |
1398
|
|
|
$caption = null, |
1399
|
|
|
$replyToMessageId = null, |
1400
|
|
|
$replyMarkup = null, |
1401
|
|
|
$disableNotification = false, |
1402
|
|
|
$parseMode = null, |
1403
|
|
|
$messageThreadId = null, |
1404
|
|
|
$protectContent = null, |
1405
|
|
|
$allowSendingWithoutReply = null, |
1406
|
|
|
$thumbnail = null |
1407
|
|
|
) { |
1408
|
|
|
return Message::fromResponse($this->call('sendDocument', [ |
|
|
|
|
1409
|
|
|
'chat_id' => $chatId, |
1410
|
|
|
'document' => $document, |
1411
|
|
|
'caption' => $caption, |
1412
|
|
|
'message_thread_id' => $messageThreadId, |
1413
|
|
|
'reply_to_message_id' => $replyToMessageId, |
1414
|
|
|
'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(), |
1415
|
|
|
'disable_notification' => (bool) $disableNotification, |
1416
|
|
|
'parse_mode' => $parseMode, |
1417
|
|
|
'protect_content' => (bool) $protectContent, |
1418
|
|
|
'allow_sending_without_reply' => (bool) $allowSendingWithoutReply, |
1419
|
|
|
'thumbnail' => $thumbnail, |
1420
|
|
|
])); |
1421
|
|
|
} |
1422
|
|
|
|
1423
|
|
|
/** |
1424
|
|
|
* Use this method to get basic info about a file and prepare it for downloading. |
1425
|
|
|
* For the moment, bots can download files of up to 20MB in size. |
1426
|
|
|
* On success, a File object is returned. |
1427
|
|
|
* The file can then be downloaded via the link https://api.telegram.org/file/bot<token>/<file_path>, |
1428
|
|
|
* where <file_path> is taken from the response. |
1429
|
|
|
* It is guaranteed that the link will be valid for at least 1 hour. |
1430
|
|
|
* When the link expires, a new one can be requested by calling getFile again. |
1431
|
|
|
* |
1432
|
|
|
* @param string $fileId |
1433
|
|
|
* |
1434
|
|
|
* @return File |
1435
|
|
|
* @throws InvalidArgumentException |
1436
|
|
|
* @throws Exception |
1437
|
|
|
*/ |
1438
|
|
|
public function getFile($fileId) |
1439
|
|
|
{ |
1440
|
|
|
return File::fromResponse($this->call('getFile', ['file_id' => $fileId])); |
|
|
|
|
1441
|
|
|
} |
1442
|
|
|
|
1443
|
|
|
/** |
1444
|
|
|
* Use this method to send answers to an inline query. On success, True is returned. |
1445
|
|
|
* No more than 50 results per query are allowed. |
1446
|
|
|
* |
1447
|
|
|
* @param string $inlineQueryId |
1448
|
|
|
* @param AbstractInlineQueryResult[] $results |
1449
|
|
|
* @param int $cacheTime |
1450
|
|
|
* @param bool $isPersonal |
1451
|
|
|
* @param string $nextOffset |
1452
|
|
|
* @param string $switchPmText |
1453
|
|
|
* @param string $switchPmParameter |
1454
|
|
|
* |
1455
|
|
|
* @return mixed |
1456
|
|
|
* @throws Exception |
1457
|
|
|
*/ |
1458
|
|
|
public function answerInlineQuery( |
1459
|
|
|
$inlineQueryId, |
1460
|
|
|
$results, |
1461
|
|
|
$cacheTime = 300, |
1462
|
|
|
$isPersonal = false, |
1463
|
|
|
$nextOffset = '', |
1464
|
|
|
$switchPmText = null, |
1465
|
|
|
$switchPmParameter = null |
1466
|
|
|
) { |
1467
|
|
|
$results = array_map( |
1468
|
|
|
/** |
1469
|
|
|
* @param AbstractInlineQueryResult $item |
1470
|
|
|
* @return array |
1471
|
|
|
*/ |
1472
|
|
|
function ($item) { |
1473
|
|
|
/** @var array $array */ |
1474
|
|
|
$array = $item->toJson(true); |
1475
|
|
|
|
1476
|
|
|
return $array; |
1477
|
|
|
}, |
1478
|
|
|
$results |
1479
|
|
|
); |
1480
|
|
|
|
1481
|
|
|
return $this->call('answerInlineQuery', [ |
|
|
|
|
1482
|
|
|
'inline_query_id' => $inlineQueryId, |
1483
|
|
|
'results' => json_encode($results), |
1484
|
|
|
'cache_time' => $cacheTime, |
1485
|
|
|
'is_personal' => $isPersonal, |
1486
|
|
|
'next_offset' => $nextOffset, |
1487
|
|
|
'switch_pm_text' => $switchPmText, |
1488
|
|
|
'switch_pm_parameter' => $switchPmParameter, |
1489
|
|
|
]); |
1490
|
|
|
} |
1491
|
|
|
|
1492
|
|
|
/** |
1493
|
|
|
* Use this method to kick a user from a group or a supergroup. |
1494
|
|
|
* In the case of supergroups, the user will not be able to return to the group |
1495
|
|
|
* on their own using invite links, etc., unless unbanned first. |
1496
|
|
|
* The bot must be an administrator in the group for this to work. Returns True on success. |
1497
|
|
|
* |
1498
|
|
|
* @param int|string $chatId Unique identifier for the target group |
1499
|
|
|
* or username of the target supergroup (in the format @supergroupusername) |
1500
|
|
|
* @param int $userId Unique identifier of the target user |
1501
|
|
|
* @param null|int $untilDate Date when the user will be unbanned, unix time. |
1502
|
|
|
* If user is banned for more than 366 days or less than 30 seconds from the current time |
1503
|
|
|
* they are considered to be banned forever |
1504
|
|
|
* |
1505
|
|
|
* @return bool |
1506
|
|
|
* @throws Exception |
1507
|
|
|
*/ |
1508
|
|
|
public function kickChatMember($chatId, $userId, $untilDate = null) |
1509
|
|
|
{ |
1510
|
|
|
@trigger_error(sprintf('Method "%s::%s" is deprecated. Use "banChatMember"', __CLASS__, __METHOD__), \E_USER_DEPRECATED); |
1511
|
|
|
|
1512
|
|
|
return $this->call('kickChatMember', [ |
|
|
|
|
1513
|
|
|
'chat_id' => $chatId, |
1514
|
|
|
'user_id' => $userId, |
1515
|
|
|
'until_date' => $untilDate |
1516
|
|
|
]); |
1517
|
|
|
} |
1518
|
|
|
|
1519
|
|
|
/** |
1520
|
|
|
* Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, |
1521
|
|
|
* the user will not be able to return to the chat on their own using invite links, etc., unless unbanned first. |
1522
|
|
|
* The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. |
1523
|
|
|
* Returns True on success. |
1524
|
|
|
* |
1525
|
|
|
* @param int|string $chatId Unique identifier for the target group or username of the |
1526
|
|
|
* target supergroup or channel (in the format @channelusername) |
1527
|
|
|
* @param int $userId Unique identifier of the target user |
1528
|
|
|
* @param null|int $untilDate Date when the user will be unbanned, unix time. |
1529
|
|
|
* If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever. |
1530
|
|
|
* Applied for supergroups and channels only. |
1531
|
|
|
* @param bool|null $revokeMessages Pass True to delete all messages from the chat for the user that is being removed. |
1532
|
|
|
* If False, the user will be able to see messages in the group that were sent before the user was removed. |
1533
|
|
|
* Always True for supergroups and channels. |
1534
|
|
|
* |
1535
|
|
|
* @return bool |
1536
|
|
|
* @throws Exception |
1537
|
|
|
*/ |
1538
|
|
|
public function banChatMember($chatId, $userId, $untilDate = null, $revokeMessages = null) |
1539
|
|
|
{ |
1540
|
|
|
return $this->call('banChatMember', [ |
|
|
|
|
1541
|
|
|
'chat_id' => $chatId, |
1542
|
|
|
'user_id' => $userId, |
1543
|
|
|
'until_date' => $untilDate, |
1544
|
|
|
'revoke_messages' => $revokeMessages, |
1545
|
|
|
]); |
1546
|
|
|
} |
1547
|
|
|
|
1548
|
|
|
/** |
1549
|
|
|
* Use this method to unban a previously kicked user in a supergroup. |
1550
|
|
|
* The user will not return to the group automatically, but will be able to join via link, etc. |
1551
|
|
|
* The bot must be an administrator in the group for this to work. Returns True on success. |
1552
|
|
|
* |
1553
|
|
|
* @param int|string $chatId Unique identifier for the target group |
1554
|
|
|
* or username of the target supergroup (in the format @supergroupusername) |
1555
|
|
|
* @param int $userId Unique identifier of the target user |
1556
|
|
|
* |
1557
|
|
|
* @return bool |
1558
|
|
|
* @throws Exception |
1559
|
|
|
*/ |
1560
|
|
|
public function unbanChatMember($chatId, $userId) |
1561
|
|
|
{ |
1562
|
|
|
return $this->call('unbanChatMember', [ |
|
|
|
|
1563
|
|
|
'chat_id' => $chatId, |
1564
|
|
|
'user_id' => $userId, |
1565
|
|
|
]); |
1566
|
|
|
} |
1567
|
|
|
|
1568
|
|
|
/** |
1569
|
|
|
* Use this method to send answers to callback queries sent from inline keyboards. |
1570
|
|
|
* The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. |
1571
|
|
|
* |
1572
|
|
|
* @param string $callbackQueryId |
1573
|
|
|
* @param string|null $text |
1574
|
|
|
* @param bool $showAlert |
1575
|
|
|
* @param string|null $url |
1576
|
|
|
* @param int $cacheTime |
1577
|
|
|
* |
1578
|
|
|
* @return bool |
1579
|
|
|
* @throws Exception |
1580
|
|
|
*/ |
1581
|
|
|
public function answerCallbackQuery($callbackQueryId, $text = null, $showAlert = false, $url = null, $cacheTime = 0) |
1582
|
|
|
{ |
1583
|
|
|
return $this->call('answerCallbackQuery', [ |
|
|
|
|
1584
|
|
|
'callback_query_id' => $callbackQueryId, |
1585
|
|
|
'text' => $text, |
1586
|
|
|
'show_alert' => (bool) $showAlert, |
1587
|
|
|
'url' => $url, |
1588
|
|
|
'cache_time' => $cacheTime |
1589
|
|
|
]); |
1590
|
|
|
} |
1591
|
|
|
|
1592
|
|
|
/** |
1593
|
|
|
* Use this method to change the list of the bot's commands. Returns True on success. |
1594
|
|
|
* |
1595
|
|
|
* @param ArrayOfBotCommand|BotCommand[] $commands |
1596
|
|
|
* @param string|null $scope |
1597
|
|
|
* @param string|null $languageCode |
1598
|
|
|
* |
1599
|
|
|
* @return mixed |
1600
|
|
|
* @throws Exception |
1601
|
|
|
* @throws HttpException |
1602
|
|
|
* @throws InvalidJsonException |
1603
|
|
|
*/ |
1604
|
|
|
public function setMyCommands($commands, $scope = null, $languageCode = null) |
1605
|
|
|
{ |
1606
|
|
|
if (!$commands instanceof ArrayOfBotCommand) { |
1607
|
|
|
@trigger_error(sprintf('Passing array of BotCommand to "%s::%s" is deprecated. Use %s', __CLASS__, __METHOD__, ArrayOfBotCommand::class), \E_USER_DEPRECATED); |
1608
|
|
|
$commands = new ArrayOfBotCommand($commands); |
1609
|
|
|
} |
1610
|
|
|
|
1611
|
9 |
|
return $this->call('setMyCommands', [ |
|
|
|
|
1612
|
|
|
'commands' => $commands->toJson(), |
1613
|
9 |
|
'scope' => $scope, |
1614
|
9 |
|
'language_code' => $languageCode, |
1615
|
|
|
]); |
1616
|
|
|
} |
1617
|
|
|
|
1618
|
|
|
/** |
1619
|
|
|
* Use this method to get the current list of the bot's commands. Requires no parameters. |
1620
|
|
|
* Returns Array of BotCommand on success. |
1621
|
|
|
* |
1622
|
|
|
* @return ArrayOfBotCommand |
1623
|
|
|
* |
1624
|
|
|
* @throws Exception |
1625
|
|
|
* @throws HttpException |
1626
|
|
|
* @throws InvalidJsonException |
1627
|
|
|
*/ |
1628
|
|
|
public function getMyCommands() |
1629
|
|
|
{ |
1630
|
|
|
return ArrayOfBotCommand::fromResponse($this->call('getMyCommands')); |
|
|
|
|
1631
|
|
|
} |
1632
|
|
|
|
1633
|
|
|
/** |
1634
|
|
|
* Use this method to edit text messages sent by the bot or via the bot |
1635
|
|
|
* On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. |
1636
|
|
|
* |
1637
|
|
|
* @param int|string $chatId |
1638
|
|
|
* @param int $messageId |
1639
|
|
|
* @param string $text |
1640
|
|
|
* @param string $inlineMessageId |
1641
|
|
|
* @param string|null $parseMode |
1642
|
|
|
* @param bool $disablePreview |
1643
|
|
|
* @param InlineKeyboardMarkup|null $replyMarkup |
1644
|
|
|
* |
1645
|
|
|
* @return Message|true |
1646
|
|
|
* @throws Exception |
1647
|
|
|
*/ |
1648
|
|
|
public function editMessageText( |
1649
|
|
|
$chatId, |
1650
|
|
|
$messageId, |
1651
|
|
|
$text, |
1652
|
|
|
$parseMode = null, |
1653
|
|
|
$disablePreview = false, |
1654
|
|
|
$replyMarkup = null, |
1655
|
|
|
$inlineMessageId = null |
1656
|
|
|
) { |
1657
|
|
|
$response = $this->call('editMessageText', [ |
|
|
|
|
1658
|
|
|
'chat_id' => $chatId, |
1659
|
|
|
'message_id' => $messageId, |
1660
|
|
|
'text' => $text, |
1661
|
|
|
'inline_message_id' => $inlineMessageId, |
1662
|
|
|
'parse_mode' => $parseMode, |
1663
|
|
|
'disable_web_page_preview' => $disablePreview, |
1664
|
|
|
'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(), |
1665
|
|
|
]); |
1666
|
|
|
if ($response === true) { |
1667
|
|
|
return true; |
1668
|
|
|
} |
1669
|
|
|
|
1670
|
|
|
return Message::fromResponse($response); |
1671
|
|
|
} |
1672
|
|
|
|
1673
|
|
|
/** |
1674
|
|
|
* Use this method to edit text messages sent by the bot or via the bot |
1675
|
|
|
* On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. |
1676
|
|
|
* |
1677
|
|
|
* @param int|string $chatId |
1678
|
|
|
* @param int $messageId |
1679
|
|
|
* @param string|null $caption |
1680
|
|
|
* @param InlineKeyboardMarkup|null $replyMarkup |
1681
|
|
|
* @param string $inlineMessageId |
1682
|
|
|
* @param string|null $parseMode |
1683
|
|
|
* |
1684
|
|
|
* @return Message|true |
1685
|
|
|
* @throws InvalidArgumentException |
1686
|
|
|
* @throws Exception |
1687
|
|
|
*/ |
1688
|
|
|
public function editMessageCaption( |
1689
|
|
|
$chatId, |
1690
|
|
|
$messageId, |
1691
|
|
|
$caption = null, |
1692
|
|
|
$replyMarkup = null, |
1693
|
|
|
$inlineMessageId = null, |
1694
|
|
|
$parseMode = null |
1695
|
|
|
) { |
1696
|
|
|
$response = $this->call('editMessageCaption', [ |
|
|
|
|
1697
|
|
|
'chat_id' => $chatId, |
1698
|
|
|
'message_id' => $messageId, |
1699
|
|
|
'inline_message_id' => $inlineMessageId, |
1700
|
|
|
'caption' => $caption, |
1701
|
|
|
'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(), |
1702
|
|
|
'parse_mode' => $parseMode |
1703
|
|
|
]); |
1704
|
|
|
if ($response === true) { |
1705
|
|
|
return true; |
1706
|
|
|
} |
1707
|
|
|
|
1708
|
|
|
return Message::fromResponse($response); |
1709
|
|
|
} |
1710
|
|
|
|
1711
|
|
|
/** |
1712
|
|
|
* Use this method to edit animation, audio, document, photo, or video messages. |
1713
|
|
|
* If a message is a part of a message album, then it can be edited only to a photo or a video. |
1714
|
|
|
* Otherwise, message type can be changed arbitrarily. |
1715
|
|
|
* When inline message is edited, new file can't be uploaded. |
1716
|
|
|
* Use previously uploaded file via its file_id or specify a URL. |
1717
|
|
|
* On success, if the edited message was sent by the bot, the edited Message is returned, otherwise True is returned |
1718
|
|
|
* |
1719
|
|
|
* @param string $chatId |
1720
|
|
|
* @param string $messageId |
1721
|
|
|
* @param InputMedia $media |
1722
|
|
|
* @param string|null $inlineMessageId |
1723
|
|
|
* @param InlineKeyboardMarkup|null $replyMarkup |
1724
|
|
|
* @param array<string, \CURLFile|\CURLStringFile> $attachments Attachments to use in attach://<attachment> |
1725
|
|
|
* |
1726
|
|
|
* @return Message|true |
1727
|
|
|
* |
1728
|
|
|
* @throws Exception |
1729
|
|
|
* @throws HttpException |
1730
|
|
|
* @throws InvalidJsonException |
1731
|
|
|
*/ |
1732
|
|
|
public function editMessageMedia( |
1733
|
|
|
$chatId, |
1734
|
|
|
$messageId, |
1735
|
|
|
InputMedia $media, |
1736
|
|
|
$inlineMessageId = null, |
1737
|
|
|
$replyMarkup = null, |
1738
|
|
|
$attachments = [] |
1739
|
|
|
) { |
1740
|
|
|
$response = $this->call('editMessageMedia', [ |
|
|
|
|
1741
|
|
|
'chat_id' => $chatId, |
1742
|
|
|
'message_id' => $messageId, |
1743
|
|
|
'inline_message_id' => $inlineMessageId, |
1744
|
|
|
'media' => $media->toJson(), |
1745
|
|
|
'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(), |
1746
|
|
|
] + $attachments); |
1747
|
|
|
if ($response === true) { |
1748
|
|
|
return true; |
1749
|
|
|
} |
1750
|
|
|
|
1751
|
|
|
return Message::fromResponse($response); |
1752
|
|
|
} |
1753
|
|
|
|
1754
|
|
|
/** |
1755
|
|
|
* Use this method to edit only the reply markup of messages sent by the bot or via the bot |
1756
|
|
|
* On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. |
1757
|
|
|
* |
1758
|
|
|
* @param int|string $chatId |
1759
|
|
|
* @param int $messageId |
1760
|
|
|
* @param InlineKeyboardMarkup|null $replyMarkup |
1761
|
|
|
* @param string $inlineMessageId |
1762
|
|
|
* |
1763
|
|
|
* @return Message|true |
1764
|
|
|
* @throws Exception |
1765
|
|
|
*/ |
1766
|
|
|
public function editMessageReplyMarkup( |
1767
|
|
|
$chatId, |
1768
|
|
|
$messageId, |
1769
|
|
|
$replyMarkup = null, |
1770
|
|
|
$inlineMessageId = null |
1771
|
|
|
) { |
1772
|
|
|
$response = $this->call('editMessageReplyMarkup', [ |
|
|
|
|
1773
|
|
|
'chat_id' => $chatId, |
1774
|
|
|
'message_id' => $messageId, |
1775
|
|
|
'inline_message_id' => $inlineMessageId, |
1776
|
|
|
'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(), |
1777
|
|
|
]); |
1778
|
|
|
if ($response === true) { |
1779
|
|
|
return true; |
1780
|
|
|
} |
1781
|
|
|
|
1782
|
|
|
return Message::fromResponse($response); |
1783
|
|
|
} |
1784
|
|
|
|
1785
|
|
|
/** |
1786
|
|
|
* Use this method to delete a message, including service messages, with the following limitations: |
1787
|
|
|
* - A message can only be deleted if it was sent less than 48 hours ago. |
1788
|
|
|
* - Bots can delete outgoing messages in groups and supergroups. |
1789
|
|
|
* - Bots granted can_post_messages permissions can delete outgoing messages in channels. |
1790
|
|
|
* - If the bot is an administrator of a group, it can delete any message there. |
1791
|
|
|
* - If the bot has can_delete_messages permission in a supergroup or a channel, it can delete any message there. |
1792
|
|
|
* |
1793
|
|
|
* @param int|string $chatId |
1794
|
|
|
* @param int $messageId |
1795
|
|
|
* |
1796
|
|
|
* @return bool |
1797
|
|
|
* @throws Exception |
1798
|
|
|
*/ |
1799
|
|
|
public function deleteMessage($chatId, $messageId) |
1800
|
|
|
{ |
1801
|
|
|
return $this->call('deleteMessage', [ |
|
|
|
|
1802
|
|
|
'chat_id' => $chatId, |
1803
|
|
|
'message_id' => $messageId, |
1804
|
|
|
]); |
1805
|
|
|
} |
1806
|
|
|
|
1807
|
|
|
/** |
1808
|
|
|
* @deprecated |
1809
|
|
|
* |
1810
|
|
|
* @param Update $update |
1811
|
|
|
* @param string $eventName |
1812
|
|
|
* |
1813
|
|
|
* @throws Exception |
1814
|
|
|
* |
1815
|
|
|
* @return void |
1816
|
|
|
*/ |
1817
|
|
|
public function trackUpdate(Update $update, $eventName = 'Message') |
1818
|
|
|
{ |
1819
|
|
|
@trigger_error(sprintf('Method "%s::%s" is deprecated', __CLASS__, __METHOD__), \E_USER_DEPRECATED); |
1820
|
|
|
|
1821
|
|
|
if (!in_array($update->getUpdateId(), $this->trackedEvents)) { |
|
|
|
|
1822
|
|
|
$message = $update->getMessage(); |
1823
|
|
|
if (!$message) { |
1824
|
|
|
return; |
1825
|
|
|
} |
1826
|
|
|
$this->trackedEvents[] = $update->getUpdateId(); |
|
|
|
|
1827
|
|
|
|
1828
|
|
|
$this->track($message, $eventName); |
|
|
|
|
1829
|
|
|
|
1830
|
|
|
if (count($this->trackedEvents) > self::MAX_TRACKED_EVENTS) { |
|
|
|
|
1831
|
|
|
$this->trackedEvents = array_slice($this->trackedEvents, (int) round(self::MAX_TRACKED_EVENTS / 4)); |
|
|
|
|
1832
|
|
|
} |
1833
|
|
|
} |
1834
|
|
|
} |
1835
|
|
|
|
1836
|
|
|
/** |
1837
|
|
|
* @deprecated |
1838
|
|
|
* |
1839
|
|
|
* Wrapper for tracker |
1840
|
|
|
* |
1841
|
|
|
* @param Message $message |
1842
|
|
|
* @param string $eventName |
1843
|
|
|
* |
1844
|
|
|
* @throws Exception |
1845
|
|
|
* |
1846
|
|
|
* @return void |
1847
|
|
|
*/ |
1848
|
|
|
public function track(Message $message, $eventName = 'Message') |
1849
|
|
|
{ |
1850
|
|
|
@trigger_error(sprintf('Method "%s::%s" is deprecated', __CLASS__, __METHOD__), \E_USER_DEPRECATED); |
1851
|
|
|
|
1852
|
|
|
if ($this->tracker instanceof Botan) { |
|
|
|
|
1853
|
|
|
$this->tracker->track($message, $eventName); |
|
|
|
|
1854
|
|
|
} |
1855
|
|
|
} |
1856
|
|
|
|
1857
|
|
|
/** |
1858
|
|
|
* Use this method to send invoices. On success, the sent Message is returned. |
1859
|
|
|
* |
1860
|
|
|
* @param int|string $chatId |
1861
|
|
|
* @param string $title |
1862
|
|
|
* @param string $description |
1863
|
|
|
* @param string $payload |
1864
|
|
|
* @param string $providerToken |
1865
|
|
|
* @param string $startParameter |
1866
|
|
|
* @param string $currency |
1867
|
|
|
* @param array $prices |
1868
|
|
|
* @param bool $isFlexible |
1869
|
|
|
* @param string|null $photoUrl |
1870
|
|
|
* @param int|null $photoSize |
1871
|
|
|
* @param int|null $photoWidth |
1872
|
|
|
* @param int|null $photoHeight |
1873
|
|
|
* @param bool $needName |
1874
|
|
|
* @param bool $needPhoneNumber |
1875
|
|
|
* @param bool $needEmail |
1876
|
|
|
* @param bool $needShippingAddress |
1877
|
|
|
* @param int|null $replyToMessageId |
1878
|
|
|
* @param InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $replyMarkup |
1879
|
|
|
* @param bool $disableNotification |
1880
|
|
|
* @param string|null $providerData |
1881
|
|
|
* @param bool $sendPhoneNumberToProvider |
1882
|
|
|
* @param bool $sendEmailToProvider |
1883
|
|
|
* @param int|null $messageThreadId |
1884
|
|
|
* @param bool|null $protectContent |
1885
|
|
|
* @param bool|null $allowSendingWithoutReply |
1886
|
|
|
* |
1887
|
|
|
* @return Message |
1888
|
|
|
* @throws Exception |
1889
|
|
|
*/ |
1890
|
|
|
public function sendInvoice( |
1891
|
|
|
$chatId, |
1892
|
|
|
$title, |
1893
|
|
|
$description, |
1894
|
|
|
$payload, |
1895
|
|
|
$providerToken, |
1896
|
|
|
$startParameter, |
1897
|
|
|
$currency, |
1898
|
|
|
$prices, |
1899
|
|
|
$isFlexible = false, |
1900
|
|
|
$photoUrl = null, |
1901
|
|
|
$photoSize = null, |
1902
|
|
|
$photoWidth = null, |
1903
|
|
|
$photoHeight = null, |
1904
|
|
|
$needName = false, |
1905
|
|
|
$needPhoneNumber = false, |
1906
|
|
|
$needEmail = false, |
1907
|
|
|
$needShippingAddress = false, |
1908
|
|
|
$replyToMessageId = null, |
1909
|
|
|
$replyMarkup = null, |
1910
|
|
|
$disableNotification = false, |
1911
|
|
|
$providerData = null, |
1912
|
|
|
$sendPhoneNumberToProvider = false, |
1913
|
|
|
$sendEmailToProvider = false, |
1914
|
|
|
$messageThreadId = null, |
1915
|
|
|
$protectContent = null, |
1916
|
|
|
$allowSendingWithoutReply = null |
1917
|
|
|
) { |
1918
|
|
|
return Message::fromResponse($this->call('sendInvoice', [ |
|
|
|
|
1919
|
|
|
'chat_id' => $chatId, |
1920
|
|
|
'title' => $title, |
1921
|
|
|
'description' => $description, |
1922
|
|
|
'payload' => $payload, |
1923
|
|
|
'provider_token' => $providerToken, |
1924
|
|
|
'start_parameter' => $startParameter, |
1925
|
|
|
'currency' => $currency, |
1926
|
|
|
'prices' => json_encode($prices), |
1927
|
|
|
'is_flexible' => $isFlexible, |
1928
|
|
|
'photo_url' => $photoUrl, |
1929
|
|
|
'photo_size' => $photoSize, |
1930
|
|
|
'photo_width' => $photoWidth, |
1931
|
|
|
'photo_height' => $photoHeight, |
1932
|
|
|
'need_name' => $needName, |
1933
|
|
|
'need_phone_number' => $needPhoneNumber, |
1934
|
|
|
'need_email' => $needEmail, |
1935
|
|
|
'need_shipping_address' => $needShippingAddress, |
1936
|
|
|
'message_thread_id' => $messageThreadId, |
1937
|
|
|
'reply_to_message_id' => $replyToMessageId, |
1938
|
|
|
'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(), |
1939
|
|
|
'disable_notification' => (bool) $disableNotification, |
1940
|
|
|
'provider_data' => $providerData, |
1941
|
|
|
'send_phone_number_to_provider' => (bool) $sendPhoneNumberToProvider, |
1942
|
|
|
'send_email_to_provider' => (bool) $sendEmailToProvider, |
1943
|
|
|
'protect_content' => (bool) $protectContent, |
1944
|
|
|
'allow_sending_without_reply' => (bool) $allowSendingWithoutReply, |
1945
|
|
|
])); |
1946
|
|
|
} |
1947
|
|
|
|
1948
|
|
|
/** |
1949
|
|
|
* If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API |
1950
|
|
|
* will send an Update with a shipping_query field to the bot. Use this method to reply to shipping queries. |
1951
|
|
|
* On success, True is returned. |
1952
|
|
|
* |
1953
|
|
|
* @param string $shippingQueryId |
1954
|
|
|
* @param bool $ok |
1955
|
|
|
* @param array $shippingOptions |
1956
|
|
|
* @param null|string $errorMessage |
1957
|
|
|
* |
1958
|
|
|
* @return bool |
1959
|
|
|
* @throws Exception |
1960
|
|
|
*/ |
1961
|
|
|
public function answerShippingQuery($shippingQueryId, $ok = true, $shippingOptions = [], $errorMessage = null) |
1962
|
|
|
{ |
1963
|
|
|
return $this->call('answerShippingQuery', [ |
|
|
|
|
1964
|
|
|
'shipping_query_id' => $shippingQueryId, |
1965
|
|
|
'ok' => (bool) $ok, |
1966
|
|
|
'shipping_options' => json_encode($shippingOptions), |
1967
|
|
|
'error_message' => $errorMessage |
1968
|
|
|
]); |
1969
|
|
|
} |
1970
|
|
|
|
1971
|
|
|
/** |
1972
|
|
|
* Use this method to respond to such pre-checkout queries. On success, True is returned. |
1973
|
|
|
* Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent. |
1974
|
|
|
* |
1975
|
|
|
* @param string $preCheckoutQueryId |
1976
|
|
|
* @param bool $ok |
1977
|
|
|
* @param null|string $errorMessage |
1978
|
|
|
* |
1979
|
|
|
* @return bool |
1980
|
|
|
* @throws Exception |
1981
|
|
|
*/ |
1982
|
|
|
public function answerPreCheckoutQuery($preCheckoutQueryId, $ok = true, $errorMessage = null) |
1983
|
|
|
{ |
1984
|
|
|
return $this->call('answerPreCheckoutQuery', [ |
|
|
|
|
1985
|
|
|
'pre_checkout_query_id' => $preCheckoutQueryId, |
1986
|
|
|
'ok' => (bool) $ok, |
1987
|
|
|
'error_message' => $errorMessage |
1988
|
|
|
]); |
1989
|
|
|
} |
1990
|
|
|
|
1991
|
|
|
/** |
1992
|
|
|
* Use this method to restrict a user in a supergroup. |
1993
|
|
|
* The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights. |
1994
|
|
|
* Pass True for all boolean parameters to lift restrictions from a user. |
1995
|
|
|
* |
1996
|
|
|
* @param string|int $chatId Unique identifier for the target chat or username of the target supergroup |
1997
|
|
|
* (in the format @supergroupusername) |
1998
|
|
|
* @param int $userId Unique identifier of the target user |
1999
|
|
|
* @param null|integer $untilDate Date when restrictions will be lifted for the user, unix time. |
2000
|
|
|
* If user is restricted for more than 366 days or less than 30 seconds from the current time, |
2001
|
|
|
* they are considered to be restricted forever |
2002
|
|
|
* @param bool $canSendMessages Pass True, if the user can send text messages, contacts, locations and venues |
2003
|
|
|
* @param bool $canSendMediaMessages No Pass True, if the user can send audios, documents, photos, videos, |
2004
|
|
|
* video notes and voice notes, implies can_send_messages |
2005
|
|
|
* @param bool $canSendOtherMessages Pass True, if the user can send animations, games, stickers and |
2006
|
|
|
* use inline bots, implies can_send_media_messages |
2007
|
|
|
* @param bool $canAddWebPagePreviews Pass True, if the user may add web page previews to their messages, |
2008
|
|
|
* implies can_send_media_messages |
2009
|
|
|
* |
2010
|
|
|
* @return bool |
2011
|
|
|
* @throws Exception |
2012
|
|
|
*/ |
2013
|
|
|
public function restrictChatMember( |
2014
|
|
|
$chatId, |
2015
|
|
|
$userId, |
2016
|
|
|
$untilDate = null, |
2017
|
|
|
$canSendMessages = false, |
2018
|
|
|
$canSendMediaMessages = false, |
2019
|
|
|
$canSendOtherMessages = false, |
2020
|
|
|
$canAddWebPagePreviews = false |
2021
|
|
|
) { |
2022
|
|
|
return $this->call('restrictChatMember', [ |
|
|
|
|
2023
|
|
|
'chat_id' => $chatId, |
2024
|
|
|
'user_id' => $userId, |
2025
|
|
|
'until_date' => $untilDate, |
2026
|
|
|
'can_send_messages' => $canSendMessages, |
2027
|
|
|
'can_send_media_messages' => $canSendMediaMessages, |
2028
|
|
|
'can_send_other_messages' => $canSendOtherMessages, |
2029
|
|
|
'can_add_web_page_previews' => $canAddWebPagePreviews |
2030
|
|
|
]); |
2031
|
|
|
} |
2032
|
|
|
|
2033
|
|
|
/** |
2034
|
|
|
* Use this method to promote or demote a user in a supergroup or a channel. |
2035
|
|
|
* The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
2036
|
|
|
* Pass False for all boolean parameters to demote a user. |
2037
|
|
|
* |
2038
|
|
|
* @param string|int $chatId Unique identifier for the target chat or username of the target supergroup |
2039
|
|
|
* (in the format @supergroupusername) |
2040
|
|
|
* @param int $userId Unique identifier of the target user |
2041
|
|
|
* @param bool $canChangeInfo Pass True, if the administrator can change chat title, photo and other settings |
2042
|
|
|
* @param bool $canPostMessages Pass True, if the administrator can create channel posts, channels only |
2043
|
|
|
* @param bool $canEditMessages Pass True, if the administrator can edit messages of other users, channels only |
2044
|
|
|
* @param bool $canDeleteMessages Pass True, if the administrator can delete messages of other users |
2045
|
|
|
* @param bool $canInviteUsers Pass True, if the administrator can invite new users to the chat |
2046
|
|
|
* @param bool $canRestrictMembers Pass True, if the administrator can restrict, ban or unban chat members |
2047
|
|
|
* @param bool $canPinMessages Pass True, if the administrator can pin messages, supergroups only |
2048
|
|
|
* @param bool $canPromoteMembers Pass True, if the administrator can add new administrators with a subset of his |
2049
|
|
|
* own privileges or demote administrators that he has promoted,directly or |
2050
|
|
|
* indirectly (promoted by administrators that were appointed by him) |
2051
|
|
|
* @param bool $canManageTopics Pass True if the user is allowed to create, rename, close, and reopen forum topics, supergroups only |
2052
|
|
|
* @param bool $isAnonymous Pass True if the administrator's presence in the chat is hidden |
2053
|
|
|
* @return bool |
2054
|
|
|
* |
2055
|
|
|
* @throws Exception |
2056
|
|
|
* @throws HttpException |
2057
|
|
|
* @throws InvalidJsonException |
2058
|
|
|
*/ |
2059
|
|
|
public function promoteChatMember( |
2060
|
|
|
$chatId, |
2061
|
|
|
$userId, |
2062
|
|
|
$canChangeInfo = true, |
2063
|
|
|
$canPostMessages = true, |
2064
|
|
|
$canEditMessages = true, |
2065
|
|
|
$canDeleteMessages = true, |
2066
|
|
|
$canInviteUsers = true, |
2067
|
|
|
$canRestrictMembers = true, |
2068
|
|
|
$canPinMessages = true, |
2069
|
|
|
$canPromoteMembers = true, |
2070
|
|
|
$canManageTopics = true, |
2071
|
|
|
$isAnonymous = false |
2072
|
|
|
) { |
2073
|
|
|
return $this->call('promoteChatMember', [ |
|
|
|
|
2074
|
|
|
'chat_id' => $chatId, |
2075
|
|
|
'user_id' => $userId, |
2076
|
|
|
'is_anonymous' => $isAnonymous, |
2077
|
|
|
'can_change_info' => $canChangeInfo, |
2078
|
|
|
'can_post_messages' => $canPostMessages, |
2079
|
|
|
'can_edit_messages' => $canEditMessages, |
2080
|
|
|
'can_delete_messages' => $canDeleteMessages, |
2081
|
|
|
'can_invite_users' => $canInviteUsers, |
2082
|
|
|
'can_restrict_members' => $canRestrictMembers, |
2083
|
|
|
'can_pin_messages' => $canPinMessages, |
2084
|
|
|
'can_promote_members' => $canPromoteMembers, |
2085
|
|
|
'can_manage_topics' => $canManageTopics |
2086
|
|
|
]); |
2087
|
|
|
} |
2088
|
|
|
|
2089
|
|
|
/** |
2090
|
|
|
* Use this method to export an invite link to a supergroup or a channel. |
2091
|
|
|
* The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
2092
|
|
|
* |
2093
|
|
|
* @param string|int $chatId Unique identifier for the target chat or username of the target channel |
2094
|
|
|
* (in the format @channelusername) |
2095
|
|
|
* @return string |
2096
|
|
|
* @throws Exception |
2097
|
|
|
*/ |
2098
|
|
|
public function exportChatInviteLink($chatId) |
2099
|
|
|
{ |
2100
|
|
|
return $this->call('exportChatInviteLink', [ |
|
|
|
|
2101
|
|
|
'chat_id' => $chatId |
2102
|
|
|
]); |
2103
|
|
|
} |
2104
|
|
|
|
2105
|
|
|
/** |
2106
|
|
|
* Use this method to create an additional invite link for a chat. The bot must be an administrator in the chat |
2107
|
|
|
* for this to work and must have the appropriate administrator rights. |
2108
|
|
|
* The link can be revoked using the method revokeChatInviteLink. |
2109
|
|
|
* Returns the new invite link as ChatInviteLink object. |
2110
|
|
|
* |
2111
|
|
|
* @param int|string $chatId Unique identifier for the target chat or |
2112
|
|
|
* username of the target channel (in the format @channelusername) |
2113
|
|
|
* @param string|null $name Invite link name; 0-32 characters |
2114
|
|
|
* @param int|null $expireDate Point in time (Unix timestamp) when the link will expire |
2115
|
|
|
* @param int|null $memberLimit The maximum number of users that can be members of the chat simultaneously |
2116
|
|
|
* after joining the chat via this invite link; 1-99999 |
2117
|
|
|
* @param bool|null $createsJoinRequest True, if users joining the chat via the link need to be approved by chat administrators. |
2118
|
|
|
* If True, member_limit can't be specified |
2119
|
|
|
* @return ChatInviteLink |
2120
|
|
|
* @throws Exception |
2121
|
|
|
*/ |
2122
|
|
|
public function createChatInviteLink($chatId, $name = null, $expireDate = null, $memberLimit = null, $createsJoinRequest = null) |
2123
|
|
|
{ |
2124
|
|
|
return ChatInviteLink::fromResponse($this->call('createChatInviteLink', [ |
|
|
|
|
2125
|
|
|
'chat_id' => $chatId, |
2126
|
|
|
'name' => $name, |
2127
|
|
|
'expire_date' => $expireDate, |
2128
|
|
|
'member_limit' => $memberLimit, |
2129
|
|
|
'creates_join_request' => $createsJoinRequest, |
2130
|
|
|
])); |
2131
|
|
|
} |
2132
|
|
|
|
2133
|
|
|
/** |
2134
|
|
|
* Use this method to edit a non-primary invite link created by the bot. |
2135
|
|
|
* The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. |
2136
|
|
|
* Returns the edited invite link as a ChatInviteLink object. |
2137
|
|
|
* |
2138
|
|
|
* @param int|string $chatId Unique identifier for the target chat or |
2139
|
|
|
* username of the target channel (in the format @channelusername) |
2140
|
|
|
* @param string $inviteLink The invite link to edit |
2141
|
|
|
* @param string|null $name Invite link name; 0-32 characters |
2142
|
|
|
* @param int|null $expireDate Point in time (Unix timestamp) when the link will expire |
2143
|
|
|
* @param int|null $memberLimit The maximum number of users that can be members of the chat simultaneously |
2144
|
|
|
* after joining the chat via this invite link; 1-99999 |
2145
|
|
|
* @param bool|null $createsJoinRequest True, if users joining the chat via the link need to be approved by chat administrators. |
2146
|
|
|
* If True, member_limit can't be specified |
2147
|
|
|
* @return ChatInviteLink |
2148
|
|
|
* @throws Exception |
2149
|
|
|
*/ |
2150
|
|
|
public function editChatInviteLink($chatId, $inviteLink, $name = null, $expireDate = null, $memberLimit = null, $createsJoinRequest = null) |
2151
|
|
|
{ |
2152
|
|
|
return ChatInviteLink::fromResponse($this->call('editChatInviteLink', [ |
|
|
|
|
2153
|
|
|
'chat_id' => $chatId, |
2154
|
|
|
'invite_link' => $inviteLink, |
2155
|
|
|
'name' => $name, |
2156
|
|
|
'expire_date' => $expireDate, |
2157
|
|
|
'member_limit' => $memberLimit, |
2158
|
|
|
'creates_join_request' => $createsJoinRequest, |
2159
|
|
|
])); |
2160
|
|
|
} |
2161
|
|
|
|
2162
|
|
|
/** |
2163
|
|
|
* Use this method to revoke an invite link created by the bot. |
2164
|
|
|
* If the primary link is revoked, a new link is automatically generated. |
2165
|
|
|
* The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. |
2166
|
|
|
* Returns the revoked invite link as ChatInviteLink object. |
2167
|
|
|
* |
2168
|
|
|
* @param int|string $chatId Unique identifier for the target chat or |
2169
|
|
|
* username of the target channel (in the format @channelusername) |
2170
|
|
|
* @param string $inviteLink The invite link to edit |
2171
|
|
|
* @return ChatInviteLink |
2172
|
|
|
* @throws Exception |
2173
|
|
|
*/ |
2174
|
|
|
public function revokeChatInviteLink($chatId, $inviteLink) |
2175
|
|
|
{ |
2176
|
|
|
return ChatInviteLink::fromResponse($this->call('revokeChatInviteLink', [ |
|
|
|
|
2177
|
|
|
'chat_id' => $chatId, |
2178
|
|
|
'invite_link' => $inviteLink, |
2179
|
|
|
])); |
2180
|
|
|
} |
2181
|
|
|
|
2182
|
|
|
/** |
2183
|
|
|
* Use this method to approve a chat join request. The bot must be an administrator in the chat for this to work and |
2184
|
|
|
* must have the can_invite_users administrator right. Returns True on success. |
2185
|
|
|
* |
2186
|
|
|
* @param int|string $chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
2187
|
|
|
* @param int $userId Unique identifier of the target user |
2188
|
|
|
* @return bool |
2189
|
|
|
* @throws Exception |
2190
|
|
|
*/ |
2191
|
|
|
public function approveChatJoinRequest($chatId, $userId) |
2192
|
|
|
{ |
2193
|
|
|
return $this->call('approveChatJoinRequest', [ |
|
|
|
|
2194
|
|
|
'chat_id' => $chatId, |
2195
|
|
|
'user_id' => $userId, |
2196
|
|
|
]); |
2197
|
|
|
} |
2198
|
|
|
|
2199
|
|
|
/** |
2200
|
|
|
* Use this method to decline a chat join request. The bot must be an administrator in the chat for this to work and |
2201
|
|
|
* must have the can_invite_users administrator right. Returns True on success. |
2202
|
|
|
* |
2203
|
|
|
* @param int|string $chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
2204
|
|
|
* @param int $userId Unique identifier of the target user |
2205
|
|
|
* @return bool |
2206
|
|
|
* @throws Exception |
2207
|
|
|
*/ |
2208
|
|
|
public function declineChatJoinRequest($chatId, $userId) |
2209
|
|
|
{ |
2210
|
|
|
return $this->call('declineChatJoinRequest', [ |
|
|
|
|
2211
|
|
|
'chat_id' => $chatId, |
2212
|
|
|
'user_id' => $userId, |
2213
|
|
|
]); |
2214
|
|
|
} |
2215
|
|
|
|
2216
|
|
|
/** |
2217
|
|
|
* Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. |
2218
|
|
|
* The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
2219
|
|
|
* |
2220
|
|
|
* @param string|int $chatId Unique identifier for the target chat or username of the target channel |
2221
|
|
|
* (in the format @channelusername) |
2222
|
|
|
* @param \CURLFile|string $photo New chat photo, uploaded using multipart/form-data |
2223
|
|
|
* |
2224
|
|
|
* @return bool |
2225
|
|
|
* @throws Exception |
2226
|
|
|
*/ |
2227
|
|
|
public function setChatPhoto($chatId, $photo) |
2228
|
|
|
{ |
2229
|
|
|
return $this->call('setChatPhoto', [ |
|
|
|
|
2230
|
|
|
'chat_id' => $chatId, |
2231
|
|
|
'photo' => $photo |
2232
|
|
|
]); |
2233
|
|
|
} |
2234
|
|
|
|
2235
|
|
|
/** |
2236
|
|
|
* Use this method to delete a chat photo. Photos can't be changed for private chats. |
2237
|
|
|
* The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
2238
|
|
|
* |
2239
|
|
|
* @param string|int $chatId Unique identifier for the target chat or username of the target channel |
2240
|
|
|
* (in the format @channelusername) |
2241
|
|
|
* |
2242
|
|
|
* @return bool |
2243
|
|
|
* @throws Exception |
2244
|
|
|
*/ |
2245
|
|
|
public function deleteChatPhoto($chatId) |
2246
|
|
|
{ |
2247
|
|
|
return $this->call('deleteChatPhoto', [ |
|
|
|
|
2248
|
|
|
'chat_id' => $chatId |
2249
|
|
|
]); |
2250
|
|
|
} |
2251
|
|
|
|
2252
|
|
|
/** |
2253
|
|
|
* Use this method to change the title of a chat. Titles can't be changed for private chats. |
2254
|
|
|
* The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
2255
|
|
|
* |
2256
|
|
|
* @param string|int $chatId Unique identifier for the target chat or username of the target channel |
2257
|
|
|
* (in the format @channelusername) |
2258
|
|
|
* @param string $title New chat title, 1-255 characters |
2259
|
|
|
* |
2260
|
|
|
* @return bool |
2261
|
|
|
* @throws Exception |
2262
|
|
|
*/ |
2263
|
|
|
public function setChatTitle($chatId, $title) |
2264
|
|
|
{ |
2265
|
|
|
return $this->call('setChatTitle', [ |
|
|
|
|
2266
|
|
|
'chat_id' => $chatId, |
2267
|
|
|
'title' => $title |
2268
|
|
|
]); |
2269
|
|
|
} |
2270
|
|
|
|
2271
|
|
|
/** |
2272
|
|
|
* Use this method to change the description of a supergroup or a channel. |
2273
|
|
|
* The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
2274
|
|
|
* |
2275
|
|
|
* @param string|int $chatId Unique identifier for the target chat or username of the target channel |
2276
|
|
|
* (in the format @channelusername) |
2277
|
|
|
* @param string|null $description New chat description, 0-255 characters |
2278
|
|
|
* |
2279
|
|
|
* @return bool |
2280
|
|
|
* @throws Exception |
2281
|
|
|
*/ |
2282
|
|
|
public function setChatDescription($chatId, $description = null) |
2283
|
|
|
{ |
2284
|
|
|
return $this->call('setChatDescription', [ |
|
|
|
|
2285
|
|
|
'chat_id' => $chatId, |
2286
|
|
|
'title' => $description |
2287
|
|
|
]); |
2288
|
|
|
} |
2289
|
|
|
|
2290
|
|
|
/** |
2291
|
|
|
* Use this method to pin a message in a supergroup. |
2292
|
|
|
* The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
2293
|
|
|
* |
2294
|
|
|
* @param string|int $chatId Unique identifier for the target chat or username of the target channel |
2295
|
|
|
* (in the format @channelusername) |
2296
|
|
|
* @param int $messageId Identifier of a message to pin |
2297
|
|
|
* @param bool $disableNotification |
2298
|
|
|
* |
2299
|
|
|
* @return bool |
2300
|
|
|
* @throws Exception |
2301
|
|
|
*/ |
2302
|
|
|
public function pinChatMessage($chatId, $messageId, $disableNotification = false) |
2303
|
|
|
{ |
2304
|
|
|
return $this->call('pinChatMessage', [ |
|
|
|
|
2305
|
|
|
'chat_id' => $chatId, |
2306
|
|
|
'message_id' => $messageId, |
2307
|
|
|
'disable_notification' => $disableNotification |
2308
|
|
|
]); |
2309
|
|
|
} |
2310
|
|
|
|
2311
|
|
|
/** |
2312
|
|
|
* Use this method to unpin a message in a supergroup chat. |
2313
|
|
|
* The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
2314
|
|
|
* |
2315
|
|
|
* @param string|int $chatId Unique identifier for the target chat or username of the target channel |
2316
|
|
|
* (in the format @channelusername) |
2317
|
|
|
* @param int|null $messageId Identifier of a message to pin (optional) |
2318
|
|
|
* |
2319
|
|
|
* @return bool |
2320
|
|
|
* @throws Exception |
2321
|
|
|
*/ |
2322
|
|
|
public function unpinChatMessage($chatId, $messageId = null) |
2323
|
|
|
{ |
2324
|
|
|
return $this->call('unpinChatMessage', [ |
|
|
|
|
2325
|
|
|
'chat_id' => $chatId, |
2326
|
|
|
'message_id' => $messageId, |
2327
|
|
|
]); |
2328
|
|
|
} |
2329
|
|
|
|
2330
|
|
|
/** |
2331
|
|
|
* Use this method to get up to date information about the chat |
2332
|
|
|
* (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). |
2333
|
|
|
* |
2334
|
|
|
* @param string|int $chatId Unique identifier for the target chat or username of the target channel |
2335
|
|
|
* (in the format @channelusername) |
2336
|
|
|
* |
2337
|
|
|
* @return Chat |
2338
|
|
|
* @throws Exception |
2339
|
|
|
*/ |
2340
|
|
|
public function getChat($chatId) |
2341
|
|
|
{ |
2342
|
|
|
return Chat::fromResponse($this->call('getChat', [ |
|
|
|
|
2343
|
|
|
'chat_id' => $chatId |
2344
|
|
|
])); |
2345
|
|
|
} |
2346
|
|
|
|
2347
|
|
|
/** |
2348
|
|
|
* Use this method to get information about a member of a chat. |
2349
|
|
|
* |
2350
|
|
|
* @param string|int $chatId Unique identifier for the target chat or username of the target channel |
2351
|
|
|
* (in the format @channelusername) |
2352
|
|
|
* @param int $userId |
2353
|
|
|
* |
2354
|
|
|
* @return ChatMember |
2355
|
|
|
* @throws Exception |
2356
|
|
|
*/ |
2357
|
|
|
public function getChatMember($chatId, $userId) |
2358
|
|
|
{ |
2359
|
|
|
return ChatMember::fromResponse($this->call('getChatMember', [ |
|
|
|
|
2360
|
|
|
'chat_id' => $chatId, |
2361
|
|
|
'user_id' => $userId |
2362
|
|
|
])); |
2363
|
|
|
} |
2364
|
|
|
|
2365
|
|
|
/** |
2366
|
|
|
* Use this method for your bot to leave a group, supergroup or channel. |
2367
|
|
|
* |
2368
|
|
|
* @param string|int $chatId Unique identifier for the target chat or username of the target channel |
2369
|
|
|
* (in the format @channelusername) |
2370
|
|
|
* |
2371
|
|
|
* @return bool |
2372
|
|
|
* @throws Exception |
2373
|
|
|
*/ |
2374
|
|
|
public function leaveChat($chatId) |
2375
|
|
|
{ |
2376
|
|
|
return $this->call('leaveChat', [ |
|
|
|
|
2377
|
|
|
'chat_id' => $chatId |
2378
|
|
|
]); |
2379
|
|
|
} |
2380
|
|
|
|
2381
|
|
|
/** |
2382
|
|
|
* Use this method to get the number of members in a chat. |
2383
|
|
|
* |
2384
|
|
|
* @param string|int $chatId Unique identifier for the target chat or username of the target channel |
2385
|
|
|
* (in the format @channelusername) |
2386
|
|
|
* |
2387
|
|
|
* @return int |
2388
|
|
|
* @throws Exception |
2389
|
|
|
*/ |
2390
|
|
|
public function getChatMembersCount($chatId) |
2391
|
|
|
{ |
2392
|
|
|
@trigger_error(sprintf('Method "%s::%s" is deprecated. Use "getChatMemberCount"', __CLASS__, __METHOD__), \E_USER_DEPRECATED); |
2393
|
|
|
|
2394
|
|
|
return $this->call('getChatMembersCount', [ |
|
|
|
|
2395
|
|
|
'chat_id' => $chatId |
2396
|
|
|
]); |
2397
|
|
|
} |
2398
|
|
|
|
2399
|
|
|
/** |
2400
|
|
|
* Use this method to get the number of members in a chat. Returns Int on success. |
2401
|
|
|
* |
2402
|
|
|
* @param string|int $chatId Unique identifier for the target chat or username of the target supergroup or channel |
2403
|
|
|
* (in the format @channelusername) |
2404
|
|
|
* |
2405
|
|
|
* @return int |
2406
|
|
|
* @throws Exception |
2407
|
|
|
*/ |
2408
|
|
|
public function getChatMemberCount($chatId) |
2409
|
|
|
{ |
2410
|
|
|
return $this->call('getChatMemberCount', [ |
|
|
|
|
2411
|
|
|
'chat_id' => $chatId |
2412
|
|
|
]); |
2413
|
|
|
} |
2414
|
|
|
|
2415
|
|
|
/** |
2416
|
|
|
* Use this method to get a list of administrators in a chat. |
2417
|
|
|
* |
2418
|
|
|
* @param string|int $chatId Unique identifier for the target chat or username of the target channel |
2419
|
|
|
* (in the format @channelusername) |
2420
|
|
|
* |
2421
|
|
|
* @return ChatMember[] |
2422
|
|
|
* @throws InvalidArgumentException |
2423
|
|
|
* @throws Exception |
2424
|
|
|
*/ |
2425
|
|
|
public function getChatAdministrators($chatId) |
2426
|
|
|
{ |
2427
|
|
|
return ArrayOfChatMemberEntity::fromResponse( |
2428
|
|
|
$this->call( |
|
|
|
|
2429
|
|
|
'getChatAdministrators', |
2430
|
|
|
[ |
2431
|
|
|
'chat_id' => $chatId |
2432
|
|
|
] |
2433
|
|
|
) |
2434
|
|
|
); |
2435
|
|
|
} |
2436
|
|
|
|
2437
|
|
|
/** |
2438
|
|
|
* As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long. |
2439
|
|
|
* Use this method to send video messages. |
2440
|
|
|
* On success, the sent Message is returned. |
2441
|
|
|
* |
2442
|
|
|
* @param int|string $chatId chat_id or @channel_name |
2443
|
|
|
* @param \CURLFile|string $videoNote |
2444
|
|
|
* @param int|null $duration |
2445
|
|
|
* @param int|null $length |
2446
|
|
|
* @param int|null $replyToMessageId |
2447
|
|
|
* @param InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $replyMarkup |
2448
|
|
|
* @param bool $disableNotification |
2449
|
|
|
* @param int|null $messageThreadId |
2450
|
|
|
* @param bool|null $protectContent |
2451
|
|
|
* @param bool|null $allowSendingWithoutReply |
2452
|
|
|
* @param \CURLFile|\CURLStringFile|string|null $thumbnail |
2453
|
|
|
* |
2454
|
|
|
* @return Message |
2455
|
|
|
* @throws InvalidArgumentException |
2456
|
|
|
* @throws Exception |
2457
|
|
|
*/ |
2458
|
|
|
public function sendVideoNote( |
2459
|
|
|
$chatId, |
2460
|
|
|
$videoNote, |
2461
|
|
|
$duration = null, |
2462
|
|
|
$length = null, |
2463
|
|
|
$replyToMessageId = null, |
2464
|
|
|
$replyMarkup = null, |
2465
|
|
|
$disableNotification = false, |
2466
|
|
|
$messageThreadId = null, |
2467
|
|
|
$protectContent = null, |
2468
|
|
|
$allowSendingWithoutReply = null, |
2469
|
|
|
$thumbnail = null |
2470
|
|
|
) { |
2471
|
|
|
return Message::fromResponse($this->call('sendVideoNote', [ |
|
|
|
|
2472
|
|
|
'chat_id' => $chatId, |
2473
|
|
|
'video_note' => $videoNote, |
2474
|
|
|
'duration' => $duration, |
2475
|
|
|
'length' => $length, |
2476
|
|
|
'message_thread_id' => $messageThreadId, |
2477
|
|
|
'reply_to_message_id' => $replyToMessageId, |
2478
|
|
|
'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(), |
2479
|
|
|
'disable_notification' => (bool) $disableNotification, |
2480
|
|
|
'protect_content' => (bool) $protectContent, |
2481
|
|
|
'allow_sending_without_reply' => (bool) $allowSendingWithoutReply, |
2482
|
|
|
'thumbnail' => $thumbnail, |
2483
|
|
|
])); |
2484
|
|
|
} |
2485
|
|
|
|
2486
|
|
|
/** |
2487
|
|
|
* Use this method to send a group of photos or videos as an album. |
2488
|
|
|
* On success, the sent \TelegramBot\Api\Types\Message is returned. |
2489
|
|
|
* |
2490
|
|
|
* @param int|string $chatId |
2491
|
|
|
* @param ArrayOfInputMedia $media |
2492
|
|
|
* @param bool $disableNotification |
2493
|
|
|
* @param int|null $replyToMessageId |
2494
|
|
|
* @param int|null $messageThreadId |
2495
|
|
|
* @param bool|null $protectContent |
2496
|
|
|
* @param bool|null $allowSendingWithoutReply |
2497
|
|
|
* @param array<string, \CURLFile|\CURLStringFile> $attachments Attachments to use in attach://<attachment> |
2498
|
|
|
* |
2499
|
|
|
* @return Message[] |
2500
|
|
|
* @throws Exception |
2501
|
|
|
*/ |
2502
|
|
|
public function sendMediaGroup( |
2503
|
|
|
$chatId, |
2504
|
|
|
$media, |
2505
|
|
|
$disableNotification = false, |
2506
|
|
|
$replyToMessageId = null, |
2507
|
|
|
$messageThreadId = null, |
2508
|
|
|
$protectContent = null, |
2509
|
|
|
$allowSendingWithoutReply = null, |
2510
|
|
|
$attachments = [] |
2511
|
|
|
) { |
2512
|
|
|
return ArrayOfMessages::fromResponse($this->call('sendMediaGroup', [ |
|
|
|
|
2513
|
|
|
'chat_id' => $chatId, |
2514
|
|
|
'media' => $media->toJson(), |
2515
|
|
|
'message_thread_id' => $messageThreadId, |
2516
|
|
|
'reply_to_message_id' => (int) $replyToMessageId, |
2517
|
|
|
'disable_notification' => (bool) $disableNotification, |
2518
|
|
|
'protect_content' => (bool) $protectContent, |
2519
|
|
|
'allow_sending_without_reply' => (bool) $allowSendingWithoutReply, |
2520
|
|
|
] + $attachments)); |
2521
|
|
|
} |
2522
|
|
|
|
2523
|
|
|
/** |
2524
|
|
|
* Use this method to send a native poll. A native poll can't be sent to a private chat. |
2525
|
|
|
* On success, the sent \TelegramBot\Api\Types\Message is returned. |
2526
|
|
|
* |
2527
|
|
|
* @param string|int $chatId Unique identifier for the target chat or username of the target channel |
2528
|
|
|
* (in the format @channelusername) |
2529
|
|
|
* @param string $question Poll question, 1-255 characters |
2530
|
|
|
* @param array $options A JSON-serialized list of answer options, 2-10 strings 1-100 characters each |
2531
|
|
|
* @param bool $isAnonymous True, if the poll needs to be anonymous, defaults to True |
2532
|
|
|
* @param string|null $type Poll type, “quiz” or “regular”, defaults to “regular” |
2533
|
|
|
* @param bool $allowsMultipleAnswers True, if the poll allows multiple answers, |
2534
|
|
|
* ignored for polls in quiz mode, defaults to False |
2535
|
|
|
* @param string|null $correctOptionId 0-based identifier of the correct answer option, required for polls in quiz mode |
2536
|
|
|
* @param bool $isClosed Pass True, if the poll needs to be immediately closed. This can be useful for poll preview. |
2537
|
|
|
* @param bool $disableNotification Sends the message silently. Users will receive a notification with no sound. |
2538
|
|
|
* @param int|null $replyToMessageId If the message is a reply, ID of the original message |
2539
|
|
|
* @param InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $replyMarkup Additional interface options. A JSON-serialized object for an inline keyboard, |
2540
|
|
|
* custom reply keyboard, instructions to remove reply |
2541
|
|
|
* keyboard or to force a reply from the user. |
2542
|
|
|
* @param int|null $messageThreadId Unique identifier for the target message thread (topic) of the forum; for forum supergroups only |
2543
|
|
|
* @param bool|null $protectContent |
2544
|
|
|
* @param bool|null $allowSendingWithoutReply |
2545
|
|
|
* |
2546
|
|
|
* @return Message |
2547
|
|
|
* @throws Exception |
2548
|
|
|
* @throws HttpException |
2549
|
|
|
* @throws InvalidJsonException |
2550
|
|
|
*/ |
2551
|
|
|
public function sendPoll( |
2552
|
|
|
$chatId, |
2553
|
|
|
$question, |
2554
|
|
|
$options, |
2555
|
|
|
$isAnonymous = false, |
2556
|
|
|
$type = null, |
2557
|
|
|
$allowsMultipleAnswers = false, |
2558
|
|
|
$correctOptionId = null, |
2559
|
|
|
$isClosed = false, |
2560
|
|
|
$disableNotification = false, |
2561
|
|
|
$replyToMessageId = null, |
2562
|
|
|
$replyMarkup = null, |
2563
|
|
|
$messageThreadId = null, |
2564
|
|
|
$protectContent = null, |
2565
|
|
|
$allowSendingWithoutReply = null |
2566
|
|
|
) { |
2567
|
|
|
return Message::fromResponse($this->call('sendPoll', [ |
|
|
|
|
2568
|
|
|
'chat_id' => $chatId, |
2569
|
|
|
'question' => $question, |
2570
|
|
|
'options' => json_encode($options), |
2571
|
|
|
'is_anonymous' => (bool) $isAnonymous, |
2572
|
|
|
'type' => (string) $type, |
2573
|
|
|
'allows_multiple_answers' => (bool) $allowsMultipleAnswers, |
2574
|
|
|
'correct_option_id' => (int) $correctOptionId, |
2575
|
|
|
'is_closed' => (bool) $isClosed, |
2576
|
|
|
'disable_notification' => (bool) $disableNotification, |
2577
|
|
|
'message_thread_id' => $messageThreadId, |
2578
|
|
|
'reply_to_message_id' => (int) $replyToMessageId, |
2579
|
|
|
'reply_markup' => $replyMarkup === null ? $replyMarkup : $replyMarkup->toJson(), |
2580
|
|
|
'protect_content' => (bool) $protectContent, |
2581
|
|
|
'allow_sending_without_reply' => (bool) $allowSendingWithoutReply, |
2582
|
|
|
])); |
2583
|
|
|
} |
2584
|
|
|
|
2585
|
|
|
/** |
2586
|
|
|
* Use this method to send a dice, which will have a random value from 1 to 6. |
2587
|
|
|
* On success, the sent Message is returned. (Yes, we're aware of the “proper” singular of die. |
2588
|
|
|
* But it's awkward, and we decided to help it change. One dice at a time!) |
2589
|
|
|
* |
2590
|
|
|
* @param string|int $chatId Unique identifier for the target chat or username of the target channel |
2591
|
|
|
* (in the format @channelusername) |
2592
|
|
|
* @param string $emoji Emoji on which the dice throw animation is based. Currently, must be one of “🎲”, |
2593
|
|
|
* “🎯”, “🏀”, “⚽”, or “🎰”. Dice can have values 1-6 for “🎲” and “🎯”, values 1-5 for “🏀” and “⚽”, and |
2594
|
|
|
* values 1-64 for “🎰”. Defaults to “🎲 |
2595
|
|
|
* @param bool $disableNotification Sends the message silently. Users will receive a notification with no sound. |
2596
|
|
|
* @param string|null $replyToMessageId If the message is a reply, ID of the original message |
2597
|
|
|
* @param bool $allowSendingWithoutReply Pass True, if the message should be sent even if the specified replied-to |
2598
|
|
|
* message is not found, |
2599
|
|
|
* @param InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $replyMarkup Additional interface options. A JSON-serialized object for an inline keyboard, |
2600
|
|
|
* custom reply keyboard, instructions to remove reply |
2601
|
|
|
* keyboard or to force a reply from the user. |
2602
|
|
|
* @param int|null $messageThreadId |
2603
|
|
|
* @param bool|null $protectContent |
2604
|
|
|
* |
2605
|
|
|
* @return Message |
2606
|
|
|
* @throws Exception |
2607
|
|
|
* @throws HttpException |
2608
|
|
|
* @throws InvalidJsonException |
2609
|
|
|
*/ |
2610
|
|
|
public function sendDice( |
2611
|
|
|
$chatId, |
2612
|
|
|
$emoji, |
2613
|
|
|
$disableNotification = false, |
2614
|
|
|
$replyToMessageId = null, |
2615
|
|
|
$allowSendingWithoutReply = false, |
2616
|
|
|
$replyMarkup = null, |
2617
|
|
|
$messageThreadId = null, |
2618
|
|
|
$protectContent = null |
2619
|
|
|
) { |
2620
|
|
|
return Message::fromResponse($this->call('sendDice', [ |
|
|
|
|
2621
|
|
|
'chat_id' => $chatId, |
2622
|
|
|
'emoji' => $emoji, |
2623
|
|
|
'disable_notification' => (bool) $disableNotification, |
2624
|
|
|
'message_thread_id' => $messageThreadId, |
2625
|
|
|
'reply_to_message_id' => (int) $replyToMessageId, |
2626
|
|
|
'allow_sending_without_reply' => (bool) $allowSendingWithoutReply, |
2627
|
|
|
'reply_markup' => $replyMarkup === null ? $replyMarkup : $replyMarkup->toJson(), |
2628
|
|
|
'protect_content' => (bool) $protectContent, |
2629
|
|
|
])); |
2630
|
|
|
} |
2631
|
|
|
|
2632
|
|
|
/** |
2633
|
|
|
* Use this method to stop a poll which was sent by the bot. |
2634
|
|
|
* On success, the stopped \TelegramBot\Api\Types\Poll with the final results is returned. |
2635
|
|
|
* |
2636
|
|
|
* @param int|string $chatId |
2637
|
|
|
* @param int $messageId |
2638
|
|
|
* @param InlineKeyboardMarkup|null $replyMarkup |
2639
|
|
|
* @return Poll |
2640
|
|
|
* @throws InvalidArgumentException |
2641
|
|
|
* @throws Exception |
2642
|
|
|
*/ |
2643
|
|
|
public function stopPoll( |
2644
|
|
|
$chatId, |
2645
|
|
|
$messageId, |
2646
|
|
|
$replyMarkup = null |
2647
|
|
|
) { |
2648
|
|
|
return Poll::fromResponse($this->call('stopPoll', [ |
|
|
|
|
2649
|
|
|
'chat_id' => $chatId, |
2650
|
|
|
'message_id' => $messageId, |
2651
|
|
|
'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(), |
2652
|
|
|
])); |
2653
|
|
|
} |
2654
|
|
|
|
2655
|
|
|
/** |
2656
|
|
|
* Use this method to create a topic in a forum supergroup chat. |
2657
|
|
|
* The bot must be an administrator in the chat for this to work |
2658
|
|
|
* and must have the can_manage_topics administrator rights. |
2659
|
|
|
* Returns information about the created topic as a ForumTopic object. |
2660
|
|
|
* |
2661
|
|
|
* @param int|string $chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) |
2662
|
|
|
* @param string $name Topic name, 1-128 characters |
2663
|
|
|
* @param int $iconColor Color of the topic icon in RGB format. |
2664
|
|
|
* Currently, must be one of 7322096 (0x6FB9F0), 16766590 (0xFFD67E), 13338331 (0xCB86DB), |
2665
|
|
|
* 9367192 (0x8EEE98), 16749490 (0xFF93B2), or 16478047 (0xFB6F5F) |
2666
|
|
|
* @param int|null $iconCustomEmojiId Unique identifier of the custom emoji shown as the topic icon. |
2667
|
|
|
* Use getForumTopicIconStickers to get all allowed custom emoji identifiers. |
2668
|
|
|
* |
2669
|
|
|
* @return ForumTopic |
2670
|
|
|
* |
2671
|
|
|
* @throws Exception |
2672
|
|
|
* |
2673
|
|
|
* @author bernard-ng <[email protected]> |
2674
|
|
|
*/ |
2675
|
|
|
public function createForumTopic( |
2676
|
|
|
$chatId, |
2677
|
|
|
$name, |
2678
|
|
|
$iconColor, |
2679
|
|
|
$iconCustomEmojiId = null |
2680
|
|
|
) { |
2681
|
|
|
return ForumTopic::fromResponse($this->call('createForumTopic', [ |
|
|
|
|
2682
|
|
|
'chat_id' => $chatId, |
2683
|
|
|
'name' => $name, |
2684
|
|
|
'icon_color' => $iconColor, |
2685
|
|
|
'icon_custom_emoji_id' => $iconCustomEmojiId, |
2686
|
|
|
])); |
2687
|
|
|
} |
2688
|
|
|
|
2689
|
|
|
/** |
2690
|
|
|
* Use this method to edit name and icon of a topic in a forum supergroup chat. |
2691
|
|
|
* The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights, |
2692
|
|
|
* unless it is the creator of the topic. Returns True on success. |
2693
|
|
|
* |
2694
|
|
|
* @param int|string $chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) |
2695
|
|
|
* @param int $messageThreadId Unique identifier for the target message thread of the forum topic |
2696
|
|
|
* @param string $name Topic name, 1-128 characters |
2697
|
|
|
* @param int|null $iconCustomEmojiId Unique identifier of the custom emoji shown as the topic icon. |
2698
|
|
|
* Use getForumTopicIconStickers to get all allowed custom emoji identifiers. |
2699
|
|
|
* |
2700
|
|
|
* @return bool |
2701
|
|
|
* @throws Exception |
2702
|
|
|
* |
2703
|
|
|
* @author bernard-ng <[email protected]> |
2704
|
|
|
*/ |
2705
|
|
|
public function editForumTopic( |
2706
|
|
|
$chatId, |
2707
|
|
|
$messageThreadId, |
2708
|
|
|
$name, |
2709
|
|
|
$iconCustomEmojiId = null |
2710
|
|
|
) { |
2711
|
|
|
return $this->call('editForumTopic', [ |
|
|
|
|
2712
|
|
|
'chat_id' => $chatId, |
2713
|
|
|
'message_thread_id' => $messageThreadId, |
2714
|
|
|
'name' => $name, |
2715
|
|
|
'icon_custom_emoji_id' => $iconCustomEmojiId, |
2716
|
|
|
]); |
2717
|
|
|
} |
2718
|
|
|
|
2719
|
|
|
/** |
2720
|
|
|
* Use this method to delete a topic in a forum supergroup chat. |
2721
|
|
|
* The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights, |
2722
|
|
|
* unless it is the creator of the topic. Returns True on success. |
2723
|
|
|
* |
2724
|
|
|
* @param int|string $chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) |
2725
|
|
|
* @param int $messageThreadId Unique identifier for the target message thread of the forum topic |
2726
|
|
|
* |
2727
|
|
|
* @return bool |
2728
|
|
|
* @throws Exception |
2729
|
|
|
* |
2730
|
|
|
* @author bernard-ng <[email protected]> |
2731
|
|
|
*/ |
2732
|
|
|
public function closeForumTopic($chatId, $messageThreadId) |
2733
|
|
|
{ |
2734
|
|
|
return $this->call('closeForumTopic', [ |
|
|
|
|
2735
|
|
|
'chat_id' => $chatId, |
2736
|
|
|
'message_thread_id' => $messageThreadId, |
2737
|
|
|
]); |
2738
|
|
|
} |
2739
|
|
|
|
2740
|
|
|
/** |
2741
|
|
|
* Use this method to reopen a closed topic in a forum supergroup chat. |
2742
|
|
|
* The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, |
2743
|
|
|
* unless it is the creator of the topic. Returns True on success. |
2744
|
|
|
* |
2745
|
|
|
* @param int|string $chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) |
2746
|
|
|
* @param int $messageThreadId Unique identifier for the target message thread of the forum topic |
2747
|
|
|
* |
2748
|
|
|
* @return bool |
2749
|
|
|
* @throws Exception |
2750
|
|
|
* |
2751
|
|
|
* @author bernard-ng <[email protected]> |
2752
|
|
|
*/ |
2753
|
|
|
public function reopenForumTopic($chatId, $messageThreadId) |
2754
|
|
|
{ |
2755
|
|
|
return $this->call('reopenForumTopic', [ |
|
|
|
|
2756
|
|
|
'chat_id' => $chatId, |
2757
|
|
|
'message_thread_id' => $messageThreadId, |
2758
|
|
|
]); |
2759
|
|
|
} |
2760
|
|
|
|
2761
|
|
|
/** |
2762
|
|
|
* Use this method to delete a forum topic along with all its messages in a forum supergroup chat. |
2763
|
|
|
* The bot must be an administrator in the chat for this to work and must have the can_delete_messages administrator rights. |
2764
|
|
|
* Returns True on success. |
2765
|
|
|
* |
2766
|
|
|
* @param int|string $chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) |
2767
|
|
|
* @param int $messageThreadId Unique identifier for the target message thread of the forum topic |
2768
|
|
|
* |
2769
|
|
|
* @return bool |
2770
|
|
|
* @throws Exception |
2771
|
|
|
* |
2772
|
|
|
* @author bernard-ng <[email protected]> |
2773
|
|
|
*/ |
2774
|
|
|
public function deleteForumTopic($chatId, $messageThreadId) |
2775
|
|
|
{ |
2776
|
|
|
return $this->call('deleteForumTopic', [ |
|
|
|
|
2777
|
|
|
'chat_id' => $chatId, |
2778
|
|
|
'message_thread_id' => $messageThreadId, |
2779
|
|
|
]); |
2780
|
|
|
} |
2781
|
|
|
|
2782
|
|
|
/** |
2783
|
|
|
* Use this method to clear the list of pinned messages in a forum topic. |
2784
|
|
|
* The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. |
2785
|
|
|
* Returns True on success. |
2786
|
|
|
* |
2787
|
|
|
* @param int|string $chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername) |
2788
|
|
|
* @param int $messageThreadId Unique identifier for the target message thread of the forum topic |
2789
|
|
|
* |
2790
|
|
|
* @return bool |
2791
|
|
|
* @throws Exception |
2792
|
|
|
* |
2793
|
|
|
* @author bernard-ng <[email protected]> |
2794
|
|
|
*/ |
2795
|
|
|
public function unpinAllForumTopicMessages($chatId, $messageThreadId) |
2796
|
|
|
{ |
2797
|
|
|
return $this->call('unpinAllForumTopicMessages', [ |
|
|
|
|
2798
|
|
|
'chat_id' => $chatId, |
2799
|
|
|
'message_thread_id' => $messageThreadId, |
2800
|
|
|
]); |
2801
|
|
|
} |
2802
|
|
|
|
2803
|
|
|
/** |
2804
|
|
|
* Use this method to get custom emoji stickers, which can be used as a forum topic icon by any user. |
2805
|
|
|
* Requires no parameters. Returns an Array of Sticker objects. |
2806
|
|
|
* |
2807
|
|
|
* @return Sticker[] |
2808
|
|
|
* @throws Exception |
2809
|
|
|
* |
2810
|
|
|
* @author bernard-ng <[email protected]> |
2811
|
|
|
*/ |
2812
|
|
|
public function getForumTopicIconStickers() |
2813
|
|
|
{ |
2814
|
|
|
return ArrayOfSticker::fromResponse($this->call('getForumTopicIconStickers')); |
|
|
|
|
2815
|
|
|
} |
2816
|
|
|
|
2817
|
|
|
/** |
2818
|
|
|
* @param string $webAppQueryId |
2819
|
|
|
* @param AbstractInlineQueryResult $result |
2820
|
|
|
* @return SentWebAppMessage |
2821
|
|
|
* @throws Exception |
2822
|
|
|
* @throws HttpException |
2823
|
|
|
* @throws InvalidArgumentException |
2824
|
|
|
* @throws InvalidJsonException |
2825
|
|
|
*/ |
2826
|
|
|
public function answerWebAppQuery($webAppQueryId, $result) |
2827
|
|
|
{ |
2828
|
|
|
return SentWebAppMessage::fromResponse($this->call('answerWebAppQuery', [ |
|
|
|
|
2829
|
|
|
'web_app_query_id' => $webAppQueryId, |
2830
|
|
|
'result' => $result->toJson(), |
2831
|
|
|
])); |
2832
|
|
|
} |
2833
|
|
|
|
2834
|
|
|
/** |
2835
|
|
|
* Enable proxy for curl requests. Empty string will disable proxy. |
2836
|
|
|
* |
2837
|
|
|
* @param string $proxyString |
2838
|
|
|
* @param bool $socks5 |
2839
|
|
|
* |
2840
|
|
|
* @return BotApi |
2841
|
|
|
*/ |
2842
|
|
|
public function setProxy($proxyString = '', $socks5 = false) |
2843
|
|
|
{ |
2844
|
|
|
@trigger_error(sprintf('Method "%s:%s" is deprecated. Manage options on HttpClient instance', __CLASS__, __METHOD__), \E_USER_DEPRECATED); |
2845
|
|
|
|
2846
|
|
|
if (method_exists($this->httpClient, 'setProxy')) { |
2847
|
|
|
$this->httpClient->setProxy($proxyString, $socks5); |
2848
|
|
|
} |
2849
|
|
|
|
2850
|
|
|
return $this; |
2851
|
|
|
} |
2852
|
|
|
|
2853
|
|
|
/** |
2854
|
|
|
* Set an option for a cURL transfer |
2855
|
|
|
* |
2856
|
|
|
* @param int $option The CURLOPT_XXX option to set |
2857
|
|
|
* @param mixed $value The value to be set on option |
2858
|
|
|
* |
2859
|
|
|
* @return void |
2860
|
|
|
*/ |
2861
|
|
|
public function setCurlOption($option, $value) |
2862
|
|
|
{ |
2863
|
|
|
@trigger_error(sprintf('Method "%s:%s" is deprecated. Manage options on http client instance', __CLASS__, __METHOD__), \E_USER_DEPRECATED); |
2864
|
|
|
|
2865
|
|
|
if (method_exists($this->httpClient, 'setOption')) { |
2866
|
|
|
$this->httpClient->setOption($option, $value); |
2867
|
|
|
} |
2868
|
|
|
} |
2869
|
|
|
|
2870
|
|
|
/** |
2871
|
|
|
* Unset an option for a cURL transfer |
2872
|
|
|
* |
2873
|
|
|
* @param int $option The CURLOPT_XXX option to unset |
2874
|
|
|
* |
2875
|
|
|
* @return void |
2876
|
|
|
*/ |
2877
|
|
|
public function unsetCurlOption($option) |
2878
|
|
|
{ |
2879
|
|
|
@trigger_error(sprintf('Method "%s:%s" is deprecated. Manage options on http client instance', __CLASS__, __METHOD__), \E_USER_DEPRECATED); |
2880
|
|
|
|
2881
|
|
|
if (method_exists($this->httpClient, 'unsetOption')) { |
2882
|
|
|
$this->httpClient->unsetOption($option); |
2883
|
|
|
} |
2884
|
|
|
} |
2885
|
|
|
|
2886
|
|
|
/** |
2887
|
|
|
* Clean custom options |
2888
|
|
|
* |
2889
|
|
|
* @return void |
2890
|
|
|
*/ |
2891
|
|
|
public function resetCurlOptions() |
2892
|
|
|
{ |
2893
|
|
|
@trigger_error(sprintf('Method "%s:%s" is deprecated. Manage options on http client instance', __CLASS__, __METHOD__), \E_USER_DEPRECATED); |
2894
|
|
|
|
2895
|
|
|
if (method_exists($this->httpClient, 'resetOptions')) { |
2896
|
|
|
$this->httpClient->resetOptions(); |
2897
|
|
|
} |
2898
|
|
|
} |
2899
|
|
|
} |
2900
|
|
|
|