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 int|null $duration |
||
| 818 | * @param int|null $replyToMessageId |
||
| 819 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
| 820 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
| 821 | * @param bool $disableNotification |
||
| 822 | * @param string|null $parseMode |
||
| 823 | * |
||
| 824 | * @return \TelegramBot\Api\Types\Message |
||
| 825 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
| 826 | * @throws \TelegramBot\Api\Exception |
||
| 827 | */ |
||
| 828 | public function sendVoice( |
||
| 847 | |||
| 848 | /** |
||
| 849 | * Use this method to forward messages of any kind. On success, the sent Message is returned. |
||
| 850 | * |
||
| 851 | * @param int|string $chatId chat_id or @channel_name |
||
| 852 | * @param int $fromChatId |
||
| 853 | * @param int $messageId |
||
| 854 | * @param bool $disableNotification |
||
| 855 | * |
||
| 856 | * @return \TelegramBot\Api\Types\Message |
||
| 857 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
| 858 | * @throws \TelegramBot\Api\Exception |
||
| 859 | */ |
||
| 860 | public function forwardMessage($chatId, $fromChatId, $messageId, $disableNotification = false) |
||
| 869 | |||
| 870 | /** |
||
| 871 | * Use this method to send audio files, |
||
| 872 | * if you want Telegram clients to display them in the music player. |
||
| 873 | * Your audio must be in the .mp3 format. |
||
| 874 | * On success, the sent Message is returned. |
||
| 875 | * Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future. |
||
| 876 | * |
||
| 877 | * For backward compatibility, when the fields title and performer are both empty |
||
| 878 | * and the mime-type of the file to be sent is not audio/mpeg, the file will be sent as a playable voice message. |
||
| 879 | * For this to work, the audio must be in an .ogg file encoded with OPUS. |
||
| 880 | * This behavior will be phased out in the future. For sending voice messages, use the sendVoice method instead. |
||
| 881 | * |
||
| 882 | * @deprecated since 20th February. Removed backward compatibility from the method sendAudio. |
||
| 883 | * Voice messages now must be sent using the method sendVoice. |
||
| 884 | * There is no more need to specify a non-empty title or performer while sending the audio by file_id. |
||
| 885 | * |
||
| 886 | * @param int|string $chatId chat_id or @channel_name |
||
| 887 | * @param \CURLFile|string $audio |
||
| 888 | * @param int|null $duration |
||
| 889 | * @param string|null $performer |
||
| 890 | * @param string|null $title |
||
| 891 | * @param int|null $replyToMessageId |
||
| 892 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
| 893 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
| 894 | * @param bool $disableNotification |
||
| 895 | * @param string|null $parseMode |
||
| 896 | * |
||
| 897 | * @return \TelegramBot\Api\Types\Message |
||
| 898 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
| 899 | * @throws \TelegramBot\Api\Exception |
||
| 900 | */ |
||
| 901 | View Code Duplication | public function sendAudio( |
|
| 924 | |||
| 925 | /** |
||
| 926 | * Use this method to send photos. On success, the sent Message is returned. |
||
| 927 | * |
||
| 928 | * @param int|string $chatId chat_id or @channel_name |
||
| 929 | * @param \CURLFile|string $photo |
||
| 930 | * @param string|null $caption |
||
| 931 | * @param int|null $replyToMessageId |
||
| 932 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
| 933 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
| 934 | * @param bool $disableNotification |
||
| 935 | * @param string|null $parseMode |
||
| 936 | * |
||
| 937 | * @return \TelegramBot\Api\Types\Message |
||
| 938 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
| 939 | * @throws \TelegramBot\Api\Exception |
||
| 940 | */ |
||
| 941 | public function sendPhoto( |
||
| 960 | |||
| 961 | /** |
||
| 962 | * Use this method to send general files. On success, the sent Message is returned. |
||
| 963 | * Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future. |
||
| 964 | * |
||
| 965 | * @param int|string $chatId chat_id or @channel_name |
||
| 966 | * @param \CURLFile|string $document |
||
| 967 | * @param string|null $caption |
||
| 968 | * @param int|null $replyToMessageId |
||
| 969 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
| 970 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
| 971 | * @param bool $disableNotification |
||
| 972 | * @param string|null $parseMode |
||
| 973 | * |
||
| 974 | * @return \TelegramBot\Api\Types\Message |
||
| 975 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
| 976 | * @throws \TelegramBot\Api\Exception |
||
| 977 | */ |
||
| 978 | public function sendDocument( |
||
| 997 | |||
| 998 | /** |
||
| 999 | * Use this method to get basic info about a file and prepare it for downloading. |
||
| 1000 | * For the moment, bots can download files of up to 20MB in size. |
||
| 1001 | * On success, a File object is returned. |
||
| 1002 | * The file can then be downloaded via the link https://api.telegram.org/file/bot<token>/<file_path>, |
||
| 1003 | * where <file_path> is taken from the response. |
||
| 1004 | * It is guaranteed that the link will be valid for at least 1 hour. |
||
| 1005 | * When the link expires, a new one can be requested by calling getFile again. |
||
| 1006 | * |
||
| 1007 | * @param $fileId |
||
| 1008 | * |
||
| 1009 | * @return \TelegramBot\Api\Types\File |
||
| 1010 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
| 1011 | * @throws \TelegramBot\Api\Exception |
||
| 1012 | */ |
||
| 1013 | public function getFile($fileId) |
||
| 1017 | |||
| 1018 | /** |
||
| 1019 | * Get file contents via cURL |
||
| 1020 | * |
||
| 1021 | * @param $fileId |
||
| 1022 | * |
||
| 1023 | * @return string |
||
| 1024 | * |
||
| 1025 | * @throws \TelegramBot\Api\HttpException |
||
| 1026 | */ |
||
| 1027 | public function downloadFile($fileId) |
||
| 1039 | |||
| 1040 | /** |
||
| 1041 | * Use this method to send answers to an inline query. On success, True is returned. |
||
| 1042 | * No more than 50 results per query are allowed. |
||
| 1043 | * |
||
| 1044 | * @param string $inlineQueryId |
||
| 1045 | * @param AbstractInlineQueryResult[] $results |
||
| 1046 | * @param int $cacheTime |
||
| 1047 | * @param bool $isPersonal |
||
| 1048 | * @param string $nextOffset |
||
| 1049 | * @param string $switchPmText |
||
| 1050 | * @param string $switchPmParameter |
||
| 1051 | * |
||
| 1052 | * @return mixed |
||
| 1053 | * @throws Exception |
||
| 1054 | */ |
||
| 1055 | public function answerInlineQuery( |
||
| 1079 | |||
| 1080 | /** |
||
| 1081 | * Use this method to kick a user from a group or a supergroup. |
||
| 1082 | * In the case of supergroups, the user will not be able to return to the group |
||
| 1083 | * on their own using invite links, etc., unless unbanned first. |
||
| 1084 | * The bot must be an administrator in the group for this to work. Returns True on success. |
||
| 1085 | * |
||
| 1086 | * @param int|string $chatId Unique identifier for the target group |
||
| 1087 | * or username of the target supergroup (in the format @supergroupusername) |
||
| 1088 | * @param int $userId Unique identifier of the target user |
||
| 1089 | * @param null|int $untilDate Date when the user will be unbanned, unix time. |
||
| 1090 | * If user is banned for more than 366 days or less than 30 seconds from the current time |
||
| 1091 | * they are considered to be banned forever |
||
| 1092 | * |
||
| 1093 | * @return bool |
||
| 1094 | */ |
||
| 1095 | public function kickChatMember($chatId, $userId, $untilDate = null) |
||
| 1103 | |||
| 1104 | /** |
||
| 1105 | * Use this method to unban a previously kicked user in a supergroup. |
||
| 1106 | * The user will not return to the group automatically, but will be able to join via link, etc. |
||
| 1107 | * The bot must be an administrator in the group for this to work. Returns True on success. |
||
| 1108 | * |
||
| 1109 | * @param int|string $chatId Unique identifier for the target group |
||
| 1110 | * or username of the target supergroup (in the format @supergroupusername) |
||
| 1111 | * @param int $userId Unique identifier of the target user |
||
| 1112 | * |
||
| 1113 | * @return bool |
||
| 1114 | */ |
||
| 1115 | public function unbanChatMember($chatId, $userId) |
||
| 1122 | |||
| 1123 | /** |
||
| 1124 | * Use this method to send answers to callback queries sent from inline keyboards. |
||
| 1125 | * The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. |
||
| 1126 | * |
||
| 1127 | * @param $callbackQueryId |
||
| 1128 | * @param null $text |
||
| 1129 | * @param bool $showAlert |
||
| 1130 | * |
||
| 1131 | * @return bool |
||
| 1132 | */ |
||
| 1133 | public function answerCallbackQuery($callbackQueryId, $text = null, $showAlert = false) |
||
| 1141 | |||
| 1142 | /** |
||
| 1143 | * Use this method to change the list of the bot's commands. Returns True on success. |
||
| 1144 | * |
||
| 1145 | * @param $commands |
||
| 1146 | * |
||
| 1147 | * @return mixed |
||
| 1148 | * @throws Exception |
||
| 1149 | * @throws HttpException |
||
| 1150 | * @throws InvalidJsonException |
||
| 1151 | */ |
||
| 1152 | public function setMyCommands($commands) |
||
| 1161 | |||
| 1162 | /** |
||
| 1163 | * Use this method to get the current list of the bot's commands. Requires no parameters. |
||
| 1164 | * Returns Array of BotCommand on success. |
||
| 1165 | * |
||
| 1166 | * @return mixed |
||
| 1167 | * @throws Exception |
||
| 1168 | * @throws HttpException |
||
| 1169 | * @throws InvalidJsonException |
||
| 1170 | */ |
||
| 1171 | public function getMyCommands() |
||
| 1175 | |||
| 1176 | /** |
||
| 1177 | * Use this method to edit text messages sent by the bot or via the bot |
||
| 1178 | * |
||
| 1179 | * @param int|string $chatId |
||
| 1180 | * @param int $messageId |
||
| 1181 | * @param string $text |
||
| 1182 | * @param string $inlineMessageId |
||
| 1183 | * @param string|null $parseMode |
||
| 1184 | * @param bool $disablePreview |
||
| 1185 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
| 1186 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
| 1187 | * @return Message |
||
| 1188 | */ |
||
| 1189 | public function editMessageText( |
||
| 1208 | |||
| 1209 | /** |
||
| 1210 | * Use this method to edit text messages sent by the bot or via the bot |
||
| 1211 | * |
||
| 1212 | * @param int|string $chatId |
||
| 1213 | * @param int $messageId |
||
| 1214 | * @param string|null $caption |
||
| 1215 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
| 1216 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
| 1217 | * @param string $inlineMessageId |
||
| 1218 | * @param string|null $parseMode |
||
| 1219 | * |
||
| 1220 | * @return \TelegramBot\Api\Types\Message |
||
| 1221 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
| 1222 | * @throws \TelegramBot\Api\Exception |
||
| 1223 | */ |
||
| 1224 | View Code Duplication | public function editMessageCaption( |
|
| 1241 | |||
| 1242 | /** |
||
| 1243 | * Use this method to edit animation, audio, document, photo, or video messages. |
||
| 1244 | * If a message is a part of a message album, then it can be edited only to a photo or a video. |
||
| 1245 | * Otherwise, message type can be changed arbitrarily. |
||
| 1246 | * When inline message is edited, new file can't be uploaded. |
||
| 1247 | * Use previously uploaded file via its file_id or specify a URL. |
||
| 1248 | * On success, if the edited message was sent by the bot, the edited Message is returned, otherwise True is returned |
||
| 1249 | * |
||
| 1250 | * @param $chatId |
||
| 1251 | * @param $messageId |
||
| 1252 | * @param InputMedia $media |
||
| 1253 | * @param null $inlineMessageId |
||
| 1254 | * @param null $replyMarkup |
||
| 1255 | * @return bool|Message |
||
| 1256 | * @throws Exception |
||
| 1257 | * @throws HttpException |
||
| 1258 | * @throws InvalidJsonException |
||
| 1259 | */ |
||
| 1260 | View Code Duplication | public function editMessageMedia( |
|
| 1275 | |||
| 1276 | /** |
||
| 1277 | * Use this method to edit only the reply markup of messages sent by the bot or via the bot |
||
| 1278 | * |
||
| 1279 | * @param int|string $chatId |
||
| 1280 | * @param int $messageId |
||
| 1281 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
| 1282 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
| 1283 | * @param string $inlineMessageId |
||
| 1284 | * |
||
| 1285 | * @return Message |
||
| 1286 | */ |
||
| 1287 | public function editMessageReplyMarkup( |
||
| 1300 | |||
| 1301 | /** |
||
| 1302 | * Use this method to delete a message, including service messages, with the following limitations: |
||
| 1303 | * - A message can only be deleted if it was sent less than 48 hours ago. |
||
| 1304 | * - Bots can delete outgoing messages in groups and supergroups. |
||
| 1305 | * - Bots granted can_post_messages permissions can delete outgoing messages in channels. |
||
| 1306 | * - If the bot is an administrator of a group, it can delete any message there. |
||
| 1307 | * - If the bot has can_delete_messages permission in a supergroup or a channel, it can delete any message there. |
||
| 1308 | * |
||
| 1309 | * @param int|string $chatId |
||
| 1310 | * @param int $messageId |
||
| 1311 | * |
||
| 1312 | * @return bool |
||
| 1313 | */ |
||
| 1314 | public function deleteMessage($chatId, $messageId) |
||
| 1321 | |||
| 1322 | /** |
||
| 1323 | * Close curl |
||
| 1324 | */ |
||
| 1325 | 9 | public function __destruct() |
|
| 1329 | |||
| 1330 | /** |
||
| 1331 | * @return string |
||
| 1332 | */ |
||
| 1333 | public function getUrl() |
||
| 1337 | |||
| 1338 | /** |
||
| 1339 | * @return string |
||
| 1340 | */ |
||
| 1341 | public function getFileUrl() |
||
| 1345 | |||
| 1346 | /** |
||
| 1347 | * @param \TelegramBot\Api\Types\Update $update |
||
| 1348 | * @param string $eventName |
||
| 1349 | * |
||
| 1350 | * @throws \TelegramBot\Api\Exception |
||
| 1351 | */ |
||
| 1352 | public function trackUpdate(Update $update, $eventName = 'Message') |
||
| 1364 | |||
| 1365 | /** |
||
| 1366 | * Wrapper for tracker |
||
| 1367 | * |
||
| 1368 | * @param \TelegramBot\Api\Types\Message $message |
||
| 1369 | * @param string $eventName |
||
| 1370 | * |
||
| 1371 | * @throws \TelegramBot\Api\Exception |
||
| 1372 | */ |
||
| 1373 | public function track(Message $message, $eventName = 'Message') |
||
| 1379 | |||
| 1380 | /** |
||
| 1381 | * Use this method to send invoices. On success, the sent Message is returned. |
||
| 1382 | * |
||
| 1383 | * @param int|string $chatId |
||
| 1384 | * @param string $title |
||
| 1385 | * @param string $description |
||
| 1386 | * @param string $payload |
||
| 1387 | * @param string $providerToken |
||
| 1388 | * @param string $startParameter |
||
| 1389 | * @param string $currency |
||
| 1390 | * @param array $prices |
||
| 1391 | * @param string|null $photoUrl |
||
| 1392 | * @param int|null $photoSize |
||
| 1393 | * @param int|null $photoWidth |
||
| 1394 | * @param int|null $photoHeight |
||
| 1395 | * @param bool $needName |
||
| 1396 | * @param bool $needPhoneNumber |
||
| 1397 | * @param bool $needEmail |
||
| 1398 | * @param bool $needShippingAddress |
||
| 1399 | * @param bool $isFlexible |
||
| 1400 | * @param int|null $replyToMessageId |
||
| 1401 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
| 1402 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
| 1403 | * @param bool $disableNotification |
||
| 1404 | * @param string|null $providerData |
||
| 1405 | * @param bool $sendPhoneNumberToProvider |
||
| 1406 | * @param bool $sendEmailToProvider |
||
| 1407 | * |
||
| 1408 | * @return Message |
||
| 1409 | */ |
||
| 1410 | public function sendInvoice( |
||
| 1461 | |||
| 1462 | /** |
||
| 1463 | * If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API |
||
| 1464 | * will send an Update with a shipping_query field to the bot. Use this method to reply to shipping queries. |
||
| 1465 | * On success, True is returned. |
||
| 1466 | * |
||
| 1467 | * @param string $shippingQueryId |
||
| 1468 | * @param bool $ok |
||
| 1469 | * @param array $shipping_options |
||
| 1470 | * @param null|string $errorMessage |
||
| 1471 | * |
||
| 1472 | * @return bool |
||
| 1473 | * |
||
| 1474 | */ |
||
| 1475 | public function answerShippingQuery($shippingQueryId, $ok = true, $shipping_options = [], $errorMessage = null) |
||
| 1484 | |||
| 1485 | /** |
||
| 1486 | * Use this method to respond to such pre-checkout queries. On success, True is returned. |
||
| 1487 | * Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent. |
||
| 1488 | * |
||
| 1489 | * @param string $preCheckoutQueryId |
||
| 1490 | * @param bool $ok |
||
| 1491 | * @param null|string $errorMessage |
||
| 1492 | * |
||
| 1493 | * @return mixed |
||
| 1494 | */ |
||
| 1495 | public function answerPreCheckoutQuery($preCheckoutQueryId, $ok = true, $errorMessage = null) |
||
| 1503 | |||
| 1504 | /** |
||
| 1505 | * Use this method to restrict a user in a supergroup. |
||
| 1506 | * The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights. |
||
| 1507 | * Pass True for all boolean parameters to lift restrictions from a user. |
||
| 1508 | * |
||
| 1509 | * @param string|int $chatId Unique identifier for the target chat or username of the target supergroup |
||
| 1510 | * (in the format @supergroupusername) |
||
| 1511 | * @param int $userId Unique identifier of the target user |
||
| 1512 | * @param null|integer $untilDate Date when restrictions will be lifted for the user, unix time. |
||
| 1513 | * If user is restricted for more than 366 days or less than 30 seconds from the current time, |
||
| 1514 | * they are considered to be restricted forever |
||
| 1515 | * @param bool $canSendMessages Pass True, if the user can send text messages, contacts, locations and venues |
||
| 1516 | * @param bool $canSendMediaMessages No Pass True, if the user can send audios, documents, photos, videos, |
||
| 1517 | * video notes and voice notes, implies can_send_messages |
||
| 1518 | * @param bool $canSendOtherMessages Pass True, if the user can send animations, games, stickers and |
||
| 1519 | * use inline bots, implies can_send_media_messages |
||
| 1520 | * @param bool $canAddWebPagePreviews Pass True, if the user may add web page previews to their messages, |
||
| 1521 | * implies can_send_media_messages |
||
| 1522 | * |
||
| 1523 | * @return bool |
||
| 1524 | */ |
||
| 1525 | public function restrictChatMember( |
||
| 1544 | |||
| 1545 | /** |
||
| 1546 | * Use this method to promote or demote a user in a supergroup or a channel. |
||
| 1547 | * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
||
| 1548 | * Pass False for all boolean parameters to demote a user. |
||
| 1549 | * |
||
| 1550 | * @param string|int $chatId Unique identifier for the target chat or username of the target supergroup |
||
| 1551 | * (in the format @supergroupusername) |
||
| 1552 | * @param int $userId Unique identifier of the target user |
||
| 1553 | * @param bool $canChangeInfo Pass True, if the administrator can change chat title, photo and other settings |
||
| 1554 | * @param bool $canPostMessages Pass True, if the administrator can create channel posts, channels only |
||
| 1555 | * @param bool $canEditMessages Pass True, if the administrator can edit messages of other users, channels only |
||
| 1556 | * @param bool $canDeleteMessages Pass True, if the administrator can delete messages of other users |
||
| 1557 | * @param bool $canInviteUsers Pass True, if the administrator can invite new users to the chat |
||
| 1558 | * @param bool $canRestrictMembers Pass True, if the administrator can restrict, ban or unban chat members |
||
| 1559 | * @param bool $canPinMessages Pass True, if the administrator can pin messages, supergroups only |
||
| 1560 | * @param bool $canPromoteMembers Pass True, if the administrator can add new administrators with a subset of his |
||
| 1561 | * own privileges or demote administrators that he has promoted,directly or |
||
| 1562 | * indirectly (promoted by administrators that were appointed by him) |
||
| 1563 | * |
||
| 1564 | * @return bool |
||
| 1565 | */ |
||
| 1566 | public function promoteChatMember( |
||
| 1591 | |||
| 1592 | /** |
||
| 1593 | * Use this method to export an invite link to a supergroup or a channel. |
||
| 1594 | * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
||
| 1595 | * |
||
| 1596 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
| 1597 | * (in the format @channelusername) |
||
| 1598 | * @return string |
||
| 1599 | */ |
||
| 1600 | public function exportChatInviteLink($chatId) |
||
| 1606 | |||
| 1607 | /** |
||
| 1608 | * Use this method to set a new profile photo for the chat. Photos 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 \CURLFile|string $photo New chat photo, uploaded using multipart/form-data |
||
| 1614 | * |
||
| 1615 | * @return bool |
||
| 1616 | */ |
||
| 1617 | public function setChatPhoto($chatId, $photo) |
||
| 1624 | |||
| 1625 | /** |
||
| 1626 | * Use this method to delete a chat photo. Photos can't be changed for private chats. |
||
| 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 | * |
||
| 1632 | * @return bool |
||
| 1633 | */ |
||
| 1634 | public function deleteChatPhoto($chatId) |
||
| 1640 | |||
| 1641 | /** |
||
| 1642 | * Use this method to change the title of a chat. Titles can't be changed for private chats. |
||
| 1643 | * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
||
| 1644 | * |
||
| 1645 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
| 1646 | * (in the format @channelusername) |
||
| 1647 | * @param string $title New chat title, 1-255 characters |
||
| 1648 | * |
||
| 1649 | * @return bool |
||
| 1650 | */ |
||
| 1651 | public function setChatTitle($chatId, $title) |
||
| 1658 | |||
| 1659 | /** |
||
| 1660 | * Use this method to change the description of a supergroup or a channel. |
||
| 1661 | * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
||
| 1662 | * |
||
| 1663 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
| 1664 | * (in the format @channelusername) |
||
| 1665 | * @param string|null $description New chat description, 0-255 characters |
||
| 1666 | * |
||
| 1667 | * @return bool |
||
| 1668 | */ |
||
| 1669 | public function setChatDescription($chatId, $description = null) |
||
| 1676 | |||
| 1677 | /** |
||
| 1678 | * Use this method to pin a message in a supergroup. |
||
| 1679 | * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
||
| 1680 | * |
||
| 1681 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
| 1682 | * (in the format @channelusername) |
||
| 1683 | * @param int $messageId Identifier of a message to pin |
||
| 1684 | * @param bool $disableNotification |
||
| 1685 | * |
||
| 1686 | * @return bool |
||
| 1687 | */ |
||
| 1688 | public function pinChatMessage($chatId, $messageId, $disableNotification = false) |
||
| 1696 | |||
| 1697 | /** |
||
| 1698 | * Use this method to unpin a message in a supergroup chat. |
||
| 1699 | * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
||
| 1700 | * |
||
| 1701 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
| 1702 | * (in the format @channelusername) |
||
| 1703 | * |
||
| 1704 | * @return bool |
||
| 1705 | */ |
||
| 1706 | public function unpinChatMessage($chatId) |
||
| 1712 | |||
| 1713 | /** |
||
| 1714 | * Use this method to get up to date information about the chat |
||
| 1715 | * (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). |
||
| 1716 | * |
||
| 1717 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
| 1718 | * (in the format @channelusername) |
||
| 1719 | * |
||
| 1720 | * @return Chat |
||
| 1721 | */ |
||
| 1722 | public function getChat($chatId) |
||
| 1728 | |||
| 1729 | /** |
||
| 1730 | * Use this method to get information about a member of a chat. |
||
| 1731 | * |
||
| 1732 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
| 1733 | * (in the format @channelusername) |
||
| 1734 | * @param int $userId |
||
| 1735 | * |
||
| 1736 | * @return ChatMember |
||
| 1737 | */ |
||
| 1738 | public function getChatMember($chatId, $userId) |
||
| 1745 | |||
| 1746 | /** |
||
| 1747 | * Use this method for your bot to leave a group, supergroup or channel. |
||
| 1748 | * |
||
| 1749 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
| 1750 | * (in the format @channelusername) |
||
| 1751 | * |
||
| 1752 | * @return bool |
||
| 1753 | */ |
||
| 1754 | public function leaveChat($chatId) |
||
| 1760 | |||
| 1761 | /** |
||
| 1762 | * Use this method to get the number of members in a chat. |
||
| 1763 | * |
||
| 1764 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
| 1765 | * (in the format @channelusername) |
||
| 1766 | * |
||
| 1767 | * @return int |
||
| 1768 | */ |
||
| 1769 | public function getChatMembersCount($chatId) |
||
| 1778 | |||
| 1779 | /** |
||
| 1780 | * Use this method to get a list of administrators in a chat. |
||
| 1781 | * |
||
| 1782 | * @param string|int $chatId Unique identifier for the target chat or username of the target channel |
||
| 1783 | * (in the format @channelusername) |
||
| 1784 | * |
||
| 1785 | * @return array |
||
| 1786 | */ |
||
| 1787 | public function getChatAdministrators($chatId) |
||
| 1798 | |||
| 1799 | /** |
||
| 1800 | * As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long. |
||
| 1801 | * Use this method to send video messages. |
||
| 1802 | * On success, the sent Message is returned. |
||
| 1803 | * |
||
| 1804 | * @param int|string $chatId chat_id or @channel_name |
||
| 1805 | * @param \CURLFile|string $videoNote |
||
| 1806 | * @param int|null $duration |
||
| 1807 | * @param int|null $length |
||
| 1808 | * @param int|null $replyToMessageId |
||
| 1809 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
| 1810 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
| 1811 | * @param bool $disableNotification |
||
| 1812 | * |
||
| 1813 | * @return \TelegramBot\Api\Types\Message |
||
| 1814 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
| 1815 | * @throws \TelegramBot\Api\Exception |
||
| 1816 | */ |
||
| 1817 | public function sendVideoNote( |
||
| 1836 | |||
| 1837 | /** |
||
| 1838 | * Use this method to send a group of photos or videos as an album. |
||
| 1839 | * On success, the sent \TelegramBot\Api\Types\Message is returned. |
||
| 1840 | * |
||
| 1841 | * @param int|string $chatId |
||
| 1842 | * @param ArrayOfInputMedia $media |
||
| 1843 | * @param int|null $replyToMessageId |
||
| 1844 | * @param bool $disableNotification |
||
| 1845 | * |
||
| 1846 | * @return array |
||
| 1847 | * @throws \TelegramBot\Api\Exception |
||
| 1848 | */ |
||
| 1849 | public function sendMediaGroup( |
||
| 1862 | |||
| 1863 | /** |
||
| 1864 | * Enable proxy for curl requests. Empty string will disable proxy. |
||
| 1865 | * |
||
| 1866 | * @param string $proxyString |
||
| 1867 | * |
||
| 1868 | * @return BotApi |
||
| 1869 | */ |
||
| 1870 | public function setProxy($proxyString = '', $socks5 = false) |
||
| 1887 | |||
| 1888 | |||
| 1889 | /** |
||
| 1890 | * Use this method to send a native poll. A native poll can't be sent to a private chat. |
||
| 1891 | * On success, the sent \TelegramBot\Api\Types\Message is returned. |
||
| 1892 | * |
||
| 1893 | * @param $chatId string|int Unique identifier for the target chat or username of the target channel |
||
| 1894 | * (in the format @channelusername) |
||
| 1895 | * @param string $question Poll question, 1-255 characters |
||
| 1896 | * @param array $options A JSON-serialized list of answer options, 2-10 strings 1-100 characters each |
||
| 1897 | * @param bool $isAnonymous True, if the poll needs to be anonymous, defaults to True |
||
| 1898 | * @param null $type Poll type, “quiz” or “regular”, defaults to “regular” |
||
| 1899 | * @param bool $allowsMultipleAnswers True, if the poll allows multiple answers, |
||
| 1900 | * ignored for polls in quiz mode, defaults to False |
||
| 1901 | * @param null $correctOptionId 0-based identifier of the correct answer option, required for polls in quiz mode |
||
| 1902 | * @param bool $isClosed Pass True, if the poll needs to be immediately closed. This can be useful for poll preview. |
||
| 1903 | * @param bool $disableNotification Sends the message silently. Users will receive a notification with no sound. |
||
| 1904 | * @param int|null $replyToMessageId If the message is a reply, ID of the original message |
||
| 1905 | * @param null $replyMarkup Additional interface options. A JSON-serialized object for an inline keyboard, |
||
| 1906 | * custom reply keyboard, instructions to remove reply |
||
| 1907 | * keyboard or to force a reply from the user. |
||
| 1908 | * @return \TelegramBot\Api\Types\Message |
||
| 1909 | * @throws Exception |
||
| 1910 | * @throws HttpException |
||
| 1911 | * @throws InvalidJsonException |
||
| 1912 | */ |
||
| 1913 | public function sendPoll( |
||
| 1940 | |||
| 1941 | /** |
||
| 1942 | * Use this method to send a dice, which will have a random value from 1 to 6. |
||
| 1943 | * On success, the sent Message is returned. (Yes, we're aware of the “proper” singular of die. |
||
| 1944 | * But it's awkward, and we decided to help it change. One dice at a time!) |
||
| 1945 | * |
||
| 1946 | * @param $chatId string|int Unique identifier for the target chat or username of the target channel |
||
| 1947 | * (in the format @channelusername) |
||
| 1948 | * @param bool $disableNotification Sends the message silently. Users will receive a notification with no sound. |
||
| 1949 | * @param null $replyToMessageId If the message is a reply, ID of the original message |
||
| 1950 | * @param null $replyMarkup Additional interface options. A JSON-serialized object for an inline keyboard, |
||
| 1951 | * custom reply keyboard, instructions to remove reply |
||
| 1952 | * keyboard or to force a reply from the user. |
||
| 1953 | * @return bool|Message |
||
| 1954 | * @throws Exception |
||
| 1955 | * @throws HttpException |
||
| 1956 | * @throws InvalidJsonException |
||
| 1957 | */ |
||
| 1958 | View Code Duplication | public function sendDice( |
|
| 1971 | |||
| 1972 | /** |
||
| 1973 | * Use this method to stop a poll which was sent by the bot. |
||
| 1974 | * On success, the stopped \TelegramBot\Api\Types\Poll with the final results is returned. |
||
| 1975 | * |
||
| 1976 | * @param int|string $chatId |
||
| 1977 | * @param int $messageId |
||
| 1978 | * @param Types\ReplyKeyboardMarkup|Types\ReplyKeyboardHide|Types\ForceReply| |
||
| 1979 | * Types\ReplyKeyboardRemove|null $replyMarkup |
||
| 1980 | * @return Poll |
||
| 1981 | * @throws \TelegramBot\Api\InvalidArgumentException |
||
| 1982 | * @throws \TelegramBot\Api\Exception |
||
| 1983 | */ |
||
| 1984 | public function stopPoll( |
||
| 1995 | |||
| 1996 | /** |
||
| 1997 | * Set an option for a cURL transfer |
||
| 1998 | * |
||
| 1999 | * @param int $option The CURLOPT_XXX option to set |
||
| 2000 | * @param mixed $value The value to be set on option |
||
| 2001 | */ |
||
| 2002 | public function setCurlOption($option, $value) |
||
| 2006 | |||
| 2007 | /** |
||
| 2008 | * Unset an option for a cURL transfer |
||
| 2009 | * |
||
| 2010 | * @param int $option The CURLOPT_XXX option to unset |
||
| 2011 | */ |
||
| 2012 | public function unsetCurlOption($option) |
||
| 2016 | |||
| 2017 | /** |
||
| 2018 | * Clean custom options |
||
| 2019 | */ |
||
| 2020 | public function resetCurlOptions() |
||
| 2024 | } |
||
| 2025 |
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.