· 5 years ago · Mar 11, 2020, 05:00 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 TelegramAPI
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 /// Get the inline_query of the current update
1847
1848 /**
1849 * \return the Array inline_query.
1850 */
1851 public function Inline_Query()
1852 {
1853 return $this->data['inline_query'];
1854 }
1855
1856 /// Get the callback_query of the current update
1857
1858 /**
1859 * \return the String callback_query.
1860 */
1861 public function Callback_Query()
1862 {
1863 return $this->data['callback_query'];
1864 }
1865
1866 /// Get the callback_query id of the current update
1867
1868 /**
1869 * \return the String callback_query id.
1870 */
1871 public function Callback_ID()
1872 {
1873 return $this->data['callback_query']['id'];
1874 }
1875
1876 /// Get the Get the data of the current callback
1877
1878 /**
1879 * \deprecated Use Text() instead
1880 * \return the String callback_data.
1881 */
1882 public function Callback_Data()
1883 {
1884 return $this->data['callback_query']['data'];
1885 }
1886
1887 /// Get the Get the message of the current callback
1888
1889 /**
1890 * \return the Message.
1891 */
1892 public function Callback_Message()
1893 {
1894 return $this->data['callback_query']['message'];
1895 }
1896
1897 /// Get the Get the chati_id of the current callback
1898
1899 /**
1900 * \deprecated Use ChatId() instead
1901 * \return the String callback_query.
1902 */
1903 public function Callback_ChatID()
1904 {
1905 return $this->data['callback_query']['message']['chat']['id'];
1906 }
1907
1908 /// Get the date of the current message
1909
1910 /**
1911 * \return the String message's date.
1912 */
1913 public function Date()
1914 {
1915 return $this->data['message']['date'];
1916 }
1917
1918 /// Get the first name of the user
1919 public function FirstName()
1920 {
1921 $type = $this->getUpdateType();
1922 if ($type == self::CALLBACK_QUERY) {
1923 return @$this->data['callback_query']['from']['first_name'];
1924 }
1925 if ($type == self::CHANNEL_POST) {
1926 return @$this->data['channel_post']['from']['first_name'];
1927 }
1928 if ($type == self::EDITED_MESSAGE) {
1929 return @$this->data['edited_message']['from']['first_name'];
1930 }
1931
1932 return @$this->data['message']['from']['first_name'];
1933 }
1934
1935 /// Get the last name of the user
1936 public function LastName()
1937 {
1938 $type = $this->getUpdateType();
1939 if ($type == self::CALLBACK_QUERY) {
1940 return @$this->data['callback_query']['from']['last_name'];
1941 }
1942 if ($type == self::CHANNEL_POST) {
1943 return @$this->data['channel_post']['from']['last_name'];
1944 }
1945 if ($type == self::EDITED_MESSAGE) {
1946 return @$this->data['edited_message']['from']['last_name'];
1947 }
1948
1949 return @$this->data['message']['from']['last_name'];
1950 }
1951
1952 /// Get the username of the user
1953 public function Username()
1954 {
1955 $type = $this->getUpdateType();
1956 if ($type == self::CALLBACK_QUERY) {
1957 return @$this->data['callback_query']['from']['username'];
1958 }
1959 if ($type == self::CHANNEL_POST) {
1960 return @$this->data['channel_post']['from']['username'];
1961 }
1962 if ($type == self::EDITED_MESSAGE) {
1963 return @$this->data['edited_message']['from']['username'];
1964 }
1965
1966 return @$this->data['message']['from']['username'];
1967 }
1968
1969 /// Get the location in the message
1970 public function Location()
1971 {
1972 return $this->data['message']['location'];
1973 }
1974
1975 /// Get the update_id of the message
1976 public function UpdateID()
1977 {
1978 return $this->data['update_id'];
1979 }
1980
1981 /// Get the number of updates
1982 public function UpdateCount()
1983 {
1984 return count($this->updates['result']);
1985 }
1986
1987 /// Get user's id of current message
1988 public function UserID()
1989 {
1990 $type = $this->getUpdateType();
1991 if ($type == self::CALLBACK_QUERY) {
1992 return $this->data['callback_query']['from']['id'];
1993 }
1994 if ($type == self::CHANNEL_POST) {
1995 return $this->data['channel_post']['from']['id'];
1996 }
1997 if ($type == self::EDITED_MESSAGE) {
1998 return @$this->data['edited_message']['from']['id'];
1999 }
2000
2001 return $this->data['message']['from']['id'];
2002 }
2003
2004 /// Get user's id of current forwarded message
2005 public function FromID()
2006 {
2007 return $this->data['message']['forward_from']['id'];
2008 }
2009
2010 /// Get chat's id where current message forwarded from
2011 public function FromChatID()
2012 {
2013 return $this->data['message']['forward_from_chat']['id'];
2014 }
2015
2016 /// Tell if a message is from a group or user chat
2017
2018 /**
2019 * \return BOOLEAN true if the message is from a Group chat, false otherwise.
2020 */
2021 public function messageFromGroup()
2022 {
2023 if ($this->data['message']['chat']['type'] == 'private') {
2024 return false;
2025 }
2026
2027 return true;
2028 }
2029
2030 /// Get the title of the group chat
2031
2032 /**
2033 * \return a String of the title chat.
2034 */
2035 public function messageFromGroupTitle()
2036 {
2037 if ($this->data['message']['chat']['type'] != 'private') {
2038 return $this->data['message']['chat']['title'];
2039 }
2040 }
2041
2042 /// Set a custom keyboard
2043
2044 /** This object represents a custom keyboard with reply options
2045 * \param $options Array of Array of String; Array of button rows, each represented by an Array of Strings
2046 * \param $onetime Boolean Requests clients to hide the keyboard as soon as it's been used. Defaults to false.
2047 * \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.
2048 * \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.
2049 * \return the requested keyboard as Json.
2050 */
2051 public function buildKeyBoard(array $options, $onetime = false, $resize = false, $selective = true)
2052 {
2053 $replyMarkup = [
2054 'keyboard' => $options,
2055 'one_time_keyboard' => $onetime,
2056 'resize_keyboard' => $resize,
2057 'selective' => $selective,
2058 ];
2059 $encodedMarkup = json_encode($replyMarkup, true);
2060
2061 return $encodedMarkup;
2062 }
2063
2064 /// Set an InlineKeyBoard
2065
2066 /** This object represents an inline keyboard that appears right next to the message it belongs to.
2067 * \param $options Array of Array of InlineKeyboardButton; Array of button rows, each represented by an Array of InlineKeyboardButton
2068 * \return the requested keyboard as Json.
2069 */
2070 public function buildInlineKeyBoard(array $options)
2071 {
2072 $replyMarkup = [
2073 'inline_keyboard' => $options,
2074 ];
2075 $encodedMarkup = json_encode($replyMarkup, true);
2076
2077 return $encodedMarkup;
2078 }
2079
2080 /// Create an InlineKeyboardButton
2081
2082 /** This object represents one button of an inline keyboard. You must use exactly one of the optional fields.
2083 * \param $text String; Array of button rows, each represented by an Array of Strings
2084 * \param $url String Optional. HTTP url to be opened when button is pressed
2085 * \param $callback_data String Optional. Data to be sent in a callback query to the bot when button is pressed
2086 * \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.
2087 * \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.
2088 * \param $callback_game String Optional. Description of the game that will be launched when the user presses the button.
2089 * \param $pay Boolean Optional. Specify True, to send a <a href="https://core.telegram.org/bots/api#payments">Pay button</a>.
2090 * \return the requested button as Array.
2091 */
2092 public function buildInlineKeyboardButton($text, $url = '', $callback_data = '', $switch_inline_query = null, $switch_inline_query_current_chat = null, $callback_game = '', $pay = '')
2093 {
2094 $replyMarkup = [
2095 'text' => $text,
2096 ];
2097 if ($url != '') {
2098 $replyMarkup['url'] = $url;
2099 } elseif ($callback_data != '') {
2100 $replyMarkup['callback_data'] = $callback_data;
2101 } elseif (!is_null($switch_inline_query)) {
2102 $replyMarkup['switch_inline_query'] = $switch_inline_query;
2103 } elseif (!is_null($switch_inline_query_current_chat)) {
2104 $replyMarkup['switch_inline_query_current_chat'] = $switch_inline_query_current_chat;
2105 } elseif ($callback_game != '') {
2106 $replyMarkup['callback_game'] = $callback_game;
2107 } elseif ($pay != '') {
2108 $replyMarkup['pay'] = $pay;
2109 }
2110
2111 return $replyMarkup;
2112 }
2113
2114 /// Create a KeyboardButton
2115
2116 /** This object represents one button of an inline keyboard. You must use exactly one of the optional fields.
2117 * \param $text String; Array of button rows, each represented by an Array of Strings
2118 * \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
2119 * \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
2120 * \return the requested button as Array.
2121 */
2122 public function buildKeyboardButton($text, $request_contact = false, $request_location = false)
2123 {
2124 $replyMarkup = [
2125 'text' => $text,
2126 'request_contact' => $request_contact,
2127 'request_location' => $request_location,
2128 ];
2129
2130 return $replyMarkup;
2131 }
2132
2133 /// Hide a custom keyboard
2134
2135 /** 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.
2136 * \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.
2137 * \return the requested keyboard hide as Array.
2138 */
2139 public function buildKeyBoardHide($selective = true)
2140 {
2141 $replyMarkup = [
2142 'remove_keyboard' => true,
2143 'selective' => $selective,
2144 ];
2145 $encodedMarkup = json_encode($replyMarkup, true);
2146
2147 return $encodedMarkup;
2148 }
2149
2150 /// Display a reply interface to the user
2151 /* 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.
2152 * \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.
2153 * \return the requested force reply as Array
2154 */
2155 public function buildForceReply($selective = true)
2156 {
2157 $replyMarkup = [
2158 'force_reply' => true,
2159 'selective' => $selective,
2160 ];
2161 $encodedMarkup = json_encode($replyMarkup, true);
2162
2163 return $encodedMarkup;
2164 }
2165
2166 // Payments
2167 /// Send an invoice
2168
2169 /**
2170 * Use this method to send invoices. On success, the sent <a href="https://core.telegram.org/bots/api#message">Message</a> is returned.
2171 * <table>
2172 * <tr>
2173 * <td><strong>Parameters</strong></td>
2174 * <td><strong>Type</strong></td>
2175 * <td><strong>Required</strong></td>
2176 * <td><strong>Description</strong></td>
2177 * </tr>
2178 * <tr>
2179 * <td>chat_id</td>
2180 * <td>Integer</td>
2181 * <td>Yes</td>
2182 * <td>Unique identifier for the target private chat</td>
2183 * </tr>
2184 * <tr>
2185 * <td>title</td>
2186 * <td>String</td>
2187 * <td>Yes</td>
2188 * <td>Product name</td>
2189 * </tr>
2190 * <tr>
2191 * <td>description</td>
2192 * <td>String</td>
2193 * <td>Yes</td>
2194 * <td>Product description</td>
2195 * </tr>
2196 * <tr>
2197 * <td>payload</td>
2198 * <td>String</td>
2199 * <td>Yes</td>
2200 * <td>Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.</td>
2201 * </tr>
2202 * <tr>
2203 * <td>provider_token</td>
2204 * <td>String</td>
2205 * <td>Yes</td>
2206 * <td>Payments provider token, obtained via <a href="/">Botfather</a></td>
2207 * </tr>
2208 * <tr>
2209 * <td>start_parameter</td>
2210 * <td>String</td>
2211 * <td>Yes</td>
2212 * <td>Unique deep-linking parameter that can be used to generate this invoice when used as a start parameter</td>
2213 * </tr>
2214 * <tr>
2215 * <td>currency</td>
2216 * <td>String</td>
2217 * <td>Yes</td>
2218 * <td>Three-letter ISO 4217 currency code, see <a href="https://core.telegram.org/bots/payments#supported-currencies">more on currencies</a></td>
2219 * </tr>
2220 * <tr>
2221 * <td>prices</td>
2222 * <td>Array of <a href="https://core.telegram.org/bots/api#labeledprice">LabeledPrice</a></td>
2223 * <td>Yes</td>
2224 * <td>Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)</td>
2225 * </tr>
2226 * <tr>
2227 * <td>provider_data</td>
2228 * <td>String</td>
2229 * <td>Optional</td>
2230 * <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>
2231 * </tr>
2232 * <tr>
2233 * <td>photo_url</td>
2234 * <td>String</td>
2235 * <td>Optional</td>
2236 * <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>
2237 * </tr>
2238 * <tr>
2239 * <td>photo_size</td>
2240 * <td>Integer</td>
2241 * <td>Optional</td>
2242 * <td>Photo size</td>
2243 * </tr>
2244 * <tr>
2245 * <td>photo_width</td>
2246 * <td>Integer</td>
2247 * <td>Optional</td>
2248 * <td>Photo width</td>
2249 * </tr>
2250 * <tr>
2251 * <td>photo_height</td>
2252 * <td>Integer</td>
2253 * <td>Optional</td>
2254 * <td>Photo height</td>
2255 * </tr>
2256 * <tr>
2257 * <td>need_name</td>
2258 * <td>Bool</td>
2259 * <td>Optional</td>
2260 * <td>Pass <em>True</em>, if you require the user's full name to complete the order</td>
2261 * </tr>
2262 * <tr>
2263 * <td>need_phone_number</td>
2264 * <td>Boolean</td>
2265 * <td>Optional</td>
2266 * <td>Pass <em>True</em>, if you require the user's phone number to complete the order</td>
2267 * </tr>
2268 * <tr>
2269 * <td>need_email</td>
2270 * <td>Bool</td>
2271 * <td>Optional</td>
2272 * <td>Pass <em>True</em>, if you require the user's email to complete the order</td>
2273 * </tr>
2274 * <tr>
2275 * <td>need_shipping_address</td>
2276 * <td>Boolean</td>
2277 * <td>Optional</td>
2278 * <td>Pass <em>True</em>, if you require the user's shipping address to complete the order</td>
2279 * </tr>
2280 * <tr>
2281 * <td>is_flexible</td>
2282 * <td>Boolean</td>
2283 * <td>Optional</td>
2284 * <td>Pass <em>True</em>, if the final price depends on the shipping method</td>
2285 * </tr>
2286 * <tr>
2287 * <td>disable_notification</td>
2288 * <td>Boolean</td>
2289 * <td>Optional</td>
2290 * <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>
2291 * </tr>
2292 * <tr>
2293 * <td>reply_to_message_id</td>
2294 * <td>Integer</td>
2295 * <td>Optional</td>
2296 * <td>If the message is a reply, ID of the original message</td>
2297 * </tr>
2298 * <tr>
2299 * <td>reply_markup</td>
2300 * <td><a href="https://core.telegram.org/bots/api#inlinekeyboardmarkup">InlineKeyboardMarkup</a></td>
2301 * <td>Optional</td>
2302 * <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>
2303 * </tr>
2304 * </table>
2305 * \param $content the request parameters as array
2306 * \return the JSON Telegram's reply.
2307 */
2308 public function sendInvoice(array $content)
2309 {
2310 return $this->endpoint('sendInvoice', $content);
2311 }
2312
2313 /// Answer a shipping query
2314
2315 /**
2316 * 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.
2317 * <table>
2318 * <tr>
2319 * <td><strong>Parameters</strong></td>
2320 * <td><strong>Type</strong></td>
2321 * <td><strong>Required</strong></td>
2322 * <td><strong>Description</strong></td>
2323 * </tr>
2324 * <tr>
2325 * <td>shipping_query_id</td>
2326 * <td>String</td>
2327 * <td>Yes</td>
2328 * <td>Unique identifier for the query to be answered</td>
2329 * </tr>
2330 * <tr>
2331 * <td>ok</td>
2332 * <td>Boolean</td>
2333 * <td>Yes</td>
2334 * <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>
2335 * </tr>
2336 * <tr>
2337 * <td>shipping_options</td>
2338 * <td>Array of <a href="https://core.telegram.org/bots/api#shippingoption">ShippingOption</a></td>
2339 * <td>Optional</td>
2340 * <td>Required if <em>ok</em> is True. A JSON-serialized array of available shipping options.</td>
2341 * </tr>
2342 * <tr>
2343 * <td>error_message</td>
2344 * <td>String</td>
2345 * <td>Optional</td>
2346 * <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>
2347 * </tr>
2348 * </table>
2349 * \param $content the request parameters as array
2350 * \return the JSON Telegram's reply.
2351 */
2352 public function answerShippingQuery(array $content)
2353 {
2354 return $this->endpoint('answerShippingQuery', $content);
2355 }
2356
2357 /// Answer a PreCheckout query
2358
2359 /**
2360 * 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.
2361 * <table>
2362 * <tr>
2363 * <td><strong>Parameters</strong></td>
2364 * <td><strong>Type</strong></td>
2365 * <td><strong>Required</strong></td>
2366 * <td><strong>Description</strong></td>
2367 * </tr>
2368 * <tr>
2369 * <td>pre_checkout_query_id</td>
2370 * <td>String</td>
2371 * <td>Yes</td>
2372 * <td>Unique identifier for the query to be answered</td>
2373 * </tr>
2374 * <tr>
2375 * <td>ok</td>
2376 * <td>Boolean</td>
2377 * <td>Yes</td>
2378 * <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>
2379 * </tr>
2380 * <tr>
2381 * <td>error_message</td>
2382 * <td>String</td>
2383 * <td>Optional</td>
2384 * <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>
2385 * </tr>
2386 * </table>
2387 * \param $content the request parameters as array
2388 * \return the JSON Telegram's reply.
2389 */
2390 public function answerPreCheckoutQuery(array $content)
2391 {
2392 return $this->endpoint('answerPreCheckoutQuery', $content);
2393 }
2394
2395 /// Send a video note
2396
2397 /**
2398 * 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.
2399 * <table>
2400 * <tr>
2401 * <td><strong>Parameters</strong></td>
2402 * <td><strong>Type</strong></td>
2403 * <td><strong>Required</strong></td>
2404 * <td><strong>Description</strong></td>
2405 * </tr>
2406 * <tr>
2407 * <td>chat_id</td>
2408 * <td>Integer or String</td>
2409 * <td>Yes</td>
2410 * <td>Unique identifier for the target chat or username of the target channel (in the format \c \@channelusername)</td>
2411 * </tr>
2412 * <tr>
2413 * <td>video_note</td>
2414 * <td><a href="https://core.telegram.org/bots/api#inputfile">InputFile</a> or String</td>
2415 * <td>Yes</td>
2416 * <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>
2417 * </tr>
2418 * <tr>
2419 * <td>duration</td>
2420 * <td>Integer</td>
2421 * <td>Optional</td>
2422 * <td>Duration of sent video in seconds</td>
2423 * </tr>
2424 * <tr>
2425 * <td>length</td>
2426 * <td>Integer</td>
2427 * <td>Optional</td>
2428 * <td>Video width and height</td>
2429 * </tr>
2430 * <tr>
2431 * <td>disable_notification</td>
2432 * <td>Boolean</td>
2433 * <td>Optional</td>
2434 * <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>
2435 * </tr>
2436 * <tr>
2437 * <td>reply_to_message_id</td>
2438 * <td>Integer</td>
2439 * <td>Optional</td>
2440 * <td>If the message is a reply, ID of the original message</td>
2441 * </tr>
2442 * <tr>
2443 * <td>reply_markup</td>
2444 * <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>
2445 * <td>Optional</td>
2446 * <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>
2447 * </tr>
2448 * </table>
2449 * \param $content the request parameters as array
2450 * \return the JSON Telegram's reply.
2451 */
2452 public function sendVideoNote(array $content)
2453 {
2454 return $this->endpoint('sendVideoNote', $content);
2455 }
2456
2457 /// Restrict Chat Member
2458
2459 /**
2460 * 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.
2461 * <table>
2462 * <tr>
2463 * <td><strong>Parameters</strong></td>
2464 * <td><strong>Type</strong></td>
2465 * <td><strong>Required</strong></td>
2466 * <td><strong>Description</strong></td>
2467 * </tr>
2468 * <tr>
2469 * <td>chat_id</td>
2470 * <td>Yes</td>
2471 * <td>Unique identifier for the target chat or username of the target channel (in the format \c \@channelusername)</td>
2472 * </tr>
2473 * <tr>
2474 * <td>photo</td>
2475 * <td><a href="https://core.telegram.org/bots/api#inputfile">InputFile</a> or String</td>
2476 * <td>Yes</td>
2477 * <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>
2478 * </tr>
2479 * <tr>
2480 * <td>caption</td>
2481 * <td>String</td>
2482 * <td>Optional</td>
2483 * <td>Photo caption (may also be used when resending photos by <em>file_id</em>), 0-200 characters</td>
2484 * </tr>
2485 * <tr>
2486 * <td>disable_notification</td>
2487 * <td>Boolean</td>
2488 * <td>Optional</td>
2489 * <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>
2490 * </tr>
2491 * <tr>
2492 * <td>reply_to_message_id</td>
2493 * <td>Integer</td>
2494 * <td>Optional</td>
2495 * <td>If the message is a reply, ID of the original message</td>
2496 * </tr>
2497 * <tr>
2498 * <td>reply_markup</td>
2499 * <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>
2500 * <td>Optional</td>
2501 * <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>
2502 * </tr>
2503 * </table>
2504 * \param $content the request parameters as array
2505 * \return the JSON Telegram's reply.
2506 */
2507 public function restrictChatMember(array $content)
2508 {
2509 return $this->endpoint('restrictChatMember', $content);
2510 }
2511
2512 /// Promote Chat Member
2513
2514 /**
2515 * 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
2516 * <table>
2517 * <tr>
2518 * <td><strong>Parameters</strong></td>
2519 * <td><strong>Type</strong></td>
2520 * <td><strong>Required</strong></td>
2521 * <td><strong>Description</strong></td>
2522 * </tr>
2523 * <tr>
2524 * <td>chat_id</td>
2525 * <td>Integer or String</td>
2526 * <td>Yes</td>
2527 * <td>Unique identifier for the target chat or username of the target channel (in the format \c \@channelusername)</td>
2528 * </tr>
2529 * <tr>
2530 * <td>user_id</td>
2531 * <td>Integer</td>
2532 * <td>Yes</td>
2533 * <td>Unique identifier of the target user</td>
2534 * </tr>
2535 * <tr>
2536 * <td>can_change_info</td>
2537 * <td>Boolean</td>
2538 * <td>No</td>
2539 * <td>Pass True, if the administrator can change chat title, photo and other settings</td>
2540 * </tr>
2541 * <tr>
2542 * <td>can_post_messages</td>
2543 * <td>Boolean</td>
2544 * <td>No</td>
2545 * <td>Pass True, if the administrator can create channel posts, channels only</td>
2546 * </tr>
2547 * <tr>
2548 * <td>can_edit_messages</td>
2549 * <td>Boolean</td>
2550 * <td>No</td>
2551 * <td>Pass True, if the administrator can edit messages of other users, channels only</td>
2552 * </tr>
2553 * <tr>
2554 * <td>can_delete_messages</td>
2555 * <td>Boolean</td>
2556 * <td>No</td>
2557 * <td>Pass True, if the administrator can delete messages of other users</td>
2558 * </tr>
2559 * <tr>
2560 * <td>can_invite_users</td>
2561 * <td>Boolean</td>
2562 * <td>No</td>
2563 * <td>Pass True, if the administrator can invite new users to the chat</td>
2564 * </tr>
2565 * <tr>
2566 * <td>can_restrict_members</td>
2567 * <td>Boolean</td>
2568 * <td>No</td>
2569 * <td>Pass True, if the administrator can restrict, ban or unban chat members</td>
2570 * </tr>
2571 * <tr>
2572 * <td>can_pin_messages</td>
2573 * <td>Boolean</td>
2574 * <td>No</td>
2575 * <td>Pass True, if the administrator can pin messages, supergroups only</td>
2576 * </tr>
2577 * <tr>
2578 * <td>can_promote_members</td>
2579 * <td>Boolean</td>
2580 * <td>No</td>
2581 * <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>
2582 * </tr>
2583 * </table>
2584 * \param $content the request parameters as array
2585 * \return the JSON Telegram's reply.
2586 */
2587 public function promoteChatMember(array $content)
2588 {
2589 return $this->endpoint('promoteChatMember', $content);
2590 }
2591
2592 //// Export Chat Invite Link
2593
2594 /**
2595 * 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.
2596 * <table>
2597 * <tr>
2598 * <td><strong>Parameters</strong></td>
2599 * <td><strong>Type</strong></td>
2600 * <td><strong>Required</strong></td>
2601 * <td><strong>Description</strong></td>
2602 * </tr>
2603 * <tr>
2604 * <td>chat_id</td>
2605 * <td>Integer or String</td>
2606 * <td>Yes</td>
2607 * <td>Unique identifier for the target chat or username of the target channel (in the format \c \@channelusername)</td>
2608 * </tr>
2609 * </table>
2610 * \param $content the request parameters as array
2611 * \return the JSON Telegram's reply.
2612 */
2613 public function exportChatInviteLink(array $content)
2614 {
2615 return $this->endpoint('exportChatInviteLink', $content);
2616 }
2617
2618 /// Set Chat Photo
2619
2620 /**
2621 * 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.
2622 * <table>
2623 * <tr>
2624 * <td><strong>Parameters</strong></td>
2625 * <td><strong>Type</strong></td>
2626 * <td><strong>Required</strong></td>
2627 * <td><strong>Description</strong></td>
2628 * </tr>
2629 * <tr>
2630 * <td>chat_id</td>
2631 * <td>Integer or String</td>
2632 * <td>Yes</td>
2633 * <td>Unique identifier for the target chat or username of the target channel (in the format \c \@channelusername)</td>
2634 * </tr>
2635 * <tr>
2636 * <td>photo</td>
2637 * <td><a href="https://core.telegram.org/bots/api#inputfile">InputFile</a></td>
2638 * <td>Yes</td>
2639 * <td>New chat photo, uploaded using multipart/form-data</td>
2640 * </tr>
2641 * </table>
2642 * \param $content the request parameters as array
2643 * \return the JSON Telegram's reply.
2644 */
2645 public function setChatPhoto(array $content)
2646 {
2647 return $this->endpoint('setChatPhoto', $content);
2648 }
2649
2650 /// Delete Chat Photo
2651
2652 /**
2653 * 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.
2654 * <table>
2655 * <tr>
2656 * <td><strong>Parameters</strong></td>
2657 * <td><strong>Type</strong></td>
2658 * <td><strong>Required</strong></td>
2659 * <td><strong>Description</strong></td>
2660 * </tr>
2661 * <tr>
2662 * <td>chat_id</td>
2663 * <td>Integer or String</td>
2664 * <td>Yes</td>
2665 * <td>Unique identifier for the target chat or username of the target channel (in the format \c \@channelusername)</td>
2666 * </tr>
2667 * </table>
2668 * \param $content the request parameters as array
2669 * \return the JSON Telegram's reply.
2670 */
2671 public function deleteChatPhoto(array $content)
2672 {
2673 return $this->endpoint('deleteChatPhoto', $content);
2674 }
2675
2676 /// Set Chat Title
2677
2678 /**
2679 * 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.
2680 * <table>
2681 * <tr>
2682 * <td><strong>Parameters</strong></td>
2683 * <td><strong>Type</strong></td>
2684 * <td><strong>Required</strong></td>
2685 * <td><strong>Description</strong></td>
2686 * </tr>
2687 * <tr>
2688 * <td>chat_id</td>
2689 * <td>Integer or String</td>
2690 * <td>Yes</td>
2691 * <td>Unique identifier for the target chat or username of the target channel (in the format \c \@channelusername)</td>
2692 * </tr>
2693 * <tr>
2694 * <td>title</td>
2695 * <td>String</td>
2696 * <td>Yes</td>
2697 * <td>New chat title, 1-255 characters</td>
2698 * </tr>
2699 * </table>
2700 * \param $content the request parameters as array
2701 * \return the JSON Telegram's reply.
2702 */
2703 public function setChatTitle(array $content)
2704 {
2705 return $this->endpoint('setChatTitle', $content);
2706 }
2707
2708 /// Set Chat Description
2709
2710 /**
2711 * 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.
2712 * <table>
2713 * <tr>
2714 * <td><strong>Parameters</strong></td>
2715 * <td><strong>Type</strong></td>
2716 * <td><strong>Required</strong></td>
2717 * <td><strong>Description</strong></td>
2718 * </tr>
2719 * <tr>
2720 * <td>chat_id</td>
2721 * <td>Integer or String</td>
2722 * <td>Yes</td>
2723 * <td>Unique identifier for the target chat or username of the target channel (in the format \c \@channelusername)</td>
2724 * </tr>
2725 * <tr>
2726 * <td>description</td>
2727 * <td>String</td>
2728 * <td>No</td>
2729 * <td>New chat description, 0-255 characters</td>
2730 * </tr>
2731 * </table>
2732 * \param $content the request parameters as array
2733 * \return the JSON Telegram's reply.
2734 */
2735 public function setChatDescription(array $content)
2736 {
2737 return $this->endpoint('setChatDescription', $content);
2738 }
2739
2740 /// Pin Chat Message
2741
2742 /**
2743 * 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.
2744 * <table>
2745 * <tr>
2746 * <td><strong>Parameters</strong></td>
2747 * <td><strong>Type</strong></td>
2748 * <td><strong>Required</strong></td>
2749 * <td><strong>Description</strong></td>
2750 * </tr>
2751 * <tr>
2752 * <td>chat_id</td>
2753 * <td>Integer or String</td>
2754 * <td>Yes</td>
2755 * <td>Unique identifier for the target chat or username of the target channel (in the format \c \@channelusername)</td>
2756 * </tr>
2757 * <tr>
2758 * <td>message_id</td>
2759 * <td>Integer</td>
2760 * <td>Yes</td>
2761 * <td>Identifier of a message to pin</td>
2762 * </tr>
2763 * <tr>
2764 * <td>disable_notification</td>
2765 * <td>Boolean</td>
2766 * <td>No</td>
2767 * <td>Pass <em>True</em>, if it is not necessary to send a notification to all group members about the new pinned message</td>
2768 * </tr>
2769 * </table>
2770 * \param $content the request parameters as array
2771 * \return the JSON Telegram's reply.
2772 */
2773 public function pinChatMessage(array $content)
2774 {
2775 return $this->endpoint('pinChatMessage', $content);
2776 }
2777
2778 /// Unpin Chat Message
2779
2780 /**
2781 * 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.
2782 * <table>
2783 * <tr>
2784 * <td><strong>Parameters</strong></td>
2785 * <td><strong>Type</strong></td>
2786 * <td><strong>Required</strong></td>
2787 * <td><strong>Description</strong></td>
2788 * </tr>
2789 * <tr>
2790 * <td>chat_id</td>
2791 * <td>Integer or String</td>
2792 * <td>Yes</td>
2793 * <td>Unique identifier for the target chat or username of the target channel (in the format \c \@channelusername)</td>
2794 * </tr>
2795 * </table>
2796 * \param $content the request parameters as array
2797 * \return the JSON Telegram's reply.
2798 */
2799 public function unpinChatMessage(array $content)
2800 {
2801 return $this->endpoint('unpinChatMessage', $content);
2802 }
2803
2804 /// Get Sticker Set
2805
2806 /**
2807 * Use this method to get a sticker set. On success, a StickerSet object is returned.
2808 * <table>
2809 * <tr>
2810 * <td><strong>Parameters</strong></td>
2811 * <td><strong>Type</strong></td>
2812 * <td><strong>Required</strong></td>
2813 * <td><strong>Description</strong></td>
2814 * </tr>
2815 * <tr>
2816 * <td>name</td>
2817 * <td>String</td>
2818 * <td>Yes</td>
2819 * <td>Short name of the sticker set that is used in <code>t.me/addstickers/</code> URLs (e.g., <em>animals</em>)</td>
2820 * </tr>
2821 * </table>
2822 * \param $content the request parameters as array
2823 * \return the JSON Telegram's reply.
2824 */
2825 public function getStickerSet(array $content)
2826 {
2827 return $this->endpoint('getStickerSet', $content);
2828 }
2829
2830 /// Upload Sticker File
2831
2832 /**
2833 * 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.
2834 * <table>
2835 * <tr>
2836 * <td><strong>Parameters</strong></td>
2837 * <td><strong>Type</strong></td>
2838 * <td><strong>Required</strong></td>
2839 * <td><strong>Description</strong></td>
2840 * </tr>
2841 * <tr>
2842 * <td>user_id</td>
2843 * <td>Integer</td>
2844 * <td>Yes</td>
2845 * <td>User identifier of sticker file owner</td>
2846 * </tr>
2847 * <tr>
2848 * <td>png_sticker</td>
2849 * <td><a href="https://core.telegram.org/bots/api#inputfile">InputFile</a></td>
2850 * <td>Yes</td>
2851 * <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>
2852 * </tr>
2853 * </table>
2854 * \param $content the request parameters as array
2855 * \return the JSON Telegram's reply.
2856 */
2857 public function uploadStickerFile(array $content)
2858 {
2859 return $this->endpoint('uploadStickerFile', $content);
2860 }
2861
2862 /// Create New Sticker Set
2863
2864 /**
2865 * 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.
2866 * <table>
2867 * <tr>
2868 * <td><strong>Parameters</strong></td>
2869 * <td><strong>Type</strong></td>
2870 * <td><strong>Required</strong></td>
2871 * <td><strong>Description</strong></td>
2872 * </tr>
2873 * <tr>
2874 * <td>user_id</td>
2875 * <td>Integer</td>
2876 * <td>Yes</td>
2877 * <td>User identifier of created sticker set owner</td>
2878 * </tr>
2879 * <tr>
2880 * <td>name</td>
2881 * <td>String</td>
2882 * <td>Yes</td>
2883 * <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>
2884 * </tr>
2885 * <tr>
2886 * <td>title</td>
2887 * <td>String</td>
2888 * <td>Yes</td>
2889 * <td>Sticker set title, 1-64 characters</td>
2890 * </tr>
2891 * <tr>
2892 * <td>png_sticker</td>
2893 * <td><a href="https://core.telegram.org/bots/api#inputfile">InputFile</a> or String</td>
2894 * <td>Yes</td>
2895 * <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>
2896 * </tr>
2897 * <tr>
2898 * <td>emojis</td>
2899 * <td>String</td>
2900 * <td>Yes</td>
2901 * <td>One or more emoji corresponding to the sticker</td>
2902 * </tr>
2903 * <tr>
2904 * <td>is_masks</td>
2905 * <td>Boolean</td>
2906 * <td>Optional</td>
2907 * <td>Pass <em>True</em>, if a set of mask stickers should be created</td>
2908 * </tr>
2909 * <tr>
2910 * <td>mask_position</td>
2911 * <td><a href="https://core.telegram.org/bots/api#maskposition">MaskPosition</a></td>
2912 * <td>Optional</td>
2913 * <td>Position where the mask should be placed on faces</td>
2914 * </tr>
2915 * </table>
2916 * \param $content the request parameters as array
2917 * \return the JSON Telegram's reply.
2918 */
2919 public function createNewStickerSet(array $content)
2920 {
2921 return $this->endpoint('createNewStickerSet', $content);
2922 }
2923
2924 /// Add Sticker To Set
2925
2926 /**
2927 * Use this method to add a new sticker to a set created by the bot. Returns True on success.
2928 * <table>
2929 * <tr>
2930 * <td><strong>Parameters</strong></td>
2931 * <td><strong>Type</strong></td>
2932 * <td><strong>Required</strong></td>
2933 * <td><strong>Description</strong></td>
2934 * </tr>
2935 * <tr>
2936 * <td>user_id</td>
2937 * <td>Integer</td>
2938 * <td>Yes</td>
2939 * <td>User identifier of sticker set owner</td>
2940 * </tr>
2941 * <tr>
2942 * <td>name</td>
2943 * <td>String</td>
2944 * <td>Yes</td>
2945 * <td>Sticker set name</td>
2946 * </tr>
2947 * <tr>
2948 * <td>png_sticker</td>
2949 * <td><a href="https://core.telegram.org/bots/api#inputfile">InputFile</a> or String</td>
2950 * <td>Yes</td>
2951 * <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>
2952 * </tr>
2953 * <tr>
2954 * <td>emojis</td>
2955 * <td>String</td>
2956 * <td>Yes</td>
2957 * <td>One or more emoji corresponding to the sticker</td>
2958 * </tr>
2959 * <tr>
2960 * <td>mask_position</td>
2961 * <td><a href="https://core.telegram.org/bots/api#maskposition">MaskPosition</a></td>
2962 * <td>Optional</td>
2963 * <td>Position where the mask should be placed on faces</td>
2964 * </tr>
2965 * </table>
2966 * \param $content the request parameters as array
2967 * \return the JSON Telegram's reply.
2968 */
2969 public function addStickerToSet(array $content)
2970 {
2971 return $this->endpoint('addStickerToSet', $content);
2972 }
2973
2974 /// Set Sticker Position In Set
2975
2976 /**
2977 * Use this method to move a sticker in a set created by the bot to a specific position . Returns True on success.
2978 * <table>
2979 * <tr>
2980 * <td><strong>Parameters</strong></td>
2981 * <td><strong>Type</strong></td>
2982 * <td><strong>Required</strong></td>
2983 * <td><strong>Description</strong></td>
2984 * </tr>
2985 * <tr>
2986 * <td>sticker</td>
2987 * <td>String</td>
2988 * <td>Yes</td>
2989 * <td>File identifier of the sticker</td>
2990 * </tr>
2991 * <tr>
2992 * <td>position</td>
2993 * <td>Integer</td>
2994 * <td>Yes</td>
2995 * <td>New sticker position in the set, zero-based</td>
2996 * </tr>
2997 * </table>
2998 * \param $content the request parameters as array
2999 * \return the JSON Telegram's reply.
3000 */
3001 public function setStickerPositionInSet(array $content)
3002 {
3003 return $this->endpoint('setStickerPositionInSet', $content);
3004 }
3005
3006 /// Delete Sticker From Set
3007
3008 /**
3009 * Use this method to delete a sticker from a set created by the bot. Returns True on success.
3010 * <table>
3011 * <tr>
3012 * <td><strong>Parameters</strong></td>
3013 * <td><strong>Type</strong></td>
3014 * <td><strong>Required</strong></td>
3015 * <td><strong>Description</strong></td>
3016 * </tr>
3017 * <tr>
3018 * <td>sticker</td>
3019 * <td>String</td>
3020 * <td>Yes</td>
3021 * <td>File identifier of the sticker</td>
3022 * </tr>
3023 * </table>
3024 * \param $content the request parameters as array
3025 * \return the JSON Telegram's reply.
3026 */
3027 public function deleteStickerFromSet(array $content)
3028 {
3029 return $this->endpoint('deleteStickerFromSet', $content);
3030 }
3031
3032 /// Delete a message
3033
3034 /**
3035 * 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.
3036 * <table>
3037 * <tr>
3038 * <td><strong>Parameters</strong></td>
3039 * <td><strong>Type</strong></td>
3040 * <td><strong>Required</strong></td>
3041 * <td><strong>Description</strong></td>
3042 * </tr>
3043 * <tr>
3044 * <td>chat_id</td>
3045 * <td>Integer or String</td>
3046 * <td>Yes</td>
3047 * <td>Unique identifier for the target chat or username of the target channel (in the format \c \@channelusername)</td>
3048 * </tr>
3049 * <tr>
3050 * <td>message_id</td>
3051 * <td>Integer</td>
3052 * <td>Yes</td>
3053 * <td>Identifier of the message to delete</td>
3054 * </tr>
3055 * </table>
3056 * \param $content the request parameters as array
3057 * \return the JSON Telegram's reply.
3058 */
3059 public function deleteMessage(array $content)
3060 {
3061 return $this->endpoint('deleteMessage', $content);
3062 }
3063
3064 /// Receive incoming messages using polling
3065
3066 /** Use this method to receive incoming updates using long polling.
3067 * \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.
3068 * \param $limit Integer Limits the number of updates to be retrieved. Values between 1—100 are accepted. Defaults to 100
3069 * \param $timeout Integer Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling
3070 * \param $update Boolean If true updates the pending message list to the last update received. Default to true.
3071 * \return the updates as Array.
3072 */
3073 public function getUpdates($offset = 0, $limit = 100, $timeout = 0, $update = true)
3074 {
3075 $content = ['offset' => $offset, 'limit' => $limit, 'timeout' => $timeout];
3076 $this->updates = $this->endpoint('getUpdates', $content);
3077 if ($update) {
3078 if (is_array($this->updates['result']) && count($this->updates['result']) >= 1) { //for CLI working.
3079 $last_element_id = $this->updates['result'][count($this->updates['result']) - 1]['update_id'] + 1;
3080 $content = ['offset' => $last_element_id, 'limit' => '1', 'timeout' => $timeout];
3081 $this->endpoint('getUpdates', $content);
3082 }
3083 }
3084
3085 return $this->updates;
3086 }
3087
3088 /// Serve an update
3089
3090 /** Use this method to use the bultin function like Text() or Username() on a specific update.
3091 * \param $update Integer The index of the update in the updates array.
3092 */
3093 public function serveUpdate($update)
3094 {
3095 $this->data = $this->updates['result'][$update];
3096 }
3097
3098 /// Return current update type
3099
3100 /**
3101 * Return current update type `False` on failure.
3102 *
3103 * @return bool|string
3104 */
3105 public function getUpdateType()
3106 {
3107 $update = $this->data;
3108 if (isset($update['inline_query'])) {
3109 return self::INLINE_QUERY;
3110 }
3111 if (isset($update['callback_query'])) {
3112 return self::CALLBACK_QUERY;
3113 }
3114 if (isset($update['edited_message'])) {
3115 return self::EDITED_MESSAGE;
3116 }
3117 if (isset($update['message']['text'])) {
3118 return self::MESSAGE;
3119 }
3120 if (isset($update['message']['photo'])) {
3121 return self::PHOTO;
3122 }
3123 if (isset($update['message']['video'])) {
3124 return self::VIDEO;
3125 }
3126 if (isset($update['message']['audio'])) {
3127 return self::AUDIO;
3128 }
3129 if (isset($update['message']['voice'])) {
3130 return self::VOICE;
3131 }
3132 if (isset($update['message']['contact'])) {
3133 return self::CONTACT;
3134 }
3135 if (isset($update['message']['location'])) {
3136 return self::LOCATION;
3137 }
3138 if (isset($update['message']['reply_to_message'])) {
3139 return self::REPLY;
3140 }
3141 if (isset($update['message']['animation'])) {
3142 return self::ANIMATION;
3143 }
3144 if (isset($update['message']['sticker'])) {
3145 return self::STICKER;
3146 }
3147 if (isset($update['message']['document'])) {
3148 return self::DOCUMENT;
3149 }
3150 if (isset($update['channel_post'])) {
3151 return self::CHANNEL_POST;
3152 }
3153
3154 return false;
3155 }
3156
3157 private function sendAPIRequest($url, array $content, $post = true)
3158 {
3159 if (isset($content['chat_id'])) {
3160 $url = $url.'?chat_id='.$content['chat_id'];
3161 unset($content['chat_id']);
3162 }
3163 $ch = curl_init();
3164 curl_setopt($ch, CURLOPT_URL, $url);
3165 curl_setopt($ch, CURLOPT_HEADER, false);
3166 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
3167 if ($post) {
3168 curl_setopt($ch, CURLOPT_POST, 1);
3169 curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
3170 }
3171 // echo "inside curl if";
3172 if (!empty($this->proxy)) {
3173 // echo "inside proxy if";
3174 if (array_key_exists('type', $this->proxy)) {
3175 curl_setopt($ch, CURLOPT_PROXYTYPE, $this->proxy['type']);
3176 }
3177
3178 if (array_key_exists('auth', $this->proxy)) {
3179 curl_setopt($ch, CURLOPT_PROXYUSERPWD, $this->proxy['auth']);
3180 }
3181
3182 if (array_key_exists('url', $this->proxy)) {
3183 // echo "Proxy Url";
3184 curl_setopt($ch, CURLOPT_PROXY, $this->proxy['url']);
3185 }
3186
3187 if (array_key_exists('port', $this->proxy)) {
3188 // echo "Proxy port";
3189 curl_setopt($ch, CURLOPT_PROXYPORT, $this->proxy['port']);
3190 }
3191 }
3192 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
3193 $result = curl_exec($ch);
3194 if ($result === false) {
3195 $result = json_encode(['ok'=>false, 'curl_error_code' => curl_errno($ch), 'curl_error' => curl_error($ch)]);
3196 }
3197
3198 curl_close($ch);
3199 if ($this->log_errors) {
3200 if (class_exists('TelegramErrorLogger')) {
3201 $loggerArray = ($this->getData() == null) ? [$content] : [$this->getData(), $content];
3202 TelegramErrorLogger::log(json_decode($result, true), $loggerArray);
3203 }
3204 }
3205
3206 return $result;
3207 }
3208}
3209
3210// Helper for Uploading file using CURL
3211if (!function_exists('curl_file_create')) {
3212 function curl_file_create($filename, $mimetype = '', $postname = '')
3213 {
3214 return "@$filename;filename="
3215 .($postname ?: basename($filename))
3216 .($mimetype ? ";type=$mimetype" : '');
3217 }
3218}