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 |
||
28 | class BotApi |
||
29 | { |
||
30 | /** |
||
31 | * HTTP codes |
||
32 | * |
||
33 | * @var array |
||
34 | */ |
||
35 | public static $codes = [ |
||
36 | // Informational 1xx |
||
37 | 100 => 'Continue', |
||
38 | 101 => 'Switching Protocols', |
||
39 | 102 => 'Processing', // RFC2518 |
||
40 | // Success 2xx |
||
41 | 200 => 'OK', |
||
42 | 201 => 'Created', |
||
43 | 202 => 'Accepted', |
||
44 | 203 => 'Non-Authoritative Information', |
||
45 | 204 => 'No Content', |
||
46 | 205 => 'Reset Content', |
||
47 | 206 => 'Partial Content', |
||
48 | 207 => 'Multi-Status', // RFC4918 |
||
49 | 208 => 'Already Reported', // RFC5842 |
||
50 | 226 => 'IM Used', // RFC3229 |
||
51 | // Redirection 3xx |
||
52 | 300 => 'Multiple Choices', |
||
53 | 301 => 'Moved Permanently', |
||
54 | 302 => 'Found', // 1.1 |
||
55 | 303 => 'See Other', |
||
56 | 304 => 'Not Modified', |
||
57 | 305 => 'Use Proxy', |
||
58 | // 306 is deprecated but reserved |
||
59 | 307 => 'Temporary Redirect', |
||
60 | 308 => 'Permanent Redirect', // RFC7238 |
||
61 | // Client Error 4xx |
||
62 | 400 => 'Bad Request', |
||
63 | 401 => 'Unauthorized', |
||
64 | 402 => 'Payment Required', |
||
65 | 403 => 'Forbidden', |
||
66 | 404 => 'Not Found', |
||
67 | 405 => 'Method Not Allowed', |
||
68 | 406 => 'Not Acceptable', |
||
69 | 407 => 'Proxy Authentication Required', |
||
70 | 408 => 'Request Timeout', |
||
71 | 409 => 'Conflict', |
||
72 | 410 => 'Gone', |
||
73 | 411 => 'Length Required', |
||
74 | 412 => 'Precondition Failed', |
||
75 | 413 => 'Payload Too Large', |
||
76 | 414 => 'URI Too Long', |
||
77 | 415 => 'Unsupported Media Type', |
||
78 | 416 => 'Range Not Satisfiable', |
||
79 | 417 => 'Expectation Failed', |
||
80 | 422 => 'Unprocessable Entity', // RFC4918 |
||
81 | 423 => 'Locked', // RFC4918 |
||
82 | 424 => 'Failed Dependency', // RFC4918 |
||
83 | 425 => 'Reserved for WebDAV advanced collections expired proposal', // RFC2817 |
||
84 | 426 => 'Upgrade Required', // RFC2817 |
||
85 | 428 => 'Precondition Required', // RFC6585 |
||
86 | 429 => 'Too Many Requests', // RFC6585 |
||
87 | 431 => 'Request Header Fields Too Large', // RFC6585 |
||
88 | // Server Error 5xx |
||
89 | 500 => 'Internal Server Error', |
||
90 | 501 => 'Not Implemented', |
||
91 | 502 => 'Bad Gateway', |
||
92 | 503 => 'Service Unavailable', |
||
93 | 504 => 'Gateway Timeout', |
||
94 | 505 => 'HTTP Version Not Supported', |
||
95 | 506 => 'Variant Also Negotiates (Experimental)', // RFC2295 |
||
96 | 507 => 'Insufficient Storage', // RFC4918 |
||
97 | 508 => 'Loop Detected', // RFC5842 |
||
98 | 510 => 'Not Extended', // RFC2774 |
||
99 | 511 => 'Network Authentication Required', // RFC6585 |
||
100 | ]; |
||
101 | |||
102 | private $proxySettings = []; |
||
103 | |||
104 | /** |
||
105 | * Default http status code |
||
106 | */ |
||
107 | const DEFAULT_STATUS_CODE = 200; |
||
108 | |||
109 | /** |
||
110 | * Not Modified http status code |
||
111 | */ |
||
112 | const NOT_MODIFIED_STATUS_CODE = 304; |
||
113 | |||
114 | /** |
||
115 | * Limits for tracked ids |
||
116 | */ |
||
117 | const MAX_TRACKED_EVENTS = 200; |
||
118 | |||
119 | /** |
||
120 | * Url prefixes |
||
121 | */ |
||
122 | const URL_PREFIX = 'https://api.telegram.org/bot'; |
||
123 | |||
124 | /** |
||
125 | * Url prefix for files |
||
126 | */ |
||
127 | const FILE_URL_PREFIX = 'https://api.telegram.org/file/bot'; |
||
128 | |||
129 | /** |
||
130 | * CURL object |
||
131 | * |
||
132 | * @var |
||
133 | */ |
||
134 | protected $curl; |
||
135 | |||
136 | /** |
||
137 | * CURL custom options |
||
138 | * |
||
139 | * @var array |
||
140 | */ |
||
141 | protected $customCurlOptions = []; |
||
142 | |||
143 | /** |
||
144 | * Bot token |
||
145 | * |
||
146 | * @var string |
||
147 | */ |
||
148 | protected $token; |
||
149 | |||
150 | /** |
||
151 | * Botan tracker |
||
152 | * |
||
153 | * @var \TelegramBot\Api\Botan |
||
154 | */ |
||
155 | protected $tracker; |
||
156 | |||
157 | /** |
||
158 | * list of event ids |
||
159 | * |
||
160 | * @var array |
||
161 | */ |
||
162 | protected $trackedEvents = []; |
||
163 | |||
164 | /** |
||
165 | * Check whether return associative array |
||
166 | * |
||
167 | * @var bool |
||
168 | */ |
||
169 | protected $returnArray = true; |
||
170 | |||
171 | /** |
||
172 | * Constructor |
||
173 | * |
||
174 | * @param string $token Telegram Bot API token |
||
175 | * @param string|null $trackerToken Yandex AppMetrica application api_key |
||
176 | */ |
||
177 | 9 | public function __construct($token, $trackerToken = null) |
|
186 | |||
187 | /** |
||
188 | * Set return array |
||
189 | * |
||
190 | * @param bool $mode |
||
191 | * |
||
192 | * @return $this |
||
193 | */ |
||
194 | public function setModeObject($mode = true) |
||
200 | |||
201 | |||
202 | /** |
||
203 | * Call method |
||
204 | * |
||
205 | * @param string $method |
||
206 | * @param array|null $data |
||
207 | * |
||
208 | * @return mixed |
||
209 | * @throws \TelegramBot\Api\Exception |
||
210 | * @throws \TelegramBot\Api\HttpException |
||
211 | * @throws \TelegramBot\Api\InvalidJsonException |
||
212 | */ |
||
213 | public function call($method, array $data = null) |
||
248 | |||
249 | /** |
||
250 | * curl_exec wrapper for response validation |
||
251 | * |
||
252 | * @param array $options |
||
253 | * |
||
254 | * @return string |
||
255 | * |
||
256 | * @throws \TelegramBot\Api\HttpException |
||
257 | */ |
||
258 | protected function executeCurl(array $options) |
||
270 | |||
271 | /** |
||
272 | * Response validation |
||
273 | * |
||
274 | * @param resource $curl |
||
275 | * @param string $response |
||
276 | * @throws HttpException |
||
277 | */ |
||
278 | public static function curlValidate($curl, $response = null) |
||
289 | |||
290 | /** |
||
291 | * JSON validation |
||
292 | * |
||
293 | * @param string $jsonString |
||
294 | * @param boolean $asArray |
||
295 | * |
||
296 | * @return object|array |
||
297 | * @throws \TelegramBot\Api\InvalidJsonException |
||
298 | */ |
||
299 | public static function jsonValidate($jsonString, $asArray) |
||
309 | |||
310 | /** |
||
311 | * Use this method to send text messages. On success, the sent \TelegramBot\Api\Types\Message is returned. |
||
312 | * |
||
313 | * @param int|string $chatId |
||
314 | * @param string $text |
||
315 | * @param string|null $parseMode |
||
316 | * @param bool $disablePreview |
||
317 | * @param int|null $replyToMessageId |
||
318 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
319 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
320 | * @param bool $disableNotification |
||
321 | * |
||
322 | * @return \TelegramBot\Api\Types\Message |
||
323 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
324 | * @throws \TelegramBot\Api\Exception |
||
325 | */ |
||
326 | public function sendMessage( |
||
345 | |||
346 | /** |
||
347 | * @param int|string $chatId |
||
348 | * @param int|string $fromChatId |
||
349 | * @param int $messageId |
||
350 | * @param string|null $caption |
||
351 | * @param string|null $parseMode |
||
352 | * @param ArrayOfMessageEntity|null $captionEntities |
||
353 | * @param bool $disableNotification |
||
354 | * @param int|null $replyToMessageId |
||
355 | * @param bool $allowSendingWithoutReply |
||
356 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
357 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
358 | * |
||
359 | * @return Message |
||
360 | * @throws Exception |
||
361 | * @throws HttpException |
||
362 | * @throws InvalidJsonException |
||
363 | */ |
||
364 | View Code Duplication | public function copyMessage( |
|
389 | |||
390 | /** |
||
391 | * Use this method to send phone contacts |
||
392 | * |
||
393 | * @param int|string $chatId chat_id or @channel_name |
||
394 | * @param string $phoneNumber |
||
395 | * @param string $firstName |
||
396 | * @param string $lastName |
||
397 | * @param int|null $replyToMessageId |
||
398 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
399 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
400 | * @param bool $disableNotification |
||
401 | * |
||
402 | * @return \TelegramBot\Api\Types\Message |
||
403 | * @throws \TelegramBot\Api\Exception |
||
404 | */ |
||
405 | public function sendContact( |
||
424 | |||
425 | /** |
||
426 | * Use this method when you need to tell the user that something is happening on the bot's side. |
||
427 | * The status is set for 5 seconds or less (when a message arrives from your bot, |
||
428 | * Telegram clients clear its typing status). |
||
429 | * |
||
430 | * We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive. |
||
431 | * |
||
432 | * Type of action to broadcast. Choose one, depending on what the user is about to receive: |
||
433 | * `typing` for text messages, `upload_photo` for photos, `record_video` or `upload_video` for videos, |
||
434 | * `record_audio` or upload_audio for audio files, `upload_document` for general files, |
||
435 | * `find_location` for location data. |
||
436 | * |
||
437 | * @param int $chatId |
||
438 | * @param string $action |
||
439 | * |
||
440 | * @return bool |
||
441 | * @throws \TelegramBot\Api\Exception |
||
442 | */ |
||
443 | public function sendChatAction($chatId, $action) |
||
450 | |||
451 | /** |
||
452 | * Use this method to get a list of profile pictures for a user. |
||
453 | * |
||
454 | * @param int $userId |
||
455 | * @param int $offset |
||
456 | * @param int $limit |
||
457 | * |
||
458 | * @return \TelegramBot\Api\Types\UserProfilePhotos |
||
459 | * @throws \TelegramBot\Api\Exception |
||
460 | */ |
||
461 | public function getUserProfilePhotos($userId, $offset = 0, $limit = 100) |
||
469 | |||
470 | /** |
||
471 | * Use this method to specify a url and receive incoming updates via an outgoing webhook. |
||
472 | * Whenever there is an update for the bot, we will send an HTTPS POST request to the specified url, |
||
473 | * containing a JSON-serialized Update. |
||
474 | * In case of an unsuccessful request, we will give up after a reasonable amount of attempts. |
||
475 | * |
||
476 | * @param string $url HTTPS url to send updates to. Use an empty string to remove webhook integration |
||
477 | * @param \CURLFile|string $certificate Upload your public key certificate |
||
478 | * so that the root certificate in use can be checked |
||
479 | * |
||
480 | * @return string |
||
481 | * |
||
482 | * @throws \TelegramBot\Api\Exception |
||
483 | */ |
||
484 | public function setWebhook($url = '', $certificate = null) |
||
488 | |||
489 | |||
490 | /** |
||
491 | * Use this method to clear webhook and use getUpdates again! |
||
492 | * |
||
493 | * @return mixed |
||
494 | * |
||
495 | * @throws \TelegramBot\Api\Exception |
||
496 | */ |
||
497 | public function deleteWebhook() |
||
501 | |||
502 | /** |
||
503 | * Use this method to get current webhook status. Requires no parameters. |
||
504 | * On success, returns a WebhookInfo object. If the bot is using getUpdates, |
||
505 | * will return an object with the url field empty. |
||
506 | * |
||
507 | * @return \TelegramBot\Api\Types\WebhookInfo |
||
508 | * @throws \TelegramBot\Api\Exception |
||
509 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
510 | */ |
||
511 | public function getWebhookInfo() |
||
515 | |||
516 | /** |
||
517 | * A simple method for testing your bot's auth token.Requires no parameters. |
||
518 | * Returns basic information about the bot in form of a User object. |
||
519 | * |
||
520 | * @return \TelegramBot\Api\Types\User |
||
521 | * @throws \TelegramBot\Api\Exception |
||
522 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
523 | */ |
||
524 | public function getMe() |
||
528 | |||
529 | /** |
||
530 | * Use this method to receive incoming updates using long polling. |
||
531 | * An Array of Update objects is returned. |
||
532 | * |
||
533 | * Notes |
||
534 | * 1. This method will not work if an outgoing webhook is set up. |
||
535 | * 2. In order to avoid getting duplicate updates, recalculate offset after each server response. |
||
536 | * |
||
537 | * @param int $offset |
||
538 | * @param int $limit |
||
539 | * @param int $timeout |
||
540 | * |
||
541 | * @return Update[] |
||
542 | * @throws \TelegramBot\Api\Exception |
||
543 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
544 | */ |
||
545 | 2 | public function getUpdates($offset = 0, $limit = 100, $timeout = 0) |
|
561 | |||
562 | /** |
||
563 | * Use this method to send point on the map. On success, the sent Message is returned. |
||
564 | * |
||
565 | * @param int|string $chatId |
||
566 | * @param float $latitude |
||
567 | * @param float $longitude |
||
568 | * @param int|null $replyToMessageId |
||
569 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
570 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
571 | * @param bool $disableNotification |
||
572 | * |
||
573 | * @param null|int $livePeriod |
||
574 | * @return \TelegramBot\Api\Types\Message |
||
575 | */ |
||
576 | public function sendLocation( |
||
595 | |||
596 | /** |
||
597 | * Use this method to edit live location messages sent by the bot or via the bot (for inline bots). |
||
598 | * |
||
599 | * @param int|string $chatId |
||
600 | * @param int $messageId |
||
601 | * @param string $inlineMessageId |
||
602 | * @param float $latitude |
||
603 | * @param float $longitude |
||
604 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
605 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
606 | * @return \TelegramBot\Api\Types\Message |
||
607 | */ |
||
608 | public function editMessageLiveLocation( |
||
625 | |||
626 | /** |
||
627 | * Use this method to stop updating a live location message sent by the bot or via the bot (for inline bots) before |
||
628 | * live_period expires. |
||
629 | * |
||
630 | * @param int|string $chatId |
||
631 | * @param int $messageId |
||
632 | * @param string $inlineMessageId |
||
633 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
634 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
635 | * @return \TelegramBot\Api\Types\Message |
||
636 | */ |
||
637 | public function stopMessageLiveLocation( |
||
650 | |||
651 | /** |
||
652 | * Use this method to send information about a venue. On success, the sent Message is returned. |
||
653 | * |
||
654 | * @param int|string $chatId chat_id or @channel_name |
||
655 | * @param float $latitude |
||
656 | * @param float $longitude |
||
657 | * @param string $title |
||
658 | * @param string $address |
||
659 | * @param string|null $foursquareId |
||
660 | * @param int|null $replyToMessageId |
||
661 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
662 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
663 | * @param bool $disableNotification |
||
664 | * |
||
665 | * @return \TelegramBot\Api\Types\Message |
||
666 | * @throws \TelegramBot\Api\Exception |
||
667 | */ |
||
668 | public function sendVenue( |
||
691 | |||
692 | /** |
||
693 | * Use this method to send .webp stickers. On success, the sent Message is returned. |
||
694 | * |
||
695 | * @param int|string $chatId chat_id or @channel_name |
||
696 | * @param \CURLFile|string $sticker |
||
697 | * @param int|null $replyToMessageId |
||
698 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
699 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
700 | * @param bool $disableNotification |
||
701 | * |
||
702 | * @return \TelegramBot\Api\Types\Message |
||
703 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
704 | * @throws \TelegramBot\Api\Exception |
||
705 | */ |
||
706 | View Code Duplication | public function sendSticker( |
|
721 | |||
722 | /** |
||
723 | * Use this method to send video files, |
||
724 | * Telegram clients support mp4 videos (other formats may be sent as Document). |
||
725 | * On success, the sent Message is returned. |
||
726 | * |
||
727 | * @param int|string $chatId chat_id or @channel_name |
||
728 | * @param \CURLFile|string $video |
||
729 | * @param int|null $duration |
||
730 | * @param string|null $caption |
||
731 | * @param int|null $replyToMessageId |
||
732 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
733 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
734 | * @param bool $disableNotification |
||
735 | * @param bool $supportsStreaming Pass True, if the uploaded video is suitable for streaming |
||
736 | * @param string|null $parseMode |
||
737 | * |
||
738 | * @return \TelegramBot\Api\Types\Message |
||
739 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
740 | * @throws \TelegramBot\Api\Exception |
||
741 | */ |
||
742 | View Code Duplication | public function sendVideo( |
|
765 | |||
766 | /** |
||
767 | * Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound), |
||
768 | * On success, the sent Message is returned. |
||
769 | * Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future. |
||
770 | * |
||
771 | * @param int|string $chatId chat_id or @channel_name |
||
772 | * @param \CURLFile|string $animation |
||
773 | * @param int|null $duration |
||
774 | * @param string|null $caption |
||
775 | * @param int|null $replyToMessageId |
||
776 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
777 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
778 | * @param bool $disableNotification |
||
779 | * @param string|null $parseMode |
||
780 | * |
||
781 | * @return \TelegramBot\Api\Types\Message |
||
782 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
783 | * @throws \TelegramBot\Api\Exception |
||
784 | */ |
||
785 | public function sendAnimation( |
||
806 | |||
807 | /** |
||
808 | * Use this method to send audio files, |
||
809 | * if you want Telegram clients to display the file as a playable voice message. |
||
810 | * For this to work, your audio must be in an .ogg file encoded with OPUS |
||
811 | * (other formats may be sent as Audio or Document). |
||
812 | * On success, the sent Message is returned. |
||
813 | * Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future. |
||
814 | * |
||
815 | * @param int|string $chatId chat_id or @channel_name |
||
816 | * @param \CURLFile|string $voice |
||
817 | * @param string $caption Voice message caption, 0-1024 characters after entities parsing |
||
818 | * @param int|null $duration |
||
819 | * @param int|null $replyToMessageId |
||
820 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
821 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
822 | * @param bool $disableNotification |
||
823 | * @param bool $allowSendingWithoutReply Pass True, if the message should be sent even if the specified |
||
824 | * replied-to message is not found |
||
825 | * @param string|null $parseMode |
||
826 | * |
||
827 | * @return \TelegramBot\Api\Types\Message |
||
828 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
829 | * @throws \TelegramBot\Api\Exception |
||
830 | */ |
||
831 | View Code Duplication | public function sendVoice( |
|
854 | |||
855 | /** |
||
856 | * Use this method to forward messages of any kind. On success, the sent Message is returned. |
||
857 | * |
||
858 | * @param int|string $chatId chat_id or @channel_name |
||
859 | * @param int $fromChatId |
||
860 | * @param int $messageId |
||
861 | * @param bool $disableNotification |
||
862 | * |
||
863 | * @return \TelegramBot\Api\Types\Message |
||
864 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
865 | * @throws \TelegramBot\Api\Exception |
||
866 | */ |
||
867 | public function forwardMessage($chatId, $fromChatId, $messageId, $disableNotification = false) |
||
876 | |||
877 | /** |
||
878 | * Use this method to send audio files, |
||
879 | * if you want Telegram clients to display them in the music player. |
||
880 | * Your audio must be in the .mp3 format. |
||
881 | * On success, the sent Message is returned. |
||
882 | * Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future. |
||
883 | * |
||
884 | * For backward compatibility, when the fields title and performer are both empty |
||
885 | * and the mime-type of the file to be sent is not audio/mpeg, the file will be sent as a playable voice message. |
||
886 | * For this to work, the audio must be in an .ogg file encoded with OPUS. |
||
887 | * This behavior will be phased out in the future. For sending voice messages, use the sendVoice method instead. |
||
888 | * |
||
889 | * @deprecated since 20th February. Removed backward compatibility from the method sendAudio. |
||
890 | * Voice messages now must be sent using the method sendVoice. |
||
891 | * There is no more need to specify a non-empty title or performer while sending the audio by file_id. |
||
892 | * |
||
893 | * @param int|string $chatId chat_id or @channel_name |
||
894 | * @param \CURLFile|string $audio |
||
895 | * @param int|null $duration |
||
896 | * @param string|null $performer |
||
897 | * @param string|null $title |
||
898 | * @param int|null $replyToMessageId |
||
899 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
900 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
901 | * @param bool $disableNotification |
||
902 | * @param string|null $parseMode |
||
903 | * |
||
904 | * @return \TelegramBot\Api\Types\Message |
||
905 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
906 | * @throws \TelegramBot\Api\Exception |
||
907 | */ |
||
908 | View Code Duplication | public function sendAudio( |
|
931 | |||
932 | /** |
||
933 | * Use this method to send photos. On success, the sent Message is returned. |
||
934 | * |
||
935 | * @param int|string $chatId chat_id or @channel_name |
||
936 | * @param \CURLFile|string $photo |
||
937 | * @param string|null $caption |
||
938 | * @param int|null $replyToMessageId |
||
939 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
940 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
941 | * @param bool $disableNotification |
||
942 | * @param string|null $parseMode |
||
943 | * |
||
944 | * @return \TelegramBot\Api\Types\Message |
||
945 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
946 | * @throws \TelegramBot\Api\Exception |
||
947 | */ |
||
948 | public function sendPhoto( |
||
967 | |||
968 | /** |
||
969 | * Use this method to send general files. On success, the sent Message is returned. |
||
970 | * Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future. |
||
971 | * |
||
972 | * @param int|string $chatId chat_id or @channel_name |
||
973 | * @param \CURLFile|string $document |
||
974 | * @param string|null $caption |
||
975 | * @param int|null $replyToMessageId |
||
976 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
977 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
978 | * @param bool $disableNotification |
||
979 | * @param string|null $parseMode |
||
980 | * |
||
981 | * @return \TelegramBot\Api\Types\Message |
||
982 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
983 | * @throws \TelegramBot\Api\Exception |
||
984 | */ |
||
985 | public function sendDocument( |
||
1004 | |||
1005 | /** |
||
1006 | * Use this method to get basic info about a file and prepare it for downloading. |
||
1007 | * For the moment, bots can download files of up to 20MB in size. |
||
1008 | * On success, a File object is returned. |
||
1009 | * The file can then be downloaded via the link https://api.telegram.org/file/bot<token>/<file_path>, |
||
1010 | * where <file_path> is taken from the response. |
||
1011 | * It is guaranteed that the link will be valid for at least 1 hour. |
||
1012 | * When the link expires, a new one can be requested by calling getFile again. |
||
1013 | * |
||
1014 | * @param $fileId |
||
1015 | * |
||
1016 | * @return \TelegramBot\Api\Types\File |
||
1017 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
1018 | * @throws \TelegramBot\Api\Exception |
||
1019 | */ |
||
1020 | public function getFile($fileId) |
||
1024 | |||
1025 | /** |
||
1026 | * Get file contents via cURL |
||
1027 | * |
||
1028 | * @param $fileId |
||
1029 | * |
||
1030 | * @return string |
||
1031 | * |
||
1032 | * @throws \TelegramBot\Api\HttpException |
||
1033 | */ |
||
1034 | public function downloadFile($fileId) |
||
1046 | |||
1047 | /** |
||
1048 | * Use this method to send answers to an inline query. On success, True is returned. |
||
1049 | * No more than 50 results per query are allowed. |
||
1050 | * |
||
1051 | * @param string $inlineQueryId |
||
1052 | * @param AbstractInlineQueryResult[] $results |
||
1053 | * @param int $cacheTime |
||
1054 | * @param bool $isPersonal |
||
1055 | * @param string $nextOffset |
||
1056 | * @param string $switchPmText |
||
1057 | * @param string $switchPmParameter |
||
1058 | * |
||
1059 | * @return mixed |
||
1060 | * @throws Exception |
||
1061 | */ |
||
1062 | public function answerInlineQuery( |
||
1086 | |||
1087 | /** |
||
1088 | * Use this method to kick a user from a group or a supergroup. |
||
1089 | * In the case of supergroups, the user will not be able to return to the group |
||
1090 | * on their own using invite links, etc., unless unbanned first. |
||
1091 | * The bot must be an administrator in the group for this to work. Returns True on success. |
||
1092 | * |
||
1093 | * @param int|string $chatId Unique identifier for the target group |
||
1094 | * or username of the target supergroup (in the format @supergroupusername) |
||
1095 | * @param int $userId Unique identifier of the target user |
||
1096 | * @param null|int $untilDate Date when the user will be unbanned, unix time. |
||
1097 | * If user is banned for more than 366 days or less than 30 seconds from the current time |
||
1098 | * they are considered to be banned forever |
||
1099 | * |
||
1100 | * @return bool |
||
1101 | */ |
||
1102 | public function kickChatMember($chatId, $userId, $untilDate = null) |
||
1110 | |||
1111 | /** |
||
1112 | * Use this method to unban a previously kicked user in a supergroup. |
||
1113 | * The user will not return to the group automatically, but will be able to join via link, etc. |
||
1114 | * The bot must be an administrator in the group for this to work. Returns True on success. |
||
1115 | * |
||
1116 | * @param int|string $chatId Unique identifier for the target group |
||
1117 | * or username of the target supergroup (in the format @supergroupusername) |
||
1118 | * @param int $userId Unique identifier of the target user |
||
1119 | * |
||
1120 | * @return bool |
||
1121 | */ |
||
1122 | public function unbanChatMember($chatId, $userId) |
||
1129 | |||
1130 | /** |
||
1131 | * Use this method to send answers to callback queries sent from inline keyboards. |
||
1132 | * The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. |
||
1133 | * |
||
1134 | * @param $callbackQueryId |
||
1135 | * @param null $text |
||
1136 | * @param bool $showAlert |
||
1137 | * |
||
1138 | * @return bool |
||
1139 | */ |
||
1140 | public function answerCallbackQuery($callbackQueryId, $text = null, $showAlert = false) |
||
1148 | |||
1149 | /** |
||
1150 | * Use this method to change the list of the bot's commands. Returns True on success. |
||
1151 | * |
||
1152 | * @param $commands |
||
1153 | * |
||
1154 | * @return mixed |
||
1155 | * @throws Exception |
||
1156 | * @throws HttpException |
||
1157 | * @throws InvalidJsonException |
||
1158 | */ |
||
1159 | public function setMyCommands($commands) |
||
1168 | |||
1169 | /** |
||
1170 | * Use this method to get the current list of the bot's commands. Requires no parameters. |
||
1171 | * Returns Array of BotCommand on success. |
||
1172 | * |
||
1173 | * @return mixed |
||
1174 | * @throws Exception |
||
1175 | * @throws HttpException |
||
1176 | * @throws InvalidJsonException |
||
1177 | */ |
||
1178 | public function getMyCommands() |
||
1182 | |||
1183 | /** |
||
1184 | * Use this method to edit text messages sent by the bot or via the bot |
||
1185 | * |
||
1186 | * @param int|string $chatId |
||
1187 | * @param int $messageId |
||
1188 | * @param string $text |
||
1189 | * @param string $inlineMessageId |
||
1190 | * @param string|null $parseMode |
||
1191 | * @param bool $disablePreview |
||
1192 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
1193 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
1194 | * @return Message |
||
1195 | */ |
||
1196 | public function editMessageText( |
||
1215 | |||
1216 | /** |
||
1217 | * Use this method to edit text messages sent by the bot or via the bot |
||
1218 | * |
||
1219 | * @param int|string $chatId |
||
1220 | * @param int $messageId |
||
1221 | * @param string|null $caption |
||
1222 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
1223 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
1224 | * @param string $inlineMessageId |
||
1225 | * @param string|null $parseMode |
||
1226 | * |
||
1227 | * @return \TelegramBot\Api\Types\Message |
||
1228 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
1229 | * @throws \TelegramBot\Api\Exception |
||
1230 | */ |
||
1231 | View Code Duplication | public function editMessageCaption( |
|
1248 | |||
1249 | /** |
||
1250 | * Use this method to edit animation, audio, document, photo, or video messages. |
||
1251 | * If a message is a part of a message album, then it can be edited only to a photo or a video. |
||
1252 | * Otherwise, message type can be changed arbitrarily. |
||
1253 | * When inline message is edited, new file can't be uploaded. |
||
1254 | * Use previously uploaded file via its file_id or specify a URL. |
||
1255 | * On success, if the edited message was sent by the bot, the edited Message is returned, otherwise True is returned |
||
1256 | * |
||
1257 | * @param $chatId |
||
1258 | * @param $messageId |
||
1259 | * @param InputMedia $media |
||
1260 | * @param null $inlineMessageId |
||
1261 | * @param null $replyMarkup |
||
1262 | * @return bool|Message |
||
1263 | * @throws Exception |
||
1264 | * @throws HttpException |
||
1265 | * @throws InvalidJsonException |
||
1266 | */ |
||
1267 | View Code Duplication | public function editMessageMedia( |
|
1282 | |||
1283 | /** |
||
1284 | * Use this method to edit only the reply markup of messages sent by the bot or via the bot |
||
1285 | * |
||
1286 | * @param int|string $chatId |
||
1287 | * @param int $messageId |
||
1288 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
1289 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
1290 | * @param string $inlineMessageId |
||
1291 | * |
||
1292 | * @return Message |
||
1293 | */ |
||
1294 | public function editMessageReplyMarkup( |
||
1307 | |||
1308 | /** |
||
1309 | * Use this method to delete a message, including service messages, with the following limitations: |
||
1310 | * - A message can only be deleted if it was sent less than 48 hours ago. |
||
1311 | * - Bots can delete outgoing messages in groups and supergroups. |
||
1312 | * - Bots granted can_post_messages permissions can delete outgoing messages in channels. |
||
1313 | * - If the bot is an administrator of a group, it can delete any message there. |
||
1314 | * - If the bot has can_delete_messages permission in a supergroup or a channel, it can delete any message there. |
||
1315 | * |
||
1316 | * @param int|string $chatId |
||
1317 | * @param int $messageId |
||
1318 | * |
||
1319 | * @return bool |
||
1320 | */ |
||
1321 | public function deleteMessage($chatId, $messageId) |
||
1328 | |||
1329 | /** |
||
1330 | * Close curl |
||
1331 | */ |
||
1332 | 9 | public function __destruct() |
|
1336 | |||
1337 | /** |
||
1338 | * @return string |
||
1339 | */ |
||
1340 | public function getUrl() |
||
1344 | |||
1345 | /** |
||
1346 | * @return string |
||
1347 | */ |
||
1348 | public function getFileUrl() |
||
1352 | |||
1353 | /** |
||
1354 | * @param \TelegramBot\Api\Types\Update $update |
||
1355 | * @param string $eventName |
||
1356 | * |
||
1357 | * @throws \TelegramBot\Api\Exception |
||
1358 | */ |
||
1359 | public function trackUpdate(Update $update, $eventName = 'Message') |
||
1371 | |||
1372 | /** |
||
1373 | * Wrapper for tracker |
||
1374 | * |
||
1375 | * @param \TelegramBot\Api\Types\Message $message |
||
1376 | * @param string $eventName |
||
1377 | * |
||
1378 | * @throws \TelegramBot\Api\Exception |
||
1379 | */ |
||
1380 | public function track(Message $message, $eventName = 'Message') |
||
1386 | |||
1387 | /** |
||
1388 | * Use this method to send invoices. On success, the sent Message is returned. |
||
1389 | * |
||
1390 | * @param int|string $chatId |
||
1391 | * @param string $title |
||
1392 | * @param string $description |
||
1393 | * @param string $payload |
||
1394 | * @param string $providerToken |
||
1395 | * @param string $startParameter |
||
1396 | * @param string $currency |
||
1397 | * @param array $prices |
||
1398 | * @param string|null $photoUrl |
||
1399 | * @param int|null $photoSize |
||
1400 | * @param int|null $photoWidth |
||
1401 | * @param int|null $photoHeight |
||
1402 | * @param bool $needName |
||
1403 | * @param bool $needPhoneNumber |
||
1404 | * @param bool $needEmail |
||
1405 | * @param bool $needShippingAddress |
||
1406 | * @param bool $isFlexible |
||
1407 | * @param int|null $replyToMessageId |
||
1408 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
1409 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
1410 | * @param bool $disableNotification |
||
1411 | * @param string|null $providerData |
||
1412 | * @param bool $sendPhoneNumberToProvider |
||
1413 | * @param bool $sendEmailToProvider |
||
1414 | * |
||
1415 | * @return Message |
||
1416 | */ |
||
1417 | public function sendInvoice( |
||
1468 | |||
1469 | /** |
||
1470 | * If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API |
||
1471 | * will send an Update with a shipping_query field to the bot. Use this method to reply to shipping queries. |
||
1472 | * On success, True is returned. |
||
1473 | * |
||
1474 | * @param string $shippingQueryId |
||
1475 | * @param bool $ok |
||
1476 | * @param array $shipping_options |
||
1477 | * @param null|string $errorMessage |
||
1478 | * |
||
1479 | * @return bool |
||
1480 | * |
||
1481 | */ |
||
1482 | public function answerShippingQuery($shippingQueryId, $ok = true, $shipping_options = [], $errorMessage = null) |
||
1491 | |||
1492 | /** |
||
1493 | * Use this method to respond to such pre-checkout queries. On success, True is returned. |
||
1494 | * Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent. |
||
1495 | * |
||
1496 | * @param string $preCheckoutQueryId |
||
1497 | * @param bool $ok |
||
1498 | * @param null|string $errorMessage |
||
1499 | * |
||
1500 | * @return mixed |
||
1501 | */ |
||
1502 | public function answerPreCheckoutQuery($preCheckoutQueryId, $ok = true, $errorMessage = null) |
||
1510 | |||
1511 | /** |
||
1512 | * Use this method to restrict a user in a supergroup. |
||
1513 | * The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights. |
||
1514 | * Pass True for all boolean parameters to lift restrictions from a user. |
||
1515 | * |
||
1516 | * @param string|int $chatId Unique identifier for the target chat or username of the target supergroup |
||
1517 | * (in the format @supergroupusername) |
||
1518 | * @param int $userId Unique identifier of the target user |
||
1519 | * @param null|integer $untilDate Date when restrictions will be lifted for the user, unix time. |
||
1520 | * If user is restricted for more than 366 days or less than 30 seconds from the current time, |
||
1521 | * they are considered to be restricted forever |
||
1522 | * @param bool $canSendMessages Pass True, if the user can send text messages, contacts, locations and venues |
||
1523 | * @param bool $canSendMediaMessages No Pass True, if the user can send audios, documents, photos, videos, |
||
1524 | * video notes and voice notes, implies can_send_messages |
||
1525 | * @param bool $canSendOtherMessages Pass True, if the user can send animations, games, stickers and |
||
1526 | * use inline bots, implies can_send_media_messages |
||
1527 | * @param bool $canAddWebPagePreviews Pass True, if the user may add web page previews to their messages, |
||
1528 | * implies can_send_media_messages |
||
1529 | * |
||
1530 | * @return bool |
||
1531 | */ |
||
1532 | public function restrictChatMember( |
||
1551 | |||
1552 | /** |
||
1553 | * Use this method to promote or demote a user in a supergroup or a channel. |
||
1554 | * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
||
1555 | * Pass False for all boolean parameters to demote a user. |
||
1556 | * |
||
1557 | * @param string|int $chatId Unique identifier for the target chat or username of the target supergroup |
||
1558 | * (in the format @supergroupusername) |
||
1559 | * @param int $userId Unique identifier of the target user |
||
1560 | * @param bool $canChangeInfo Pass True, if the administrator can change chat title, photo and other settings |
||
1561 | * @param bool $canPostMessages Pass True, if the administrator can create channel posts, channels only |
||
1562 | * @param bool $canEditMessages Pass True, if the administrator can edit messages of other users, channels only |
||
1563 | * @param bool $canDeleteMessages Pass True, if the administrator can delete messages of other users |
||
1564 | * @param bool $canInviteUsers Pass True, if the administrator can invite new users to the chat |
||
1565 | * @param bool $canRestrictMembers Pass True, if the administrator can restrict, ban or unban chat members |
||
1566 | * @param bool $canPinMessages Pass True, if the administrator can pin messages, supergroups only |
||
1567 | * @param bool $canPromoteMembers Pass True, if the administrator can add new administrators with a subset of his |
||
1568 | * own privileges or demote administrators that he has promoted,directly or |
||
1569 | * indirectly (promoted by administrators that were appointed by him) |
||
1570 | * |
||
1571 | * @return bool |
||
1572 | */ |
||
1573 | public function promoteChatMember( |
||
1598 | |||
1599 | /** |
||
1600 | * Use this method to export an invite link to a supergroup or a channel. |
||
1601 | * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
||
1602 | * |
||
1603 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
1604 | * (in the format @channelusername) |
||
1605 | * @return string |
||
1606 | */ |
||
1607 | public function exportChatInviteLink($chatId) |
||
1613 | |||
1614 | /** |
||
1615 | * Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. |
||
1616 | * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
||
1617 | * |
||
1618 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
1619 | * (in the format @channelusername) |
||
1620 | * @param \CURLFile|string $photo New chat photo, uploaded using multipart/form-data |
||
1621 | * |
||
1622 | * @return bool |
||
1623 | */ |
||
1624 | public function setChatPhoto($chatId, $photo) |
||
1631 | |||
1632 | /** |
||
1633 | * Use this method to delete a chat photo. Photos can't be changed for private chats. |
||
1634 | * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
||
1635 | * |
||
1636 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
1637 | * (in the format @channelusername) |
||
1638 | * |
||
1639 | * @return bool |
||
1640 | */ |
||
1641 | public function deleteChatPhoto($chatId) |
||
1647 | |||
1648 | /** |
||
1649 | * Use this method to change the title of a chat. Titles can't be changed for private chats. |
||
1650 | * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
||
1651 | * |
||
1652 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
1653 | * (in the format @channelusername) |
||
1654 | * @param string $title New chat title, 1-255 characters |
||
1655 | * |
||
1656 | * @return bool |
||
1657 | */ |
||
1658 | public function setChatTitle($chatId, $title) |
||
1665 | |||
1666 | /** |
||
1667 | * Use this method to change the description of a supergroup or a channel. |
||
1668 | * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
||
1669 | * |
||
1670 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
1671 | * (in the format @channelusername) |
||
1672 | * @param string|null $description New chat description, 0-255 characters |
||
1673 | * |
||
1674 | * @return bool |
||
1675 | */ |
||
1676 | public function setChatDescription($chatId, $description = null) |
||
1683 | |||
1684 | /** |
||
1685 | * Use this method to pin a message in a supergroup. |
||
1686 | * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
||
1687 | * |
||
1688 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
1689 | * (in the format @channelusername) |
||
1690 | * @param int $messageId Identifier of a message to pin |
||
1691 | * @param bool $disableNotification |
||
1692 | * |
||
1693 | * @return bool |
||
1694 | */ |
||
1695 | public function pinChatMessage($chatId, $messageId, $disableNotification = false) |
||
1703 | |||
1704 | /** |
||
1705 | * Use this method to unpin a message in a supergroup chat. |
||
1706 | * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
||
1707 | * |
||
1708 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
1709 | * (in the format @channelusername) |
||
1710 | * |
||
1711 | * @return bool |
||
1712 | */ |
||
1713 | public function unpinChatMessage($chatId) |
||
1719 | |||
1720 | /** |
||
1721 | * Use this method to get up to date information about the chat |
||
1722 | * (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). |
||
1723 | * |
||
1724 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
1725 | * (in the format @channelusername) |
||
1726 | * |
||
1727 | * @return Chat |
||
1728 | */ |
||
1729 | public function getChat($chatId) |
||
1735 | |||
1736 | /** |
||
1737 | * Use this method to get information about a member of a chat. |
||
1738 | * |
||
1739 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
1740 | * (in the format @channelusername) |
||
1741 | * @param int $userId |
||
1742 | * |
||
1743 | * @return ChatMember |
||
1744 | */ |
||
1745 | public function getChatMember($chatId, $userId) |
||
1752 | |||
1753 | /** |
||
1754 | * Use this method for your bot to leave a group, supergroup or channel. |
||
1755 | * |
||
1756 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
1757 | * (in the format @channelusername) |
||
1758 | * |
||
1759 | * @return bool |
||
1760 | */ |
||
1761 | public function leaveChat($chatId) |
||
1767 | |||
1768 | /** |
||
1769 | * Use this method to get the number of members in a chat. |
||
1770 | * |
||
1771 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
1772 | * (in the format @channelusername) |
||
1773 | * |
||
1774 | * @return int |
||
1775 | */ |
||
1776 | public function getChatMembersCount($chatId) |
||
1785 | |||
1786 | /** |
||
1787 | * Use this method to get a list of administrators in a chat. |
||
1788 | * |
||
1789 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
1790 | * (in the format @channelusername) |
||
1791 | * |
||
1792 | * @return array |
||
1793 | */ |
||
1794 | public function getChatAdministrators($chatId) |
||
1805 | |||
1806 | /** |
||
1807 | * As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long. |
||
1808 | * Use this method to send video messages. |
||
1809 | * On success, the sent Message is returned. |
||
1810 | * |
||
1811 | * @param int|string $chatId chat_id or @channel_name |
||
1812 | * @param \CURLFile|string $videoNote |
||
1813 | * @param int|null $duration |
||
1814 | * @param int|null $length |
||
1815 | * @param int|null $replyToMessageId |
||
1816 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
1817 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
1818 | * @param bool $disableNotification |
||
1819 | * |
||
1820 | * @return \TelegramBot\Api\Types\Message |
||
1821 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
1822 | * @throws \TelegramBot\Api\Exception |
||
1823 | */ |
||
1824 | public function sendVideoNote( |
||
1843 | |||
1844 | /** |
||
1845 | * Use this method to send a group of photos or videos as an album. |
||
1846 | * On success, the sent \TelegramBot\Api\Types\Message is returned. |
||
1847 | * |
||
1848 | * @param int|string $chatId |
||
1849 | * @param ArrayOfInputMedia $media |
||
1850 | * @param int|null $replyToMessageId |
||
1851 | * @param bool $disableNotification |
||
1852 | * |
||
1853 | * @return array |
||
1854 | * @throws \TelegramBot\Api\Exception |
||
1855 | */ |
||
1856 | public function sendMediaGroup( |
||
1869 | |||
1870 | /** |
||
1871 | * Enable proxy for curl requests. Empty string will disable proxy. |
||
1872 | * |
||
1873 | * @param string $proxyString |
||
1874 | * |
||
1875 | * @return BotApi |
||
1876 | */ |
||
1877 | public function setProxy($proxyString = '', $socks5 = false) |
||
1894 | |||
1895 | |||
1896 | /** |
||
1897 | * Use this method to send a native poll. A native poll can't be sent to a private chat. |
||
1898 | * On success, the sent \TelegramBot\Api\Types\Message is returned. |
||
1899 | * |
||
1900 | * @param $chatId string|int Unique identifier for the target chat or username of the target channel |
||
1901 | * (in the format @channelusername) |
||
1902 | * @param string $question Poll question, 1-255 characters |
||
1903 | * @param array $options A JSON-serialized list of answer options, 2-10 strings 1-100 characters each |
||
1904 | * @param bool $isAnonymous True, if the poll needs to be anonymous, defaults to True |
||
1905 | * @param null $type Poll type, “quiz” or “regular”, defaults to “regular” |
||
1906 | * @param bool $allowsMultipleAnswers True, if the poll allows multiple answers, |
||
1907 | * ignored for polls in quiz mode, defaults to False |
||
1908 | * @param null $correctOptionId 0-based identifier of the correct answer option, required for polls in quiz mode |
||
1909 | * @param bool $isClosed Pass True, if the poll needs to be immediately closed. This can be useful for poll preview. |
||
1910 | * @param bool $disableNotification Sends the message silently. Users will receive a notification with no sound. |
||
1911 | * @param int|null $replyToMessageId If the message is a reply, ID of the original message |
||
1912 | * @param null $replyMarkup Additional interface options. A JSON-serialized object for an inline keyboard, |
||
1913 | * custom reply keyboard, instructions to remove reply |
||
1914 | * keyboard or to force a reply from the user. |
||
1915 | * @return \TelegramBot\Api\Types\Message |
||
1916 | * @throws Exception |
||
1917 | * @throws HttpException |
||
1918 | * @throws InvalidJsonException |
||
1919 | */ |
||
1920 | public function sendPoll( |
||
1947 | |||
1948 | /** |
||
1949 | * Use this method to send a dice, which will have a random value from 1 to 6. |
||
1950 | * On success, the sent Message is returned. (Yes, we're aware of the “proper” singular of die. |
||
1951 | * But it's awkward, and we decided to help it change. One dice at a time!) |
||
1952 | * |
||
1953 | * @param $chatId string|int Unique identifier for the target chat or username of the target channel |
||
1954 | * (in the format @channelusername) |
||
1955 | * @param $emoji string Emoji on which the dice throw animation is based. Currently, must be one of “🎲”, |
||
1956 | * “🎯”, “🏀”, “⚽”, or “🎰”. Dice can have values 1-6 for “🎲” and “🎯”, values 1-5 for “🏀” and “⚽”, and |
||
1957 | * values 1-64 for “🎰”. Defaults to “🎲 |
||
1958 | * @param bool $disableNotification Sends the message silently. Users will receive a notification with no sound. |
||
1959 | * @param null $replyToMessageId If the message is a reply, ID of the original message |
||
1960 | * @param bool $$allowSendingWithoutReply Pass True, if the message should be sent even if the specified replied-to |
||
1961 | * message is not found, |
||
1962 | * @param null $replyMarkup Additional interface options. A JSON-serialized object for an inline keyboard, |
||
1963 | * custom reply keyboard, instructions to remove reply |
||
1964 | * keyboard or to force a reply from the user. |
||
1965 | * |
||
1966 | * @return bool|Message |
||
1967 | * @throws Exception |
||
1968 | * @throws HttpException |
||
1969 | * @throws InvalidJsonException |
||
1970 | */ |
||
1971 | public function sendDice( |
||
1988 | |||
1989 | /** |
||
1990 | * Use this method to stop a poll which was sent by the bot. |
||
1991 | * On success, the stopped \TelegramBot\Api\Types\Poll with the final results is returned. |
||
1992 | * |
||
1993 | * @param int|string $chatId |
||
1994 | * @param int $messageId |
||
1995 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
1996 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
1997 | * @return Poll |
||
1998 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
1999 | * @throws \TelegramBot\Api\Exception |
||
2000 | */ |
||
2001 | public function stopPoll( |
||
2012 | |||
2013 | /** |
||
2014 | * Set an option for a cURL transfer |
||
2015 | * |
||
2016 | * @param int $option The CURLOPT_XXX option to set |
||
2017 | * @param mixed $value The value to be set on option |
||
2018 | */ |
||
2019 | public function setCurlOption($option, $value) |
||
2023 | |||
2024 | /** |
||
2025 | * Unset an option for a cURL transfer |
||
2026 | * |
||
2027 | * @param int $option The CURLOPT_XXX option to unset |
||
2028 | */ |
||
2029 | public function unsetCurlOption($option) |
||
2033 | |||
2034 | /** |
||
2035 | * Clean custom options |
||
2036 | */ |
||
2037 | public function resetCurlOptions() |
||
2041 | } |
||
2042 |
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.