· 4 years ago · Aug 24, 2021, 11:22 PM
1<?php
2
3if (file_exists('TelegramErrorLogger.php')) {
4 require_once 'TelegramErrorLogger.php';
5}
6
7/**
8 * Telegram Bot Class.
9 *
10 * @author Gabriele Grillo <gabry.grillo@alice.it>
11 */
12class Telegram
13{
14 /**
15 * Constant for type Inline Query.
16 */
17 const INLINE_QUERY = 'inline_query';
18 /**
19 * Constant for type Callback Query.
20 */
21 const CALLBACK_QUERY = 'callback_query';
22 /**
23 * Constant for type Edited Message.
24 */
25 const EDITED_MESSAGE = 'edited_message';
26 /**
27 * Constant for type Reply.
28 */
29 const REPLY = 'reply';
30 /**
31 * Constant for type Message.
32 */
33 const MESSAGE = 'message';
34 /**
35 * Constant for type Photo.
36 */
37 const PHOTO = 'photo';
38 /**
39 * Constant for type Video.
40 */
41 const VIDEO = 'video';
42 /**
43 * Constant for type Audio.
44 */
45 const AUDIO = 'audio';
46 /**
47 * Constant for type Voice.
48 */
49 const VOICE = 'voice';
50 /**
51 * Constant for type animation.
52 */
53 const ANIMATION = 'animation';
54 /**
55 * Constant for type sticker.
56 */
57 const STICKER = 'sticker';
58 /**
59 * Constant for type Document.
60 */
61 const DOCUMENT = 'document';
62 /**
63 * Constant for type Location.
64 */
65 const LOCATION = 'location';
66 /**
67 * Constant for type Contact.
68 */
69 const CONTACT = 'contact';
70 /**
71 * Constant for type Channel Post.
72 */
73 const CHANNEL_POST = 'channel_post';
74
75 private $bot_token = '';
76 private $data = [];
77 private $updates = [];
78 private $log_errors;
79 private $proxy;
80
81 /// Class constructor
82
83 /**
84 * Create a Telegram instance from the bot token
85 * \param $bot_token the bot token
86 * \param $log_errors enable or disable the logging
87 * \param $proxy array with the proxy configuration (url, port, type, auth)
88 * \return an instance of the class.
89 */
90 public function __construct($bot_token, $log_errors = true, array $proxy = [])
91 {
92 $this->bot_token = $bot_token;
93 $this->data = $this->getData();
94 $this->log_errors = $log_errors;
95 $this->proxy = $proxy;
96 }
97
98 /// Do requests to Telegram Bot API
99
100 /**
101 * Contacts the various API's endpoints
102 * \param $api the API endpoint
103 * \param $content the request parameters as array
104 * \param $post boolean tells if $content needs to be sends
105 * \return the JSON Telegram's reply.
106 */
107 public function endpoint($api, array $content, $post = true)
108 {
109 $url = 'https://api.telegram.org/bot'.$this->bot_token.'/'.$api;
110 if ($post) {
111 $reply = $this->sendAPIRequest($url, $content);
112 } else {
113 $reply = $this->sendAPIRequest($url, [], false);
114 }
115
116 return json_decode($reply, true);
117 }
118
119 /// A method for testing your bot.
120
121 /**
122 * A simple method for testing your bot's auth token. Requires no parameters.
123 * Returns basic information about the bot in form of a User object.
124 * \return the JSON Telegram's reply.
125 */
126 public function getMe()
127 {
128 return $this->endpoint('getMe', [], false);
129 }
130
131 /// A method for responding http to Telegram.
132
133 /**
134 * \return the HTTP 200 to Telegram.
135 */
136 public function respondSuccess()
137 {
138 http_response_code(200);
139
140 return json_encode(['status' => 'success']);
141 }
142
143 /// Send a message
144
145 /**
146 * Use this method to send text messages.<br/>Values inside $content:<br/>
147 * <table>
148 * <tr>
149 * <td><strong>Parameters</strong></td>
150 * <td><strong>Type</strong></td>
151 * <td><strong>Required</strong></td>
152 * <td><strong>Description</strong></td>
153 * </tr>
154 * <tr>
155 * <td>chat_id</td>
156 * <td>Integer</td>
157 * <td>Yes</td>
158 * <td>Unique identifier for the target chat or username of the target channel (in the format \c \@channelusername)</td>
159 * * </tr>
160 * <tr>
161 * <td>text</td>
162 * <td>String</td>
163 * <td>Yes</td>
164 * <td>Text of the message to be sent</td>
165 * </tr>
166 * <tr>
167 * <td>parse_mode</td>
168 * <td>String</td>
169 * <td>Optional</td>
170 * <td>Send <em>Markdown</em>, if you want Telegram apps to show bold, italic and inline URLs in your bot's message. For the moment, only Telegram for Android supports this.</td>
171 * </tr>
172 * <tr>
173 * <td>disable_web_page_preview</td>
174 * <td>Boolean</td>
175 * <td>Optional</td>
176 * <td>Disables link previews for links in this message</td>
177 * </tr>
178 * <tr>
179 * <td>reply_to_message_id</td>
180 * <td>Integer</td>
181 * <td>Optional</td>
182 * <td>If the message is a reply, ID of the original message</td>
183 * </tr>
184 * <tr>
185 * <td>reply_markup</td>
186 * <td>InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardHide or ForceReply</td>
187 * <td>Optional</td>
188 * <td>Additional interface options. A JSON-serialized object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.</td>
189 * </tr>
190 * </table>
191 * \param $content the request parameters as array
192 * \return the JSON Telegram's reply.
193 */
194 public function sendMessage(array $content)
195 {
196 return $this->endpoint('sendMessage', $content);
197 }
198
199 /// Forward a message
200
201 /**
202 * Use this method to forward messages of any kind. On success, the sent Message is returned<br/>Values inside $content:<br/>
203 * <table>
204 * <tr>
205 * <td><strong>Parameters</strong></td>
206 * <td><strong>Type</strong></td>
207 * <td><strong>Required</strong></td>
208 * <td><strong>Description</strong></td>
209 * </tr>
210 * <tr>
211 * <td>chat_id</td>
212 * <td>Integer</td>
213 * <td>Yes</td>
214 * <td>Unique identifier for the target chat or username of the target channel (in the format \c \@channelusername)</td>
215 * </tr>
216 * <tr>
217 * <td>from_chat_id</td>
218 * <td>Integer</td>
219 * <td>Yes</td>
220 * <td>Unique identifier for the target chat or username of the target channel (in the format \c \@channelusername)</td>
221 * </tr>
222 * <tr>
223 * <td>disable_notification</td>
224 * <td>Boolean</td>
225 * <td>Optional</td>
226 * <td>Sends the message silently. Users will receive a notification with no sound.</td>
227 * </tr>
228 * <tr>
229 * <td>message_id</td>
230 * <td>Integer</td>
231 * <td>Yes</td>
232 * <td>Unique message identifier</td>
233 * </tr>
234 * </table>
235 * \param $content the request parameters as array
236 * \return the JSON Telegram's reply.
237 */
238 public function forwardMessage(array $content)
239 {
240 return $this->endpoint('forwardMessage', $content);
241 }
242
243 /// Send a photo
244
245 /**
246 * Use this method to send photos. On success, the sent Message is returned.<br/>Values inside $content:<br/>
247 * <table>
248 * <tr>
249 * <td><strong>Parameters</strong></td>
250 * <td><strong>Type</strong></td>
251 * <td><strong>Required</strong></td>
252 * <td><strong>Description</strong></td>
253 * </tr>
254 * <tr>
255 * <td>chat_id</td>
256 * <td>Integer</td>
257 * <td>Yes</td>
258 * <td>Unique identifier for the target chat or username of the target channel (in the format \c \@channelusername)</td>
259 * </tr>
260 * <tr>
261 * <td>photo</td>
262 * <td><a href="https://core.telegram.org/bots/api#inputfile">InputFile</a> or String</td>
263 * <td>Yes</td>
264 * <td>Photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data.</td>
265 * </tr>
266 * <tr>
267 * <td>caption</td>
268 * <td>String</td>
269 * <td>Optional</td>
270 * <td>Photo caption (may also be used when resending photos by <em>file_id</em>).</td>
271 * </tr>
272 * <tr>
273 * <td>reply_to_message_id</td>
274 * <td>Integer</td>
275 * <td>Optional</td>
276 * <td>If the message is a reply, ID of the original message</td>
277 * </tr>
278 * <tr>
279 * <td>disable_notification</td>
280 * <td>Boolean</td>
281 * <td>Optional</td>
282 * <td>Sends the message silently. Users will receive a notification with no sound.</td>
283 * </tr>
284 * <tr>
285 * <td>reply_markup</td>
286 * <td>InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply</td>
287 * <td>Optional</td>
288 * <td>Additional interface options. A JSON-serialized object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.</td>
289 * </tr>
290 * </table>
291 * \param $content the request parameters as array
292 * \return the JSON Telegram's reply.
293 */
294 public function sendPhoto(array $content)
295 {
296 return $this->endpoint('sendPhoto', $content);
297 }
298
299 /// Send an audio
300
301 /**
302 * Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .mp3 format. On success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future.
303 * For sending voice messages, use the sendVoice method instead.<br/>Values inside $content:<br/>
304 * <table>
305 * <tr>
306 * <td><strong>Parameters</strong></td>
307 * <td><strong>Type</strong></td>
308 * <td><strong>Required</strong></td>
309 * <td><strong>Description</strong></td>
310 * </tr>
311 * <tr>
312 * <td>chat_id</td>
313 * <td>Integer</td>
314 * <td>Yes</td>
315 * <td>Unique identifier for the target chat or username of the target channel (in the format \c \@channelusername)</td>
316 * </tr>
317 * <tr>
318 * <td>audio</td>
319 * <td><a href="https://core.telegram.org/bots/api#inputfile">InputFile</a> or String</td>
320 * <td>Yes</td>
321 * <td>Audio file to send. Pass a file_id as String to send an audio file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an audio file from the Internet, or upload a new one using <strong>multipart/form-data</strong>.</td>
322 * </tr>
323 * <tr>
324 * <td>duration</td>
325 * <td>Integer</td>
326 * <td>Optional</td>
327 * <td>Duration of the audio in seconds</td>
328 * </tr>
329 * <tr>
330 * <td>performer</td>
331 * <td>String</td>
332 * <td>Optional</td>
333 * <td>Performer</td>
334 * </tr>
335 * <tr>
336 * <td>title</td>
337 * <td>String</td>
338 * <td>Optional</td>
339 * <td>Track name</td>
340 * </tr>
341 * <tr>
342 * <td>disable_notification</td>
343 * <td>Boolean</td>
344 * <td>Optional</td>
345 * <td>Sends the message silently. Users will receive a notification with no sound.</td>
346 * </tr>
347 * <tr>
348 * <td>reply_to_message_id</td>
349 * <td>Integer</td>
350 * <td>Optional</td>
351 * <td>If the message is a reply, ID of the original message</td>
352 * </tr>
353 * <tr>
354 * <td>reply_markup</td>
355 * <td>InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply</td>
356 * <td>Optional</td>
357 * <td>Additional interface options. A JSON-serialized object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.</td>
358 * </tr>
359 * </table>
360 * \param $content the request parameters as array
361 * \return the JSON Telegram's reply.
362 */
363 public function sendAudio(array $content)
364 {
365 return $this->endpoint('sendAudio', $content);
366 }
367
368 /// Send a document
369
370 /**
371 * Use this method to send general files. On success, the sent Message is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.<br/>Values inside $content:<br/>
372 * <table>
373 * <tr>
374 * <td><strong>Parameters</strong></td>
375 * <td><strong>Type</strong></td>
376 * <td><strong>Required</strong></td>
377 * <td><strong>Description</strong></td>
378 * </tr>
379 * <tr>
380 * <td>chat_id</td>
381 * <td>Integer</td>
382 * <td>Yes</td>
383 * <td>Unique identifier for the target chat or username of the target channel (in the format \c \@channelusername)</td>
384 * </tr>
385 * <tr>
386 * <td>document</td>
387 * <td>InputFile or String</td>
388 * <td>Yes</td>
389 * <td>File to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using <strong>multipart/form-data</strong>.</td>
390 * </tr>
391 * <tr>
392 * <td>caption</td>
393 * <td>String</td>
394 * <td>Optional</td>
395 * <td>Document caption (may also be used when resending documents by file_id), 0-200 characters.</td>
396 * </tr>
397 * <tr>
398 * <td>disable_notification</td>
399 * <td>Boolean</td>
400 * <td>Optional</td>
401 * <td>Sends the message silently. Users will receive a notification with no sound.</td>
402 * </tr>
403 * <tr>
404 * <td>reply_to_message_id</td>
405 * <td>Integer</td>
406 * <td>Optional</td>
407 * <td>If the message is a reply, ID of the original message</td>
408 * </tr>
409 * <tr>
410 * <td>reply_markup</td>
411 * <td>InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply</td>
412 * <td>Optional</td>
413 * <td>Additional interface options. A JSON-serialized object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.</td>
414 * </tr>
415 * </table>
416 * \param $content the request parameters as array
417 * \return the JSON Telegram's reply.
418 */
419 public function sendDocument(array $content)
420 {
421 return $this->endpoint('sendDocument', $content);
422 }
423
424 /// Send an animation
425
426 /**
427 * Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). On success, the sent Message is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future.<br/>Values inside $content:<br/>
428 * </table>
429 * <tr>
430 * <th>Parameter</th>
431 * <th>Type</th>
432 * <th>Required</th>
433 * <th>Description</th>
434 * </tr>
435 * </thead>
436 * <tbody>
437 * <tr>
438 * <td>chat_id</td>
439 * <td>Integer or String</td>
440 * <td>Yes</td>
441 * <td>Unique identifier for the target chat or username of the target channel (in the format <code>@channelusername</code>)</td>
442 * </tr>
443 * <tr>
444 * <td>animation</td>
445 * <td><a href="#inputfile">InputFile</a> or String</td>
446 * <td>Yes</td>
447 * <td>Animation to send. Pass a file_id as String to send an animation that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an animation from the Internet, or upload a new animation using multipart/form-data. <a href="#sending-files">More info on Sending Files »</a></td>
448 * </tr>
449 * <tr>
450 * <td>duration</td>
451 * <td>Integer</td>
452 * <td>Optional</td>
453 * <td>Duration of sent animation in seconds</td>
454 * </tr>
455 * <tr>
456 * <td>width</td>
457 * <td>Integer</td>
458 * <td>Optional</td>
459 * <td>Animation width</td>
460 * </tr>
461 * <tr>
462 * <td>height</td>
463 * <td>Integer</td>
464 * <td>Optional</td>
465 * <td>Animation height</td>
466 * </tr>
467 * <tr>
468 * <td>thumb</td>
469 * <td><a href="#inputfile">InputFile</a> or String</td>
470 * <td>Optional</td>
471 * <td>Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. <a href="#sending-files">More info on Sending Files »</a></td>
472 * </tr>
473 * <tr>
474 * <td>caption</td>
475 * <td>String</td>
476 * <td>Optional</td>
477 * <td>Animation caption (may also be used when resending animation by <em>file_id</em>), 0-1024 characters</td>
478 * </tr>
479 * <tr>
480 * <td>parse_mode</td>
481 * <td>String</td>
482 * <td>Optional</td>
483 * <td>Send <a href="#markdown-style"><em>Markdown</em></a> or <a href="#html-style"><em>HTML</em></a>, if you want Telegram apps to show <a href="#formatting-* options">bold, italic, fixed-width text or inline URLs</a> in the media caption.</td>
484 * </tr>
485 * <tr>
486 * <td>disable_notification</td>
487 * <td>Boolean</td>
488 * <td>Optional</td>
489 * <td>Sends the message <a href="https://telegram.org/blog/channels-2-0#silent-messages">silently</a>. Users will receive a notification with no sound.</td>
490 * </tr>
491 * <tr>
492 * <td>reply_to_message_id</td>
493 * <td>Integer</td>
494 * <td>Optional</td>
495 * <td>If the message is a reply, ID of the original message</td>
496 * </tr>
497 * <tr>
498 * <td>reply_markup</td>
499 * <td><a href="#inlinekeyboardmarkup">InlineKeyboardMarkup</a> or <a href="#replykeyboardmarkup">ReplyKeyboardMarkup</a> or <a href="#replykeyboardremove">ReplyKeyboardRemove</a> or <a href="#forcereply">ForceReply</a></td>
500 * <td>Optional</td>
501 * <td>Additional interface options. A JSON-serialized object for an <a href="https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating">inline keyboard</a>, <a href="https://core.telegram.org/bots#keyboards">custom reply keyboard</a>, instructions to remove reply keyboard or to force a reply from the user.</td>
502 * </tr>
503 * </table>
504 * \param $content the request parameters as array
505 * \return the JSON Telegram's reply.
506 */
507 public function sendAnimation(array $content)
508 {
509 return $this->endpoint('sendAnimation', $content);
510 }
511
512 /// Send a sticker
513
514 /**
515 * Use this method to send .webp stickers. On success, the sent Message is returned.<br/>Values inside $content:<br/>
516 * <table>
517 * <tr>
518 * <td><strong>Parameters</strong></td>
519 * <td><strong>Type</strong></td>
520 * <td><strong>Required</strong></td>
521 * <td><strong>Description</strong></td>
522 * </tr>
523 * <tr>
524 * <td>chat_id</td>
525 * <td>Integer</td>
526 * <td>Yes</td>
527 * <td>Unique identifier for the message recipient — User or GroupChat id</td>
528 * </tr>
529 * <tr>
530 * <td>sticker</td>
531 * <td><a href="https://core.telegram.org/bots/api#inputfile">InputFile</a> or String</td>
532 * <td>Yes</td>
533 * <td>Sticker to send. You can either pass a <em>file_id</em> as String to resend a sticker that is already on the Telegram servers, or upload a new sticker using <strong>multipart/form-data</strong>.</td>
534 * </tr>
535 * <tr>
536 * <td>reply_to_message_id</td>
537 * <td>Integer</td>
538 * <td>Optional</td>
539 * <td>If the message is a reply, ID of the original message</td>
540 * </tr>
541 * <tr>
542 * <td>reply_markup</td>
543 * <td>ReplyKeyboardMarkup or ReplyKeyboardHide or ForceReply</td>
544 * <td>Optional</td>
545 * <td>Additional interface options. A JSON-serialized object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.</td>
546 * </tr>
547 * </table>
548 * \param $content the request parameters as array
549 * \return the JSON Telegram's reply.
550 */
551 public function sendSticker(array $content)
552 {
553 return $this->endpoint('sendSticker', $content);
554 }
555
556 /// Send a video
557
558 /**
559 * Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). On success, the sent Message is returned. Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future.<br/>Values inside $content:<br/>
560 * <table>
561 * <tr>
562 * <td><strong>Parameters</strong></td>
563 * <td><strong>Type</strong></td>
564 * <td><strong>Required</strong></td>
565 * <td><strong>Description</strong></td>
566 * </tr>
567 * <tr>
568 * <td>chat_id</td>
569 * <td>Integer</td>
570 * <td>Yes</td>
571 * <td>Unique identifier for the message recipient — User or GroupChat id</td>
572 * </tr>
573 * <tr>
574 * <td>video</td>
575 * <td><a href="https://core.telegram.org/bots/api#inputfile">InputFile</a> or String</td>
576 * <td>Yes</td>
577 * <td>Video to send. Pass a file_id as String to send a video that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a video from the Internet, or upload a new video using <strong>multipart/form-data</strong>.</td>
578 * </tr>
579 * <tr>
580 * <td>duration</td>
581 * <td>Integer</td>
582 * <td>Optional</td>
583 * <td>Duration of sent video in seconds</td>
584 * </tr>
585 * <tr>
586 * <td>width</td>
587 * <td>Integer</td>
588 * <td>Optional</td>
589 * <td>Video width</td>
590 * </tr>
591 * <tr>
592 * <td>height</td>
593 * <td>Integer</td>
594 * <td>Optional</td>
595 * <td>Video height</td>
596 * </tr>
597 * <tr>
598 * <td>caption</td>
599 * <td>String</td>
600 * <td>Optional</td>
601 * <td>Video caption (may also be used when resending videos by <em>file_id</em>).</td>
602 * </tr>
603 * <tr>
604 * <td>disable_notification</td>
605 * <td>Boolean</td>
606 * <td>Optional</td>
607 * <td>Sends the message silently. Users will receive a notification with no sound.</td>
608 * </tr>
609 * <tr>
610 * <td>reply_to_message_id</td>
611 * <td>Integer</td>
612 * <td>Optional</td>
613 * <td>If the message is a reply, ID of the original message</td>
614 * </tr>
615 * <tr>
616 * <td>reply_markup</td>
617 * <td>InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply</td>
618 * <td>Optional</td>
619 * <td>Additional interface options. A JSON-serialized object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.</td>
620 * </tr>
621 * </table>
622 * \param $content the request parameters as array
623 * \return the JSON Telegram's reply.
624 */
625 public function sendVideo(array $content)
626 {
627 return $this->endpoint('sendVideo', $content);
628 }
629
630 /// Send a voice message
631
632 /**
633 * Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future.<br/>Values inside $content:<br/>
634 * <table>
635 * <tr>
636 * <td><strong>Parameters</strong></td>
637 * <td><strong>Type</strong></td>
638 * <td><strong>Required</strong></td>
639 * <td><strong>Description</strong></td>
640 * </tr>
641 * <tr>
642 * <td>chat_id</td>
643 * <td>Integer</td>
644 * <td>Yes</td>
645 * <td>Unique identifier for the target chat or username of the target channel (in the format \c \@channelusername)</td>
646 * </tr>
647 * <tr>
648 * <td>voice</td>
649 * <td><a href="https://core.telegram.org/bots/api#inputfile">InputFile</a> or String</td>
650 * <td>Yes</td>
651 * <td>Audio file to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using <strong>multipart/form-data</strong>.</td>
652 * </tr>
653 * <tr>
654 * <td>caption</td>
655 * <td>String</td>
656 * <td>Optional</td>
657 * <td>Voice message caption, 0-200 characters</td>
658 * </tr>
659 * <tr>
660 * <td>duration</td>
661 * <td>Integer</td>
662 * <td>Optional</td>
663 * <td>Duration of sent audio in seconds</td>
664 * </tr>
665 * <tr>
666 * <td>disable_notification</td>
667 * <td>Boolean</td>
668 * <td>Optional</td>
669 * <td>Sends the message silently. Users will receive a notification with no sound.</td>
670 * </tr>
671 * <tr>
672 * <td>reply_to_message_id</td>
673 * <td>Integer</td>
674 * <td>Optional</td>
675 * <td>If the message is a reply, ID of the original message</td>
676 * </tr>
677 * <tr>
678 * <td>reply_markup</td>
679 * <td>InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply</td>
680 * <td>Optional</td>
681 * <td>Additional interface options. A JSON-serialized object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.</td>
682 * </tr>
683 * </table>
684 * \param $content the request parameters as array
685 * \return the JSON Telegram's reply.
686 */
687 public function sendVoice(array $content)
688 {
689 return $this->endpoint('sendVoice', $content);
690 }
691
692 /// Send a location
693
694 /**
695 * Use this method to send point on the map. On success, the sent Message is returned.<br/>Values inside $content:<br/>
696 * <table>
697 * <tr>
698 * <td><strong>Parameters</strong></td>
699 * <td><strong>Type</strong></td>
700 * <td><strong>Required</strong></td>
701 * <td><strong>Description</strong></td>
702 * </tr>
703 * <tr>
704 * <td>chat_id</td>
705 * <td>Integer</td>
706 * <td>Yes</td>
707 * <td>Unique identifier for the target chat or username of the target channel (in the format \c \@channelusername)</td>
708 * </tr>
709 * <tr>
710 * <td>latitude</td>
711 * <td>Float number</td>
712 * <td>Yes</td>
713 * <td>Latitude of location</td>
714 * </tr>
715 * <tr>
716 * <td>longitude</td>
717 * <td>Float number</td>
718 * <td>Yes</td>
719 * <td>Longitude of location</td>
720 * </tr>
721 * <tr>
722 * <td>live_period</td>
723 * <td>Integer</td>
724 * <td>Optional</td>
725 * <td>Period in seconds for which the location will be updated (see <a href="https://telegram.org/blog/live-locations">Live Locations</a>, should be between 60 and 86400.</td>
726 * </tr>
727 * <tr>
728 * <td>disable_notification</td>
729 * <td>Boolean</td>
730 * <td>Optional</td>
731 * <td>Sends the message silently. Users will receive a notification with no sound.</td>
732 * </tr>
733 * <tr>
734 * <td>reply_to_message_id</td>
735 * <td>Integer</td>
736 * <td>Optional</td>
737 * <td>If the message is a reply, ID of the original message</td>
738 * </tr>
739 * <tr>
740 * <td>reply_markup</td>
741 * <td>InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply</td>
742 * <td>Optional</td>
743 * <td>Additional interface options. A JSON-serialized object for a custom reply keyboard, instructions to hide keyboard or to force a reply from the user.</td>
744 * </tr>
745 * </table>
746 * \param $content the request parameters as array
747 * \return the JSON Telegram's reply.
748 */
749 public function sendLocation(array $content)
750 {
751 return $this->endpoint('sendLocation', $content);
752 }
753
754 /// Edit Message Live Location
755
756 /**
757 * Use this method to edit live location messages sent by the bot or via the bot (for <a href="https://core.telegram.org/bots/api#inline-mode">inline bots</a>). A location can be edited until its <em>live_period</em> expires or editing is explicitly disabled by a call to <a href="https://core.telegram.org/bots/api#stopmessagelivelocation">stopMessageLiveLocation</a>. On success, if the edited message was sent by the bot, the edited <a href="https://core.telegram.org/bots/api#message">Message</a> is returned, otherwise <em>True</em> is returned.<br/>Values inside $content:<br/>
758 * <table>
759 * <tr>
760 * <td><strong>Parameters</strong></td>
761 * <td><strong>Type</strong></td>
762 * <td><strong>Required</strong></td>
763 * <td><strong>Description</strong></td>
764 * </tr>
765 * <tr>
766 * <td>chat_id</td>
767 * <td>Integer or String</td>
768 * <td>Optional</td>
769 * <td>Required if <em>inline_message_id</em> is not specified. Unique identifier for the target chat or username of the target channel (in the format \c \@channelusername)</td>
770 * </tr>
771 * <tr>
772 * <td>message_id</td>
773 * <td>Integer</td>
774 * <td>Optional</td>
775 * <td>Required if <em>inline_message_id</em> is not specified. Identifier of the sent message</td>
776 * </tr>
777 * <tr>
778 * <td>inline_message_id</td>
779 * <td>String</td>
780 * <td>Optional</td>
781 * <td>Required if <em>chat_id</em> and <em>message_id</em> are not specified. Identifier of the inline message</td>
782 * </tr>
783 * <tr>
784 * <td>latitude</td>
785 * <td>Float number</td>
786 * <td>Yes</td>
787 * <td>Latitude of new location</td>
788 * </tr>
789 * <tr>
790 * <td>longitude</td>
791 * <td>Float number</td>
792 * <td>Yes</td>
793 * <td>Longitude of new location</td>
794 * </tr>
795 * <tr>
796 * <td>reply_markup</td>
797 * <td><a href="https://core.telegram.org/bots/api#inlinekeyboardmarkup">InlineKeyboardMarkup</a></td>
798 * <td>Optional</td>
799 * <td>A JSON-serialized object for a new <a href="https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating">inline keyboard</a>.</td>
800 * </tr>
801 * </table>
802 * \param $content the request parameters as array
803 * \return the JSON Telegram's reply.
804 */
805 public function editMessageLiveLocation(array $content)
806 {
807 return $this->endpoint('editMessageLiveLocation', $content);
808 }
809
810 /// Stop Message Live Location
811
812 /**
813 * Use this method to stop updating a live location message sent by the bot or via the bot (for <a href="https://core.telegram.org/bots/api#inline-mode">inline bots</a>) before <em>live_period</em> expires. On success, if the message was sent by the bot, the sent <a href="https://core.telegram.org/bots/api#message">Message</a> is returned, otherwise <em>True</em> is returned.<br/>Values inside $content:<br/>
814 * <table>
815 * <tr>
816 * <td><strong>Parameters</strong></td>
817 * <td><strong>Type</strong></td>
818 * <td><strong>Required</strong></td>
819 * <td><strong>Description</strong></td>
820 * </tr>
821 * <tr>
822 * <td>chat_id</td>
823 * <td>Integer or String</td>
824 * <td>Optional</td>
825 * <td>Required if <em>inline_message_id</em> is not specified. Unique identifier for the target chat or username of the target channel (in the format \c \@channelusername)</td>
826 * </tr>
827 * <tr>
828 * <td>message_id</td>
829 * <td>Integer</td>
830 * <td>Optional</td>
831 * <td>Required if <em>inline_message_id</em> is not specified. Identifier of the sent message</td>
832 * </tr>
833 * <tr>
834 * <td>inline_message_id</td>
835 * <td>String</td>
836 * <td>Optional</td>
837 * <td>Required if <em>chat_id</em> and <em>message_id</em> are not specified. Identifier of the inline message</td>
838 * </tr>
839 * <tr>
840 * <td>reply_markup</td>
841 * <td><a href="https://core.telegram.org/bots/api#inlinekeyboardmarkup">InlineKeyboardMarkup</a></td>
842 * <td>Optional</td>
843 * <td>A JSON-serialized object for a new <a href="https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating">inline keyboard</a>.</td>
844 * </tr>
845 * </table>
846 * \param $content the request parameters as array
847 * \return the JSON Telegram's reply.
848 */
849 public function stopMessageLiveLocation(array $content)
850 {
851 return $this->endpoint('stopMessageLiveLocation', $content);
852 }
853
854 /// Set Chat Sticker Set
855
856 /**
857 * Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Use the field <em>can_set_sticker_set</em> optionally returned in <a href="https://core.telegram.org/bots/api#getchat">getChat</a> requests to check if the bot can use this method. Returns <em>True</em> on success.<br/>Values inside $content:<br/>
858 * <table>
859 * <tr>
860 * <td><strong>Parameters</strong></td>
861 * <td><strong>Type</strong></td>
862 * <td><strong>Required</strong></td>
863 * <td><strong>Description</strong></td>
864 * </tr>
865 * <tr>
866 * <td>chat_id</td>
867 * <td>Integer or String</td>
868 * <td>Yes</td>
869 * <td>Unique identifier for the target chat or username of the target supergroup (in the format <code>@supergroupusername</code>)</td>
870 * </tr>
871 * </table>
872 * \param $content the request parameters as array
873 * \return the JSON Telegram's reply.
874 */
875 public function setChatStickerSet(array $content)
876 {
877 return $this->endpoint('setChatStickerSet', $content);
878 }
879
880 /// Delete Chat Sticker Set
881
882 /**
883 * Use this method to delete a group sticker set from a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Use the field <em>can_set_sticker_set</em> optionally returned in <a href="https://core.telegram.org/bots/api#getchat">getChat</a> requests to check if the bot can use this method. Returns <em>True</em> on success.<br/>Values inside $content:<br/>
884 * <table>
885 * <tr>
886 * <td><strong>Parameters</strong></td>
887 * <td><strong>Type</strong></td>
888 * <td><strong>Required</strong></td>
889 * <td><strong>Description</strong></td>
890 * </tr>
891 * <tr>
892 * <td>chat_id</td>
893 * <td>Integer or String</td>
894 * <td>Yes</td>
895 * <td>Unique identifier for the target chat or username of the target supergroup (in the format <code>@supergroupusername</code>)</td>
896 * </tr>
897 * </table>
898 * \param $content the request parameters as array
899 * \return the JSON Telegram's reply.
900 */
901 public function deleteChatStickerSet(array $content)
902 {
903 return $this->endpoint('deleteChatStickerSet', $content);
904 }
905
906 /// Send Media Group
907
908 /**
909 * Use this method to send a group of photos or videos as an album. On success, an array of the sent <a href="https://core.telegram.org/bots/api#message">Messages</a> is returned.<br/>Values inside $content:<br/>
910 * <table>
911 * <tr>
912 * <td><strong>Parameters</strong></td>
913 * <td><strong>Type</strong></td>
914 * <td><strong>Required</strong></td>
915 * <td><strong>Description</strong></td>
916 * </tr>
917 * <tr>
918 * <td>chat_id</td>
919 * <td>Integer or String</td>
920 * <td>Yes</td>
921 * <td>Unique identifier for the target chat or username of the target channel (in the format \c \@channelusername)</td>
922 * </tr>
923 * <tr>
924 * <td>media</td>
925 * <td>Array of <a href="https://core.telegram.org/bots/api#inputmedia">InputMedia</a></td>
926 * <td>Yes</td>
927 * <td>A JSON-serialized array describing photos and videos to be sent, must include 2–10 items</td>
928 * </tr>
929 * <tr>
930 * <td>disable_notification</td>
931 * <td>Boolean</td>
932 * <td>Optional</td>
933 * <td>Sends the messages <a href="https://telegram.org/blog/channels-2-0#silent-messages">silently</a>. Users will receive a notification with no sound.</td>
934 * </tr>
935 * <tr>
936 * <td>reply_to_message_id</td>
937 * <td>Integer</td>
938 * <td>Optional</td>
939 * <td>If the messages are a reply, ID of the original message</td>
940 * </tr>
941 * </table>
942 * \param $content the request parameters as array
943 * \return the JSON Telegram's reply.
944 */
945 public function sendMediaGroup(array $content)
946 {
947 return $this->endpoint('sendMediaGroup', $content);
948 }
949
950 /// Send Venue
951
952 /**
953 * Use this method to send information about a venue. On success, the sent <a href="https://core.telegram.org/bots/api#message">Message</a> is returned.<br/>Values inside $content:<br/>
954 * <table>
955 * <tr>
956 * <td><strong>Parameters</strong></td>
957 * <td><strong>Type</strong></td>
958 * <td><strong>Required</strong></td>
959 * <td><strong>Description</strong></td>
960 * </tr>
961 * <tr>
962 * <td>chat_id</td>
963 * <td>Integer or String</td>
964 * <td>Yes</td>
965 * <td>Unique identifier for the target chat or username of the target channel (in the format \c \@channelusername)</td>
966 * </tr>
967 * <tr>
968 * <td>latitude</td>
969 * <td>Float number</td>
970 * <td>Yes</td>
971 * <td>Latitude of the venue</td>
972 * </tr>
973 * <tr>
974 * <td>longitude</td>
975 * <td>Float number</td>
976 * <td>Yes</td>
977 * <td>Longitude of the venue</td>
978 * </tr>
979 * <tr>
980 * <td>title</td>
981 * <td>String</td>
982 * <td>Yes</td>
983 * <td>Name of the venue</td>
984 * </tr>
985 * <tr>
986 * <td>address</td>
987 * <td>String</td>
988 * <td>Yes</td>
989 * <td>Address of the venue</td>
990 * </tr>
991 * <tr>
992 * <td>foursquare_id</td>
993 * <td>String</td>
994 * <td>Optional</td>
995 * <td>Foursquare identifier of the venue</td>
996 * </tr>
997 * <tr>
998 * <td>disable_notification</td>
999 * <td>Boolean</td>
1000 * <td>Optional</td>
1001 * <td>Sends the message <a href="https://telegram.org/blog/channels-2-0#silent-messages">silently</a>. iOS users will not receive a notification, Android users will receive a notification with no sound.</td>
1002 * </tr>
1003 * <tr>
1004 * <td>reply_to_message_id</td>
1005 * <td>Integer</td>
1006 * <td>Optional</td>
1007 * <td>If the message is a reply, ID of the original message</td>
1008 * </tr>
1009 * <tr>
1010 * <td>reply_markup</td>
1011 * <td><a href="https://core.telegram.org/bots/api#inlinekeyboardmarkup">InlineKeyboardMarkup</a> or <a href="https://core.telegram.org/bots/api#replykeyboardmarkup">ReplyKeyboardMarkup</a> or <a href="https://core.telegram.org/bots/api#replykeyboardhide">ReplyKeyboardHide</a> or <a href="https://core.telegram.org/bots/api#forcereply">ForceReply</a></td>
1012 * <td>Optional</td>
1013 * <td>Additional interface options. A JSON-serialized object for an <a href="https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating">inline keyboard</a>, <a href="https://core.telegram.org/bots#keyboards">custom reply keyboard</a>, instructions to hide reply keyboard or to force a reply from the user.</td>
1014 * </tr>
1015 * </table>
1016 * \param $content the request parameters as array
1017 * \return the JSON Telegram's reply.
1018 */
1019 public function sendVenue(array $content)
1020 {
1021 return $this->endpoint('sendVenue', $content);
1022 }
1023
1024 //Send contact
1025 /**Use this method to send phone contacts. On success, the sent <a href="https://core.telegram.org/bots/api#message">Message</a> is returned.</p> <br/>Values inside $content:<br/>
1026 * <table>
1027 * <tr>
1028 * <td><strong>Parameters</strong></td>
1029 * <td><strong>Type</strong></td>
1030 * <td><strong>Required</strong></td>
1031 * <td><strong>Description</strong></td>
1032 * </tr>
1033 * <tr>
1034 * <td>chat_id</td>
1035 * <td>Integer or String</td>
1036 * <td>Yes</td>
1037 * <td>Unique identifier for the target chat or username of the target channel (in the format \c \@channelusername)</td>
1038 * </tr>
1039 * <tr>
1040 * <td>phone_number</td>
1041 * <td>String</td>
1042 * <td>Yes</td>
1043 * <td>Contact's phone number</td>
1044 * </tr>
1045 * <tr>
1046 * <td>first_name</td>
1047 * <td>String</td>
1048 * <td>Yes</td>
1049 * <td>Contact's first name</td>
1050 * </tr>
1051 * <tr>
1052 * <td>last_name</td>
1053 * <td>String</td>
1054 * <td>Optional</td>
1055 * <td>Contact's last name</td>
1056 * </tr>
1057 * <tr>
1058 * <td>disable_notification</td>
1059 * <td>Boolean</td>
1060 * <td>Optional</td>
1061 * <td>Sends the message <a href="https://telegram.org/blog/channels-2-0#silent-messages">silently</a>. iOS users will not receive a notification, Android users will receive a notification with no sound.</td>
1062 * </tr>
1063 * <tr>
1064 * <td>reply_to_message_id</td>
1065 * <td>Integer</td>
1066 * <td>Optional</td>
1067 * <td>If the message is a reply, ID of the original message</td>
1068 * </tr>
1069 * <tr>
1070 * <td>reply_markup</td>
1071 * <td><a href="https://core.telegram.org/bots/api#inlinekeyboardmarkup">InlineKeyboardMarkup</a> or <a href="https://core.telegram.org/bots/api#replykeyboardmarkup">ReplyKeyboardMarkup</a> or <a href="https://core.telegram.org/bots/api#replykeyboardhide">ReplyKeyboardHide</a> or <a href="https://core.telegram.org/bots/api#forcereply">ForceReply</a></td>
1072 * <td>Optional</td>
1073 * <td>Additional interface options. A JSON-serialized object for an <a href="https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating">inline keyboard</a>, <a href="https://core.telegram.org/bots#keyboards">custom reply keyboard</a>, instructions to hide keyboard or to force a reply from the user.</td>
1074 * </tr>
1075 * </table>
1076 * \param $content the request parameters as array
1077 * \return the JSON Telegram's reply
1078 */
1079 public function sendContact(array $content)
1080 {
1081 return $this->endpoint('sendContact', $content);
1082 }
1083
1084 /// Send a chat action
1085
1086 /**
1087 * Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status).
1088 *
1089 * Example: The ImageBot needs some time to process a request and upload the image. Instead of sending a text message along the lines of “Retrieving image, please wait…”, the bot may use sendChatAction with action = upload_photo. The user will see a “sending photo” status for the bot.
1090 *
1091 * We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive.<br/>Values inside $content:<br/>
1092 * <table>
1093 * <tr>
1094 * <td><strong>Parameters</strong></td>
1095 * <td><strong>Type</strong></td>
1096 * <td><strong>Required</strong></td>
1097 * <td><strong>Description</strong></td>
1098 * </tr>
1099 * <tr>
1100 * <td>chat_id</td>
1101 * <td>Integer</td>
1102 * <td>Yes</td>
1103 * <td>Unique identifier for the message recipient — User or GroupChat id</td>
1104 * </tr>
1105 * <tr>
1106 * <td>action</td>
1107 * <td>String</td>
1108 * <td>Yes</td>
1109 * <td>Type of action to broadcast. Choose one, depending on what the user is about to receive: <em>typing</em> for text messages, <em>upload_photo</em> for photos, <em>record_video</em> or <em>upload_video</em> for videos, <em>record_audio</em> or <em>upload_audio</em> for audio files, <em>upload_document</em> for general files, <em>find_location</em> for location data.</td>
1110 * </tr>
1111 * </table>
1112 * \param $content the request parameters as array
1113 * \return the JSON Telegram's reply.
1114 */
1115 public function sendChatAction(array $content)
1116 {
1117 return $this->endpoint('sendChatAction', $content);
1118 }
1119
1120 /// Get a list of profile pictures for a user
1121
1122 /**
1123 * Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object.<br/>Values inside $content:<br/>
1124 * <table>
1125 * <tr>
1126 * <td><strong>Parameters</strong></td>
1127 * <td><strong>Type</strong></td>
1128 * <td><strong>Required</strong></td>
1129 * <td><strong>Description</strong></td>
1130 * </tr>
1131 * <tr>
1132 * <td>user_id</td>
1133 * <td>Integer</td>
1134 * <td>Yes</td>
1135 * <td>Unique identifier of the target user</td>
1136 * </tr>
1137 * <tr>
1138 * <td>offset</td>
1139 * <td>Integer</td>
1140 * <td>Optional</td>
1141 * <td>Sequential number of the first photo to be returned. By default, all photos are returned.</td>
1142 * </tr>
1143 * <tr>
1144 * <td>limit</td>
1145 * <td>Integer</td>
1146 * <td>Optional</td>
1147 * <td>Limits the number of photos to be retrieved. Values between 1—100 are accepted. Defaults to 100.</td>
1148 * </tr>
1149 * </table>
1150 * \param $content the request parameters as array
1151 * \return the JSON Telegram's reply.
1152 */
1153 public function getUserProfilePhotos(array $content)
1154 {
1155 return $this->endpoint('getUserProfilePhotos', $content);
1156 }
1157
1158 /// Use this method to get basic info about a file and prepare it for downloading
1159
1160 /**
1161 * Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. On success, a File object is returned. The file can then be downloaded via the link https://api.telegram.org/file/bot<token>/<file_path>, where <file_path> is taken from the response. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling getFile again.
1162 * \param $file_id String File identifier to get info about
1163 * \return the JSON Telegram's reply.
1164 */
1165 public function getFile($file_id)
1166 {
1167 $content = ['file_id' => $file_id];
1168
1169 return $this->endpoint('getFile', $content);
1170 }
1171
1172 /// Kick Chat Member
1173
1174 /**
1175 * Use this method to kick a user from a group or a supergroup. In the case of supergroups, the user will not be able to return to the group on their own using invite links, etc., unless <a href="https://core.telegram.org/bots/api#unbanchatmember">unbanned</a> first. The bot must be an administrator in the group for this to work. Returns <em>True</em> on success.<br>
1176 * Note: This will method only work if the \˜All Members Are Admins\' setting is off in the target group. Otherwise members may only be removed by the group's creator or by the member that added them.<br/>Values inside $content:<br/>
1177 * <table>
1178 * <tr>
1179 * <td><strong>Parameters</strong></td>
1180 * <td><strong>Type</strong></td>
1181 * <td><strong>Required</strong></td>
1182 * <td><strong>Description</strong></td>
1183 * </tr>
1184 * <tr>
1185 * <td>chat_id</td>
1186 * <td>Integer or String</td>
1187 * <td>Yes</td>
1188 * <td>Unique identifier for the target group or username of the target supergroup (in the format \c \@supergroupusername)</td>
1189 * </tr>
1190 * <tr>
1191 * <td>user_id</td>
1192 * <td>Integer</td>
1193 * <td>Yes</td>
1194 * <td>Unique identifier of the target user</td>
1195 * </tr>
1196 * </table>
1197 * \param $content the request parameters as array
1198 * \return the JSON Telegram's reply.
1199 */
1200 public function kickChatMember(array $content)
1201 {
1202 return $this->endpoint('kickChatMember', $content);
1203 }
1204
1205 /// Leave Chat
1206
1207 /**
1208 * Use this method for your bot to leave a group, supergroup or channel. Returns <em>True</em> on success.</p> <br/>Values inside $content:<br/>
1209 * <table>
1210 * <tr>
1211 * <td><strong>Parameters</strong></td>
1212 * <td><strong>Type</strong></td>
1213 * <td><strong>Required</strong></td>
1214 * <td><strong>Description</strong></td>
1215 * </tr>
1216 * <tr>
1217 * <td>chat_id</td>
1218 * <td>Integer or String</td>
1219 * <td>Yes</td>
1220 * <td>Unique identifier for the target chat or username of the target supergroup or channel (in the format \c \@channelusername)</td>
1221 * </tr>
1222 * </table>
1223 * \param $content the request parameters as array
1224 * \return the JSON Telegram's reply.
1225 */
1226 public function leaveChat(array $content)
1227 {
1228 return $this->endpoint('leaveChat', $content);
1229 }
1230
1231 /// Unban Chat Member
1232
1233 /**
1234 * Use this method to unban a previously kicked user in a supergroup. The user will <strong>not</strong> return to the group automatically, but will be able to join via link, etc. The bot must be an administrator in the group for this to work. Returns <em>True</em> on success.<br/>Values inside $content:<br/>
1235 * <table>
1236 * <tr>
1237 * <td><strong>Parameters</strong></td>
1238 * <td><strong>Type</strong></td>
1239 * <td><strong>Required</strong></td>
1240 * <td><strong>Description</strong></td>
1241 * </tr>
1242 * <tr>
1243 * <td>chat_id</td>
1244 * <td>Integer or String</td>
1245 * <td>Yes</td>
1246 * <td>Unique identifier for the target group or username of the target supergroup (in the format <code>@supergroupusername</code>)</td>
1247 * </tr>
1248 * <tr>
1249 * <td>user_id</td>
1250 * <td>Integer</td>
1251 * <td>Yes</td>
1252 * <td>Unique identifier of the target user</td>
1253 * </tr>
1254 * </table>
1255 * \param $content the request parameters as array
1256 * \return the JSON Telegram's reply.
1257 */
1258 public function unbanChatMember(array $content)
1259 {
1260 return $this->endpoint('unbanChatMember', $content);
1261 }
1262
1263 /// Get Chat Information
1264
1265 /**
1266 * Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). Returns a <a href="https://core.telegram.org/bots/api#chat">Chat</a> object on success.<br/>Values inside $content:<br/>
1267 * <table>
1268 * <tr>
1269 * <td><strong>Parameters</strong></td>
1270 * <td><strong>Type</strong></td>
1271 * <td><strong>Required</strong></td>
1272 * <td><strong>Description</strong></td>
1273 * </tr>
1274 * <tr>
1275 * <td>chat_id</td>
1276 * <td>Integer or String</td>
1277 * <td>Yes</td>
1278 * <td>Unique identifier for the target chat or username of the target supergroup or channel (in the format \c \@channelusername)</td>
1279 * </tr>
1280 * </table>
1281 * \param $content the request parameters as array
1282 * \return the JSON Telegram's reply.
1283 */
1284 public function getChat(array $content)
1285 {
1286 return $this->endpoint('getChat', $content);
1287 }
1288
1289 /**
1290 * Use this method to get a list of administrators in a chat. On success, returns an Array of <a href="https://core.telegram.org/bots/api#chatmember">ChatMember</a> objects that contains information about all chat administrators except other bots. If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned.<br/>Values inside $content:<br/>
1291 * <table>
1292 * <tr>
1293 * <td><strong>Parameters</strong></td>
1294 * <td><strong>Type</strong></td>
1295 * <td><strong>Required</strong></td>
1296 * <td><strong>Description</strong></td>
1297 * </tr>
1298 * <tr>
1299 * <td>chat_id</td>
1300 * <td>Integer or String</td>
1301 * <td>Yes</td>
1302 * <td>Unique identifier for the target chat or username of the target supergroup or channel (in the format \c \@channelusername)</td>
1303 * </tr>
1304 * </table>
1305 * \param $content the request parameters as array
1306 * \return the JSON Telegram's reply.
1307 */
1308 public function getChatAdministrators(array $content)
1309 {
1310 return $this->endpoint('getChatAdministrators', $content);
1311 }
1312
1313 /**
1314 * Use this method to get the number of members in a chat. Returns <em>Int</em> on success.<br/>Values inside $content:<br/>
1315 * <table>
1316 * <tr>
1317 * <td><strong>Parameters</strong></td>
1318 * <td><strong>Type</strong></td>
1319 * <td><strong>Required</strong></td>
1320 * <td><strong>Description</strong></td>
1321 * </tr>
1322 * <tr>
1323 * <td>chat_id</td>
1324 * <td>Integer or String</td>
1325 * <td>Yes</td>
1326 * <td>Unique identifier for the target chat or username of the target supergroup or channel (in the format \c \@channelusername)</td>
1327 * </tr>
1328 * </table>
1329 * \param $content the request parameters as array
1330 * \return the JSON Telegram's reply.
1331 */
1332 public function getChatMembersCount(array $content)
1333 {
1334 return $this->endpoint('getChatMembersCount', $content);
1335 }
1336
1337 /**
1338 * Use this method to get information about a member of a chat. Returns a <a href="https://core.telegram.org/bots/api#chatmember">ChatMember</a> object on success.<br/>Values inside $content:<br/>
1339 * <table>
1340 * <tr>
1341 * <td><strong>Parameters</strong></td>
1342 * <td><strong>Type</strong></td>
1343 * <td><strong>Required</strong></td>
1344 * <td><strong>Description</strong></td>
1345 * </tr>
1346 * <tr>
1347 * <td>chat_id</td>
1348 * <td>Integer or String</td>
1349 * <td>Yes</td>
1350 * <td>Unique identifier for the target chat or username of the target supergroup or channel (in the format \c \@channelusername)</td>
1351 * </tr>
1352 * <tr>
1353 * <td>user_id</td>
1354 * <td>Integer</td>
1355 * <td>Yes</td>
1356 * <td>Unique identifier of the target user</td>
1357 * </tr>
1358 * </table>
1359 * \param $content the request parameters as array
1360 * \return the JSON Telegram's reply.
1361 */
1362 public function getChatMember(array $content)
1363 {
1364 return $this->endpoint('getChatMember', $content);
1365 }
1366
1367 /**
1368 * Use this method to send answers to an inline query. On success, <em>True</em> is returned.<br>No more than <strong>50</strong> results per query are allowed.<br/>Values inside $content:<br/>
1369 * <table>
1370 * <tr>
1371 * <td><strong>Parameters</strong></td>
1372 * <td><strong>Type</strong></td>
1373 * <td><strong>Required</strong></td>
1374 * <td><strong>Description</strong></td>
1375 * </tr>
1376 * <tr>
1377 * <td>inline_query_id</td>
1378 * <td>String</td>
1379 * <td>Yes</td>
1380 * <td>Unique identifier for the answered query</td>
1381 * </tr>
1382 * <tr>
1383 * <td>results</td>
1384 * <td>Array of <a href="https://core.telegram.org/bots/api#inlinequeryresult">InlineQueryResult</a></td>
1385 * <td>Yes</td>
1386 * <td>A JSON-serialized array of results for the inline query</td>
1387 * </tr>
1388 * <tr>
1389 * <td>cache_time</td>
1390 * <td>Integer</td>
1391 * <td>Optional</td>
1392 * <td>The maximum amount of time in seconds that the result of the inline query may be cached on the server. Defaults to 300.</td>
1393 * </tr>
1394 * <tr>
1395 * <td>is_personal</td>
1396 * <td>Boolean</td>
1397 * <td>Optional</td>
1398 * <td>Pass <em>True</em>, if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query</td>
1399 * </tr>
1400 * <tr>
1401 * <td>next_offset</td>
1402 * <td>String</td>
1403 * <td>Optional</td>
1404 * <td>Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don‘t support pagination. Offset length can’t exceed 64 bytes.</td>
1405 * </tr>
1406 * <tr>
1407 * <td>switch_pm_text</td>
1408 * <td>String</td>
1409 * <td>Optional</td>
1410 * <td>If passed, clients will display a button with specified text that switches the user to a private chat with the bot and sends the bot a start message with the parameter <em>switch_pm_parameter</em></td>
1411 * </tr>
1412 * <tr>
1413 * <td>switch_pm_parameter</td>
1414 * <td>String</td>
1415 * <td>Optional</td>
1416 * <td>Parameter for the start message sent to the bot when user presses the switch button<br><br><em>Example:</em> An inline bot that sends YouTube videos can ask the user to connect the bot to their YouTube account to adapt search results accordingly. To do this, it displays a ‘Connect your YouTube account’ button above the results, or even before showing any. The user presses the button, switches to a private chat with the bot and, in doing so, passes a start parameter that instructs the bot to return an oauth link. Once done, the bot can offer a <a href="https://core.telegram.org/bots/api#inlinekeyboardmarkup"><em>switch_inline</em></a> button so that the user can easily return to the chat where they wanted to use the bot's inline capabilities.</td>
1417 * </tr>
1418 * </table>
1419 * \param $content the request parameters as array
1420 * \return the JSON Telegram's reply.
1421 */
1422 public function answerInlineQuery(array $content)
1423 {
1424 return $this->endpoint('answerInlineQuery', $content);
1425 }
1426
1427 /// Set Game Score
1428
1429 /**
1430 * Use this method to set the score of the specified user in a game. On success, if the message was sent by the bot, returns the edited Message, otherwise returns <em>True</em>. Returns an error, if the new score is not greater than the user's current score in the chat and <em>force</em> is <em>False</em>.<br/>
1431 * <table>
1432 * <tr>
1433 * <td><strong>Parameters</strong></td>
1434 * <td><strong>Type</strong></td>
1435 * <td><strong>Required</strong></td>
1436 * <td><strong>Description</strong></td>
1437 * </tr>
1438 * <tr>
1439 * <td>user_id</td>
1440 * <td>Integer</td>
1441 * <td>Yes</td>
1442 * <td>User identifier</td>
1443 * </tr>
1444 * <tr>
1445 * <td>score</td>
1446 * <td>Integer</td>
1447 * <td>Yes</td>
1448 * <td>New score, must be non-negative</td>
1449 * </tr>
1450 * <tr>
1451 * <td>force</td>
1452 * <td>Boolean</td>
1453 * <td>Optional</td>
1454 * <td>Pass True, if the high score is allowed to decrease. This can be useful when fixing mistakes or banning cheaters</td>
1455 * </tr>
1456 * <tr>
1457 * <td>disable_edit_message</td>
1458 * <td>Boolean</td>
1459 * <td>Optional</td>
1460 * <td>Pass True, if the game message should not be automatically edited to include the current scoreboard</td>
1461 * </tr>
1462 * <tr>
1463 * <td>chat_id</td>
1464 * <td>Integer</td>
1465 * <td>Optional</td>
1466 * <td>Required if <em>inline_message_id</em> is not specified. Unique identifier for the target chat</td>
1467 * </tr>
1468 * <tr>
1469 * <td>message_id</td>
1470 * <td>Integer</td>
1471 * <td>Optional</td>
1472 * <td>Required if <em>inline_message_id</em> is not specified. Identifier of the sent message</td>
1473 * </tr>
1474 * <tr>
1475 * <td>inline_message_id</td>
1476 * <td>String</td>
1477 * <td>Optional</td>
1478 * <td>Required if <em>chat_id</em> and <em>message_id</em> are not specified. Identifier of the inline message</td>
1479 * </tr>
1480 * </table>
1481 * \param $content the request parameters as array
1482 * \return the JSON Telegram's reply.
1483 */
1484 public function setGameScore(array $content)
1485 {
1486 return $this->endpoint('setGameScore', $content);
1487 }
1488
1489 /// Answer a callback Query
1490
1491 /**
1492 * Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, <em>True</em> is returned.<br/>Values inside $content:<br/>
1493 * <table>
1494 * <tr>
1495 * <td><strong>Parameters</strong></td>
1496 * <td><strong>Type</strong></td>
1497 * <td><strong>Required</strong></td>
1498 * <td><strong>Description</strong></td>
1499 * </tr>
1500 * <tr>
1501 * <td>callback_query_id</td>
1502 * <td>String</td>
1503 * <td>Yes</td>
1504 * <td>Unique identifier for the query to be answered</td>
1505 * </tr>
1506 * <tr>
1507 * <td>text</td>
1508 * <td>String</td>
1509 * <td>Optional</td>
1510 * <td>Text of the notification. If not specified, nothing will be shown to the user</td>
1511 * </tr>
1512 * <tr>
1513 * <td>show_alert</td>
1514 * <td>Boolean</td>
1515 * <td>Optional</td>
1516 * <td>If <em>true</em>, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to <em>false</em>.</td>
1517 * </tr>
1518 * </table>
1519 * \param $content the request parameters as array
1520 * \return the JSON Telegram's reply.
1521 */
1522 public function answerCallbackQuery(array $content)
1523 {
1524 return $this->endpoint('answerCallbackQuery', $content);
1525 }
1526
1527 /**
1528 * Use this method to edit text messages sent by the bot or via the bot (for <a href="https://core.telegram.org/bots/api#inline-mode">inline bots</a>). On success, if edited message is sent by the bot, the edited <a href="https://core.telegram.org/bots/api#message">Message</a> is returned, otherwise <em>True</em> is returned.<br/>Values inside $content:<br/>
1529 * <table>
1530 * <tr>
1531 * <td><strong>Parameters</strong></td>
1532 * <td><strong>Type</strong></td>
1533 * <td><strong>Required</strong></td>
1534 * <td><strong>Description</strong></td>
1535 * </tr>
1536 * <tr>
1537 * <td>chat_id</td>
1538 * <td>Integer or String</td>
1539 * <td>No</td>
1540 * <td>Required if <em>inline_message_id</em> is not specified. Unique identifier for the target chat or username of the target channel (in the format \c \@channelusername)</td>
1541 * </tr>
1542 * <tr>
1543 * <td>message_id</td>
1544 * <td>Integer</td>
1545 * <td>No</td>
1546 * <td>Required if <em>inline_message_id</em> is not specified. Unique identifier of the sent message</td>
1547 * </tr>
1548 * <tr>
1549 * <td>inline_message_id</td>
1550 * <td>String</td>
1551 * <td>No</td>
1552 * <td>Required if <em>chat_id</em> and <em>message_id</em> are not specified. Identifier of the inline message</td>
1553 * </tr>
1554 * <tr>
1555 * <td>text</td>
1556 * <td>String</td>
1557 * <td>Yes</td>
1558 * <td>New text of the message</td>
1559 * </tr>
1560 * <tr>
1561 * <td>parse_mode</td>
1562 * <td>String</td>
1563 * <td>Optional</td>
1564 * <td>Send <a href="https://core.telegram.org/bots/api#markdown-style"><em>Markdown</em></a> or <a href="https://core.telegram.org/bots/api#html-style"><em>HTML</em></a>, if you want Telegram apps to show <a href="https://core.telegram.org/bots/api#formatting-options">bold, italic, fixed-width text or inline URLs</a> in your bot's message.</td>
1565 * </tr>
1566 * <tr>
1567 * <td>disable_web_page_preview</td>
1568 * <td>Boolean</td>
1569 * <td>Optional</td>
1570 * <td>Disables link previews for links in this message</td>
1571 * </tr>
1572 * <tr>
1573 * <td>reply_markup</td>
1574 * <td><a href="https://core.telegram.org/bots/api#inlinekeyboardmarkup">InlineKeyboardMarkup</a></td>
1575 * <td>Optional</td>
1576 * <td>A JSON-serialized object for an <a href="https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating">inline keyboard</a>.</td>
1577 * </tr>
1578 * </table>
1579 * \param $content the request parameters as array
1580 * \return the JSON Telegram's reply.
1581 */
1582 public function editMessageText(array $content)
1583 {
1584 return $this->endpoint('editMessageText', $content);
1585 }
1586
1587 /**
1588 * Use this method to edit captions of messages sent by the bot or via the bot (for <a href="https://core.telegram.org/bots/api#inline-mode">inline bots</a>). On success, if edited message is sent by the bot, the edited <a href="https://core.telegram.org/bots/api#message">Message</a> is returned, otherwise <em>True</em> is returned.<br/>Values inside $content:<br/>
1589 * <table>
1590 * <tr>
1591 * <td><strong>Parameters</strong></td>
1592 * <td><strong>Type</strong></td>
1593 * <td><strong>Required</strong></td>
1594 * <td><strong>Description</strong></td>
1595 * </tr>
1596 * <tr>
1597 * <td>chat_id</td>
1598 * <td>Integer or String</td>
1599 * <td>No</td>
1600 * <td>Required if <em>inline_message_id</em> is not specified. Unique identifier for the target chat or username of the target channel (in the format \c \@channelusername)</td>
1601 * </tr>
1602 * <tr>
1603 * <td>message_id</td>
1604 * <td>Integer</td>
1605 * <td>No</td>
1606 * <td>Required if <em>inline_message_id</em> is not specified. Unique identifier of the sent message</td>
1607 * </tr>
1608 * <tr>
1609 * <td>inline_message_id</td>
1610 * <td>String</td>
1611 * <td>No</td>
1612 * <td>Required if <em>chat_id</em> and <em>message_id</em> are not specified. Identifier of the inline message</td>
1613 * </tr>
1614 * <tr>
1615 * <td>caption</td>
1616 * <td>String</td>
1617 * <td>Optional</td>
1618 * <td>New caption of the message</td>
1619 * </tr>
1620 * <tr>
1621 * <td>reply_markup</td>
1622 * <td><a href="https://core.telegram.org/bots/api#inlinekeyboardmarkup">InlineKeyboardMarkup</a></td>
1623 * <td>Optional</td>
1624 * <td>A JSON-serialized object for an <a href="https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating">inline keyboard</a>.</td>
1625 * </tr>
1626 * </table>
1627 * \param $content the request parameters as array
1628 * \return the JSON Telegram's reply.
1629 */
1630 public function editMessageCaption(array $content)
1631 {
1632 return $this->endpoint('editMessageCaption', $content);
1633 }
1634
1635 /**
1636 * Use this method to edit only the reply markup of messages sent by the bot or via the bot (for <a href="https://core.telegram.org/bots/api#inline-mode">inline bots</a>). On success, if edited message is sent by the bot, the edited <a href="https://core.telegram.org/bots/api#message">Message</a> is returned, otherwise <em>True</em> is returned.<br/>Values inside $content:<br/>
1637 * <table>
1638 * <tr>
1639 * <td><strong>Parameters</strong></td>
1640 * <td><strong>Type</strong></td>
1641 * <td><strong>Required</strong></td>
1642 * <td><strong>Description</strong></td>
1643 * </tr>
1644 * <tr>
1645 * <td>chat_id</td>
1646 * <td>Integer or String</td>
1647 * <td>No</td>
1648 * <td>Required if <em>inline_message_id</em> is not specified. Unique identifier for the target chat or username of the target channel (in the format \c \@channelusername)</td>
1649 * </tr>
1650 * <tr>
1651 * <td>message_id</td>
1652 * <td>Integer</td>
1653 * <td>No</td>
1654 * <td>Required if <em>inline_message_id</em> is not specified. Unique identifier of the sent message</td>
1655 * </tr>
1656 * <tr>
1657 * <td>inline_message_id</td>
1658 * <td>String</td>
1659 * <td>No</td>
1660 * <td>Required if <em>chat_id</em> and <em>message_id</em> are not specified. Identifier of the inline message</td>
1661 * </tr>
1662 * <tr>
1663 * <td>reply_markup</td>
1664 * <td><a href="https://core.telegram.org/bots/api#inlinekeyboardmarkup">InlineKeyboardMarkup</a></td>
1665 * <td>Optional</td>
1666 * <td>A JSON-serialized object for an <a href="https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating">inline keyboard</a>.</td>
1667 * </tr>
1668 * </table>
1669 * \param $content the request parameters as array
1670 * \return the JSON Telegram's reply.
1671 */
1672 public function editMessageReplyMarkup(array $content)
1673 {
1674 return $this->endpoint('editMessageReplyMarkup', $content);
1675 }
1676
1677 /// Use this method to download a file
1678
1679 /**
1680 * Use this method to to download a file from the Telegram servers.
1681 * \param $telegram_file_path String File path on Telegram servers
1682 * \param $local_file_path String File path where save the file.
1683 */
1684 public function downloadFile($telegram_file_path, $local_file_path)
1685 {
1686 $file_url = 'https://api.telegram.org/file/bot'.$this->bot_token.'/'.$telegram_file_path;
1687 $in = fopen($file_url, 'rb');
1688 $out = fopen($local_file_path, 'wb');
1689
1690 while ($chunk = fread($in, 8192)) {
1691 fwrite($out, $chunk, 8192);
1692 }
1693 fclose($in);
1694 fclose($out);
1695 }
1696
1697 /// Set a WebHook for the bot
1698
1699 /**
1700 * Use this method to specify a url and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified url, containing a JSON-serialized Update. In case of an unsuccessful request, we will give up after a reasonable amount of attempts.
1701 *
1702 * If you'd like to make sure that the Webhook request comes from Telegram, we recommend using a secret path in the URL, e.g. https://www.example.com/<token>. Since nobody else knows your bot‘s token, you can be pretty sure it’s us.
1703 * \param $url String HTTPS url to send updates to. Use an empty string to remove webhook integration
1704 * \param $certificate InputFile Upload your public key certificate so that the root certificate in use can be checked
1705 * \return the JSON Telegram's reply.
1706 */
1707 public function setWebhook($url, $certificate = '')
1708 {
1709 if ($certificate == '') {
1710 $requestBody = ['url' => $url];
1711 } else {
1712 $requestBody = ['url' => $url, 'certificate' => "@$certificate"];
1713 }
1714
1715 return $this->endpoint('setWebhook', $requestBody, true);
1716 }
1717
1718 /// Delete the WebHook for the bot
1719
1720 /**
1721 * Use this method to remove webhook integration if you decide to switch back to <a href="https://core.telegram.org/bots/api#getupdates">getUpdates</a>. Returns True on success. Requires no parameters.
1722 * \return the JSON Telegram's reply.
1723 */
1724 public function deleteWebhook()
1725 {
1726 return $this->endpoint('deleteWebhook', [], false);
1727 }
1728
1729 /// Get the data of the current message
1730
1731 /** Get the POST request of a user in a Webhook or the message actually processed in a getUpdates() enviroment.
1732 * \return the JSON users's message.
1733 */
1734 public function getData()
1735 {
1736 if (empty($this->data)) {
1737 $rawData = file_get_contents('php://input');
1738
1739 return json_decode($rawData, true);
1740 } else {
1741 return $this->data;
1742 }
1743 }
1744
1745 /// Set the data currently used
1746 public function setData(array $data)
1747 {
1748 $this->data = $data;
1749 }
1750
1751 /// Get the text of the current message
1752
1753 /**
1754 * \return the String users's text.
1755 */
1756 public function Text()
1757 {
1758 $type = $this->getUpdateType();
1759 if ($type == self::CALLBACK_QUERY) {
1760 return @$this->data['callback_query']['data'];
1761 }
1762 if ($type == self::CHANNEL_POST) {
1763 return @$this->data['channel_post']['text'];
1764 }
1765 if ($type == self::EDITED_MESSAGE) {
1766 return @$this->data['edited_message']['text'];
1767 }
1768
1769 return @$this->data['message']['text'];
1770 }
1771
1772 public function Caption()
1773 {
1774 $type = $this->getUpdateType();
1775 if ($type == self::CHANNEL_POST) {
1776 return @$this->data['channel_post']['caption'];
1777 }
1778 return @$this->data['message']['caption'];
1779 }
1780
1781 /// Get the chat_id of the current message
1782
1783 /**
1784 * \return the String users's chat_id.
1785 */
1786 public function ChatID()
1787 {
1788 $type = $this->getUpdateType();
1789 if ($type == self::CALLBACK_QUERY) {
1790 return @$this->data['callback_query']['message']['chat']['id'];
1791 }
1792 if ($type == self::CHANNEL_POST) {
1793 return @$this->data['channel_post']['chat']['id'];
1794 }
1795 if ($type == self::EDITED_MESSAGE) {
1796 return @$this->data['edited_message']['chat']['id'];
1797 }
1798 if ($type == self::INLINE_QUERY) {
1799 return @$this->data['inline_query']['from']['id'];
1800 }
1801
1802 return $this->data['message']['chat']['id'];
1803 }
1804
1805 /// Get the message_id of the current message
1806
1807 /**
1808 * \return the String message_id.
1809 */
1810 public function MessageID()
1811 {
1812 $type = $this->getUpdateType();
1813 if ($type == self::CALLBACK_QUERY) {
1814 return @$this->data['callback_query']['message']['message_id'];
1815 }
1816 if ($type == self::CHANNEL_POST) {
1817 return @$this->data['channel_post']['message_id'];
1818 }
1819 if ($type == self::EDITED_MESSAGE) {
1820 return @$this->data['edited_message']['message_id'];
1821 }
1822
1823 return $this->data['message']['message_id'];
1824 }
1825
1826 /// Get the reply_to_message message_id of the current message
1827
1828 /**
1829 * \return the String reply_to_message message_id.
1830 */
1831 public function ReplyToMessageID()
1832 {
1833 return $this->data['message']['reply_to_message']['message_id'];
1834 }
1835
1836 /// Get the reply_to_message forward_from user_id of the current message
1837
1838 /**
1839 * \return the String reply_to_message forward_from user_id.
1840 */
1841 public function ReplyToMessageFromUserID()
1842 {
1843 return $this->data['message']['reply_to_message']['forward_from']['id'];
1844 }
1845
1846 public function ReplyToMessageFromUserIDb()
1847 {
1848 return $this->data['message']['reply_to_message']['from']['id'];
1849 }
1850
1851 public function ReplyToMessageFromName()
1852 {
1853 return $this->data['message']['reply_to_message']['from']['first_name'] . ' ' . $this->data['message']['reply_to_message']['from']['last_name'];
1854 }
1855
1856 public function ReplyToMessageFromUserUsername()
1857 {
1858 return $this->data['message']['reply_to_message']['from']['username'];
1859 }
1860
1861 public function ReplyToMessageFromUserText()
1862 {
1863 return $this->data['message']['reply_to_message']['text'];
1864 }
1865
1866 /// Get the inline_query of the current update
1867
1868 /**
1869 * \return the Array inline_query.
1870 */
1871 public function Inline_Query()
1872 {
1873 return $this->data['inline_query'];
1874 }
1875
1876 /// Get the callback_query of the current update
1877
1878 /**
1879 * \return the String callback_query.
1880 */
1881 public function Callback_Query()
1882 {
1883 return $this->data['callback_query'];
1884 }
1885
1886 /// Get the callback_query id of the current update
1887
1888 /**
1889 * \return the String callback_query id.
1890 */
1891 public function Callback_ID()
1892 {
1893 return $this->data['callback_query']['id'];
1894 }
1895
1896 /// Get the Get the data of the current callback
1897
1898 /**
1899 * \deprecated Use Text() instead
1900 * \return the String callback_data.
1901 */
1902 public function Callback_Data()
1903 {
1904 return $this->data['callback_query']['data'];
1905 }
1906
1907 /// Get the Get the message of the current callback
1908
1909 /**
1910 * \return the Message.
1911 */
1912 public function Callback_Message()
1913 {
1914 return $this->data['callback_query']['message'];
1915 }
1916
1917 /// Get the Get the chati_id of the current callback
1918
1919 /**
1920 * \deprecated Use ChatId() instead
1921 * \return the String callback_query.
1922 */
1923 public function Callback_ChatID()
1924 {
1925 return $this->data['callback_query']['message']['chat']['id'];
1926 }
1927
1928 /// Get the date of the current message
1929
1930 /**
1931 * \return the String message's date.
1932 */
1933 public function Date()
1934 {
1935 return $this->data['message']['date'];
1936 }
1937
1938 /// Get the first name of the user
1939 public function FirstName()
1940 {
1941 $type = $this->getUpdateType();
1942 if ($type == self::CALLBACK_QUERY) {
1943 return @$this->data['callback_query']['from']['first_name'];
1944 }
1945 if ($type == self::CHANNEL_POST) {
1946 return @$this->data['channel_post']['from']['first_name'];
1947 }
1948 if ($type == self::EDITED_MESSAGE) {
1949 return @$this->data['edited_message']['from']['first_name'];
1950 }
1951
1952 return @$this->data['message']['from']['first_name'];
1953 }
1954
1955 /// Get the last name of the user
1956 public function LastName()
1957 {
1958 $type = $this->getUpdateType();
1959 if ($type == self::CALLBACK_QUERY) {
1960 return @$this->data['callback_query']['from']['last_name'];
1961 }
1962 if ($type == self::CHANNEL_POST) {
1963 return @$this->data['channel_post']['from']['last_name'];
1964 }
1965 if ($type == self::EDITED_MESSAGE) {
1966 return @$this->data['edited_message']['from']['last_name'];
1967 }
1968
1969 return @$this->data['message']['from']['last_name'];
1970 }
1971
1972 /// Get the username of the user
1973 public function Username()
1974 {
1975 $type = $this->getUpdateType();
1976 if ($type == self::CALLBACK_QUERY) {
1977 return @$this->data['callback_query']['from']['username'];
1978 }
1979 if ($type == self::CHANNEL_POST) {
1980 return @$this->data['channel_post']['from']['username'];
1981 }
1982 if ($type == self::EDITED_MESSAGE) {
1983 return @$this->data['edited_message']['from']['username'];
1984 }
1985
1986 return @$this->data['message']['from']['username'];
1987 }
1988
1989 /// Get the location in the message
1990 public function Location()
1991 {
1992 return $this->data['message']['location'];
1993 }
1994
1995 /// Get the update_id of the message
1996 public function UpdateID()
1997 {
1998 return $this->data['update_id'];
1999 }
2000
2001 /// Get the number of updates
2002 public function UpdateCount()
2003 {
2004 return count($this->updates['result']);
2005 }
2006
2007 /// Get user's id of current message
2008 public function UserID()
2009 {
2010 $type = $this->getUpdateType();
2011 if ($type == self::CALLBACK_QUERY) {
2012 return $this->data['callback_query']['from']['id'];
2013 }
2014 if ($type == self::CHANNEL_POST) {
2015 return $this->data['channel_post']['from']['id'];
2016 }
2017 if ($type == self::EDITED_MESSAGE) {
2018 return @$this->data['edited_message']['from']['id'];
2019 }
2020
2021 return $this->data['message']['from']['id'];
2022 }
2023
2024 /// Get user's id of current forwarded message
2025 public function FromID()
2026 {
2027 return $this->data['message']['forward_from']['id'];
2028 }
2029
2030 /// Get chat's id where current message forwarded from
2031 public function FromChatID()
2032 {
2033 return $this->data['message']['forward_from_chat']['id'];
2034 }
2035
2036 /// Tell if a message is from a group or user chat
2037
2038 /**
2039 * \return BOOLEAN true if the message is from a Group chat, false otherwise.
2040 */
2041 public function messageFromGroup()
2042 {
2043 if ($this->data['message']['chat']['type'] == 'private') {
2044 return false;
2045 }
2046
2047 return true;
2048 }
2049
2050 /// Get the title of the group chat
2051
2052 /**
2053 * \return a String of the title chat.
2054 */
2055 public function messageFromGroupTitle()
2056 {
2057 if ($this->data['message']['chat']['type'] != 'private') {
2058 return $this->data['message']['chat']['title'];
2059 }
2060 }
2061
2062 public function welcomeGroup($type)
2063 {
2064 if ($type == 'welcome') {
2065 return $this->data['message']['new_chat_members'];
2066 } else {
2067 return $this->data['message']['left_chat_member'];
2068 }
2069
2070 }
2071 public function welcomeGroupFullname($type)
2072 {
2073 if ($type == 'welcome') {
2074 return $this->data['message']['new_chat_members'][0]['first_name'] . ' ' . $this->data['message']['new_chat_members'][0]['last_name'];
2075 } else {
2076 return $this->data['message']['left_chat_member']['first_name'] . ' ' . $this->data['message']['left_chat_member']['last_name'];
2077 }
2078
2079 }
2080
2081 public function welcomeGroupUsername()
2082 {
2083 return $this->data['message']['new_chat_members'][0]['username'];
2084 }
2085
2086 public function welcomeGroupId()
2087 {
2088 return $this->data['message']['new_chat_members'][0]['id'];
2089 }
2090
2091 /// Set a custom keyboard
2092
2093 /** This object represents a custom keyboard with reply options
2094 * \param $options Array of Array of String; Array of button rows, each represented by an Array of Strings
2095 * \param $onetime Boolean Requests clients to hide the keyboard as soon as it's been used. Defaults to false.
2096 * \param $resize Boolean Requests clients to resize the keyboard vertically for optimal fit (e.g., make the keyboard smaller if there are just two rows of buttons). Defaults to false, in which case the custom keyboard is always of the same height as the app's standard keyboard.
2097 * \param $selective Boolean Use this parameter if you want to show the keyboard to specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.
2098 * \return the requested keyboard as Json.
2099 */
2100 public function buildKeyBoard(array $options, $onetime = false, $resize = false, $selective = true)
2101 {
2102 $replyMarkup = [
2103 'keyboard' => $options,
2104 'one_time_keyboard' => $onetime,
2105 'resize_keyboard' => $resize,
2106 'selective' => $selective,
2107 ];
2108 $encodedMarkup = json_encode($replyMarkup, true);
2109
2110 return $encodedMarkup;
2111 }
2112
2113 /// Set an InlineKeyBoard
2114
2115 /** This object represents an inline keyboard that appears right next to the message it belongs to.
2116 * \param $options Array of Array of InlineKeyboardButton; Array of button rows, each represented by an Array of InlineKeyboardButton
2117 * \return the requested keyboard as Json.
2118 */
2119 public function buildInlineKeyBoard(array $options)
2120 {
2121 $replyMarkup = [
2122 'inline_keyboard' => $options,
2123 ];
2124 $encodedMarkup = json_encode($replyMarkup, true);
2125
2126 return $encodedMarkup;
2127 }
2128
2129 /// Create an InlineKeyboardButton
2130
2131 /** This object represents one button of an inline keyboard. You must use exactly one of the optional fields.
2132 * \param $text String; Array of button rows, each represented by an Array of Strings
2133 * \param $url String Optional. HTTP url to be opened when button is pressed
2134 * \param $callback_data String Optional. Data to be sent in a callback query to the bot when button is pressed
2135 * \param $switch_inline_query String Optional. If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot‘s username and the specified inline query in the input field. Can be empty, in which case just the bot’s username will be inserted.
2136 * \param $switch_inline_query_current_chat String Optional. Optional. If set, pressing the button will insert the bot‘s username and the specified inline query in the current chat's input field. Can be empty, in which case only the bot’s username will be inserted.
2137 * \param $callback_game String Optional. Description of the game that will be launched when the user presses the button.
2138 * \param $pay Boolean Optional. Specify True, to send a <a href="https://core.telegram.org/bots/api#payments">Pay button</a>.
2139 * \return the requested button as Array.
2140 */
2141 public function buildInlineKeyboardButton($text, $url = '', $callback_data = '', $switch_inline_query = null, $switch_inline_query_current_chat = null, $callback_game = '', $pay = '')
2142 {
2143 $replyMarkup = [
2144 'text' => $text,
2145 ];
2146 if ($url != '') {
2147 $replyMarkup['url'] = $url;
2148 } elseif ($callback_data != '') {
2149 $replyMarkup['callback_data'] = $callback_data;
2150 } elseif (!is_null($switch_inline_query)) {
2151 $replyMarkup['switch_inline_query'] = $switch_inline_query;
2152 } elseif (!is_null($switch_inline_query_current_chat)) {
2153 $replyMarkup['switch_inline_query_current_chat'] = $switch_inline_query_current_chat;
2154 } elseif ($callback_game != '') {
2155 $replyMarkup['callback_game'] = $callback_game;
2156 } elseif ($pay != '') {
2157 $replyMarkup['pay'] = $pay;
2158 }
2159
2160 return $replyMarkup;
2161 }
2162
2163 /// Create a KeyboardButton
2164
2165 /** This object represents one button of an inline keyboard. You must use exactly one of the optional fields.
2166 * \param $text String; Array of button rows, each represented by an Array of Strings
2167 * \param $request_contact Boolean Optional. If True, the user's phone number will be sent as a contact when the button is pressed. Available in private chats only
2168 * \param $request_location Boolean Optional. If True, the user's current location will be sent when the button is pressed. Available in private chats only
2169 * \return the requested button as Array.
2170 */
2171 public function buildKeyboardButton($text, $request_contact = false, $request_location = false)
2172 {
2173 $replyMarkup = [
2174 'text' => $text,
2175 'request_contact' => $request_contact,
2176 'request_location' => $request_location,
2177 ];
2178
2179 return $replyMarkup;
2180 }
2181
2182 /// Hide a custom keyboard
2183
2184 /** Upon receiving a message with this object, Telegram clients will hide the current custom keyboard and display the default letter-keyboard. By default, custom keyboards are displayed until a new keyboard is sent by a bot. An exception is made for one-time keyboards that are hidden immediately after the user presses a button.
2185 * \param $selective Boolean Use this parameter if you want to show the keyboard to specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.
2186 * \return the requested keyboard hide as Array.
2187 */
2188 public function buildKeyBoardHide($selective = true)
2189 {
2190 $replyMarkup = [
2191 'remove_keyboard' => true,
2192 'selective' => $selective,
2193 ];
2194 $encodedMarkup = json_encode($replyMarkup, true);
2195
2196 return $encodedMarkup;
2197 }
2198
2199 /// Display a reply interface to the user
2200 /* Upon receiving a message with this object, Telegram clients will display a reply interface to the user (act as if the user has selected the bot‘s message and tapped ’Reply'). This can be extremely useful if you want to create user-friendly step-by-step interfaces without having to sacrifice privacy mode.
2201 * \param $selective Boolean Use this parameter if you want to show the keyboard to specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.
2202 * \return the requested force reply as Array
2203 */
2204 public function buildForceReply($selective = true)
2205 {
2206 $replyMarkup = [
2207 'force_reply' => true,
2208 'selective' => $selective,
2209 ];
2210 $encodedMarkup = json_encode($replyMarkup, true);
2211
2212 return $encodedMarkup;
2213 }
2214
2215 // Payments
2216 /// Send an invoice
2217
2218 /**
2219 * Use this method to send invoices. On success, the sent <a href="https://core.telegram.org/bots/api#message">Message</a> is returned.
2220 * <table>
2221 * <tr>
2222 * <td><strong>Parameters</strong></td>
2223 * <td><strong>Type</strong></td>
2224 * <td><strong>Required</strong></td>
2225 * <td><strong>Description</strong></td>
2226 * </tr>
2227 * <tr>
2228 * <td>chat_id</td>
2229 * <td>Integer</td>
2230 * <td>Yes</td>
2231 * <td>Unique identifier for the target private chat</td>
2232 * </tr>
2233 * <tr>
2234 * <td>title</td>
2235 * <td>String</td>
2236 * <td>Yes</td>
2237 * <td>Product name</td>
2238 * </tr>
2239 * <tr>
2240 * <td>description</td>
2241 * <td>String</td>
2242 * <td>Yes</td>
2243 * <td>Product description</td>
2244 * </tr>
2245 * <tr>
2246 * <td>payload</td>
2247 * <td>String</td>
2248 * <td>Yes</td>
2249 * <td>Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.</td>
2250 * </tr>
2251 * <tr>
2252 * <td>provider_token</td>
2253 * <td>String</td>
2254 * <td>Yes</td>
2255 * <td>Payments provider token, obtained via <a href="/">Botfather</a></td>
2256 * </tr>
2257 * <tr>
2258 * <td>start_parameter</td>
2259 * <td>String</td>
2260 * <td>Yes</td>
2261 * <td>Unique deep-linking parameter that can be used to generate this invoice when used as a start parameter</td>
2262 * </tr>
2263 * <tr>
2264 * <td>currency</td>
2265 * <td>String</td>
2266 * <td>Yes</td>
2267 * <td>Three-letter ISO 4217 currency code, see <a href="https://core.telegram.org/bots/payments#supported-currencies">more on currencies</a></td>
2268 * </tr>
2269 * <tr>
2270 * <td>prices</td>
2271 * <td>Array of <a href="https://core.telegram.org/bots/api#labeledprice">LabeledPrice</a></td>
2272 * <td>Yes</td>
2273 * <td>Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)</td>
2274 * </tr>
2275 * <tr>
2276 * <td>provider_data</td>
2277 * <td>String</td>
2278 * <td>Optional</td>
2279 * <td>JSON-encoded data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider.</td>
2280 * </tr>
2281 * <tr>
2282 * <td>photo_url</td>
2283 * <td>String</td>
2284 * <td>Optional</td>
2285 * <td>URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. People like it better when they see what they are paying for.</td>
2286 * </tr>
2287 * <tr>
2288 * <td>photo_size</td>
2289 * <td>Integer</td>
2290 * <td>Optional</td>
2291 * <td>Photo size</td>
2292 * </tr>
2293 * <tr>
2294 * <td>photo_width</td>
2295 * <td>Integer</td>
2296 * <td>Optional</td>
2297 * <td>Photo width</td>
2298 * </tr>
2299 * <tr>
2300 * <td>photo_height</td>
2301 * <td>Integer</td>
2302 * <td>Optional</td>
2303 * <td>Photo height</td>
2304 * </tr>
2305 * <tr>
2306 * <td>need_name</td>
2307 * <td>Bool</td>
2308 * <td>Optional</td>
2309 * <td>Pass <em>True</em>, if you require the user's full name to complete the order</td>
2310 * </tr>
2311 * <tr>
2312 * <td>need_phone_number</td>
2313 * <td>Boolean</td>
2314 * <td>Optional</td>
2315 * <td>Pass <em>True</em>, if you require the user's phone number to complete the order</td>
2316 * </tr>
2317 * <tr>
2318 * <td>need_email</td>
2319 * <td>Bool</td>
2320 * <td>Optional</td>
2321 * <td>Pass <em>True</em>, if you require the user's email to complete the order</td>
2322 * </tr>
2323 * <tr>
2324 * <td>need_shipping_address</td>
2325 * <td>Boolean</td>
2326 * <td>Optional</td>
2327 * <td>Pass <em>True</em>, if you require the user's shipping address to complete the order</td>
2328 * </tr>
2329 * <tr>
2330 * <td>is_flexible</td>
2331 * <td>Boolean</td>
2332 * <td>Optional</td>
2333 * <td>Pass <em>True</em>, if the final price depends on the shipping method</td>
2334 * </tr>
2335 * <tr>
2336 * <td>disable_notification</td>
2337 * <td>Boolean</td>
2338 * <td>Optional</td>
2339 * <td>Sends the message <a href="https://telegram.org/blog/channels-2-0#silent-messages">silently</a>. Users will receive a notification with no sound.</td>
2340 * </tr>
2341 * <tr>
2342 * <td>reply_to_message_id</td>
2343 * <td>Integer</td>
2344 * <td>Optional</td>
2345 * <td>If the message is a reply, ID of the original message</td>
2346 * </tr>
2347 * <tr>
2348 * <td>reply_markup</td>
2349 * <td><a href="https://core.telegram.org/bots/api#inlinekeyboardmarkup">InlineKeyboardMarkup</a></td>
2350 * <td>Optional</td>
2351 * <td>A JSON-serialized object for an <a href="https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating">inline keyboard</a>. If empty, one 'Pay <code>total price</code>' button will be shown. If not empty, the first button must be a Pay button.</td>
2352 * </tr>
2353 * </table>
2354 * \param $content the request parameters as array
2355 * \return the JSON Telegram's reply.
2356 */
2357 public function sendInvoice(array $content)
2358 {
2359 return $this->endpoint('sendInvoice', $content);
2360 }
2361
2362 /// Answer a shipping query
2363
2364 /**
2365 * Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an <a href="https://core.telegram.org/bots/api#updates">Update</a> with the field <em>pre_checkout_query</em>. Use this method to respond to such pre-checkout queries. On success, True is returned. <strong>Note:</strong> The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.
2366 * <table>
2367 * <tr>
2368 * <td><strong>Parameters</strong></td>
2369 * <td><strong>Type</strong></td>
2370 * <td><strong>Required</strong></td>
2371 * <td><strong>Description</strong></td>
2372 * </tr>
2373 * <tr>
2374 * <td>shipping_query_id</td>
2375 * <td>String</td>
2376 * <td>Yes</td>
2377 * <td>Unique identifier for the query to be answered</td>
2378 * </tr>
2379 * <tr>
2380 * <td>ok</td>
2381 * <td>Boolean</td>
2382 * <td>Yes</td>
2383 * <td>Specify True if delivery to the specified address is possible and False if there are any problems (for example, if delivery to the specified address is not possible)</td>
2384 * </tr>
2385 * <tr>
2386 * <td>shipping_options</td>
2387 * <td>Array of <a href="https://core.telegram.org/bots/api#shippingoption">ShippingOption</a></td>
2388 * <td>Optional</td>
2389 * <td>Required if <em>ok</em> is True. A JSON-serialized array of available shipping options.</td>
2390 * </tr>
2391 * <tr>
2392 * <td>error_message</td>
2393 * <td>String</td>
2394 * <td>Optional</td>
2395 * <td>Required if <em>ok</em> is False. Error message in human readable form that explains why it is impossible to complete the order (e.g. "Sorry, delivery to your desired address is unavailable'). Telegram will display this message to the user.</td>
2396 * </tr>
2397 * </table>
2398 * \param $content the request parameters as array
2399 * \return the JSON Telegram's reply.
2400 */
2401 public function answerShippingQuery(array $content)
2402 {
2403 return $this->endpoint('answerShippingQuery', $content);
2404 }
2405
2406 /// Answer a PreCheckout query
2407
2408 /**
2409 * Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an <a href="https://core.telegram.org/bots/api#">Update</a> with the field <em>pre_checkout_query</em>. Use this method to respond to such pre-checkout queries. On success, True is returned. <strong>Note:</strong> The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.
2410 * <table>
2411 * <tr>
2412 * <td><strong>Parameters</strong></td>
2413 * <td><strong>Type</strong></td>
2414 * <td><strong>Required</strong></td>
2415 * <td><strong>Description</strong></td>
2416 * </tr>
2417 * <tr>
2418 * <td>pre_checkout_query_id</td>
2419 * <td>String</td>
2420 * <td>Yes</td>
2421 * <td>Unique identifier for the query to be answered</td>
2422 * </tr>
2423 * <tr>
2424 * <td>ok</td>
2425 * <td>Boolean</td>
2426 * <td>Yes</td>
2427 * <td>Specify <em>True</em> if everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. Use <em>False</em> if there are any problems.</td>
2428 * </tr>
2429 * <tr>
2430 * <td>error_message</td>
2431 * <td>String</td>
2432 * <td>Optional</td>
2433 * <td>Required if <em>ok</em> is <em>False</em>. Error message in human readable form that explains the reason for failure to proceed with the checkout (e.g. "Sorry, somebody just bought the last of our amazing black T-shirts while you were busy filling out your payment details. Please choose a different color or garment!"). Telegram will display this message to the user.</td>
2434 * </tr>
2435 * </table>
2436 * \param $content the request parameters as array
2437 * \return the JSON Telegram's reply.
2438 */
2439 public function answerPreCheckoutQuery(array $content)
2440 {
2441 return $this->endpoint('answerPreCheckoutQuery', $content);
2442 }
2443
2444 /// Send a video note
2445
2446 /**
2447 * As of <a href="https://telegram.org/blog/video-messages-and-telescope">v.4.0</a>, Telegram clients support rounded square mp4 videos of up to 1 minute long. Use this method to send video messages. On success, the sent <a href="https://core.telegram.org/bots/api#message">Message</a> is returned.
2448 * <table>
2449 * <tr>
2450 * <td><strong>Parameters</strong></td>
2451 * <td><strong>Type</strong></td>
2452 * <td><strong>Required</strong></td>
2453 * <td><strong>Description</strong></td>
2454 * </tr>
2455 * <tr>
2456 * <td>chat_id</td>
2457 * <td>Integer or String</td>
2458 * <td>Yes</td>
2459 * <td>Unique identifier for the target chat or username of the target channel (in the format \c \@channelusername)</td>
2460 * </tr>
2461 * <tr>
2462 * <td>video_note</td>
2463 * <td><a href="https://core.telegram.org/bots/api#inputfile">InputFile</a> or String</td>
2464 * <td>Yes</td>
2465 * <td>Video note to send. Pass a file_id as String to send a video note that exists on the Telegram servers (recommended) or upload a new video using multipart/form-data. <a href="https://core.telegram.org/bots/api#sending-files">More info on Sending Files »</a>. Sending video notes by a URL is currently unsupported</td>
2466 * </tr>
2467 * <tr>
2468 * <td>duration</td>
2469 * <td>Integer</td>
2470 * <td>Optional</td>
2471 * <td>Duration of sent video in seconds</td>
2472 * </tr>
2473 * <tr>
2474 * <td>length</td>
2475 * <td>Integer</td>
2476 * <td>Optional</td>
2477 * <td>Video width and height</td>
2478 * </tr>
2479 * <tr>
2480 * <td>disable_notification</td>
2481 * <td>Boolean</td>
2482 * <td>Optional</td>
2483 * <td>Sends the message <a href="https://telegram.org/blog/channels-2-0#silent-messages">silently</a>. iOS users will not receive a notification, Android users will receive a notification with no sound.</td>
2484 * </tr>
2485 * <tr>
2486 * <td>reply_to_message_id</td>
2487 * <td>Integer</td>
2488 * <td>Optional</td>
2489 * <td>If the message is a reply, ID of the original message</td>
2490 * </tr>
2491 * <tr>
2492 * <td>reply_markup</td>
2493 * <td><a href="https://core.telegram.org/bots/api#inlinekeyboardmarkup">InlineKeyboardMarkup</a> or <a href="https://core.telegram.org/bots/api#replykeyboardmarkup">ReplyKeyboardMarkup</a> or <a href="https://core.telegram.org/bots/api#replykeyboardremove">ReplyKeyboardRemove</a> or <a href="https://core.telegram.org/bots/api#forcereply">ForceReply</a></td>
2494 * <td>Optional</td>
2495 * <td>Additional interface options. A JSON-serialized object for an <a href="https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating">inline keyboard</a>, <a href="https://core.telegram.org/bots#keyboards">custom reply keyboard</a>, instructions to remove reply keyboard or to force a reply from the user.</td>
2496 * </tr>
2497 * </table>
2498 * \param $content the request parameters as array
2499 * \return the JSON Telegram's reply.
2500 */
2501 public function sendVideoNote(array $content)
2502 {
2503 return $this->endpoint('sendVideoNote', $content);
2504 }
2505
2506 /// Restrict Chat Member
2507
2508 /**
2509 * Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights. Pass True for all boolean parameters to lift restrictions from a user. Returns True on success.
2510 * <table>
2511 * <tr>
2512 * <td><strong>Parameters</strong></td>
2513 * <td><strong>Type</strong></td>
2514 * <td><strong>Required</strong></td>
2515 * <td><strong>Description</strong></td>
2516 * </tr>
2517 * <tr>
2518 * <td>chat_id</td>
2519 * <td>Yes</td>
2520 * <td>Unique identifier for the target chat or username of the target channel (in the format \c \@channelusername)</td>
2521 * </tr>
2522 * <tr>
2523 * <td>photo</td>
2524 * <td><a href="https://core.telegram.org/bots/api#inputfile">InputFile</a> or String</td>
2525 * <td>Yes</td>
2526 * <td>Photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data. <a href="https://core.telegram.org/bots/api#sending-files">More info on Sending Files »</a></td>
2527 * </tr>
2528 * <tr>
2529 * <td>caption</td>
2530 * <td>String</td>
2531 * <td>Optional</td>
2532 * <td>Photo caption (may also be used when resending photos by <em>file_id</em>), 0-200 characters</td>
2533 * </tr>
2534 * <tr>
2535 * <td>disable_notification</td>
2536 * <td>Boolean</td>
2537 * <td>Optional</td>
2538 * <td>Sends the message <a href="https://telegram.org/blog/channels-2-0#silent-messages">silently</a>. Users will receive a notification with no sound.</td>
2539 * </tr>
2540 * <tr>
2541 * <td>reply_to_message_id</td>
2542 * <td>Integer</td>
2543 * <td>Optional</td>
2544 * <td>If the message is a reply, ID of the original message</td>
2545 * </tr>
2546 * <tr>
2547 * <td>reply_markup</td>
2548 * <td><a href="https://core.telegram.org/bots/api#inlinekeyboardmarkup">InlineKeyboardMarkup</a> or <a href="https://core.telegram.org/bots/api#replykeyboardmarkup">ReplyKeyboardMarkup</a> or <a href="https://core.telegram.org/bots/api#replykeyboardremove">ReplyKeyboardRemove</a> or <a href="https://core.telegram.org/bots/api#forcereply">ForceReply</a></td>
2549 * <td>Optional</td>
2550 * <td>Additional interface options. A JSON-serialized object for an <a href="https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating">inline keyboard</a>, <a href="https://core.telegram.org/bots#keyboards">custom reply keyboard</a>, instructions to remove reply keyboard or to force a reply from the user.</td>
2551 * </tr>
2552 * </table>
2553 * \param $content the request parameters as array
2554 * \return the JSON Telegram's reply.
2555 */
2556 public function restrictChatMember(array $content)
2557 {
2558 return $this->endpoint('restrictChatMember', $content);
2559 }
2560
2561 /// Promote Chat Member
2562
2563 /**
2564 * Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Pass False for all boolean parameters to demote a user. Returns True on success
2565 * <table>
2566 * <tr>
2567 * <td><strong>Parameters</strong></td>
2568 * <td><strong>Type</strong></td>
2569 * <td><strong>Required</strong></td>
2570 * <td><strong>Description</strong></td>
2571 * </tr>
2572 * <tr>
2573 * <td>chat_id</td>
2574 * <td>Integer or String</td>
2575 * <td>Yes</td>
2576 * <td>Unique identifier for the target chat or username of the target channel (in the format \c \@channelusername)</td>
2577 * </tr>
2578 * <tr>
2579 * <td>user_id</td>
2580 * <td>Integer</td>
2581 * <td>Yes</td>
2582 * <td>Unique identifier of the target user</td>
2583 * </tr>
2584 * <tr>
2585 * <td>can_change_info</td>
2586 * <td>Boolean</td>
2587 * <td>No</td>
2588 * <td>Pass True, if the administrator can change chat title, photo and other settings</td>
2589 * </tr>
2590 * <tr>
2591 * <td>can_post_messages</td>
2592 * <td>Boolean</td>
2593 * <td>No</td>
2594 * <td>Pass True, if the administrator can create channel posts, channels only</td>
2595 * </tr>
2596 * <tr>
2597 * <td>can_edit_messages</td>
2598 * <td>Boolean</td>
2599 * <td>No</td>
2600 * <td>Pass True, if the administrator can edit messages of other users, channels only</td>
2601 * </tr>
2602 * <tr>
2603 * <td>can_delete_messages</td>
2604 * <td>Boolean</td>
2605 * <td>No</td>
2606 * <td>Pass True, if the administrator can delete messages of other users</td>
2607 * </tr>
2608 * <tr>
2609 * <td>can_invite_users</td>
2610 * <td>Boolean</td>
2611 * <td>No</td>
2612 * <td>Pass True, if the administrator can invite new users to the chat</td>
2613 * </tr>
2614 * <tr>
2615 * <td>can_restrict_members</td>
2616 * <td>Boolean</td>
2617 * <td>No</td>
2618 * <td>Pass True, if the administrator can restrict, ban or unban chat members</td>
2619 * </tr>
2620 * <tr>
2621 * <td>can_pin_messages</td>
2622 * <td>Boolean</td>
2623 * <td>No</td>
2624 * <td>Pass True, if the administrator can pin messages, supergroups only</td>
2625 * </tr>
2626 * <tr>
2627 * <td>can_promote_members</td>
2628 * <td>Boolean</td>
2629 * <td>No</td>
2630 * <td>Pass True, if the administrator can add new administrators with a subset of his own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by him)</td>
2631 * </tr>
2632 * </table>
2633 * \param $content the request parameters as array
2634 * \return the JSON Telegram's reply.
2635 */
2636 public function promoteChatMember(array $content)
2637 {
2638 return $this->endpoint('promoteChatMember', $content);
2639 }
2640
2641 //// Export Chat Invite Link
2642
2643 /**
2644 * Use this method to export an invite link to a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns exported invite link as String on success.
2645 * <table>
2646 * <tr>
2647 * <td><strong>Parameters</strong></td>
2648 * <td><strong>Type</strong></td>
2649 * <td><strong>Required</strong></td>
2650 * <td><strong>Description</strong></td>
2651 * </tr>
2652 * <tr>
2653 * <td>chat_id</td>
2654 * <td>Integer or String</td>
2655 * <td>Yes</td>
2656 * <td>Unique identifier for the target chat or username of the target channel (in the format \c \@channelusername)</td>
2657 * </tr>
2658 * </table>
2659 * \param $content the request parameters as array
2660 * \return the JSON Telegram's reply.
2661 */
2662 public function exportChatInviteLink(array $content)
2663 {
2664 return $this->endpoint('exportChatInviteLink', $content);
2665 }
2666
2667 /// Set Chat Photo
2668
2669 /**
2670 * Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success. Note: In regular groups (non-supergroups), this method will only work if the ‘All Members Are Admins’ setting is off in the target group.
2671 * <table>
2672 * <tr>
2673 * <td><strong>Parameters</strong></td>
2674 * <td><strong>Type</strong></td>
2675 * <td><strong>Required</strong></td>
2676 * <td><strong>Description</strong></td>
2677 * </tr>
2678 * <tr>
2679 * <td>chat_id</td>
2680 * <td>Integer or String</td>
2681 * <td>Yes</td>
2682 * <td>Unique identifier for the target chat or username of the target channel (in the format \c \@channelusername)</td>
2683 * </tr>
2684 * <tr>
2685 * <td>photo</td>
2686 * <td><a href="https://core.telegram.org/bots/api#inputfile">InputFile</a></td>
2687 * <td>Yes</td>
2688 * <td>New chat photo, uploaded using multipart/form-data</td>
2689 * </tr>
2690 * </table>
2691 * \param $content the request parameters as array
2692 * \return the JSON Telegram's reply.
2693 */
2694 public function setChatPhoto(array $content)
2695 {
2696 return $this->endpoint('setChatPhoto', $content);
2697 }
2698
2699 /// Delete Chat Photo
2700
2701 /**
2702 * Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success. Note: In regular groups (non-supergroups), this method will only work if the ‘All Members Are Admins’ setting is off in the target group.
2703 * <table>
2704 * <tr>
2705 * <td><strong>Parameters</strong></td>
2706 * <td><strong>Type</strong></td>
2707 * <td><strong>Required</strong></td>
2708 * <td><strong>Description</strong></td>
2709 * </tr>
2710 * <tr>
2711 * <td>chat_id</td>
2712 * <td>Integer or String</td>
2713 * <td>Yes</td>
2714 * <td>Unique identifier for the target chat or username of the target channel (in the format \c \@channelusername)</td>
2715 * </tr>
2716 * </table>
2717 * \param $content the request parameters as array
2718 * \return the JSON Telegram's reply.
2719 */
2720 public function deleteChatPhoto(array $content)
2721 {
2722 return $this->endpoint('deleteChatPhoto', $content);
2723 }
2724
2725 /// Set Chat Title
2726
2727 /**
2728 * Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success. Note: In regular groups (non-supergroups), this method will only work if the ‘All Members Are Admins’ setting is off in the target group.
2729 * <table>
2730 * <tr>
2731 * <td><strong>Parameters</strong></td>
2732 * <td><strong>Type</strong></td>
2733 * <td><strong>Required</strong></td>
2734 * <td><strong>Description</strong></td>
2735 * </tr>
2736 * <tr>
2737 * <td>chat_id</td>
2738 * <td>Integer or String</td>
2739 * <td>Yes</td>
2740 * <td>Unique identifier for the target chat or username of the target channel (in the format \c \@channelusername)</td>
2741 * </tr>
2742 * <tr>
2743 * <td>title</td>
2744 * <td>String</td>
2745 * <td>Yes</td>
2746 * <td>New chat title, 1-255 characters</td>
2747 * </tr>
2748 * </table>
2749 * \param $content the request parameters as array
2750 * \return the JSON Telegram's reply.
2751 */
2752 public function setChatTitle(array $content)
2753 {
2754 return $this->endpoint('setChatTitle', $content);
2755 }
2756
2757 /// Set Chat Description
2758
2759 /**
2760 * Use this method to change the description of a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.
2761 * <table>
2762 * <tr>
2763 * <td><strong>Parameters</strong></td>
2764 * <td><strong>Type</strong></td>
2765 * <td><strong>Required</strong></td>
2766 * <td><strong>Description</strong></td>
2767 * </tr>
2768 * <tr>
2769 * <td>chat_id</td>
2770 * <td>Integer or String</td>
2771 * <td>Yes</td>
2772 * <td>Unique identifier for the target chat or username of the target channel (in the format \c \@channelusername)</td>
2773 * </tr>
2774 * <tr>
2775 * <td>description</td>
2776 * <td>String</td>
2777 * <td>No</td>
2778 * <td>New chat description, 0-255 characters</td>
2779 * </tr>
2780 * </table>
2781 * \param $content the request parameters as array
2782 * \return the JSON Telegram's reply.
2783 */
2784 public function setChatDescription(array $content)
2785 {
2786 return $this->endpoint('setChatDescription', $content);
2787 }
2788
2789 /// Pin Chat Message
2790
2791 /**
2792 * Use this method to pin a message in a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.
2793 * <table>
2794 * <tr>
2795 * <td><strong>Parameters</strong></td>
2796 * <td><strong>Type</strong></td>
2797 * <td><strong>Required</strong></td>
2798 * <td><strong>Description</strong></td>
2799 * </tr>
2800 * <tr>
2801 * <td>chat_id</td>
2802 * <td>Integer or String</td>
2803 * <td>Yes</td>
2804 * <td>Unique identifier for the target chat or username of the target channel (in the format \c \@channelusername)</td>
2805 * </tr>
2806 * <tr>
2807 * <td>message_id</td>
2808 * <td>Integer</td>
2809 * <td>Yes</td>
2810 * <td>Identifier of a message to pin</td>
2811 * </tr>
2812 * <tr>
2813 * <td>disable_notification</td>
2814 * <td>Boolean</td>
2815 * <td>No</td>
2816 * <td>Pass <em>True</em>, if it is not necessary to send a notification to all group members about the new pinned message</td>
2817 * </tr>
2818 * </table>
2819 * \param $content the request parameters as array
2820 * \return the JSON Telegram's reply.
2821 */
2822 public function pinChatMessage(array $content)
2823 {
2824 return $this->endpoint('pinChatMessage', $content);
2825 }
2826
2827 /// Unpin Chat Message
2828
2829 /**
2830 * Use this method to unpin a message in a supergroup chat. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.
2831 * <table>
2832 * <tr>
2833 * <td><strong>Parameters</strong></td>
2834 * <td><strong>Type</strong></td>
2835 * <td><strong>Required</strong></td>
2836 * <td><strong>Description</strong></td>
2837 * </tr>
2838 * <tr>
2839 * <td>chat_id</td>
2840 * <td>Integer or String</td>
2841 * <td>Yes</td>
2842 * <td>Unique identifier for the target chat or username of the target channel (in the format \c \@channelusername)</td>
2843 * </tr>
2844 * </table>
2845 * \param $content the request parameters as array
2846 * \return the JSON Telegram's reply.
2847 */
2848 public function unpinChatMessage(array $content)
2849 {
2850 return $this->endpoint('unpinChatMessage', $content);
2851 }
2852
2853 /// Get Sticker Set
2854
2855 /**
2856 * Use this method to get a sticker set. On success, a StickerSet object is returned.
2857 * <table>
2858 * <tr>
2859 * <td><strong>Parameters</strong></td>
2860 * <td><strong>Type</strong></td>
2861 * <td><strong>Required</strong></td>
2862 * <td><strong>Description</strong></td>
2863 * </tr>
2864 * <tr>
2865 * <td>name</td>
2866 * <td>String</td>
2867 * <td>Yes</td>
2868 * <td>Short name of the sticker set that is used in <code>t.me/addstickers/</code> URLs (e.g., <em>animals</em>)</td>
2869 * </tr>
2870 * </table>
2871 * \param $content the request parameters as array
2872 * \return the JSON Telegram's reply.
2873 */
2874 public function getStickerSet(array $content)
2875 {
2876 return $this->endpoint('getStickerSet', $content);
2877 }
2878
2879 /// Upload Sticker File
2880
2881 /**
2882 * Use this method to upload a .png file with a sticker for later use in createNewStickerSet and addStickerToSet methods (can be used multiple times). Returns the uploaded File on success.
2883 * <table>
2884 * <tr>
2885 * <td><strong>Parameters</strong></td>
2886 * <td><strong>Type</strong></td>
2887 * <td><strong>Required</strong></td>
2888 * <td><strong>Description</strong></td>
2889 * </tr>
2890 * <tr>
2891 * <td>user_id</td>
2892 * <td>Integer</td>
2893 * <td>Yes</td>
2894 * <td>User identifier of sticker file owner</td>
2895 * </tr>
2896 * <tr>
2897 * <td>png_sticker</td>
2898 * <td><a href="https://core.telegram.org/bots/api#inputfile">InputFile</a></td>
2899 * <td>Yes</td>
2900 * <td><strong>Png</strong> image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. <a href="https://core.telegram.org/bots/api#sending-files">More info on Sending Files »</a></td>
2901 * </tr>
2902 * </table>
2903 * \param $content the request parameters as array
2904 * \return the JSON Telegram's reply.
2905 */
2906 public function uploadStickerFile(array $content)
2907 {
2908 return $this->endpoint('uploadStickerFile', $content);
2909 }
2910
2911 /// Create New Sticker Set
2912
2913 /**
2914 * Use this method to create new sticker set owned by a user. The bot will be able to edit the created sticker set. Returns True on success.
2915 * <table>
2916 * <tr>
2917 * <td><strong>Parameters</strong></td>
2918 * <td><strong>Type</strong></td>
2919 * <td><strong>Required</strong></td>
2920 * <td><strong>Description</strong></td>
2921 * </tr>
2922 * <tr>
2923 * <td>user_id</td>
2924 * <td>Integer</td>
2925 * <td>Yes</td>
2926 * <td>User identifier of created sticker set owner</td>
2927 * </tr>
2928 * <tr>
2929 * <td>name</td>
2930 * <td>String</td>
2931 * <td>Yes</td>
2932 * <td>Short name of sticker set, to be used in <code>t.me/addstickers/</code> URLs (e.g., <em>animals</em>). Can contain only english letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in <em>“_by_<bot username>”</em>. <em><bot_username></em> is case insensitive. 1-64 characters.</td>
2933 * </tr>
2934 * <tr>
2935 * <td>title</td>
2936 * <td>String</td>
2937 * <td>Yes</td>
2938 * <td>Sticker set title, 1-64 characters</td>
2939 * </tr>
2940 * <tr>
2941 * <td>png_sticker</td>
2942 * <td><a href="https://core.telegram.org/bots/api#inputfile">InputFile</a> or String</td>
2943 * <td>Yes</td>
2944 * <td><strong>Png</strong> image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a <em>file_id</em> as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. <a href="https://core.telegram.org/bots/api#sending-files">More info on Sending Files »</a></td>
2945 * </tr>
2946 * <tr>
2947 * <td>emojis</td>
2948 * <td>String</td>
2949 * <td>Yes</td>
2950 * <td>One or more emoji corresponding to the sticker</td>
2951 * </tr>
2952 * <tr>
2953 * <td>is_masks</td>
2954 * <td>Boolean</td>
2955 * <td>Optional</td>
2956 * <td>Pass <em>True</em>, if a set of mask stickers should be created</td>
2957 * </tr>
2958 * <tr>
2959 * <td>mask_position</td>
2960 * <td><a href="https://core.telegram.org/bots/api#maskposition">MaskPosition</a></td>
2961 * <td>Optional</td>
2962 * <td>Position where the mask should be placed on faces</td>
2963 * </tr>
2964 * </table>
2965 * \param $content the request parameters as array
2966 * \return the JSON Telegram's reply.
2967 */
2968 public function createNewStickerSet(array $content)
2969 {
2970 return $this->endpoint('createNewStickerSet', $content);
2971 }
2972
2973 /// Add Sticker To Set
2974
2975 /**
2976 * Use this method to add a new sticker to a set created by the bot. Returns True on success.
2977 * <table>
2978 * <tr>
2979 * <td><strong>Parameters</strong></td>
2980 * <td><strong>Type</strong></td>
2981 * <td><strong>Required</strong></td>
2982 * <td><strong>Description</strong></td>
2983 * </tr>
2984 * <tr>
2985 * <td>user_id</td>
2986 * <td>Integer</td>
2987 * <td>Yes</td>
2988 * <td>User identifier of sticker set owner</td>
2989 * </tr>
2990 * <tr>
2991 * <td>name</td>
2992 * <td>String</td>
2993 * <td>Yes</td>
2994 * <td>Sticker set name</td>
2995 * </tr>
2996 * <tr>
2997 * <td>png_sticker</td>
2998 * <td><a href="https://core.telegram.org/bots/api#inputfile">InputFile</a> or String</td>
2999 * <td>Yes</td>
3000 * <td><strong>Png</strong> image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a <em>file_id</em> as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. <a href="https://core.telegram.org/bots/api#sending-files">More info on Sending Files »</a></td>
3001 * </tr>
3002 * <tr>
3003 * <td>emojis</td>
3004 * <td>String</td>
3005 * <td>Yes</td>
3006 * <td>One or more emoji corresponding to the sticker</td>
3007 * </tr>
3008 * <tr>
3009 * <td>mask_position</td>
3010 * <td><a href="https://core.telegram.org/bots/api#maskposition">MaskPosition</a></td>
3011 * <td>Optional</td>
3012 * <td>Position where the mask should be placed on faces</td>
3013 * </tr>
3014 * </table>
3015 * \param $content the request parameters as array
3016 * \return the JSON Telegram's reply.
3017 */
3018 public function addStickerToSet(array $content)
3019 {
3020 return $this->endpoint('addStickerToSet', $content);
3021 }
3022
3023 /// Set Sticker Position In Set
3024
3025 /**
3026 * Use this method to move a sticker in a set created by the bot to a specific position . Returns True on success.
3027 * <table>
3028 * <tr>
3029 * <td><strong>Parameters</strong></td>
3030 * <td><strong>Type</strong></td>
3031 * <td><strong>Required</strong></td>
3032 * <td><strong>Description</strong></td>
3033 * </tr>
3034 * <tr>
3035 * <td>sticker</td>
3036 * <td>String</td>
3037 * <td>Yes</td>
3038 * <td>File identifier of the sticker</td>
3039 * </tr>
3040 * <tr>
3041 * <td>position</td>
3042 * <td>Integer</td>
3043 * <td>Yes</td>
3044 * <td>New sticker position in the set, zero-based</td>
3045 * </tr>
3046 * </table>
3047 * \param $content the request parameters as array
3048 * \return the JSON Telegram's reply.
3049 */
3050 public function setStickerPositionInSet(array $content)
3051 {
3052 return $this->endpoint('setStickerPositionInSet', $content);
3053 }
3054
3055 /// Delete Sticker From Set
3056
3057 /**
3058 * Use this method to delete a sticker from a set created by the bot. Returns True on success.
3059 * <table>
3060 * <tr>
3061 * <td><strong>Parameters</strong></td>
3062 * <td><strong>Type</strong></td>
3063 * <td><strong>Required</strong></td>
3064 * <td><strong>Description</strong></td>
3065 * </tr>
3066 * <tr>
3067 * <td>sticker</td>
3068 * <td>String</td>
3069 * <td>Yes</td>
3070 * <td>File identifier of the sticker</td>
3071 * </tr>
3072 * </table>
3073 * \param $content the request parameters as array
3074 * \return the JSON Telegram's reply.
3075 */
3076 public function deleteStickerFromSet(array $content)
3077 {
3078 return $this->endpoint('deleteStickerFromSet', $content);
3079 }
3080
3081 /// Delete a message
3082
3083 /**
3084 * Use this method to delete a message. A message can only be deleted if it was sent less than 48 hours ago. Any such recently sent outgoing message may be deleted. Additionally, if the bot is an administrator in a group chat, it can delete any message. If the bot is an administrator in a supergroup, it can delete messages from any other user and service messages about people joining or leaving the group (other types of service messages may only be removed by the group creator). In channels, bots can only remove their own messages. Returns True on success.
3085 * <table>
3086 * <tr>
3087 * <td><strong>Parameters</strong></td>
3088 * <td><strong>Type</strong></td>
3089 * <td><strong>Required</strong></td>
3090 * <td><strong>Description</strong></td>
3091 * </tr>
3092 * <tr>
3093 * <td>chat_id</td>
3094 * <td>Integer or String</td>
3095 * <td>Yes</td>
3096 * <td>Unique identifier for the target chat or username of the target channel (in the format \c \@channelusername)</td>
3097 * </tr>
3098 * <tr>
3099 * <td>message_id</td>
3100 * <td>Integer</td>
3101 * <td>Yes</td>
3102 * <td>Identifier of the message to delete</td>
3103 * </tr>
3104 * </table>
3105 * \param $content the request parameters as array
3106 * \return the JSON Telegram's reply.
3107 */
3108 public function deleteMessage(array $content)
3109 {
3110 return $this->endpoint('deleteMessage', $content);
3111 }
3112
3113 /// Receive incoming messages using polling
3114
3115 /** Use this method to receive incoming updates using long polling.
3116 * \param $offset Integer Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id.
3117 * \param $limit Integer Limits the number of updates to be retrieved. Values between 1—100 are accepted. Defaults to 100
3118 * \param $timeout Integer Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling
3119 * \param $update Boolean If true updates the pending message list to the last update received. Default to true.
3120 * \return the updates as Array.
3121 */
3122 public function getUpdates($offset = 0, $limit = 100, $timeout = 0, $update = true)
3123 {
3124 $content = ['offset' => $offset, 'limit' => $limit, 'timeout' => $timeout];
3125 $this->updates = $this->endpoint('getUpdates', $content);
3126 if ($update) {
3127 if (is_array($this->updates['result']) && count($this->updates['result']) >= 1) { //for CLI working.
3128 $last_element_id = $this->updates['result'][count($this->updates['result']) - 1]['update_id'] + 1;
3129 $content = ['offset' => $last_element_id, 'limit' => '1', 'timeout' => $timeout];
3130 $this->endpoint('getUpdates', $content);
3131 }
3132 }
3133
3134 return $this->updates;
3135 }
3136
3137 /// Serve an update
3138
3139 /** Use this method to use the bultin function like Text() or Username() on a specific update.
3140 * \param $update Integer The index of the update in the updates array.
3141 */
3142 public function serveUpdate($update)
3143 {
3144 $this->data = $this->updates['result'][$update];
3145 }
3146
3147 /// Return current update type
3148
3149 /**
3150 * Return current update type `False` on failure.
3151 *
3152 * @return bool|string
3153 */
3154 public function getUpdateType()
3155 {
3156 $update = $this->data;
3157 if (isset($update['inline_query'])) {
3158 return self::INLINE_QUERY;
3159 }
3160 if (isset($update['callback_query'])) {
3161 return self::CALLBACK_QUERY;
3162 }
3163 if (isset($update['edited_message'])) {
3164 return self::EDITED_MESSAGE;
3165 }
3166 if (isset($update['message']['text'])) {
3167 return self::MESSAGE;
3168 }
3169 if (isset($update['message']['photo'])) {
3170 return self::PHOTO;
3171 }
3172 if (isset($update['message']['video'])) {
3173 return self::VIDEO;
3174 }
3175 if (isset($update['message']['audio'])) {
3176 return self::AUDIO;
3177 }
3178 if (isset($update['message']['voice'])) {
3179 return self::VOICE;
3180 }
3181 if (isset($update['message']['contact'])) {
3182 return self::CONTACT;
3183 }
3184 if (isset($update['message']['location'])) {
3185 return self::LOCATION;
3186 }
3187 if (isset($update['message']['reply_to_message'])) {
3188 return self::REPLY;
3189 }
3190 if (isset($update['message']['animation'])) {
3191 return self::ANIMATION;
3192 }
3193 if (isset($update['message']['sticker'])) {
3194 return self::STICKER;
3195 }
3196 if (isset($update['message']['document'])) {
3197 return self::DOCUMENT;
3198 }
3199 if (isset($update['channel_post'])) {
3200 return self::CHANNEL_POST;
3201 }
3202
3203 return false;
3204 }
3205
3206 private function sendAPIRequest($url, array $content, $post = true)
3207 {
3208 if (isset($content['chat_id'])) {
3209 $url = $url.'?chat_id='.$content['chat_id'];
3210 unset($content['chat_id']);
3211 }
3212 $ch = curl_init();
3213 curl_setopt($ch, CURLOPT_URL, $url);
3214 curl_setopt($ch, CURLOPT_HEADER, false);
3215 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
3216 if ($post) {
3217 curl_setopt($ch, CURLOPT_POST, 1);
3218 curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
3219 }
3220 // echo "inside curl if";
3221 if (!empty($this->proxy)) {
3222 // echo "inside proxy if";
3223 if (array_key_exists('type', $this->proxy)) {
3224 curl_setopt($ch, CURLOPT_PROXYTYPE, $this->proxy['type']);
3225 }
3226
3227 if (array_key_exists('auth', $this->proxy)) {
3228 curl_setopt($ch, CURLOPT_PROXYUSERPWD, $this->proxy['auth']);
3229 }
3230
3231 if (array_key_exists('url', $this->proxy)) {
3232 // echo "Proxy Url";
3233 curl_setopt($ch, CURLOPT_PROXY, $this->proxy['url']);
3234 }
3235
3236 if (array_key_exists('port', $this->proxy)) {
3237 // echo "Proxy port";
3238 curl_setopt($ch, CURLOPT_PROXYPORT, $this->proxy['port']);
3239 }
3240 }
3241 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
3242 $result = curl_exec($ch);
3243 if ($result === false) {
3244 $result = json_encode(['ok'=>false, 'curl_error_code' => curl_errno($ch), 'curl_error' => curl_error($ch)]);
3245 }
3246 curl_close($ch);
3247 if ($this->log_errors) {
3248 if (class_exists('TelegramErrorLogger')) {
3249 $loggerArray = ($this->getData() == null) ? [$content] : [$this->getData(), $content];
3250 TelegramErrorLogger::log(json_decode($result, true), $loggerArray);
3251 }
3252 }
3253
3254 return $result;
3255 }
3256}
3257
3258// Helper for Uploading file using CURL
3259if (!function_exists('curl_file_create')) {
3260 function curl_file_create($filename, $mimetype = '', $postname = '')
3261 {
3262 return "@$filename;filename="
3263 .($postname ?: basename($filename))
3264 .($mimetype ? ";type=$mimetype" : '');
3265 }
3266}
3267