Complex classes like Request 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 Request, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 19 | class Request |
||
| 20 | { |
||
| 21 | /** |
||
| 22 | * Telegram object |
||
| 23 | * |
||
| 24 | * @var \Longman\TelegramBot\Telegram |
||
| 25 | */ |
||
| 26 | private static $telegram; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * URI of the Telegram API |
||
| 30 | * |
||
| 31 | * @var string |
||
| 32 | */ |
||
| 33 | private static $api_base_uri = 'https://api.telegram.org'; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Guzzle Client object |
||
| 37 | * |
||
| 38 | * @var \GuzzleHttp\Client |
||
| 39 | */ |
||
| 40 | private static $client; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Input value of the request |
||
| 44 | * |
||
| 45 | * @var string |
||
| 46 | */ |
||
| 47 | private static $input; |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Request limiter |
||
| 51 | * |
||
| 52 | * @var boolean |
||
| 53 | */ |
||
| 54 | private static $limiter_enabled; |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Request limiter's interval between checks |
||
| 58 | * |
||
| 59 | * @var boolean |
||
| 60 | */ |
||
| 61 | private static $limiter_interval; |
||
| 62 | |||
| 63 | /** |
||
| 64 | * Available actions to send |
||
| 65 | * |
||
| 66 | * @var array |
||
| 67 | */ |
||
| 68 | private static $actions = [ |
||
| 69 | 'getUpdates', |
||
| 70 | 'setWebhook', |
||
| 71 | 'deleteWebhook', |
||
| 72 | 'getMe', |
||
| 73 | 'sendMessage', |
||
| 74 | 'forwardMessage', |
||
| 75 | 'sendPhoto', |
||
| 76 | 'sendAudio', |
||
| 77 | 'sendDocument', |
||
| 78 | 'sendSticker', |
||
| 79 | 'sendVideo', |
||
| 80 | 'sendVoice', |
||
| 81 | 'sendLocation', |
||
| 82 | 'sendVenue', |
||
| 83 | 'sendContact', |
||
| 84 | 'sendChatAction', |
||
| 85 | 'getUserProfilePhotos', |
||
| 86 | 'getFile', |
||
| 87 | 'kickChatMember', |
||
| 88 | 'leaveChat', |
||
| 89 | 'unbanChatMember', |
||
| 90 | 'getChat', |
||
| 91 | 'getChatAdministrators', |
||
| 92 | 'getChatMember', |
||
| 93 | 'getChatMembersCount', |
||
| 94 | 'answerCallbackQuery', |
||
| 95 | 'answerInlineQuery', |
||
| 96 | 'editMessageText', |
||
| 97 | 'editMessageCaption', |
||
| 98 | 'editMessageReplyMarkup', |
||
| 99 | 'getWebhookInfo', |
||
| 100 | ]; |
||
| 101 | |||
| 102 | /** |
||
| 103 | * Initialize |
||
| 104 | * |
||
| 105 | * @param \Longman\TelegramBot\Telegram $telegram |
||
| 106 | * |
||
| 107 | * @throws TelegramException |
||
| 108 | */ |
||
| 109 | 30 | public static function initialize(Telegram $telegram) |
|
| 118 | |||
| 119 | /** |
||
| 120 | * Set a custom Guzzle HTTP Client object |
||
| 121 | * |
||
| 122 | * @param Client $client |
||
| 123 | * |
||
| 124 | * @throws TelegramException |
||
| 125 | */ |
||
| 126 | 30 | public static function setClient(Client $client) |
|
| 134 | |||
| 135 | /** |
||
| 136 | * Set input from custom input or stdin and return it |
||
| 137 | * |
||
| 138 | * @return string |
||
| 139 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 140 | */ |
||
| 141 | public static function getInput() |
||
| 159 | |||
| 160 | /** |
||
| 161 | * Generate general fake server response |
||
| 162 | * |
||
| 163 | * @param array $data Data to add to fake response |
||
| 164 | * |
||
| 165 | * @return array Fake response data |
||
| 166 | */ |
||
| 167 | 1 | public static function generateGeneralFakeServerResponse(array $data = []) |
|
| 197 | |||
| 198 | /** |
||
| 199 | * Properly set up the request params |
||
| 200 | * |
||
| 201 | * If any item of the array is a resource, reformat it to a multipart request. |
||
| 202 | * Else, just return the passed data as form params. |
||
| 203 | * |
||
| 204 | * @param array $data |
||
| 205 | * |
||
| 206 | * @return array |
||
| 207 | */ |
||
| 208 | private static function setUpRequestParams(array $data) |
||
| 229 | |||
| 230 | /** |
||
| 231 | * Execute HTTP Request |
||
| 232 | * |
||
| 233 | * @param string $action Action to execute |
||
| 234 | * @param array $data Data to attach to the execution |
||
| 235 | * |
||
| 236 | * @return string Result of the HTTP Request |
||
| 237 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 238 | */ |
||
| 239 | public static function execute($action, array $data = []) |
||
| 270 | |||
| 271 | /** |
||
| 272 | * Download file |
||
| 273 | * |
||
| 274 | * @param \Longman\TelegramBot\Entities\File $file |
||
| 275 | * |
||
| 276 | * @return boolean |
||
| 277 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 278 | */ |
||
| 279 | public static function downloadFile(File $file) |
||
| 307 | |||
| 308 | /** |
||
| 309 | * Encode file |
||
| 310 | * |
||
| 311 | * @param string $file |
||
| 312 | * |
||
| 313 | * @return resource |
||
| 314 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 315 | */ |
||
| 316 | protected static function encodeFile($file) |
||
| 325 | |||
| 326 | /** |
||
| 327 | * Send command |
||
| 328 | * |
||
| 329 | * @todo Fake response doesn't need json encoding? |
||
| 330 | * |
||
| 331 | * @param string $action |
||
| 332 | * @param array $data |
||
| 333 | * |
||
| 334 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
| 335 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 336 | */ |
||
| 337 | public static function send($action, array $data = []) |
||
| 361 | |||
| 362 | /** |
||
| 363 | * Make sure the data isn't empty, else throw an exception |
||
| 364 | * |
||
| 365 | * @param array $data |
||
| 366 | * |
||
| 367 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 368 | */ |
||
| 369 | private static function ensureNonEmptyData(array $data) |
||
| 375 | |||
| 376 | /** |
||
| 377 | * Make sure the action is valid, else throw an exception |
||
| 378 | * |
||
| 379 | * @param string $action |
||
| 380 | * |
||
| 381 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 382 | */ |
||
| 383 | private static function ensureValidAction($action) |
||
| 389 | |||
| 390 | /** |
||
| 391 | * Assign an encoded file to a data array |
||
| 392 | * |
||
| 393 | * @param array $data |
||
| 394 | * @param string $field |
||
| 395 | * @param string $file |
||
| 396 | * |
||
| 397 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 398 | */ |
||
| 399 | private static function assignEncodedFile(&$data, $field, $file) |
||
| 405 | |||
| 406 | /** |
||
| 407 | * Returns basic information about the bot in form of a User object |
||
| 408 | * |
||
| 409 | * @link https://core.telegram.org/bots/api#getme |
||
| 410 | * |
||
| 411 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
| 412 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 413 | */ |
||
| 414 | public static function getMe() |
||
| 420 | |||
| 421 | /** |
||
| 422 | * Use this method to send text messages. On success, the sent Message is returned |
||
| 423 | * |
||
| 424 | * @link https://core.telegram.org/bots/api#sendmessage |
||
| 425 | * |
||
| 426 | * @param array $data |
||
| 427 | * |
||
| 428 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
| 429 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 430 | */ |
||
| 431 | public static function sendMessage(array $data) |
||
| 446 | |||
| 447 | /** |
||
| 448 | * Use this method to forward messages of any kind. On success, the sent Message is returned |
||
| 449 | * |
||
| 450 | * @link https://core.telegram.org/bots/api#forwardmessage |
||
| 451 | * |
||
| 452 | * @param array $data |
||
| 453 | * |
||
| 454 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
| 455 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 456 | */ |
||
| 457 | public static function forwardMessage(array $data) |
||
| 461 | |||
| 462 | /** |
||
| 463 | * Use this method to send photos. On success, the sent Message is returned |
||
| 464 | * |
||
| 465 | * @link https://core.telegram.org/bots/api#sendphoto |
||
| 466 | * |
||
| 467 | * @param array $data |
||
| 468 | * @param string $file |
||
| 469 | * |
||
| 470 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
| 471 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 472 | */ |
||
| 473 | public static function sendPhoto(array $data, $file = null) |
||
| 479 | |||
| 480 | /** |
||
| 481 | * Use this method to send audio files |
||
| 482 | * |
||
| 483 | * Your audio must be in the .mp3 format. On success, the sent Message is returned. |
||
| 484 | * Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future. |
||
| 485 | * For sending voice messages, use the sendVoice method instead. |
||
| 486 | * |
||
| 487 | * @link https://core.telegram.org/bots/api#sendaudio |
||
| 488 | * |
||
| 489 | * @param array $data |
||
| 490 | * @param string $file |
||
| 491 | * |
||
| 492 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
| 493 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 494 | */ |
||
| 495 | public static function sendAudio(array $data, $file = null) |
||
| 501 | |||
| 502 | /** |
||
| 503 | * Use this method to send general files. On success, the sent Message is returned. |
||
| 504 | * |
||
| 505 | * Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future. |
||
| 506 | * |
||
| 507 | * @link https://core.telegram.org/bots/api#senddocument |
||
| 508 | * |
||
| 509 | * @param array $data |
||
| 510 | * @param string $file |
||
| 511 | * |
||
| 512 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
| 513 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 514 | */ |
||
| 515 | public static function sendDocument(array $data, $file = null) |
||
| 521 | |||
| 522 | /** |
||
| 523 | * Use this method to send .webp stickers. On success, the sent Message is returned. |
||
| 524 | * |
||
| 525 | * @link https://core.telegram.org/bots/api#sendsticker |
||
| 526 | * |
||
| 527 | * @param array $data |
||
| 528 | * @param string $file |
||
| 529 | * |
||
| 530 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
| 531 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 532 | */ |
||
| 533 | public static function sendSticker(array $data, $file = null) |
||
| 539 | |||
| 540 | /** |
||
| 541 | * Use this method to send video files. On success, the sent Message is returned. |
||
| 542 | * |
||
| 543 | * Telegram clients support mp4 videos (other formats may be sent as Document). |
||
| 544 | * Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future. |
||
| 545 | * |
||
| 546 | * @link https://core.telegram.org/bots/api#sendvideo |
||
| 547 | * |
||
| 548 | * @param array $data |
||
| 549 | * @param string $file |
||
| 550 | * |
||
| 551 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
| 552 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 553 | */ |
||
| 554 | public static function sendVideo(array $data, $file = null) |
||
| 560 | |||
| 561 | /** |
||
| 562 | * Use this method to send audio files. On success, the sent Message is returned. |
||
| 563 | * |
||
| 564 | * Telegram clients will display the file as a playable voice message. |
||
| 565 | * For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Audio or Document). |
||
| 566 | * Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future. |
||
| 567 | * |
||
| 568 | * @link https://core.telegram.org/bots/api#sendvoice |
||
| 569 | * |
||
| 570 | * @param array $data |
||
| 571 | * @param string $file |
||
| 572 | * |
||
| 573 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
| 574 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 575 | */ |
||
| 576 | public static function sendVoice(array $data, $file = null) |
||
| 582 | |||
| 583 | /** |
||
| 584 | * Use this method to send point on the map. On success, the sent Message is returned. |
||
| 585 | * |
||
| 586 | * @link https://core.telegram.org/bots/api#sendlocation |
||
| 587 | * |
||
| 588 | * @param array $data |
||
| 589 | * |
||
| 590 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
| 591 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 592 | */ |
||
| 593 | public static function sendLocation(array $data) |
||
| 597 | |||
| 598 | /** |
||
| 599 | * Use this method to send information about a venue. On success, the sent Message is returned. |
||
| 600 | * |
||
| 601 | * @link https://core.telegram.org/bots/api#sendvenue |
||
| 602 | * |
||
| 603 | * @param array $data |
||
| 604 | * |
||
| 605 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
| 606 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 607 | */ |
||
| 608 | public static function sendVenue(array $data) |
||
| 612 | |||
| 613 | /** |
||
| 614 | * Use this method to send phone contacts. On success, the sent Message is returned. |
||
| 615 | * |
||
| 616 | * @link https://core.telegram.org/bots/api#sendcontact |
||
| 617 | * |
||
| 618 | * @param array $data |
||
| 619 | * |
||
| 620 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
| 621 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 622 | */ |
||
| 623 | public static function sendContact(array $data) |
||
| 627 | |||
| 628 | /** |
||
| 629 | * Use this method when you need to tell the user that something is happening on the bot's side. |
||
| 630 | * |
||
| 631 | * The status is set for 5 seconds or less. |
||
| 632 | * (when a message arrives from your bot, Telegram clients clear its typing status) |
||
| 633 | * |
||
| 634 | * @link https://core.telegram.org/bots/api#sendchataction |
||
| 635 | * |
||
| 636 | * @param array $data |
||
| 637 | * |
||
| 638 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
| 639 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 640 | */ |
||
| 641 | public static function sendChatAction(array $data) |
||
| 645 | |||
| 646 | /** |
||
| 647 | * Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object. |
||
| 648 | * |
||
| 649 | * @param array $data |
||
| 650 | * |
||
| 651 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
| 652 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 653 | */ |
||
| 654 | public static function getUserProfilePhotos(array $data) |
||
| 658 | |||
| 659 | /** |
||
| 660 | * Use this method to get basic info about a file and prepare it for downloading. On success, a File object is returned. |
||
| 661 | * |
||
| 662 | * For the moment, bots can download files of up to 20MB in size. |
||
| 663 | * The file can then be downloaded via the link https://api.telegram.org/file/bot<token>/<file_path>, |
||
| 664 | * where <file_path> is taken from the response. |
||
| 665 | * It is guaranteed that the link will be valid for at least 1 hour. |
||
| 666 | * When the link expires, a new one can be requested by calling getFile again. |
||
| 667 | * |
||
| 668 | * @link https://core.telegram.org/bots/api#getfile |
||
| 669 | * |
||
| 670 | * @param array $data |
||
| 671 | * |
||
| 672 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
| 673 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 674 | */ |
||
| 675 | public static function getFile(array $data) |
||
| 679 | |||
| 680 | /** |
||
| 681 | * Use this method to kick a user from a group or a supergroup. Returns True on success. |
||
| 682 | * |
||
| 683 | * In the case of supergroups, the user will not be able to return to the group on their own using invite links, etc., unless unbanned first. |
||
| 684 | * The bot must be an administrator in the group for this to work. |
||
| 685 | * |
||
| 686 | * @link https://core.telegram.org/bots/api#kickchatmember |
||
| 687 | * |
||
| 688 | * @param array $data |
||
| 689 | * |
||
| 690 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
| 691 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 692 | */ |
||
| 693 | public static function kickChatMember(array $data) |
||
| 697 | |||
| 698 | /** |
||
| 699 | * Use this method for your bot to leave a group, supergroup or channel. Returns True on success. |
||
| 700 | * |
||
| 701 | * @link https://core.telegram.org/bots/api#leavechat |
||
| 702 | * |
||
| 703 | * @param array $data |
||
| 704 | * |
||
| 705 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
| 706 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 707 | */ |
||
| 708 | public static function leaveChat(array $data) |
||
| 712 | |||
| 713 | /** |
||
| 714 | * Use this method to unban a previously kicked user in a supergroup. Returns True on success. |
||
| 715 | * |
||
| 716 | * The user will not return to the group automatically, but will be able to join via link, etc. |
||
| 717 | * The bot must be an administrator in the group for this to work. |
||
| 718 | * |
||
| 719 | * @link https://core.telegram.org/bots/api#unbanchatmember |
||
| 720 | * |
||
| 721 | * @param array $data |
||
| 722 | * |
||
| 723 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
| 724 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 725 | */ |
||
| 726 | public static function unbanChatMember(array $data) |
||
| 730 | |||
| 731 | /** |
||
| 732 | * Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). Returns a Chat object on success. |
||
| 733 | * |
||
| 734 | * @todo add get response in ServerResponse.php? |
||
| 735 | * |
||
| 736 | * @link https://core.telegram.org/bots/api#getchat |
||
| 737 | * |
||
| 738 | * @param array $data |
||
| 739 | * |
||
| 740 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
| 741 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 742 | */ |
||
| 743 | public static function getChat(array $data) |
||
| 747 | |||
| 748 | /** |
||
| 749 | * Use this method to get a list of administrators in a chat. |
||
| 750 | * |
||
| 751 | * On success, returns an Array of ChatMember objects that contains information about all chat administrators except other bots. |
||
| 752 | * If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned. |
||
| 753 | * |
||
| 754 | * @todo add get response in ServerResponse.php? |
||
| 755 | * |
||
| 756 | * @link https://core.telegram.org/bots/api#getchatadministrators |
||
| 757 | * |
||
| 758 | * @param array $data |
||
| 759 | * |
||
| 760 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
| 761 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 762 | */ |
||
| 763 | public static function getChatAdministrators(array $data) |
||
| 767 | |||
| 768 | /** |
||
| 769 | * Use this method to get the number of members in a chat. Returns Int on success. |
||
| 770 | * |
||
| 771 | * @todo add get response in ServerResponse.php? |
||
| 772 | * |
||
| 773 | * @link https://core.telegram.org/bots/api#getchatmemberscount |
||
| 774 | * |
||
| 775 | * @param array $data |
||
| 776 | * |
||
| 777 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
| 778 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 779 | */ |
||
| 780 | public static function getChatMembersCount(array $data) |
||
| 784 | |||
| 785 | /** |
||
| 786 | * Use this method to get information about a member of a chat. Returns a ChatMember object on success. |
||
| 787 | * |
||
| 788 | * @todo add get response in ServerResponse.php? |
||
| 789 | * |
||
| 790 | * @link https://core.telegram.org/bots/api#getchatmember |
||
| 791 | * |
||
| 792 | * @param array $data |
||
| 793 | * |
||
| 794 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
| 795 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 796 | */ |
||
| 797 | public static function getChatMember(array $data) |
||
| 801 | |||
| 802 | /** |
||
| 803 | * Use this method to send answers to callback queries sent from inline keyboards. On success, True is returned. |
||
| 804 | * |
||
| 805 | * The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. |
||
| 806 | * |
||
| 807 | * @link https://core.telegram.org/bots/api#answercallbackquery |
||
| 808 | * |
||
| 809 | * @param array $data |
||
| 810 | * |
||
| 811 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
| 812 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 813 | */ |
||
| 814 | public static function answerCallbackQuery(array $data) |
||
| 818 | |||
| 819 | /** |
||
| 820 | * Get updates |
||
| 821 | * |
||
| 822 | * @link https://core.telegram.org/bots/api#getupdates |
||
| 823 | * |
||
| 824 | * @param array $data |
||
| 825 | * |
||
| 826 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
| 827 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 828 | */ |
||
| 829 | public static function getUpdates(array $data) |
||
| 833 | |||
| 834 | /** |
||
| 835 | * Set webhook |
||
| 836 | * |
||
| 837 | * @link https://core.telegram.org/bots/api#setwebhook |
||
| 838 | * |
||
| 839 | * @param string $url |
||
| 840 | * @param array $data Optional parameters. |
||
| 841 | * |
||
| 842 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
| 843 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 844 | */ |
||
| 845 | public static function setWebhook($url = '', array $data = []) |
||
| 860 | |||
| 861 | /** |
||
| 862 | * Delete webhook |
||
| 863 | * |
||
| 864 | * @link https://core.telegram.org/bots/api#deletewebhook |
||
| 865 | * |
||
| 866 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
| 867 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 868 | */ |
||
| 869 | public static function deleteWebhook() |
||
| 874 | |||
| 875 | /** |
||
| 876 | * Use this method to edit text and game messages sent by the bot or via the bot (for inline bots). |
||
| 877 | * |
||
| 878 | * On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned. |
||
| 879 | * |
||
| 880 | * @link https://core.telegram.org/bots/api#editmessagetext |
||
| 881 | * |
||
| 882 | * @param array $data |
||
| 883 | * |
||
| 884 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
| 885 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 886 | */ |
||
| 887 | public static function editMessageText(array $data) |
||
| 891 | |||
| 892 | /** |
||
| 893 | * Use this method to edit captions of messages sent by the bot or via the bot (for inline bots). |
||
| 894 | * |
||
| 895 | * On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned. |
||
| 896 | * |
||
| 897 | * @link https://core.telegram.org/bots/api#editmessagecaption |
||
| 898 | * |
||
| 899 | * @param array $data |
||
| 900 | * |
||
| 901 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
| 902 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 903 | */ |
||
| 904 | public static function editMessageCaption(array $data) |
||
| 908 | |||
| 909 | /** |
||
| 910 | * Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots). |
||
| 911 | * |
||
| 912 | * On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned. |
||
| 913 | * |
||
| 914 | * @link https://core.telegram.org/bots/api#editmessagereplymarkup |
||
| 915 | * |
||
| 916 | * @param array $data |
||
| 917 | * |
||
| 918 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
| 919 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 920 | */ |
||
| 921 | public static function editMessageReplyMarkup(array $data) |
||
| 925 | |||
| 926 | /** |
||
| 927 | * Use this method to send answers to an inline query. On success, True is returned. |
||
| 928 | * |
||
| 929 | * No more than 50 results per query are allowed. |
||
| 930 | * |
||
| 931 | * @link https://core.telegram.org/bots/api#answerinlinequery |
||
| 932 | * |
||
| 933 | * @param array $data |
||
| 934 | * |
||
| 935 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
| 936 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 937 | */ |
||
| 938 | public static function answerInlineQuery(array $data) |
||
| 942 | |||
| 943 | /** |
||
| 944 | * Return an empty Server Response |
||
| 945 | * |
||
| 946 | * No request to telegram are sent, this function is used in commands that |
||
| 947 | * don't need to fire a message after execution |
||
| 948 | * |
||
| 949 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
| 950 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 951 | */ |
||
| 952 | public static function emptyResponse() |
||
| 956 | |||
| 957 | /** |
||
| 958 | * Send message to all active chats |
||
| 959 | * |
||
| 960 | * @param string $callback_function |
||
| 961 | * @param array $data |
||
| 962 | * @param boolean $send_groups |
||
| 963 | * @param boolean $send_super_groups |
||
| 964 | * @param boolean $send_users |
||
| 965 | * @param string $date_from |
||
| 966 | * @param string $date_to |
||
| 967 | * |
||
| 968 | * @return array |
||
| 969 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 970 | */ |
||
| 971 | public static function sendToActiveChats( |
||
| 997 | |||
| 998 | /** |
||
| 999 | * Use this method to get current webhook status. |
||
| 1000 | * |
||
| 1001 | * @link https://core.telegram.org/bots/api#getwebhookinfo |
||
| 1002 | * |
||
| 1003 | * @return Entities\ServerResponse |
||
| 1004 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 1005 | */ |
||
| 1006 | public static function getWebhookInfo() |
||
| 1011 | |||
| 1012 | /** |
||
| 1013 | * Enable request limiter |
||
| 1014 | * |
||
| 1015 | * @param boolean $value |
||
| 1016 | * @param array $options |
||
| 1017 | * |
||
| 1018 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 1019 | */ |
||
| 1020 | public static function setLimiter($value = true, array $options = []) |
||
| 1037 | |||
| 1038 | /** |
||
| 1039 | * This functions delays API requests to prevent reaching Telegram API limits |
||
| 1040 | * Can be disabled while in execution by 'Request::setLimiter(false)' |
||
| 1041 | * |
||
| 1042 | * @link https://core.telegram.org/bots/faq#my-bot-is-hitting-limits-how-do-i-avoid-this |
||
| 1043 | * |
||
| 1044 | * @param string $action |
||
| 1045 | * @param array $data |
||
| 1046 | * |
||
| 1047 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
| 1048 | */ |
||
| 1049 | private static function limitTelegramRequests($action, array $data = []) |
||
| 1097 | } |
||
| 1098 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..