Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like BotApi often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use BotApi, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
25 | class BotApi |
||
26 | { |
||
27 | /** |
||
28 | * HTTP codes |
||
29 | * |
||
30 | * @var array |
||
31 | */ |
||
32 | public static $codes = [ |
||
33 | // Informational 1xx |
||
34 | 100 => 'Continue', |
||
35 | 101 => 'Switching Protocols', |
||
36 | 102 => 'Processing', // RFC2518 |
||
37 | // Success 2xx |
||
38 | 200 => 'OK', |
||
39 | 201 => 'Created', |
||
40 | 202 => 'Accepted', |
||
41 | 203 => 'Non-Authoritative Information', |
||
42 | 204 => 'No Content', |
||
43 | 205 => 'Reset Content', |
||
44 | 206 => 'Partial Content', |
||
45 | 207 => 'Multi-Status', // RFC4918 |
||
46 | 208 => 'Already Reported', // RFC5842 |
||
47 | 226 => 'IM Used', // RFC3229 |
||
48 | // Redirection 3xx |
||
49 | 300 => 'Multiple Choices', |
||
50 | 301 => 'Moved Permanently', |
||
51 | 302 => 'Found', // 1.1 |
||
52 | 303 => 'See Other', |
||
53 | 304 => 'Not Modified', |
||
54 | 305 => 'Use Proxy', |
||
55 | // 306 is deprecated but reserved |
||
56 | 307 => 'Temporary Redirect', |
||
57 | 308 => 'Permanent Redirect', // RFC7238 |
||
58 | // Client Error 4xx |
||
59 | 400 => 'Bad Request', |
||
60 | 401 => 'Unauthorized', |
||
61 | 402 => 'Payment Required', |
||
62 | 403 => 'Forbidden', |
||
63 | 404 => 'Not Found', |
||
64 | 405 => 'Method Not Allowed', |
||
65 | 406 => 'Not Acceptable', |
||
66 | 407 => 'Proxy Authentication Required', |
||
67 | 408 => 'Request Timeout', |
||
68 | 409 => 'Conflict', |
||
69 | 410 => 'Gone', |
||
70 | 411 => 'Length Required', |
||
71 | 412 => 'Precondition Failed', |
||
72 | 413 => 'Payload Too Large', |
||
73 | 414 => 'URI Too Long', |
||
74 | 415 => 'Unsupported Media Type', |
||
75 | 416 => 'Range Not Satisfiable', |
||
76 | 417 => 'Expectation Failed', |
||
77 | 422 => 'Unprocessable Entity', // RFC4918 |
||
78 | 423 => 'Locked', // RFC4918 |
||
79 | 424 => 'Failed Dependency', // RFC4918 |
||
80 | 425 => 'Reserved for WebDAV advanced collections expired proposal', // RFC2817 |
||
81 | 426 => 'Upgrade Required', // RFC2817 |
||
82 | 428 => 'Precondition Required', // RFC6585 |
||
83 | 429 => 'Too Many Requests', // RFC6585 |
||
84 | 431 => 'Request Header Fields Too Large', // RFC6585 |
||
85 | // Server Error 5xx |
||
86 | 500 => 'Internal Server Error', |
||
87 | 501 => 'Not Implemented', |
||
88 | 502 => 'Bad Gateway', |
||
89 | 503 => 'Service Unavailable', |
||
90 | 504 => 'Gateway Timeout', |
||
91 | 505 => 'HTTP Version Not Supported', |
||
92 | 506 => 'Variant Also Negotiates (Experimental)', // RFC2295 |
||
93 | 507 => 'Insufficient Storage', // RFC4918 |
||
94 | 508 => 'Loop Detected', // RFC5842 |
||
95 | 510 => 'Not Extended', // RFC2774 |
||
96 | 511 => 'Network Authentication Required', // RFC6585 |
||
97 | ]; |
||
98 | |||
99 | private $proxySettings = []; |
||
100 | |||
101 | /** |
||
102 | * Default http status code |
||
103 | */ |
||
104 | const DEFAULT_STATUS_CODE = 200; |
||
105 | |||
106 | /** |
||
107 | * Not Modified http status code |
||
108 | */ |
||
109 | const NOT_MODIFIED_STATUS_CODE = 304; |
||
110 | |||
111 | /** |
||
112 | * Limits for tracked ids |
||
113 | */ |
||
114 | const MAX_TRACKED_EVENTS = 200; |
||
115 | |||
116 | /** |
||
117 | * Url prefixes |
||
118 | */ |
||
119 | const URL_PREFIX = 'https://api.telegram.org/bot'; |
||
120 | |||
121 | /** |
||
122 | * Url prefix for files |
||
123 | */ |
||
124 | const FILE_URL_PREFIX = 'https://api.telegram.org/file/bot'; |
||
125 | |||
126 | /** |
||
127 | * CURL object |
||
128 | * |
||
129 | * @var |
||
130 | */ |
||
131 | protected $curl; |
||
132 | |||
133 | /** |
||
134 | * CURL custom options |
||
135 | * |
||
136 | * @var array |
||
137 | */ |
||
138 | protected $customCurlOptions = []; |
||
139 | |||
140 | /** |
||
141 | * Bot token |
||
142 | * |
||
143 | * @var string |
||
144 | */ |
||
145 | protected $token; |
||
146 | |||
147 | /** |
||
148 | * Botan tracker |
||
149 | * |
||
150 | * @var \TelegramBot\Api\Botan |
||
151 | */ |
||
152 | protected $tracker; |
||
153 | |||
154 | /** |
||
155 | * list of event ids |
||
156 | * |
||
157 | * @var array |
||
158 | */ |
||
159 | protected $trackedEvents = []; |
||
160 | |||
161 | /** |
||
162 | * Check whether return associative array |
||
163 | * |
||
164 | * @var bool |
||
165 | */ |
||
166 | protected $returnArray = true; |
||
167 | |||
168 | /** |
||
169 | * Constructor |
||
170 | * |
||
171 | * @param string $token Telegram Bot API token |
||
172 | * @param string|null $trackerToken Yandex AppMetrica application api_key |
||
173 | */ |
||
174 | 9 | public function __construct($token, $trackerToken = null) |
|
183 | |||
184 | /** |
||
185 | * Set return array |
||
186 | * |
||
187 | * @param bool $mode |
||
188 | * |
||
189 | * @return $this |
||
190 | */ |
||
191 | public function setModeObject($mode = true) |
||
197 | |||
198 | |||
199 | /** |
||
200 | * Call method |
||
201 | * |
||
202 | * @param string $method |
||
203 | * @param array|null $data |
||
204 | * |
||
205 | * @return mixed |
||
206 | * @throws \TelegramBot\Api\Exception |
||
207 | * @throws \TelegramBot\Api\HttpException |
||
208 | * @throws \TelegramBot\Api\InvalidJsonException |
||
209 | */ |
||
210 | public function call($method, array $data = null) |
||
245 | |||
246 | /** |
||
247 | * curl_exec wrapper for response validation |
||
248 | * |
||
249 | * @param array $options |
||
250 | * |
||
251 | * @return string |
||
252 | * |
||
253 | * @throws \TelegramBot\Api\HttpException |
||
254 | */ |
||
255 | protected function executeCurl(array $options) |
||
267 | |||
268 | /** |
||
269 | * Response validation |
||
270 | * |
||
271 | * @param resource $curl |
||
272 | * @param string $response |
||
273 | * @throws HttpException |
||
274 | */ |
||
275 | public static function curlValidate($curl, $response = null) |
||
286 | |||
287 | /** |
||
288 | * JSON validation |
||
289 | * |
||
290 | * @param string $jsonString |
||
291 | * @param boolean $asArray |
||
292 | * |
||
293 | * @return object|array |
||
294 | * @throws \TelegramBot\Api\InvalidJsonException |
||
295 | */ |
||
296 | public static function jsonValidate($jsonString, $asArray) |
||
306 | |||
307 | /** |
||
308 | * Use this method to send text messages. On success, the sent \TelegramBot\Api\Types\Message is returned. |
||
309 | * |
||
310 | * @param int|string $chatId |
||
311 | * @param string $text |
||
312 | * @param string|null $parseMode |
||
313 | * @param bool $disablePreview |
||
314 | * @param int|null $replyToMessageId |
||
315 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
316 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
317 | * @param bool $disableNotification |
||
318 | * |
||
319 | * @return \TelegramBot\Api\Types\Message |
||
320 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
321 | * @throws \TelegramBot\Api\Exception |
||
322 | */ |
||
323 | public function sendMessage( |
||
342 | |||
343 | /** |
||
344 | * Use this method to send phone contacts |
||
345 | * |
||
346 | * @param int|string $chatId chat_id or @channel_name |
||
347 | * @param string $phoneNumber |
||
348 | * @param string $firstName |
||
349 | * @param string $lastName |
||
350 | * @param int|null $replyToMessageId |
||
351 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
352 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
353 | * @param bool $disableNotification |
||
354 | * |
||
355 | * @return \TelegramBot\Api\Types\Message |
||
356 | * @throws \TelegramBot\Api\Exception |
||
357 | */ |
||
358 | public function sendContact( |
||
377 | |||
378 | /** |
||
379 | * Use this method when you need to tell the user that something is happening on the bot's side. |
||
380 | * The status is set for 5 seconds or less (when a message arrives from your bot, |
||
381 | * Telegram clients clear its typing status). |
||
382 | * |
||
383 | * We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive. |
||
384 | * |
||
385 | * Type of action to broadcast. Choose one, depending on what the user is about to receive: |
||
386 | * `typing` for text messages, `upload_photo` for photos, `record_video` or `upload_video` for videos, |
||
387 | * `record_audio` or upload_audio for audio files, `upload_document` for general files, |
||
388 | * `find_location` for location data. |
||
389 | * |
||
390 | * @param int $chatId |
||
391 | * @param string $action |
||
392 | * |
||
393 | * @return bool |
||
394 | * @throws \TelegramBot\Api\Exception |
||
395 | */ |
||
396 | public function sendChatAction($chatId, $action) |
||
403 | |||
404 | /** |
||
405 | * Use this method to get a list of profile pictures for a user. |
||
406 | * |
||
407 | * @param int $userId |
||
408 | * @param int $offset |
||
409 | * @param int $limit |
||
410 | * |
||
411 | * @return \TelegramBot\Api\Types\UserProfilePhotos |
||
412 | * @throws \TelegramBot\Api\Exception |
||
413 | */ |
||
414 | public function getUserProfilePhotos($userId, $offset = 0, $limit = 100) |
||
422 | |||
423 | /** |
||
424 | * Use this method to specify a url and receive incoming updates via an outgoing webhook. |
||
425 | * Whenever there is an update for the bot, we will send an HTTPS POST request to the specified url, |
||
426 | * containing a JSON-serialized Update. |
||
427 | * In case of an unsuccessful request, we will give up after a reasonable amount of attempts. |
||
428 | * |
||
429 | * @param string $url HTTPS url to send updates to. Use an empty string to remove webhook integration |
||
430 | * @param \CURLFile|string $certificate Upload your public key certificate |
||
431 | * so that the root certificate in use can be checked |
||
432 | * |
||
433 | * @return string |
||
434 | * |
||
435 | * @throws \TelegramBot\Api\Exception |
||
436 | */ |
||
437 | public function setWebhook($url = '', $certificate = null) |
||
441 | |||
442 | |||
443 | /** |
||
444 | * Use this method to clear webhook and use getUpdates again! |
||
445 | * |
||
446 | * @return mixed |
||
447 | * |
||
448 | * @throws \TelegramBot\Api\Exception |
||
449 | */ |
||
450 | public function deleteWebhook() |
||
454 | |||
455 | /** |
||
456 | * A simple method for testing your bot's auth token.Requires no parameters. |
||
457 | * Returns basic information about the bot in form of a User object. |
||
458 | * |
||
459 | * @return \TelegramBot\Api\Types\User |
||
460 | * @throws \TelegramBot\Api\Exception |
||
461 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
462 | */ |
||
463 | public function getMe() |
||
467 | |||
468 | /** |
||
469 | * Use this method to receive incoming updates using long polling. |
||
470 | * An Array of Update objects is returned. |
||
471 | * |
||
472 | * Notes |
||
473 | * 1. This method will not work if an outgoing webhook is set up. |
||
474 | * 2. In order to avoid getting duplicate updates, recalculate offset after each server response. |
||
475 | * |
||
476 | * @param int $offset |
||
477 | * @param int $limit |
||
478 | * @param int $timeout |
||
479 | * |
||
480 | * @return Update[] |
||
481 | * @throws \TelegramBot\Api\Exception |
||
482 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
483 | */ |
||
484 | 2 | public function getUpdates($offset = 0, $limit = 100, $timeout = 0) |
|
500 | |||
501 | /** |
||
502 | * Use this method to send point on the map. On success, the sent Message is returned. |
||
503 | * |
||
504 | * @param int|string $chatId |
||
505 | * @param float $latitude |
||
506 | * @param float $longitude |
||
507 | * @param int|null $replyToMessageId |
||
508 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
509 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
510 | * @param bool $disableNotification |
||
511 | * |
||
512 | * @param null|int $livePeriod |
||
513 | * @return \TelegramBot\Api\Types\Message |
||
514 | */ |
||
515 | public function sendLocation( |
||
534 | |||
535 | /** |
||
536 | * Use this method to edit live location messages sent by the bot or via the bot (for inline bots). |
||
537 | * |
||
538 | * @param int|string $chatId |
||
539 | * @param int $messageId |
||
540 | * @param string $inlineMessageId |
||
541 | * @param float $latitude |
||
542 | * @param float $longitude |
||
543 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
544 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
545 | * @return \TelegramBot\Api\Types\Message |
||
546 | */ |
||
547 | public function editMessageLiveLocation( |
||
564 | |||
565 | /** |
||
566 | * Use this method to stop updating a live location message sent by the bot or via the bot (for inline bots) before |
||
567 | * live_period expires. |
||
568 | * |
||
569 | * @param int|string $chatId |
||
570 | * @param int $messageId |
||
571 | * @param string $inlineMessageId |
||
572 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
573 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
574 | * @return \TelegramBot\Api\Types\Message |
||
575 | */ |
||
576 | public function stopMessageLiveLocation( |
||
589 | |||
590 | /** |
||
591 | * Use this method to send information about a venue. On success, the sent Message is returned. |
||
592 | * |
||
593 | * @param int|string $chatId chat_id or @channel_name |
||
594 | * @param float $latitude |
||
595 | * @param float $longitude |
||
596 | * @param string $title |
||
597 | * @param string $address |
||
598 | * @param string|null $foursquareId |
||
599 | * @param int|null $replyToMessageId |
||
600 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
601 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
602 | * @param bool $disableNotification |
||
603 | * |
||
604 | * @return \TelegramBot\Api\Types\Message |
||
605 | * @throws \TelegramBot\Api\Exception |
||
606 | */ |
||
607 | public function sendVenue( |
||
630 | |||
631 | /** |
||
632 | * Use this method to send .webp stickers. On success, the sent Message is returned. |
||
633 | * |
||
634 | * @param int|string $chatId chat_id or @channel_name |
||
635 | * @param \CURLFile|string $sticker |
||
636 | * @param int|null $replyToMessageId |
||
637 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
638 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
639 | * @param bool $disableNotification |
||
640 | * |
||
641 | * @return \TelegramBot\Api\Types\Message |
||
642 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
643 | * @throws \TelegramBot\Api\Exception |
||
644 | */ |
||
645 | View Code Duplication | public function sendSticker( |
|
660 | |||
661 | /** |
||
662 | * Use this method to send video files, |
||
663 | * Telegram clients support mp4 videos (other formats may be sent as Document). |
||
664 | * On success, the sent Message is returned. |
||
665 | * |
||
666 | * @param int|string $chatId chat_id or @channel_name |
||
667 | * @param \CURLFile|string $video |
||
668 | * @param int|null $duration |
||
669 | * @param string|null $caption |
||
670 | * @param int|null $replyToMessageId |
||
671 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
672 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
673 | * @param bool $disableNotification |
||
674 | * @param bool $supportsStreaming Pass True, if the uploaded video is suitable for streaming |
||
675 | * @param string|null $parseMode |
||
676 | * |
||
677 | * @return \TelegramBot\Api\Types\Message |
||
678 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
679 | * @throws \TelegramBot\Api\Exception |
||
680 | */ |
||
681 | View Code Duplication | public function sendVideo( |
|
704 | |||
705 | /** |
||
706 | * Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound), |
||
707 | * On success, the sent Message is returned. |
||
708 | * Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future. |
||
709 | * |
||
710 | * @param int|string $chatId chat_id or @channel_name |
||
711 | * @param \CURLFile|string $animation |
||
712 | * @param int|null $duration |
||
713 | * @param string|null $caption |
||
714 | * @param int|null $replyToMessageId |
||
715 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
716 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
717 | * @param bool $disableNotification |
||
718 | * @param string|null $parseMode |
||
719 | * |
||
720 | * @return \TelegramBot\Api\Types\Message |
||
721 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
722 | * @throws \TelegramBot\Api\Exception |
||
723 | */ |
||
724 | View Code Duplication | public function sendAnimation( |
|
745 | |||
746 | /** |
||
747 | * Use this method to send audio files, |
||
748 | * if you want Telegram clients to display the file as a playable voice message. |
||
749 | * For this to work, your audio must be in an .ogg file encoded with OPUS |
||
750 | * (other formats may be sent as Audio or Document). |
||
751 | * On success, the sent Message is returned. |
||
752 | * Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future. |
||
753 | * |
||
754 | * @param int|string $chatId chat_id or @channel_name |
||
755 | * @param \CURLFile|string $voice |
||
756 | * @param int|null $duration |
||
757 | * @param int|null $replyToMessageId |
||
758 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
759 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
760 | * @param bool $disableNotification |
||
761 | * @param string|null $parseMode |
||
762 | * |
||
763 | * @return \TelegramBot\Api\Types\Message |
||
764 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
765 | * @throws \TelegramBot\Api\Exception |
||
766 | */ |
||
767 | public function sendVoice( |
||
786 | |||
787 | /** |
||
788 | * Use this method to forward messages of any kind. On success, the sent Message is returned. |
||
789 | * |
||
790 | * @param int|string $chatId chat_id or @channel_name |
||
791 | * @param int $fromChatId |
||
792 | * @param int $messageId |
||
793 | * @param bool $disableNotification |
||
794 | * |
||
795 | * @return \TelegramBot\Api\Types\Message |
||
796 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
797 | * @throws \TelegramBot\Api\Exception |
||
798 | */ |
||
799 | public function forwardMessage($chatId, $fromChatId, $messageId, $disableNotification = false) |
||
808 | |||
809 | /** |
||
810 | * Use this method to send audio files, |
||
811 | * if you want Telegram clients to display them in the music player. |
||
812 | * Your audio must be in the .mp3 format. |
||
813 | * On success, the sent Message is returned. |
||
814 | * Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future. |
||
815 | * |
||
816 | * For backward compatibility, when the fields title and performer are both empty |
||
817 | * and the mime-type of the file to be sent is not audio/mpeg, the file will be sent as a playable voice message. |
||
818 | * For this to work, the audio must be in an .ogg file encoded with OPUS. |
||
819 | * This behavior will be phased out in the future. For sending voice messages, use the sendVoice method instead. |
||
820 | * |
||
821 | * @deprecated since 20th February. Removed backward compatibility from the method sendAudio. |
||
822 | * Voice messages now must be sent using the method sendVoice. |
||
823 | * There is no more need to specify a non-empty title or performer while sending the audio by file_id. |
||
824 | * |
||
825 | * @param int|string $chatId chat_id or @channel_name |
||
826 | * @param \CURLFile|string $audio |
||
827 | * @param int|null $duration |
||
828 | * @param string|null $performer |
||
829 | * @param string|null $title |
||
830 | * @param int|null $replyToMessageId |
||
831 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
832 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
833 | * @param bool $disableNotification |
||
834 | * @param string|null $parseMode |
||
835 | * |
||
836 | * @return \TelegramBot\Api\Types\Message |
||
837 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
838 | * @throws \TelegramBot\Api\Exception |
||
839 | */ |
||
840 | View Code Duplication | public function sendAudio( |
|
863 | |||
864 | /** |
||
865 | * Use this method to send photos. On success, the sent Message is returned. |
||
866 | * |
||
867 | * @param int|string $chatId chat_id or @channel_name |
||
868 | * @param \CURLFile|string $photo |
||
869 | * @param string|null $caption |
||
870 | * @param int|null $replyToMessageId |
||
871 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
872 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
873 | * @param bool $disableNotification |
||
874 | * @param string|null $parseMode |
||
875 | * |
||
876 | * @return \TelegramBot\Api\Types\Message |
||
877 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
878 | * @throws \TelegramBot\Api\Exception |
||
879 | */ |
||
880 | public function sendPhoto( |
||
899 | |||
900 | /** |
||
901 | * Use this method to send general files. On success, the sent Message is returned. |
||
902 | * Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future. |
||
903 | * |
||
904 | * @param int|string $chatId chat_id or @channel_name |
||
905 | * @param \CURLFile|string $document |
||
906 | * @param string|null $caption |
||
907 | * @param int|null $replyToMessageId |
||
908 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
909 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
910 | * @param bool $disableNotification |
||
911 | * @param string|null $parseMode |
||
912 | * |
||
913 | * @return \TelegramBot\Api\Types\Message |
||
914 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
915 | * @throws \TelegramBot\Api\Exception |
||
916 | */ |
||
917 | public function sendDocument( |
||
936 | |||
937 | /** |
||
938 | * Use this method to get basic info about a file and prepare it for downloading. |
||
939 | * For the moment, bots can download files of up to 20MB in size. |
||
940 | * On success, a File object is returned. |
||
941 | * The file can then be downloaded via the link https://api.telegram.org/file/bot<token>/<file_path>, |
||
942 | * where <file_path> is taken from the response. |
||
943 | * It is guaranteed that the link will be valid for at least 1 hour. |
||
944 | * When the link expires, a new one can be requested by calling getFile again. |
||
945 | * |
||
946 | * @param $fileId |
||
947 | * |
||
948 | * @return \TelegramBot\Api\Types\File |
||
949 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
950 | * @throws \TelegramBot\Api\Exception |
||
951 | */ |
||
952 | public function getFile($fileId) |
||
956 | |||
957 | /** |
||
958 | * Get file contents via cURL |
||
959 | * |
||
960 | * @param $fileId |
||
961 | * |
||
962 | * @return string |
||
963 | * |
||
964 | * @throws \TelegramBot\Api\HttpException |
||
965 | */ |
||
966 | public function downloadFile($fileId) |
||
978 | |||
979 | /** |
||
980 | * Use this method to send answers to an inline query. On success, True is returned. |
||
981 | * No more than 50 results per query are allowed. |
||
982 | * |
||
983 | * @param string $inlineQueryId |
||
984 | * @param AbstractInlineQueryResult[] $results |
||
985 | * @param int $cacheTime |
||
986 | * @param bool $isPersonal |
||
987 | * @param string $nextOffset |
||
988 | * @param string $switchPmText |
||
989 | * @param string $switchPmParameter |
||
990 | * |
||
991 | * @return mixed |
||
992 | * @throws Exception |
||
993 | */ |
||
994 | public function answerInlineQuery( |
||
1018 | |||
1019 | /** |
||
1020 | * Use this method to kick a user from a group or a supergroup. |
||
1021 | * In the case of supergroups, the user will not be able to return to the group |
||
1022 | * on their own using invite links, etc., unless unbanned first. |
||
1023 | * The bot must be an administrator in the group for this to work. Returns True on success. |
||
1024 | * |
||
1025 | * @param int|string $chatId Unique identifier for the target group |
||
1026 | * or username of the target supergroup (in the format @supergroupusername) |
||
1027 | * @param int $userId Unique identifier of the target user |
||
1028 | * @param null|int $untilDate Date when the user will be unbanned, unix time. |
||
1029 | * If user is banned for more than 366 days or less than 30 seconds from the current time |
||
1030 | * they are considered to be banned forever |
||
1031 | * |
||
1032 | * @return bool |
||
1033 | */ |
||
1034 | public function kickChatMember($chatId, $userId, $untilDate = null) |
||
1042 | |||
1043 | /** |
||
1044 | * Use this method to unban a previously kicked user in a supergroup. |
||
1045 | * The user will not return to the group automatically, but will be able to join via link, etc. |
||
1046 | * The bot must be an administrator in the group for this to work. Returns True on success. |
||
1047 | * |
||
1048 | * @param int|string $chatId Unique identifier for the target group |
||
1049 | * or username of the target supergroup (in the format @supergroupusername) |
||
1050 | * @param int $userId Unique identifier of the target user |
||
1051 | * |
||
1052 | * @return bool |
||
1053 | */ |
||
1054 | public function unbanChatMember($chatId, $userId) |
||
1061 | |||
1062 | /** |
||
1063 | * Use this method to send answers to callback queries sent from inline keyboards. |
||
1064 | * The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. |
||
1065 | * |
||
1066 | * @param $callbackQueryId |
||
1067 | * @param null $text |
||
1068 | * @param bool $showAlert |
||
1069 | * |
||
1070 | * @return bool |
||
1071 | */ |
||
1072 | public function answerCallbackQuery($callbackQueryId, $text = null, $showAlert = false) |
||
1080 | |||
1081 | |||
1082 | /** |
||
1083 | * Use this method to edit text messages sent by the bot or via the bot |
||
1084 | * |
||
1085 | * @param int|string $chatId |
||
1086 | * @param int $messageId |
||
1087 | * @param string $text |
||
1088 | * @param string $inlineMessageId |
||
1089 | * @param string|null $parseMode |
||
1090 | * @param bool $disablePreview |
||
1091 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
1092 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
1093 | * @return Message |
||
1094 | */ |
||
1095 | public function editMessageText( |
||
1114 | |||
1115 | /** |
||
1116 | * Use this method to edit text messages sent by the bot or via the bot |
||
1117 | * |
||
1118 | * @param int|string $chatId |
||
1119 | * @param int $messageId |
||
1120 | * @param string|null $caption |
||
1121 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
1122 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
1123 | * @param string $inlineMessageId |
||
1124 | * |
||
1125 | * @return \TelegramBot\Api\Types\Message |
||
1126 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
1127 | * @throws \TelegramBot\Api\Exception |
||
1128 | */ |
||
1129 | View Code Duplication | public function editMessageCaption( |
|
1144 | |||
1145 | /** |
||
1146 | * Use this method to edit animation, audio, document, photo, or video messages. |
||
1147 | * If a message is a part of a message album, then it can be edited only to a photo or a video. |
||
1148 | * Otherwise, message type can be changed arbitrarily. |
||
1149 | * When inline message is edited, new file can't be uploaded. |
||
1150 | * Use previously uploaded file via its file_id or specify a URL. |
||
1151 | * On success, if the edited message was sent by the bot, the edited Message is returned, otherwise True is returned |
||
1152 | * |
||
1153 | * @param $chatId |
||
1154 | * @param $messageId |
||
1155 | * @param InputMedia $media |
||
1156 | * @param null $inlineMessageId |
||
1157 | * @param null $replyMarkup |
||
1158 | * @return bool|Message |
||
1159 | * @throws Exception |
||
1160 | * @throws HttpException |
||
1161 | * @throws InvalidJsonException |
||
1162 | */ |
||
1163 | View Code Duplication | public function editMessageMedia( |
|
1178 | |||
1179 | /** |
||
1180 | * Use this method to edit only the reply markup of messages sent by the bot or via the bot |
||
1181 | * |
||
1182 | * @param int|string $chatId |
||
1183 | * @param int $messageId |
||
1184 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
1185 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
1186 | * @param string $inlineMessageId |
||
1187 | * |
||
1188 | * @return Message |
||
1189 | */ |
||
1190 | public function editMessageReplyMarkup( |
||
1203 | |||
1204 | /** |
||
1205 | * Use this method to delete a message, including service messages, with the following limitations: |
||
1206 | * - A message can only be deleted if it was sent less than 48 hours ago. |
||
1207 | * - Bots can delete outgoing messages in groups and supergroups. |
||
1208 | * - Bots granted can_post_messages permissions can delete outgoing messages in channels. |
||
1209 | * - If the bot is an administrator of a group, it can delete any message there. |
||
1210 | * - If the bot has can_delete_messages permission in a supergroup or a channel, it can delete any message there. |
||
1211 | * |
||
1212 | * @param int|string $chatId |
||
1213 | * @param int $messageId |
||
1214 | * |
||
1215 | * @return bool |
||
1216 | */ |
||
1217 | public function deleteMessage($chatId, $messageId) |
||
1224 | |||
1225 | /** |
||
1226 | * Close curl |
||
1227 | */ |
||
1228 | 9 | public function __destruct() |
|
1232 | |||
1233 | /** |
||
1234 | * @return string |
||
1235 | */ |
||
1236 | public function getUrl() |
||
1240 | |||
1241 | /** |
||
1242 | * @return string |
||
1243 | */ |
||
1244 | public function getFileUrl() |
||
1248 | |||
1249 | /** |
||
1250 | * @param \TelegramBot\Api\Types\Update $update |
||
1251 | * @param string $eventName |
||
1252 | * |
||
1253 | * @throws \TelegramBot\Api\Exception |
||
1254 | */ |
||
1255 | public function trackUpdate(Update $update, $eventName = 'Message') |
||
1267 | |||
1268 | /** |
||
1269 | * Wrapper for tracker |
||
1270 | * |
||
1271 | * @param \TelegramBot\Api\Types\Message $message |
||
1272 | * @param string $eventName |
||
1273 | * |
||
1274 | * @throws \TelegramBot\Api\Exception |
||
1275 | */ |
||
1276 | public function track(Message $message, $eventName = 'Message') |
||
1282 | |||
1283 | /** |
||
1284 | * Use this method to send invoices. On success, the sent Message is returned. |
||
1285 | * |
||
1286 | * @param int|string $chatId |
||
1287 | * @param string $title |
||
1288 | * @param string $description |
||
1289 | * @param string $payload |
||
1290 | * @param string $providerToken |
||
1291 | * @param string $startParameter |
||
1292 | * @param string $currency |
||
1293 | * @param array $prices |
||
1294 | * @param string|null $photoUrl |
||
1295 | * @param int|null $photoSize |
||
1296 | * @param int|null $photoWidth |
||
1297 | * @param int|null $photoHeight |
||
1298 | * @param bool $needName |
||
1299 | * @param bool $needPhoneNumber |
||
1300 | * @param bool $needEmail |
||
1301 | * @param bool $needShippingAddress |
||
1302 | * @param bool $isFlexible |
||
1303 | * @param int|null $replyToMessageId |
||
1304 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
1305 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
1306 | * @param bool $disableNotification |
||
1307 | * @param string|null $providerData |
||
1308 | * @param bool $sendPhoneNumberToProvider |
||
1309 | * @param bool $sendEmailToProvider |
||
1310 | * |
||
1311 | * @return Message |
||
1312 | */ |
||
1313 | public function sendInvoice( |
||
1364 | |||
1365 | /** |
||
1366 | * If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API |
||
1367 | * will send an Update with a shipping_query field to the bot. Use this method to reply to shipping queries. |
||
1368 | * On success, True is returned. |
||
1369 | * |
||
1370 | * @param string $shippingQueryId |
||
1371 | * @param bool $ok |
||
1372 | * @param array $shipping_options |
||
1373 | * @param null|string $errorMessage |
||
1374 | * |
||
1375 | * @return bool |
||
1376 | * |
||
1377 | */ |
||
1378 | public function answerShippingQuery($shippingQueryId, $ok = true, $shipping_options = [], $errorMessage = null) |
||
1387 | |||
1388 | /** |
||
1389 | * Use this method to respond to such pre-checkout queries. On success, True is returned. |
||
1390 | * Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent. |
||
1391 | * |
||
1392 | * @param string $preCheckoutQueryId |
||
1393 | * @param bool $ok |
||
1394 | * @param null|string $errorMessage |
||
1395 | * |
||
1396 | * @return mixed |
||
1397 | */ |
||
1398 | public function answerPreCheckoutQuery($preCheckoutQueryId, $ok = true, $errorMessage = null) |
||
1406 | |||
1407 | /** |
||
1408 | * Use this method to restrict a user in a supergroup. |
||
1409 | * The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights. |
||
1410 | * Pass True for all boolean parameters to lift restrictions from a user. |
||
1411 | * |
||
1412 | * @param string|int $chatId Unique identifier for the target chat or username of the target supergroup |
||
1413 | * (in the format @supergroupusername) |
||
1414 | * @param int $userId Unique identifier of the target user |
||
1415 | * @param null|integer $untilDate Date when restrictions will be lifted for the user, unix time. |
||
1416 | * If user is restricted for more than 366 days or less than 30 seconds from the current time, |
||
1417 | * they are considered to be restricted forever |
||
1418 | * @param bool $canSendMessages Pass True, if the user can send text messages, contacts, locations and venues |
||
1419 | * @param bool $canSendMediaMessages No Pass True, if the user can send audios, documents, photos, videos, |
||
1420 | * video notes and voice notes, implies can_send_messages |
||
1421 | * @param bool $canSendOtherMessages Pass True, if the user can send animations, games, stickers and |
||
1422 | * use inline bots, implies can_send_media_messages |
||
1423 | * @param bool $canAddWebPagePreviews Pass True, if the user may add web page previews to their messages, |
||
1424 | * implies can_send_media_messages |
||
1425 | * |
||
1426 | * @return bool |
||
1427 | */ |
||
1428 | public function restrictChatMember( |
||
1447 | |||
1448 | /** |
||
1449 | * Use this method to promote or demote a user in a supergroup or a channel. |
||
1450 | * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
||
1451 | * Pass False for all boolean parameters to demote a user. |
||
1452 | * |
||
1453 | * @param string|int $chatId Unique identifier for the target chat or username of the target supergroup |
||
1454 | * (in the format @supergroupusername) |
||
1455 | * @param int $userId Unique identifier of the target user |
||
1456 | * @param bool $canChangeInfo Pass True, if the administrator can change chat title, photo and other settings |
||
1457 | * @param bool $canPostMessages Pass True, if the administrator can create channel posts, channels only |
||
1458 | * @param bool $canEditMessages Pass True, if the administrator can edit messages of other users, channels only |
||
1459 | * @param bool $canDeleteMessages Pass True, if the administrator can delete messages of other users |
||
1460 | * @param bool $canInviteUsers Pass True, if the administrator can invite new users to the chat |
||
1461 | * @param bool $canRestrictMembers Pass True, if the administrator can restrict, ban or unban chat members |
||
1462 | * @param bool $canPinMessages Pass True, if the administrator can pin messages, supergroups only |
||
1463 | * @param bool $canPromoteMembers Pass True, if the administrator can add new administrators with a subset of his |
||
1464 | * own privileges or demote administrators that he has promoted,directly or |
||
1465 | * indirectly (promoted by administrators that were appointed by him) |
||
1466 | * |
||
1467 | * @return bool |
||
1468 | */ |
||
1469 | public function promoteChatMember( |
||
1494 | |||
1495 | /** |
||
1496 | * Use this method to export an invite link to a supergroup or a channel. |
||
1497 | * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
||
1498 | * |
||
1499 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
1500 | * (in the format @channelusername) |
||
1501 | * @return string |
||
1502 | */ |
||
1503 | public function exportChatInviteLink($chatId) |
||
1509 | |||
1510 | /** |
||
1511 | * Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. |
||
1512 | * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
||
1513 | * |
||
1514 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
1515 | * (in the format @channelusername) |
||
1516 | * @param \CURLFile|string $photo New chat photo, uploaded using multipart/form-data |
||
1517 | * |
||
1518 | * @return bool |
||
1519 | */ |
||
1520 | public function setChatPhoto($chatId, $photo) |
||
1527 | |||
1528 | /** |
||
1529 | * Use this method to delete a chat photo. Photos can't be changed for private chats. |
||
1530 | * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
||
1531 | * |
||
1532 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
1533 | * (in the format @channelusername) |
||
1534 | * |
||
1535 | * @return bool |
||
1536 | */ |
||
1537 | public function deleteChatPhoto($chatId) |
||
1543 | |||
1544 | /** |
||
1545 | * Use this method to change the title of a chat. Titles can't be changed for private chats. |
||
1546 | * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
||
1547 | * |
||
1548 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
1549 | * (in the format @channelusername) |
||
1550 | * @param string $title New chat title, 1-255 characters |
||
1551 | * |
||
1552 | * @return bool |
||
1553 | */ |
||
1554 | public function setChatTitle($chatId, $title) |
||
1561 | |||
1562 | /** |
||
1563 | * Use this method to change the description of a supergroup or a channel. |
||
1564 | * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
||
1565 | * |
||
1566 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
1567 | * (in the format @channelusername) |
||
1568 | * @param string|null $description New chat description, 0-255 characters |
||
1569 | * |
||
1570 | * @return bool |
||
1571 | */ |
||
1572 | public function setChatDescription($chatId, $description = null) |
||
1579 | |||
1580 | /** |
||
1581 | * Use this method to pin a message in a supergroup. |
||
1582 | * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
||
1583 | * |
||
1584 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
1585 | * (in the format @channelusername) |
||
1586 | * @param int $messageId Identifier of a message to pin |
||
1587 | * @param bool $disableNotification |
||
1588 | * |
||
1589 | * @return bool |
||
1590 | */ |
||
1591 | public function pinChatMessage($chatId, $messageId, $disableNotification = false) |
||
1599 | |||
1600 | /** |
||
1601 | * Use this method to unpin a message in a supergroup chat. |
||
1602 | * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
||
1603 | * |
||
1604 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
1605 | * (in the format @channelusername) |
||
1606 | * |
||
1607 | * @return bool |
||
1608 | */ |
||
1609 | public function unpinChatMessage($chatId) |
||
1615 | |||
1616 | /** |
||
1617 | * Use this method to get up to date information about the chat |
||
1618 | * (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). |
||
1619 | * |
||
1620 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
1621 | * (in the format @channelusername) |
||
1622 | * |
||
1623 | * @return Chat |
||
1624 | */ |
||
1625 | public function getChat($chatId) |
||
1631 | |||
1632 | /** |
||
1633 | * Use this method to get information about a member of a chat. |
||
1634 | * |
||
1635 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
1636 | * (in the format @channelusername) |
||
1637 | * @param int $userId |
||
1638 | * |
||
1639 | * @return ChatMember |
||
1640 | */ |
||
1641 | public function getChatMember($chatId, $userId) |
||
1648 | |||
1649 | /** |
||
1650 | * Use this method for your bot to leave a group, supergroup or channel. |
||
1651 | * |
||
1652 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
1653 | * (in the format @channelusername) |
||
1654 | * |
||
1655 | * @return bool |
||
1656 | */ |
||
1657 | public function leaveChat($chatId) |
||
1663 | |||
1664 | /** |
||
1665 | * Use this method to get the number of members in a chat. |
||
1666 | * |
||
1667 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
1668 | * (in the format @channelusername) |
||
1669 | * |
||
1670 | * @return int |
||
1671 | */ |
||
1672 | public function getChatMembersCount($chatId) |
||
1681 | |||
1682 | /** |
||
1683 | * Use this method to get a list of administrators in a chat. |
||
1684 | * |
||
1685 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
1686 | * (in the format @channelusername) |
||
1687 | * |
||
1688 | * @return array |
||
1689 | */ |
||
1690 | public function getChatAdministrators($chatId) |
||
1701 | |||
1702 | /** |
||
1703 | * As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long. |
||
1704 | * Use this method to send video messages. |
||
1705 | * On success, the sent Message is returned. |
||
1706 | * |
||
1707 | * @param int|string $chatId chat_id or @channel_name |
||
1708 | * @param \CURLFile|string $videoNote |
||
1709 | * @param int|null $duration |
||
1710 | * @param int|null $length |
||
1711 | * @param int|null $replyToMessageId |
||
1712 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
1713 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
1714 | * @param bool $disableNotification |
||
1715 | * |
||
1716 | * @return \TelegramBot\Api\Types\Message |
||
1717 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
1718 | * @throws \TelegramBot\Api\Exception |
||
1719 | */ |
||
1720 | public function sendVideoNote( |
||
1739 | |||
1740 | /** |
||
1741 | * Use this method to send a group of photos or videos as an album. |
||
1742 | * On success, the sent \TelegramBot\Api\Types\Message is returned. |
||
1743 | * |
||
1744 | * @param int|string $chatId |
||
1745 | * @param ArrayOfInputMedia $media |
||
1746 | * @param int|null $replyToMessageId |
||
1747 | * @param bool $disableNotification |
||
1748 | * |
||
1749 | * @return array |
||
1750 | * @throws \TelegramBot\Api\Exception |
||
1751 | */ |
||
1752 | public function sendMediaGroup( |
||
1765 | |||
1766 | /** |
||
1767 | * Enable proxy for curl requests. Empty string will disable proxy. |
||
1768 | * |
||
1769 | * @param string $proxyString |
||
1770 | * |
||
1771 | * @return BotApi |
||
1772 | */ |
||
1773 | public function setProxy($proxyString = '', $socks5 = false) |
||
1790 | |||
1791 | |||
1792 | /** |
||
1793 | * Use this method to send a native poll. A native poll can't be sent to a private chat. |
||
1794 | * On success, the sent \TelegramBot\Api\Types\Message is returned. |
||
1795 | * |
||
1796 | * @param $chatId string|int Unique identifier for the target chat or username of the target channel |
||
1797 | * (in the format @channelusername) |
||
1798 | * @param string $question Poll question, 1-255 characters |
||
1799 | * @param array $options A JSON-serialized list of answer options, 2-10 strings 1-100 characters each |
||
1800 | * @param bool $isAnonymous True, if the poll needs to be anonymous, defaults to True |
||
1801 | * @param null $type Poll type, “quiz” or “regular”, defaults to “regular” |
||
1802 | * @param bool $allowsMultipleAnswers True, if the poll allows multiple answers, |
||
1803 | * ignored for polls in quiz mode, defaults to False |
||
1804 | * @param null $correctOptionId 0-based identifier of the correct answer option, required for polls in quiz mode |
||
1805 | * @param bool $isClosed Pass True, if the poll needs to be immediately closed. This can be useful for poll preview. |
||
1806 | * @param bool $disableNotification Sends the message silently. Users will receive a notification with no sound. |
||
1807 | * @param int|null $replyToMessageId If the message is a reply, ID of the original message |
||
1808 | * @param null $replyMarkup Additional interface options. A JSON-serialized object for an inline keyboard, |
||
1809 | * custom reply keyboard, instructions to remove reply |
||
1810 | * keyboard or to force a reply from the user. |
||
1811 | * |
||
1812 | * @return \TelegramBot\Api\Types\Message |
||
1813 | * @throws Exception |
||
1814 | * @throws HttpException |
||
1815 | * @throws InvalidJsonException |
||
1816 | */ |
||
1817 | public function sendPoll( |
||
1844 | |||
1845 | /** |
||
1846 | * Use this method to send a dice, which will have a random value from 1 to 6. |
||
1847 | * On success, the sent Message is returned. (Yes, we're aware of the “proper” singular of die. |
||
1848 | * But it's awkward, and we decided to help it change. One dice at a time!) |
||
1849 | * |
||
1850 | * @param $chatId string|int Unique identifier for the target chat or username of the target channel |
||
1851 | * (in the format @channelusername) |
||
1852 | * @param bool $disableNotification Sends the message silently. Users will receive a notification with no sound. |
||
1853 | * @param null $replyToMessageId If the message is a reply, ID of the original message |
||
1854 | * @param null $replyMarkup Additional interface options. A JSON-serialized object for an inline keyboard, |
||
1855 | * custom reply keyboard, instructions to remove reply |
||
1856 | * keyboard or to force a reply from the user. |
||
1857 | * @return bool|Message |
||
1858 | * @throws Exception |
||
1859 | * @throws HttpException |
||
1860 | * @throws InvalidJsonException |
||
1861 | */ |
||
1862 | View Code Duplication | public function sendDice( |
|
1875 | |||
1876 | /** |
||
1877 | * Use this method to stop a poll which was sent by the bot. |
||
1878 | * On success, the stopped \TelegramBot\Api\Types\Poll with the final results is returned. |
||
1879 | * |
||
1880 | * @param int|string $chatId |
||
1881 | * @param int $messageId |
||
1882 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
1883 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
1884 | * @return Poll |
||
1885 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
1886 | * @throws \TelegramBot\Api\Exception |
||
1887 | */ |
||
1888 | public function stopPoll( |
||
1899 | |||
1900 | /** |
||
1901 | * Set an option for a cURL transfer |
||
1902 | * |
||
1903 | * @param int $option The CURLOPT_XXX option to set |
||
1904 | * @param mixed $value The value to be set on option |
||
1905 | */ |
||
1906 | public function setCurlOption($option, $value) |
||
1910 | |||
1911 | /** |
||
1912 | * Unset an option for a cURL transfer |
||
1913 | * |
||
1914 | * @param int $option The CURLOPT_XXX option to unset |
||
1915 | */ |
||
1916 | public function unsetCurlOption($option) |
||
1920 | |||
1921 | /** |
||
1922 | * Clean custom options |
||
1923 | */ |
||
1924 | public function resetCurlOptions() |
||
1928 | } |
||
1929 |
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.