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 |
||
27 | class BotApi |
||
28 | { |
||
29 | /** |
||
30 | * HTTP codes |
||
31 | * |
||
32 | * @var array |
||
33 | */ |
||
34 | public static $codes = [ |
||
35 | // Informational 1xx |
||
36 | 100 => 'Continue', |
||
37 | 101 => 'Switching Protocols', |
||
38 | 102 => 'Processing', // RFC2518 |
||
39 | // Success 2xx |
||
40 | 200 => 'OK', |
||
41 | 201 => 'Created', |
||
42 | 202 => 'Accepted', |
||
43 | 203 => 'Non-Authoritative Information', |
||
44 | 204 => 'No Content', |
||
45 | 205 => 'Reset Content', |
||
46 | 206 => 'Partial Content', |
||
47 | 207 => 'Multi-Status', // RFC4918 |
||
48 | 208 => 'Already Reported', // RFC5842 |
||
49 | 226 => 'IM Used', // RFC3229 |
||
50 | // Redirection 3xx |
||
51 | 300 => 'Multiple Choices', |
||
52 | 301 => 'Moved Permanently', |
||
53 | 302 => 'Found', // 1.1 |
||
54 | 303 => 'See Other', |
||
55 | 304 => 'Not Modified', |
||
56 | 305 => 'Use Proxy', |
||
57 | // 306 is deprecated but reserved |
||
58 | 307 => 'Temporary Redirect', |
||
59 | 308 => 'Permanent Redirect', // RFC7238 |
||
60 | // Client Error 4xx |
||
61 | 400 => 'Bad Request', |
||
62 | 401 => 'Unauthorized', |
||
63 | 402 => 'Payment Required', |
||
64 | 403 => 'Forbidden', |
||
65 | 404 => 'Not Found', |
||
66 | 405 => 'Method Not Allowed', |
||
67 | 406 => 'Not Acceptable', |
||
68 | 407 => 'Proxy Authentication Required', |
||
69 | 408 => 'Request Timeout', |
||
70 | 409 => 'Conflict', |
||
71 | 410 => 'Gone', |
||
72 | 411 => 'Length Required', |
||
73 | 412 => 'Precondition Failed', |
||
74 | 413 => 'Payload Too Large', |
||
75 | 414 => 'URI Too Long', |
||
76 | 415 => 'Unsupported Media Type', |
||
77 | 416 => 'Range Not Satisfiable', |
||
78 | 417 => 'Expectation Failed', |
||
79 | 422 => 'Unprocessable Entity', // RFC4918 |
||
80 | 423 => 'Locked', // RFC4918 |
||
81 | 424 => 'Failed Dependency', // RFC4918 |
||
82 | 425 => 'Reserved for WebDAV advanced collections expired proposal', // RFC2817 |
||
83 | 426 => 'Upgrade Required', // RFC2817 |
||
84 | 428 => 'Precondition Required', // RFC6585 |
||
85 | 429 => 'Too Many Requests', // RFC6585 |
||
86 | 431 => 'Request Header Fields Too Large', // RFC6585 |
||
87 | // Server Error 5xx |
||
88 | 500 => 'Internal Server Error', |
||
89 | 501 => 'Not Implemented', |
||
90 | 502 => 'Bad Gateway', |
||
91 | 503 => 'Service Unavailable', |
||
92 | 504 => 'Gateway Timeout', |
||
93 | 505 => 'HTTP Version Not Supported', |
||
94 | 506 => 'Variant Also Negotiates (Experimental)', // RFC2295 |
||
95 | 507 => 'Insufficient Storage', // RFC4918 |
||
96 | 508 => 'Loop Detected', // RFC5842 |
||
97 | 510 => 'Not Extended', // RFC2774 |
||
98 | 511 => 'Network Authentication Required', // RFC6585 |
||
99 | ]; |
||
100 | |||
101 | private $proxySettings = []; |
||
102 | |||
103 | /** |
||
104 | * Default http status code |
||
105 | */ |
||
106 | const DEFAULT_STATUS_CODE = 200; |
||
107 | |||
108 | /** |
||
109 | * Not Modified http status code |
||
110 | */ |
||
111 | const NOT_MODIFIED_STATUS_CODE = 304; |
||
112 | |||
113 | /** |
||
114 | * Limits for tracked ids |
||
115 | */ |
||
116 | const MAX_TRACKED_EVENTS = 200; |
||
117 | |||
118 | /** |
||
119 | * Url prefixes |
||
120 | */ |
||
121 | const URL_PREFIX = 'https://api.telegram.org/bot'; |
||
122 | |||
123 | /** |
||
124 | * Url prefix for files |
||
125 | */ |
||
126 | const FILE_URL_PREFIX = 'https://api.telegram.org/file/bot'; |
||
127 | |||
128 | /** |
||
129 | * CURL object |
||
130 | * |
||
131 | * @var |
||
132 | */ |
||
133 | protected $curl; |
||
134 | |||
135 | /** |
||
136 | * CURL custom options |
||
137 | * |
||
138 | * @var array |
||
139 | */ |
||
140 | protected $customCurlOptions = []; |
||
141 | |||
142 | /** |
||
143 | * Bot token |
||
144 | * |
||
145 | * @var string |
||
146 | */ |
||
147 | protected $token; |
||
148 | |||
149 | /** |
||
150 | * Botan tracker |
||
151 | * |
||
152 | * @var \TelegramBot\Api\Botan |
||
153 | */ |
||
154 | protected $tracker; |
||
155 | |||
156 | /** |
||
157 | * list of event ids |
||
158 | * |
||
159 | * @var array |
||
160 | */ |
||
161 | protected $trackedEvents = []; |
||
162 | |||
163 | /** |
||
164 | * Check whether return associative array |
||
165 | * |
||
166 | * @var bool |
||
167 | */ |
||
168 | protected $returnArray = true; |
||
169 | |||
170 | /** |
||
171 | * Constructor |
||
172 | * |
||
173 | * @param string $token Telegram Bot API token |
||
174 | * @param string|null $trackerToken Yandex AppMetrica application api_key |
||
175 | */ |
||
176 | 9 | public function __construct($token, $trackerToken = null) |
|
185 | |||
186 | /** |
||
187 | * Set return array |
||
188 | * |
||
189 | * @param bool $mode |
||
190 | * |
||
191 | * @return $this |
||
192 | */ |
||
193 | public function setModeObject($mode = true) |
||
199 | |||
200 | |||
201 | /** |
||
202 | * Call method |
||
203 | * |
||
204 | * @param string $method |
||
205 | * @param array|null $data |
||
206 | * |
||
207 | * @return mixed |
||
208 | * @throws \TelegramBot\Api\Exception |
||
209 | * @throws \TelegramBot\Api\HttpException |
||
210 | * @throws \TelegramBot\Api\InvalidJsonException |
||
211 | */ |
||
212 | public function call($method, array $data = null) |
||
247 | |||
248 | /** |
||
249 | * curl_exec wrapper for response validation |
||
250 | * |
||
251 | * @param array $options |
||
252 | * |
||
253 | * @return string |
||
254 | * |
||
255 | * @throws \TelegramBot\Api\HttpException |
||
256 | */ |
||
257 | protected function executeCurl(array $options) |
||
269 | |||
270 | /** |
||
271 | * Response validation |
||
272 | * |
||
273 | * @param resource $curl |
||
274 | * @param string $response |
||
275 | * @throws HttpException |
||
276 | */ |
||
277 | public static function curlValidate($curl, $response = null) |
||
288 | |||
289 | /** |
||
290 | * JSON validation |
||
291 | * |
||
292 | * @param string $jsonString |
||
293 | * @param boolean $asArray |
||
294 | * |
||
295 | * @return object|array |
||
296 | * @throws \TelegramBot\Api\InvalidJsonException |
||
297 | */ |
||
298 | public static function jsonValidate($jsonString, $asArray) |
||
308 | |||
309 | /** |
||
310 | * Use this method to send text messages. On success, the sent \TelegramBot\Api\Types\Message is returned. |
||
311 | * |
||
312 | * @param int|string $chatId |
||
313 | * @param string $text |
||
314 | * @param string|null $parseMode |
||
315 | * @param bool $disablePreview |
||
316 | * @param int|null $replyToMessageId |
||
317 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
318 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
319 | * @param bool $disableNotification |
||
320 | * |
||
321 | * @return \TelegramBot\Api\Types\Message |
||
322 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
323 | * @throws \TelegramBot\Api\Exception |
||
324 | */ |
||
325 | public function sendMessage( |
||
344 | |||
345 | /** |
||
346 | * @param int|string $chatId |
||
347 | * @param int|string $fromChatId |
||
348 | * @param int $messageId |
||
349 | * @param string|null $caption |
||
350 | * @param string|null $parseMode |
||
351 | * @param ArrayOfMessageEntity|null $captionEntities |
||
352 | * @param bool $disableNotification |
||
353 | * @param int|null $replyToMessageId |
||
354 | * @param bool $allowSendingWithoutReply |
||
355 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
356 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
357 | * |
||
358 | * @return Message |
||
359 | * @throws Exception |
||
360 | * @throws HttpException |
||
361 | * @throws InvalidJsonException |
||
362 | */ |
||
363 | View Code Duplication | public function copyMessage( |
|
388 | |||
389 | /** |
||
390 | * Use this method to send phone contacts |
||
391 | * |
||
392 | * @param int|string $chatId chat_id or @channel_name |
||
393 | * @param string $phoneNumber |
||
394 | * @param string $firstName |
||
395 | * @param string $lastName |
||
396 | * @param int|null $replyToMessageId |
||
397 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
398 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
399 | * @param bool $disableNotification |
||
400 | * |
||
401 | * @return \TelegramBot\Api\Types\Message |
||
402 | * @throws \TelegramBot\Api\Exception |
||
403 | */ |
||
404 | public function sendContact( |
||
423 | |||
424 | /** |
||
425 | * Use this method when you need to tell the user that something is happening on the bot's side. |
||
426 | * The status is set for 5 seconds or less (when a message arrives from your bot, |
||
427 | * Telegram clients clear its typing status). |
||
428 | * |
||
429 | * We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive. |
||
430 | * |
||
431 | * Type of action to broadcast. Choose one, depending on what the user is about to receive: |
||
432 | * `typing` for text messages, `upload_photo` for photos, `record_video` or `upload_video` for videos, |
||
433 | * `record_audio` or upload_audio for audio files, `upload_document` for general files, |
||
434 | * `find_location` for location data. |
||
435 | * |
||
436 | * @param int $chatId |
||
437 | * @param string $action |
||
438 | * |
||
439 | * @return bool |
||
440 | * @throws \TelegramBot\Api\Exception |
||
441 | */ |
||
442 | public function sendChatAction($chatId, $action) |
||
449 | |||
450 | /** |
||
451 | * Use this method to get a list of profile pictures for a user. |
||
452 | * |
||
453 | * @param int $userId |
||
454 | * @param int $offset |
||
455 | * @param int $limit |
||
456 | * |
||
457 | * @return \TelegramBot\Api\Types\UserProfilePhotos |
||
458 | * @throws \TelegramBot\Api\Exception |
||
459 | */ |
||
460 | public function getUserProfilePhotos($userId, $offset = 0, $limit = 100) |
||
468 | |||
469 | /** |
||
470 | * Use this method to specify a url and receive incoming updates via an outgoing webhook. |
||
471 | * Whenever there is an update for the bot, we will send an HTTPS POST request to the specified url, |
||
472 | * containing a JSON-serialized Update. |
||
473 | * In case of an unsuccessful request, we will give up after a reasonable amount of attempts. |
||
474 | * |
||
475 | * @param string $url HTTPS url to send updates to. Use an empty string to remove webhook integration |
||
476 | * @param \CURLFile|string $certificate Upload your public key certificate |
||
477 | * so that the root certificate in use can be checked |
||
478 | * |
||
479 | * @return string |
||
480 | * |
||
481 | * @throws \TelegramBot\Api\Exception |
||
482 | */ |
||
483 | public function setWebhook($url = '', $certificate = null) |
||
487 | |||
488 | |||
489 | /** |
||
490 | * Use this method to clear webhook and use getUpdates again! |
||
491 | * |
||
492 | * @return mixed |
||
493 | * |
||
494 | * @throws \TelegramBot\Api\Exception |
||
495 | */ |
||
496 | public function deleteWebhook() |
||
500 | |||
501 | /** |
||
502 | * Use this method to get current webhook status. Requires no parameters. |
||
503 | * On success, returns a WebhookInfo object. If the bot is using getUpdates, |
||
504 | * will return an object with the url field empty. |
||
505 | * |
||
506 | * @return \TelegramBot\Api\Types\WebhookInfo |
||
507 | * @throws \TelegramBot\Api\Exception |
||
508 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
509 | */ |
||
510 | public function getWebhookInfo() |
||
514 | |||
515 | /** |
||
516 | * A simple method for testing your bot's auth token.Requires no parameters. |
||
517 | * Returns basic information about the bot in form of a User object. |
||
518 | * |
||
519 | * @return \TelegramBot\Api\Types\User |
||
520 | * @throws \TelegramBot\Api\Exception |
||
521 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
522 | */ |
||
523 | public function getMe() |
||
527 | |||
528 | /** |
||
529 | * Use this method to receive incoming updates using long polling. |
||
530 | * An Array of Update objects is returned. |
||
531 | * |
||
532 | * Notes |
||
533 | * 1. This method will not work if an outgoing webhook is set up. |
||
534 | * 2. In order to avoid getting duplicate updates, recalculate offset after each server response. |
||
535 | * |
||
536 | * @param int $offset |
||
537 | * @param int $limit |
||
538 | * @param int $timeout |
||
539 | * |
||
540 | * @return Update[] |
||
541 | * @throws \TelegramBot\Api\Exception |
||
542 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
543 | */ |
||
544 | 2 | public function getUpdates($offset = 0, $limit = 100, $timeout = 0) |
|
560 | |||
561 | /** |
||
562 | * Use this method to send point on the map. On success, the sent Message is returned. |
||
563 | * |
||
564 | * @param int|string $chatId |
||
565 | * @param float $latitude |
||
566 | * @param float $longitude |
||
567 | * @param int|null $replyToMessageId |
||
568 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
569 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
570 | * @param bool $disableNotification |
||
571 | * |
||
572 | * @param null|int $livePeriod |
||
573 | * @return \TelegramBot\Api\Types\Message |
||
574 | */ |
||
575 | public function sendLocation( |
||
594 | |||
595 | /** |
||
596 | * Use this method to edit live location messages sent by the bot or via the bot (for inline bots). |
||
597 | * |
||
598 | * @param int|string $chatId |
||
599 | * @param int $messageId |
||
600 | * @param string $inlineMessageId |
||
601 | * @param float $latitude |
||
602 | * @param float $longitude |
||
603 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
604 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
605 | * @return \TelegramBot\Api\Types\Message |
||
606 | */ |
||
607 | public function editMessageLiveLocation( |
||
624 | |||
625 | /** |
||
626 | * Use this method to stop updating a live location message sent by the bot or via the bot (for inline bots) before |
||
627 | * live_period expires. |
||
628 | * |
||
629 | * @param int|string $chatId |
||
630 | * @param int $messageId |
||
631 | * @param string $inlineMessageId |
||
632 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
633 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
634 | * @return \TelegramBot\Api\Types\Message |
||
635 | */ |
||
636 | public function stopMessageLiveLocation( |
||
649 | |||
650 | /** |
||
651 | * Use this method to send information about a venue. On success, the sent Message is returned. |
||
652 | * |
||
653 | * @param int|string $chatId chat_id or @channel_name |
||
654 | * @param float $latitude |
||
655 | * @param float $longitude |
||
656 | * @param string $title |
||
657 | * @param string $address |
||
658 | * @param string|null $foursquareId |
||
659 | * @param int|null $replyToMessageId |
||
660 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
661 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
662 | * @param bool $disableNotification |
||
663 | * |
||
664 | * @return \TelegramBot\Api\Types\Message |
||
665 | * @throws \TelegramBot\Api\Exception |
||
666 | */ |
||
667 | public function sendVenue( |
||
690 | |||
691 | /** |
||
692 | * Use this method to send .webp stickers. On success, the sent Message is returned. |
||
693 | * |
||
694 | * @param int|string $chatId chat_id or @channel_name |
||
695 | * @param \CURLFile|string $sticker |
||
696 | * @param int|null $replyToMessageId |
||
697 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
698 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
699 | * @param bool $disableNotification |
||
700 | * |
||
701 | * @return \TelegramBot\Api\Types\Message |
||
702 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
703 | * @throws \TelegramBot\Api\Exception |
||
704 | */ |
||
705 | View Code Duplication | public function sendSticker( |
|
720 | |||
721 | /** |
||
722 | * Use this method to send video files, |
||
723 | * Telegram clients support mp4 videos (other formats may be sent as Document). |
||
724 | * On success, the sent Message is returned. |
||
725 | * |
||
726 | * @param int|string $chatId chat_id or @channel_name |
||
727 | * @param \CURLFile|string $video |
||
728 | * @param int|null $duration |
||
729 | * @param string|null $caption |
||
730 | * @param int|null $replyToMessageId |
||
731 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
732 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
733 | * @param bool $disableNotification |
||
734 | * @param bool $supportsStreaming Pass True, if the uploaded video is suitable for streaming |
||
735 | * @param string|null $parseMode |
||
736 | * |
||
737 | * @return \TelegramBot\Api\Types\Message |
||
738 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
739 | * @throws \TelegramBot\Api\Exception |
||
740 | */ |
||
741 | View Code Duplication | public function sendVideo( |
|
764 | |||
765 | /** |
||
766 | * Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound), |
||
767 | * On success, the sent Message is returned. |
||
768 | * Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future. |
||
769 | * |
||
770 | * @param int|string $chatId chat_id or @channel_name |
||
771 | * @param \CURLFile|string $animation |
||
772 | * @param int|null $duration |
||
773 | * @param string|null $caption |
||
774 | * @param int|null $replyToMessageId |
||
775 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
776 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
777 | * @param bool $disableNotification |
||
778 | * @param string|null $parseMode |
||
779 | * |
||
780 | * @return \TelegramBot\Api\Types\Message |
||
781 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
782 | * @throws \TelegramBot\Api\Exception |
||
783 | */ |
||
784 | public function sendAnimation( |
||
805 | |||
806 | /** |
||
807 | * Use this method to send audio files, |
||
808 | * if you want Telegram clients to display the file as a playable voice message. |
||
809 | * For this to work, your audio must be in an .ogg file encoded with OPUS |
||
810 | * (other formats may be sent as Audio or Document). |
||
811 | * On success, the sent Message is returned. |
||
812 | * Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future. |
||
813 | * |
||
814 | * @param int|string $chatId chat_id or @channel_name |
||
815 | * @param \CURLFile|string $voice |
||
816 | * @param int|null $duration |
||
817 | * @param int|null $replyToMessageId |
||
818 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
819 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
820 | * @param bool $disableNotification |
||
821 | * @param string|null $parseMode |
||
822 | * |
||
823 | * @return \TelegramBot\Api\Types\Message |
||
824 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
825 | * @throws \TelegramBot\Api\Exception |
||
826 | */ |
||
827 | public function sendVoice( |
||
846 | |||
847 | /** |
||
848 | * Use this method to forward messages of any kind. On success, the sent Message is returned. |
||
849 | * |
||
850 | * @param int|string $chatId chat_id or @channel_name |
||
851 | * @param int $fromChatId |
||
852 | * @param int $messageId |
||
853 | * @param bool $disableNotification |
||
854 | * |
||
855 | * @return \TelegramBot\Api\Types\Message |
||
856 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
857 | * @throws \TelegramBot\Api\Exception |
||
858 | */ |
||
859 | public function forwardMessage($chatId, $fromChatId, $messageId, $disableNotification = false) |
||
868 | |||
869 | /** |
||
870 | * Use this method to send audio files, |
||
871 | * if you want Telegram clients to display them in the music player. |
||
872 | * Your audio must be in the .mp3 format. |
||
873 | * On success, the sent Message is returned. |
||
874 | * Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future. |
||
875 | * |
||
876 | * For backward compatibility, when the fields title and performer are both empty |
||
877 | * and the mime-type of the file to be sent is not audio/mpeg, the file will be sent as a playable voice message. |
||
878 | * For this to work, the audio must be in an .ogg file encoded with OPUS. |
||
879 | * This behavior will be phased out in the future. For sending voice messages, use the sendVoice method instead. |
||
880 | * |
||
881 | * @deprecated since 20th February. Removed backward compatibility from the method sendAudio. |
||
882 | * Voice messages now must be sent using the method sendVoice. |
||
883 | * There is no more need to specify a non-empty title or performer while sending the audio by file_id. |
||
884 | * |
||
885 | * @param int|string $chatId chat_id or @channel_name |
||
886 | * @param \CURLFile|string $audio |
||
887 | * @param int|null $duration |
||
888 | * @param string|null $performer |
||
889 | * @param string|null $title |
||
890 | * @param int|null $replyToMessageId |
||
891 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
892 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
893 | * @param bool $disableNotification |
||
894 | * @param string|null $parseMode |
||
895 | * |
||
896 | * @return \TelegramBot\Api\Types\Message |
||
897 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
898 | * @throws \TelegramBot\Api\Exception |
||
899 | */ |
||
900 | View Code Duplication | public function sendAudio( |
|
923 | |||
924 | /** |
||
925 | * Use this method to send photos. On success, the sent Message is returned. |
||
926 | * |
||
927 | * @param int|string $chatId chat_id or @channel_name |
||
928 | * @param \CURLFile|string $photo |
||
929 | * @param string|null $caption |
||
930 | * @param int|null $replyToMessageId |
||
931 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
932 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
933 | * @param bool $disableNotification |
||
934 | * @param string|null $parseMode |
||
935 | * |
||
936 | * @return \TelegramBot\Api\Types\Message |
||
937 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
938 | * @throws \TelegramBot\Api\Exception |
||
939 | */ |
||
940 | public function sendPhoto( |
||
959 | |||
960 | /** |
||
961 | * Use this method to send general files. On success, the sent Message is returned. |
||
962 | * Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future. |
||
963 | * |
||
964 | * @param int|string $chatId chat_id or @channel_name |
||
965 | * @param \CURLFile|string $document |
||
966 | * @param string|null $caption |
||
967 | * @param int|null $replyToMessageId |
||
968 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
969 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
970 | * @param bool $disableNotification |
||
971 | * @param string|null $parseMode |
||
972 | * |
||
973 | * @return \TelegramBot\Api\Types\Message |
||
974 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
975 | * @throws \TelegramBot\Api\Exception |
||
976 | */ |
||
977 | public function sendDocument( |
||
996 | |||
997 | /** |
||
998 | * Use this method to get basic info about a file and prepare it for downloading. |
||
999 | * For the moment, bots can download files of up to 20MB in size. |
||
1000 | * On success, a File object is returned. |
||
1001 | * The file can then be downloaded via the link https://api.telegram.org/file/bot<token>/<file_path>, |
||
1002 | * where <file_path> is taken from the response. |
||
1003 | * It is guaranteed that the link will be valid for at least 1 hour. |
||
1004 | * When the link expires, a new one can be requested by calling getFile again. |
||
1005 | * |
||
1006 | * @param $fileId |
||
1007 | * |
||
1008 | * @return \TelegramBot\Api\Types\File |
||
1009 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
1010 | * @throws \TelegramBot\Api\Exception |
||
1011 | */ |
||
1012 | public function getFile($fileId) |
||
1016 | |||
1017 | /** |
||
1018 | * Get file contents via cURL |
||
1019 | * |
||
1020 | * @param $fileId |
||
1021 | * |
||
1022 | * @return string |
||
1023 | * |
||
1024 | * @throws \TelegramBot\Api\HttpException |
||
1025 | */ |
||
1026 | public function downloadFile($fileId) |
||
1038 | |||
1039 | /** |
||
1040 | * Use this method to send answers to an inline query. On success, True is returned. |
||
1041 | * No more than 50 results per query are allowed. |
||
1042 | * |
||
1043 | * @param string $inlineQueryId |
||
1044 | * @param AbstractInlineQueryResult[] $results |
||
1045 | * @param int $cacheTime |
||
1046 | * @param bool $isPersonal |
||
1047 | * @param string $nextOffset |
||
1048 | * @param string $switchPmText |
||
1049 | * @param string $switchPmParameter |
||
1050 | * |
||
1051 | * @return mixed |
||
1052 | * @throws Exception |
||
1053 | */ |
||
1054 | public function answerInlineQuery( |
||
1078 | |||
1079 | /** |
||
1080 | * Use this method to kick a user from a group or a supergroup. |
||
1081 | * In the case of supergroups, the user will not be able to return to the group |
||
1082 | * on their own using invite links, etc., unless unbanned first. |
||
1083 | * The bot must be an administrator in the group for this to work. Returns True on success. |
||
1084 | * |
||
1085 | * @param int|string $chatId Unique identifier for the target group |
||
1086 | * or username of the target supergroup (in the format @supergroupusername) |
||
1087 | * @param int $userId Unique identifier of the target user |
||
1088 | * @param null|int $untilDate Date when the user will be unbanned, unix time. |
||
1089 | * If user is banned for more than 366 days or less than 30 seconds from the current time |
||
1090 | * they are considered to be banned forever |
||
1091 | * |
||
1092 | * @return bool |
||
1093 | */ |
||
1094 | public function kickChatMember($chatId, $userId, $untilDate = null) |
||
1102 | |||
1103 | /** |
||
1104 | * Use this method to unban a previously kicked user in a supergroup. |
||
1105 | * The user will not return to the group automatically, but will be able to join via link, etc. |
||
1106 | * The bot must be an administrator in the group for this to work. Returns True on success. |
||
1107 | * |
||
1108 | * @param int|string $chatId Unique identifier for the target group |
||
1109 | * or username of the target supergroup (in the format @supergroupusername) |
||
1110 | * @param int $userId Unique identifier of the target user |
||
1111 | * |
||
1112 | * @return bool |
||
1113 | */ |
||
1114 | public function unbanChatMember($chatId, $userId) |
||
1121 | |||
1122 | /** |
||
1123 | * Use this method to send answers to callback queries sent from inline keyboards. |
||
1124 | * The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. |
||
1125 | * |
||
1126 | * @param $callbackQueryId |
||
1127 | * @param null $text |
||
1128 | * @param bool $showAlert |
||
1129 | * |
||
1130 | * @return bool |
||
1131 | */ |
||
1132 | public function answerCallbackQuery($callbackQueryId, $text = null, $showAlert = false) |
||
1140 | |||
1141 | |||
1142 | /** |
||
1143 | * Use this method to edit text messages sent by the bot or via the bot |
||
1144 | * |
||
1145 | * @param int|string $chatId |
||
1146 | * @param int $messageId |
||
1147 | * @param string $text |
||
1148 | * @param string $inlineMessageId |
||
1149 | * @param string|null $parseMode |
||
1150 | * @param bool $disablePreview |
||
1151 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
1152 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
1153 | * @return Message |
||
1154 | */ |
||
1155 | public function editMessageText( |
||
1174 | |||
1175 | /** |
||
1176 | * Use this method to edit text messages sent by the bot or via the bot |
||
1177 | * |
||
1178 | * @param int|string $chatId |
||
1179 | * @param int $messageId |
||
1180 | * @param string|null $caption |
||
1181 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
1182 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
1183 | * @param string $inlineMessageId |
||
1184 | * @param string|null $parseMode |
||
1185 | * |
||
1186 | * @return \TelegramBot\Api\Types\Message |
||
1187 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
1188 | * @throws \TelegramBot\Api\Exception |
||
1189 | */ |
||
1190 | View Code Duplication | public function editMessageCaption( |
|
1207 | |||
1208 | /** |
||
1209 | * Use this method to edit animation, audio, document, photo, or video messages. |
||
1210 | * If a message is a part of a message album, then it can be edited only to a photo or a video. |
||
1211 | * Otherwise, message type can be changed arbitrarily. |
||
1212 | * When inline message is edited, new file can't be uploaded. |
||
1213 | * Use previously uploaded file via its file_id or specify a URL. |
||
1214 | * On success, if the edited message was sent by the bot, the edited Message is returned, otherwise True is returned |
||
1215 | * |
||
1216 | * @param $chatId |
||
1217 | * @param $messageId |
||
1218 | * @param InputMedia $media |
||
1219 | * @param null $inlineMessageId |
||
1220 | * @param null $replyMarkup |
||
1221 | * @return bool|Message |
||
1222 | * @throws Exception |
||
1223 | * @throws HttpException |
||
1224 | * @throws InvalidJsonException |
||
1225 | */ |
||
1226 | View Code Duplication | public function editMessageMedia( |
|
1241 | |||
1242 | /** |
||
1243 | * Use this method to edit only the reply markup of messages sent by the bot or via the bot |
||
1244 | * |
||
1245 | * @param int|string $chatId |
||
1246 | * @param int $messageId |
||
1247 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
1248 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
1249 | * @param string $inlineMessageId |
||
1250 | * |
||
1251 | * @return Message |
||
1252 | */ |
||
1253 | public function editMessageReplyMarkup( |
||
1266 | |||
1267 | /** |
||
1268 | * Use this method to delete a message, including service messages, with the following limitations: |
||
1269 | * - A message can only be deleted if it was sent less than 48 hours ago. |
||
1270 | * - Bots can delete outgoing messages in groups and supergroups. |
||
1271 | * - Bots granted can_post_messages permissions can delete outgoing messages in channels. |
||
1272 | * - If the bot is an administrator of a group, it can delete any message there. |
||
1273 | * - If the bot has can_delete_messages permission in a supergroup or a channel, it can delete any message there. |
||
1274 | * |
||
1275 | * @param int|string $chatId |
||
1276 | * @param int $messageId |
||
1277 | * |
||
1278 | * @return bool |
||
1279 | */ |
||
1280 | public function deleteMessage($chatId, $messageId) |
||
1287 | |||
1288 | /** |
||
1289 | * Close curl |
||
1290 | */ |
||
1291 | 9 | public function __destruct() |
|
1295 | |||
1296 | /** |
||
1297 | * @return string |
||
1298 | */ |
||
1299 | public function getUrl() |
||
1303 | |||
1304 | /** |
||
1305 | * @return string |
||
1306 | */ |
||
1307 | public function getFileUrl() |
||
1311 | |||
1312 | /** |
||
1313 | * @param \TelegramBot\Api\Types\Update $update |
||
1314 | * @param string $eventName |
||
1315 | * |
||
1316 | * @throws \TelegramBot\Api\Exception |
||
1317 | */ |
||
1318 | public function trackUpdate(Update $update, $eventName = 'Message') |
||
1330 | |||
1331 | /** |
||
1332 | * Wrapper for tracker |
||
1333 | * |
||
1334 | * @param \TelegramBot\Api\Types\Message $message |
||
1335 | * @param string $eventName |
||
1336 | * |
||
1337 | * @throws \TelegramBot\Api\Exception |
||
1338 | */ |
||
1339 | public function track(Message $message, $eventName = 'Message') |
||
1345 | |||
1346 | /** |
||
1347 | * Use this method to send invoices. On success, the sent Message is returned. |
||
1348 | * |
||
1349 | * @param int|string $chatId |
||
1350 | * @param string $title |
||
1351 | * @param string $description |
||
1352 | * @param string $payload |
||
1353 | * @param string $providerToken |
||
1354 | * @param string $startParameter |
||
1355 | * @param string $currency |
||
1356 | * @param array $prices |
||
1357 | * @param string|null $photoUrl |
||
1358 | * @param int|null $photoSize |
||
1359 | * @param int|null $photoWidth |
||
1360 | * @param int|null $photoHeight |
||
1361 | * @param bool $needName |
||
1362 | * @param bool $needPhoneNumber |
||
1363 | * @param bool $needEmail |
||
1364 | * @param bool $needShippingAddress |
||
1365 | * @param bool $isFlexible |
||
1366 | * @param int|null $replyToMessageId |
||
1367 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
1368 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
1369 | * @param bool $disableNotification |
||
1370 | * @param string|null $providerData |
||
1371 | * @param bool $sendPhoneNumberToProvider |
||
1372 | * @param bool $sendEmailToProvider |
||
1373 | * |
||
1374 | * @return Message |
||
1375 | */ |
||
1376 | public function sendInvoice( |
||
1427 | |||
1428 | /** |
||
1429 | * If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API |
||
1430 | * will send an Update with a shipping_query field to the bot. Use this method to reply to shipping queries. |
||
1431 | * On success, True is returned. |
||
1432 | * |
||
1433 | * @param string $shippingQueryId |
||
1434 | * @param bool $ok |
||
1435 | * @param array $shipping_options |
||
1436 | * @param null|string $errorMessage |
||
1437 | * |
||
1438 | * @return bool |
||
1439 | * |
||
1440 | */ |
||
1441 | public function answerShippingQuery($shippingQueryId, $ok = true, $shipping_options = [], $errorMessage = null) |
||
1450 | |||
1451 | /** |
||
1452 | * Use this method to respond to such pre-checkout queries. On success, True is returned. |
||
1453 | * Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent. |
||
1454 | * |
||
1455 | * @param string $preCheckoutQueryId |
||
1456 | * @param bool $ok |
||
1457 | * @param null|string $errorMessage |
||
1458 | * |
||
1459 | * @return mixed |
||
1460 | */ |
||
1461 | public function answerPreCheckoutQuery($preCheckoutQueryId, $ok = true, $errorMessage = null) |
||
1469 | |||
1470 | /** |
||
1471 | * Use this method to restrict a user in a supergroup. |
||
1472 | * The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights. |
||
1473 | * Pass True for all boolean parameters to lift restrictions from a user. |
||
1474 | * |
||
1475 | * @param string|int $chatId Unique identifier for the target chat or username of the target supergroup |
||
1476 | * (in the format @supergroupusername) |
||
1477 | * @param int $userId Unique identifier of the target user |
||
1478 | * @param null|integer $untilDate Date when restrictions will be lifted for the user, unix time. |
||
1479 | * If user is restricted for more than 366 days or less than 30 seconds from the current time, |
||
1480 | * they are considered to be restricted forever |
||
1481 | * @param bool $canSendMessages Pass True, if the user can send text messages, contacts, locations and venues |
||
1482 | * @param bool $canSendMediaMessages No Pass True, if the user can send audios, documents, photos, videos, |
||
1483 | * video notes and voice notes, implies can_send_messages |
||
1484 | * @param bool $canSendOtherMessages Pass True, if the user can send animations, games, stickers and |
||
1485 | * use inline bots, implies can_send_media_messages |
||
1486 | * @param bool $canAddWebPagePreviews Pass True, if the user may add web page previews to their messages, |
||
1487 | * implies can_send_media_messages |
||
1488 | * |
||
1489 | * @return bool |
||
1490 | */ |
||
1491 | public function restrictChatMember( |
||
1510 | |||
1511 | /** |
||
1512 | * Use this method to promote or demote a user in a supergroup or a channel. |
||
1513 | * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
||
1514 | * Pass False for all boolean parameters to demote 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 bool $canChangeInfo Pass True, if the administrator can change chat title, photo and other settings |
||
1520 | * @param bool $canPostMessages Pass True, if the administrator can create channel posts, channels only |
||
1521 | * @param bool $canEditMessages Pass True, if the administrator can edit messages of other users, channels only |
||
1522 | * @param bool $canDeleteMessages Pass True, if the administrator can delete messages of other users |
||
1523 | * @param bool $canInviteUsers Pass True, if the administrator can invite new users to the chat |
||
1524 | * @param bool $canRestrictMembers Pass True, if the administrator can restrict, ban or unban chat members |
||
1525 | * @param bool $canPinMessages Pass True, if the administrator can pin messages, supergroups only |
||
1526 | * @param bool $canPromoteMembers Pass True, if the administrator can add new administrators with a subset of his |
||
1527 | * own privileges or demote administrators that he has promoted,directly or |
||
1528 | * indirectly (promoted by administrators that were appointed by him) |
||
1529 | * |
||
1530 | * @return bool |
||
1531 | */ |
||
1532 | public function promoteChatMember( |
||
1557 | |||
1558 | /** |
||
1559 | * Use this method to export an invite link to a supergroup or a channel. |
||
1560 | * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
||
1561 | * |
||
1562 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
1563 | * (in the format @channelusername) |
||
1564 | * @return string |
||
1565 | */ |
||
1566 | public function exportChatInviteLink($chatId) |
||
1572 | |||
1573 | /** |
||
1574 | * Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. |
||
1575 | * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
||
1576 | * |
||
1577 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
1578 | * (in the format @channelusername) |
||
1579 | * @param \CURLFile|string $photo New chat photo, uploaded using multipart/form-data |
||
1580 | * |
||
1581 | * @return bool |
||
1582 | */ |
||
1583 | public function setChatPhoto($chatId, $photo) |
||
1590 | |||
1591 | /** |
||
1592 | * Use this method to delete a chat photo. Photos can't be changed for private chats. |
||
1593 | * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
||
1594 | * |
||
1595 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
1596 | * (in the format @channelusername) |
||
1597 | * |
||
1598 | * @return bool |
||
1599 | */ |
||
1600 | public function deleteChatPhoto($chatId) |
||
1606 | |||
1607 | /** |
||
1608 | * Use this method to change the title of a chat. Titles can't be changed for private chats. |
||
1609 | * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
||
1610 | * |
||
1611 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
1612 | * (in the format @channelusername) |
||
1613 | * @param string $title New chat title, 1-255 characters |
||
1614 | * |
||
1615 | * @return bool |
||
1616 | */ |
||
1617 | public function setChatTitle($chatId, $title) |
||
1624 | |||
1625 | /** |
||
1626 | * Use this method to change the description of a supergroup or a channel. |
||
1627 | * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
||
1628 | * |
||
1629 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
1630 | * (in the format @channelusername) |
||
1631 | * @param string|null $description New chat description, 0-255 characters |
||
1632 | * |
||
1633 | * @return bool |
||
1634 | */ |
||
1635 | public function setChatDescription($chatId, $description = null) |
||
1642 | |||
1643 | /** |
||
1644 | * Use this method to pin a message in a supergroup. |
||
1645 | * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
||
1646 | * |
||
1647 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
1648 | * (in the format @channelusername) |
||
1649 | * @param int $messageId Identifier of a message to pin |
||
1650 | * @param bool $disableNotification |
||
1651 | * |
||
1652 | * @return bool |
||
1653 | */ |
||
1654 | public function pinChatMessage($chatId, $messageId, $disableNotification = false) |
||
1662 | |||
1663 | /** |
||
1664 | * Use this method to unpin a message in a supergroup chat. |
||
1665 | * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
||
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 bool |
||
1671 | */ |
||
1672 | public function unpinChatMessage($chatId) |
||
1678 | |||
1679 | /** |
||
1680 | * Use this method to get up to date information about the chat |
||
1681 | * (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). |
||
1682 | * |
||
1683 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
1684 | * (in the format @channelusername) |
||
1685 | * |
||
1686 | * @return Chat |
||
1687 | */ |
||
1688 | public function getChat($chatId) |
||
1694 | |||
1695 | /** |
||
1696 | * Use this method to get information about a member of a chat. |
||
1697 | * |
||
1698 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
1699 | * (in the format @channelusername) |
||
1700 | * @param int $userId |
||
1701 | * |
||
1702 | * @return ChatMember |
||
1703 | */ |
||
1704 | public function getChatMember($chatId, $userId) |
||
1711 | |||
1712 | /** |
||
1713 | * Use this method for your bot to leave a group, supergroup or channel. |
||
1714 | * |
||
1715 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
1716 | * (in the format @channelusername) |
||
1717 | * |
||
1718 | * @return bool |
||
1719 | */ |
||
1720 | public function leaveChat($chatId) |
||
1726 | |||
1727 | /** |
||
1728 | * Use this method to get the number of members in a chat. |
||
1729 | * |
||
1730 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
1731 | * (in the format @channelusername) |
||
1732 | * |
||
1733 | * @return int |
||
1734 | */ |
||
1735 | public function getChatMembersCount($chatId) |
||
1744 | |||
1745 | /** |
||
1746 | * Use this method to get a list of administrators in a chat. |
||
1747 | * |
||
1748 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
1749 | * (in the format @channelusername) |
||
1750 | * |
||
1751 | * @return array |
||
1752 | */ |
||
1753 | public function getChatAdministrators($chatId) |
||
1764 | |||
1765 | /** |
||
1766 | * As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long. |
||
1767 | * Use this method to send video messages. |
||
1768 | * On success, the sent Message is returned. |
||
1769 | * |
||
1770 | * @param int|string $chatId chat_id or @channel_name |
||
1771 | * @param \CURLFile|string $videoNote |
||
1772 | * @param int|null $duration |
||
1773 | * @param int|null $length |
||
1774 | * @param int|null $replyToMessageId |
||
1775 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
1776 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
1777 | * @param bool $disableNotification |
||
1778 | * |
||
1779 | * @return \TelegramBot\Api\Types\Message |
||
1780 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
1781 | * @throws \TelegramBot\Api\Exception |
||
1782 | */ |
||
1783 | public function sendVideoNote( |
||
1802 | |||
1803 | /** |
||
1804 | * Use this method to send a group of photos or videos as an album. |
||
1805 | * On success, the sent \TelegramBot\Api\Types\Message is returned. |
||
1806 | * |
||
1807 | * @param int|string $chatId |
||
1808 | * @param ArrayOfInputMedia $media |
||
1809 | * @param int|null $replyToMessageId |
||
1810 | * @param bool $disableNotification |
||
1811 | * |
||
1812 | * @return array |
||
1813 | * @throws \TelegramBot\Api\Exception |
||
1814 | */ |
||
1815 | public function sendMediaGroup( |
||
1828 | |||
1829 | /** |
||
1830 | * Enable proxy for curl requests. Empty string will disable proxy. |
||
1831 | * |
||
1832 | * @param string $proxyString |
||
1833 | * |
||
1834 | * @return BotApi |
||
1835 | */ |
||
1836 | public function setProxy($proxyString = '', $socks5 = false) |
||
1853 | |||
1854 | |||
1855 | /** |
||
1856 | * Use this method to send a native poll. A native poll can't be sent to a private chat. |
||
1857 | * On success, the sent \TelegramBot\Api\Types\Message is returned. |
||
1858 | * |
||
1859 | * @param $chatId string|int Unique identifier for the target chat or username of the target channel |
||
1860 | * (in the format @channelusername) |
||
1861 | * @param string $question Poll question, 1-255 characters |
||
1862 | * @param array $options A JSON-serialized list of answer options, 2-10 strings 1-100 characters each |
||
1863 | * @param bool $isAnonymous True, if the poll needs to be anonymous, defaults to True |
||
1864 | * @param null $type Poll type, “quiz” or “regular”, defaults to “regular” |
||
1865 | * @param bool $allowsMultipleAnswers True, if the poll allows multiple answers, |
||
1866 | * ignored for polls in quiz mode, defaults to False |
||
1867 | * @param null $correctOptionId 0-based identifier of the correct answer option, required for polls in quiz mode |
||
1868 | * @param bool $isClosed Pass True, if the poll needs to be immediately closed. This can be useful for poll preview. |
||
1869 | * @param bool $disableNotification Sends the message silently. Users will receive a notification with no sound. |
||
1870 | * @param int|null $replyToMessageId If the message is a reply, ID of the original message |
||
1871 | * @param null $replyMarkup Additional interface options. A JSON-serialized object for an inline keyboard, |
||
1872 | * custom reply keyboard, instructions to remove reply |
||
1873 | * keyboard or to force a reply from the user. |
||
1874 | * @return \TelegramBot\Api\Types\Message |
||
1875 | * @throws Exception |
||
1876 | * @throws HttpException |
||
1877 | * @throws InvalidJsonException |
||
1878 | */ |
||
1879 | public function sendPoll( |
||
1906 | |||
1907 | /** |
||
1908 | * Use this method to send a dice, which will have a random value from 1 to 6. |
||
1909 | * On success, the sent Message is returned. (Yes, we're aware of the “proper” singular of die. |
||
1910 | * But it's awkward, and we decided to help it change. One dice at a time!) |
||
1911 | * |
||
1912 | * @param $chatId string|int Unique identifier for the target chat or username of the target channel |
||
1913 | * (in the format @channelusername) |
||
1914 | * @param bool $disableNotification Sends the message silently. Users will receive a notification with no sound. |
||
1915 | * @param null $replyToMessageId If the message is a reply, ID of the original message |
||
1916 | * @param null $replyMarkup Additional interface options. A JSON-serialized object for an inline keyboard, |
||
1917 | * custom reply keyboard, instructions to remove reply |
||
1918 | * keyboard or to force a reply from the user. |
||
1919 | * @return bool|Message |
||
1920 | * @throws Exception |
||
1921 | * @throws HttpException |
||
1922 | * @throws InvalidJsonException |
||
1923 | */ |
||
1924 | View Code Duplication | public function sendDice( |
|
1937 | |||
1938 | /** |
||
1939 | * Use this method to stop a poll which was sent by the bot. |
||
1940 | * On success, the stopped \TelegramBot\Api\Types\Poll with the final results is returned. |
||
1941 | * |
||
1942 | * @param int|string $chatId |
||
1943 | * @param int $messageId |
||
1944 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
1945 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
1946 | * @return Poll |
||
1947 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
1948 | * @throws \TelegramBot\Api\Exception |
||
1949 | */ |
||
1950 | public function stopPoll( |
||
1961 | |||
1962 | /** |
||
1963 | * Set an option for a cURL transfer |
||
1964 | * |
||
1965 | * @param int $option The CURLOPT_XXX option to set |
||
1966 | * @param mixed $value The value to be set on option |
||
1967 | */ |
||
1968 | public function setCurlOption($option, $value) |
||
1972 | |||
1973 | /** |
||
1974 | * Unset an option for a cURL transfer |
||
1975 | * |
||
1976 | * @param int $option The CURLOPT_XXX option to unset |
||
1977 | */ |
||
1978 | public function unsetCurlOption($option) |
||
1982 | |||
1983 | /** |
||
1984 | * Clean custom options |
||
1985 | */ |
||
1986 | public function resetCurlOptions() |
||
1990 | } |
||
1991 |
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.