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 \Longman\TelegramBot\Exception\TelegramException |
||
108 | */ |
||
109 | 30 | public static function initialize(Telegram $telegram) |
|
118 | |||
119 | /** |
||
120 | * Set input from custom input or stdin and return it |
||
121 | * |
||
122 | * @return string |
||
123 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
124 | */ |
||
125 | public static function getInput() |
||
143 | |||
144 | /** |
||
145 | * Generate general fake server response |
||
146 | * |
||
147 | * @param array $data Data to add to fake response |
||
148 | * |
||
149 | * @return array Fake response data |
||
150 | */ |
||
151 | 1 | public static function generateGeneralFakeServerResponse(array $data = []) |
|
181 | |||
182 | /** |
||
183 | * Properly set up the request params |
||
184 | * |
||
185 | * If any item of the array is a resource, reformat it to a multipart request. |
||
186 | * Else, just return the passed data as form params. |
||
187 | * |
||
188 | * @param array $data |
||
189 | * |
||
190 | * @return array |
||
191 | */ |
||
192 | private static function setUpRequestParams(array $data) |
||
193 | { |
||
194 | $has_resource = false; |
||
195 | $multipart = []; |
||
196 | |||
197 | // Convert any nested arrays into JSON strings. |
||
198 | array_walk($data, function (&$item) { |
||
199 | is_array($item) && $item = json_encode($item); |
||
200 | }); |
||
201 | |||
202 | //Reformat data array in multipart way if it contains a resource |
||
203 | foreach ($data as $key => $item) { |
||
204 | $has_resource |= (is_resource($item) || $item instanceof \GuzzleHttp\Psr7\Stream); |
||
205 | $multipart[] = ['name' => $key, 'contents' => $item]; |
||
206 | } |
||
207 | if ($has_resource) { |
||
208 | return ['multipart' => $multipart]; |
||
209 | } |
||
210 | |||
211 | return ['form_params' => $data]; |
||
212 | } |
||
213 | |||
214 | /** |
||
215 | * Execute HTTP Request |
||
216 | * |
||
217 | * @param string $action Action to execute |
||
218 | * @param array $data Data to attach to the execution |
||
219 | * |
||
220 | * @return string Result of the HTTP Request |
||
221 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
222 | */ |
||
223 | public static function execute($action, array $data = []) |
||
224 | { |
||
225 | //Fix so that the keyboard markup is a string, not an object |
||
226 | if (isset($data['reply_markup'])) { |
||
227 | $data['reply_markup'] = json_encode($data['reply_markup']); |
||
228 | } |
||
229 | |||
230 | $result = null; |
||
231 | $request_params = self::setUpRequestParams($data); |
||
232 | $request_params['debug'] = TelegramLog::getDebugLogTempStream(); |
||
233 | |||
234 | try { |
||
235 | $response = self::$client->post( |
||
236 | '/bot' . self::$telegram->getApiKey() . '/' . $action, |
||
237 | $request_params |
||
238 | ); |
||
239 | $result = (string) $response->getBody(); |
||
240 | |||
241 | //Logging getUpdates Update |
||
242 | if ($action === 'getUpdates') { |
||
243 | TelegramLog::update($result); |
||
244 | } |
||
245 | } catch (RequestException $e) { |
||
246 | $result = ($e->getResponse()) ? (string) $e->getResponse()->getBody() : ''; |
||
247 | } finally { |
||
248 | //Logging verbose debug output |
||
249 | TelegramLog::endDebugLogTempStream('Verbose HTTP Request output:' . PHP_EOL . '%s' . PHP_EOL); |
||
250 | } |
||
251 | |||
252 | return $result; |
||
253 | } |
||
254 | |||
255 | /** |
||
256 | * Download file |
||
257 | * |
||
258 | * @param \Longman\TelegramBot\Entities\File $file |
||
259 | * |
||
260 | * @return boolean |
||
261 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
262 | */ |
||
263 | public static function downloadFile(File $file) |
||
291 | |||
292 | /** |
||
293 | * Encode file |
||
294 | * |
||
295 | * @param string $file |
||
296 | * |
||
297 | * @return resource |
||
298 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
299 | */ |
||
300 | protected static function encodeFile($file) |
||
309 | |||
310 | /** |
||
311 | * Send command |
||
312 | * |
||
313 | * @todo Fake response doesn't need json encoding? |
||
314 | * |
||
315 | * @param string $action |
||
316 | * @param array $data |
||
317 | * |
||
318 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
319 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
320 | */ |
||
321 | public static function send($action, array $data = []) |
||
345 | |||
346 | /** |
||
347 | * Make sure the data isn't empty, else throw an exception |
||
348 | * |
||
349 | * @param array $data |
||
350 | * |
||
351 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
352 | */ |
||
353 | private static function ensureNonEmptyData(array $data) |
||
359 | |||
360 | /** |
||
361 | * Make sure the action is valid, else throw an exception |
||
362 | * |
||
363 | * @param string $action |
||
364 | * |
||
365 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
366 | */ |
||
367 | private static function ensureValidAction($action) |
||
373 | |||
374 | /** |
||
375 | * Assign an encoded file to a data array |
||
376 | * |
||
377 | * @param array $data |
||
378 | * @param string $field |
||
379 | * @param string $file |
||
380 | * |
||
381 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
382 | */ |
||
383 | private static function assignEncodedFile(&$data, $field, $file) |
||
389 | |||
390 | /** |
||
391 | * Returns basic information about the bot in form of a User object |
||
392 | * |
||
393 | * @link https://core.telegram.org/bots/api#getme |
||
394 | * |
||
395 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
396 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
397 | */ |
||
398 | public static function getMe() |
||
404 | |||
405 | /** |
||
406 | * Use this method to send text messages. On success, the sent Message is returned |
||
407 | * |
||
408 | * @link https://core.telegram.org/bots/api#sendmessage |
||
409 | * |
||
410 | * @param array $data |
||
411 | * |
||
412 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
413 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
414 | */ |
||
415 | public static function sendMessage(array $data) |
||
430 | |||
431 | /** |
||
432 | * Use this method to forward messages of any kind. On success, the sent Message is returned |
||
433 | * |
||
434 | * @link https://core.telegram.org/bots/api#forwardmessage |
||
435 | * |
||
436 | * @param array $data |
||
437 | * |
||
438 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
439 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
440 | */ |
||
441 | public static function forwardMessage(array $data) |
||
445 | |||
446 | /** |
||
447 | * Use this method to send photos. On success, the sent Message is returned |
||
448 | * |
||
449 | * @link https://core.telegram.org/bots/api#sendphoto |
||
450 | * |
||
451 | * @param array $data |
||
452 | * @param string $file |
||
453 | * |
||
454 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
455 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
456 | */ |
||
457 | public static function sendPhoto(array $data, $file = null) |
||
463 | |||
464 | /** |
||
465 | * Use this method to send audio files |
||
466 | * |
||
467 | * Your audio must be in the .mp3 format. On success, the sent Message is returned. |
||
468 | * Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future. |
||
469 | * For sending voice messages, use the sendVoice method instead. |
||
470 | * |
||
471 | * @link https://core.telegram.org/bots/api#sendaudio |
||
472 | * |
||
473 | * @param array $data |
||
474 | * @param string $file |
||
475 | * |
||
476 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
477 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
478 | */ |
||
479 | public static function sendAudio(array $data, $file = null) |
||
485 | |||
486 | /** |
||
487 | * Use this method to send general files. On success, the sent Message is returned. |
||
488 | * |
||
489 | * Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future. |
||
490 | * |
||
491 | * @link https://core.telegram.org/bots/api#senddocument |
||
492 | * |
||
493 | * @param array $data |
||
494 | * @param string $file |
||
495 | * |
||
496 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
497 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
498 | */ |
||
499 | public static function sendDocument(array $data, $file = null) |
||
505 | |||
506 | /** |
||
507 | * Use this method to send .webp stickers. On success, the sent Message is returned. |
||
508 | * |
||
509 | * @link https://core.telegram.org/bots/api#sendsticker |
||
510 | * |
||
511 | * @param array $data |
||
512 | * @param string $file |
||
513 | * |
||
514 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
515 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
516 | */ |
||
517 | public static function sendSticker(array $data, $file = null) |
||
523 | |||
524 | /** |
||
525 | * Use this method to send video files. On success, the sent Message is returned. |
||
526 | * |
||
527 | * Telegram clients support mp4 videos (other formats may be sent as Document). |
||
528 | * Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future. |
||
529 | * |
||
530 | * @link https://core.telegram.org/bots/api#sendvideo |
||
531 | * |
||
532 | * @param array $data |
||
533 | * @param string $file |
||
534 | * |
||
535 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
536 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
537 | */ |
||
538 | public static function sendVideo(array $data, $file = null) |
||
544 | |||
545 | /** |
||
546 | * Use this method to send audio files. On success, the sent Message is returned. |
||
547 | * |
||
548 | * Telegram clients will display the file as a playable voice message. |
||
549 | * For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Audio or Document). |
||
550 | * Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future. |
||
551 | * |
||
552 | * @link https://core.telegram.org/bots/api#sendvoice |
||
553 | * |
||
554 | * @param array $data |
||
555 | * @param string $file |
||
556 | * |
||
557 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
558 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
559 | */ |
||
560 | public static function sendVoice(array $data, $file = null) |
||
566 | |||
567 | /** |
||
568 | * Use this method to send point on the map. On success, the sent Message is returned. |
||
569 | * |
||
570 | * @link https://core.telegram.org/bots/api#sendlocation |
||
571 | * |
||
572 | * @param array $data |
||
573 | * |
||
574 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
575 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
576 | */ |
||
577 | public static function sendLocation(array $data) |
||
581 | |||
582 | /** |
||
583 | * Use this method to send information about a venue. On success, the sent Message is returned. |
||
584 | * |
||
585 | * @link https://core.telegram.org/bots/api#sendvenue |
||
586 | * |
||
587 | * @param array $data |
||
588 | * |
||
589 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
590 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
591 | */ |
||
592 | public static function sendVenue(array $data) |
||
596 | |||
597 | /** |
||
598 | * Use this method to send phone contacts. On success, the sent Message is returned. |
||
599 | * |
||
600 | * @link https://core.telegram.org/bots/api#sendcontact |
||
601 | * |
||
602 | * @param array $data |
||
603 | * |
||
604 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
605 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
606 | */ |
||
607 | public static function sendContact(array $data) |
||
611 | |||
612 | /** |
||
613 | * Use this method when you need to tell the user that something is happening on the bot's side. |
||
614 | * |
||
615 | * The status is set for 5 seconds or less. |
||
616 | * (when a message arrives from your bot, Telegram clients clear its typing status) |
||
617 | * |
||
618 | * @link https://core.telegram.org/bots/api#sendchataction |
||
619 | * |
||
620 | * @param array $data |
||
621 | * |
||
622 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
623 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
624 | */ |
||
625 | public static function sendChatAction(array $data) |
||
629 | |||
630 | /** |
||
631 | * Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object. |
||
632 | * |
||
633 | * @param array $data |
||
634 | * |
||
635 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
636 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
637 | */ |
||
638 | public static function getUserProfilePhotos(array $data) |
||
642 | |||
643 | /** |
||
644 | * Use this method to get basic info about a file and prepare it for downloading. On success, a File object is returned. |
||
645 | * |
||
646 | * For the moment, bots can download files of up to 20MB in size. |
||
647 | * The file can then be downloaded via the link https://api.telegram.org/file/bot<token>/<file_path>, |
||
648 | * where <file_path> is taken from the response. |
||
649 | * It is guaranteed that the link will be valid for at least 1 hour. |
||
650 | * When the link expires, a new one can be requested by calling getFile again. |
||
651 | * |
||
652 | * @link https://core.telegram.org/bots/api#getfile |
||
653 | * |
||
654 | * @param array $data |
||
655 | * |
||
656 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
657 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
658 | */ |
||
659 | public static function getFile(array $data) |
||
663 | |||
664 | /** |
||
665 | * Use this method to kick a user from a group or a supergroup. Returns True on success. |
||
666 | * |
||
667 | * 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. |
||
668 | * The bot must be an administrator in the group for this to work. |
||
669 | * |
||
670 | * @link https://core.telegram.org/bots/api#kickchatmember |
||
671 | * |
||
672 | * @param array $data |
||
673 | * |
||
674 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
675 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
676 | */ |
||
677 | public static function kickChatMember(array $data) |
||
681 | |||
682 | /** |
||
683 | * Use this method for your bot to leave a group, supergroup or channel. Returns True on success. |
||
684 | * |
||
685 | * @link https://core.telegram.org/bots/api#leavechat |
||
686 | * |
||
687 | * @param array $data |
||
688 | * |
||
689 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
690 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
691 | */ |
||
692 | public static function leaveChat(array $data) |
||
696 | |||
697 | /** |
||
698 | * Use this method to unban a previously kicked user in a supergroup. Returns True on success. |
||
699 | * |
||
700 | * The user will not return to the group automatically, but will be able to join via link, etc. |
||
701 | * The bot must be an administrator in the group for this to work. |
||
702 | * |
||
703 | * @link https://core.telegram.org/bots/api#unbanchatmember |
||
704 | * |
||
705 | * @param array $data |
||
706 | * |
||
707 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
708 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
709 | */ |
||
710 | public static function unbanChatMember(array $data) |
||
714 | |||
715 | /** |
||
716 | * 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. |
||
717 | * |
||
718 | * @todo add get response in ServerResponse.php? |
||
719 | * |
||
720 | * @link https://core.telegram.org/bots/api#getchat |
||
721 | * |
||
722 | * @param array $data |
||
723 | * |
||
724 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
725 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
726 | */ |
||
727 | public static function getChat(array $data) |
||
731 | |||
732 | /** |
||
733 | * Use this method to get a list of administrators in a chat. |
||
734 | * |
||
735 | * On success, returns an Array of ChatMember objects that contains information about all chat administrators except other bots. |
||
736 | * If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned. |
||
737 | * |
||
738 | * @todo add get response in ServerResponse.php? |
||
739 | * |
||
740 | * @link https://core.telegram.org/bots/api#getchatadministrators |
||
741 | * |
||
742 | * @param array $data |
||
743 | * |
||
744 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
745 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
746 | */ |
||
747 | public static function getChatAdministrators(array $data) |
||
751 | |||
752 | /** |
||
753 | * Use this method to get the number of members in a chat. Returns Int on success. |
||
754 | * |
||
755 | * @todo add get response in ServerResponse.php? |
||
756 | * |
||
757 | * @link https://core.telegram.org/bots/api#getchatmemberscount |
||
758 | * |
||
759 | * @param array $data |
||
760 | * |
||
761 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
762 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
763 | */ |
||
764 | public static function getChatMembersCount(array $data) |
||
768 | |||
769 | /** |
||
770 | * Use this method to get information about a member of a chat. Returns a ChatMember object on success. |
||
771 | * |
||
772 | * @todo add get response in ServerResponse.php? |
||
773 | * |
||
774 | * @link https://core.telegram.org/bots/api#getchatmember |
||
775 | * |
||
776 | * @param array $data |
||
777 | * |
||
778 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
779 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
780 | */ |
||
781 | public static function getChatMember(array $data) |
||
785 | |||
786 | /** |
||
787 | * Use this method to send answers to callback queries sent from inline keyboards. On success, True is returned. |
||
788 | * |
||
789 | * The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. |
||
790 | * |
||
791 | * @link https://core.telegram.org/bots/api#answercallbackquery |
||
792 | * |
||
793 | * @param array $data |
||
794 | * |
||
795 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
796 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
797 | */ |
||
798 | public static function answerCallbackQuery(array $data) |
||
802 | |||
803 | /** |
||
804 | * Get updates |
||
805 | * |
||
806 | * @link https://core.telegram.org/bots/api#getupdates |
||
807 | * |
||
808 | * @param array $data |
||
809 | * |
||
810 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
811 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
812 | */ |
||
813 | public static function getUpdates(array $data) |
||
817 | |||
818 | /** |
||
819 | * Set webhook |
||
820 | * |
||
821 | * @link https://core.telegram.org/bots/api#setwebhook |
||
822 | * |
||
823 | * @param string $url |
||
824 | * @param array $data Optional parameters. |
||
825 | * |
||
826 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
827 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
828 | */ |
||
829 | public static function setWebhook($url = '', array $data = []) |
||
844 | |||
845 | /** |
||
846 | * Delete webhook |
||
847 | * |
||
848 | * @link https://core.telegram.org/bots/api#deletewebhook |
||
849 | * |
||
850 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
851 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
852 | */ |
||
853 | public static function deleteWebhook() |
||
858 | |||
859 | /** |
||
860 | * Use this method to edit text and game messages sent by the bot or via the bot (for inline bots). |
||
861 | * |
||
862 | * On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned. |
||
863 | * |
||
864 | * @link https://core.telegram.org/bots/api#editmessagetext |
||
865 | * |
||
866 | * @param array $data |
||
867 | * |
||
868 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
869 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
870 | */ |
||
871 | public static function editMessageText(array $data) |
||
875 | |||
876 | /** |
||
877 | * Use this method to edit captions of messages sent by the bot or via the bot (for inline bots). |
||
878 | * |
||
879 | * On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned. |
||
880 | * |
||
881 | * @link https://core.telegram.org/bots/api#editmessagecaption |
||
882 | * |
||
883 | * @param array $data |
||
884 | * |
||
885 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
886 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
887 | */ |
||
888 | public static function editMessageCaption(array $data) |
||
892 | |||
893 | /** |
||
894 | * Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots). |
||
895 | * |
||
896 | * On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned. |
||
897 | * |
||
898 | * @link https://core.telegram.org/bots/api#editmessagereplymarkup |
||
899 | * |
||
900 | * @param array $data |
||
901 | * |
||
902 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
903 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
904 | */ |
||
905 | public static function editMessageReplyMarkup(array $data) |
||
909 | |||
910 | /** |
||
911 | * Use this method to send answers to an inline query. On success, True is returned. |
||
912 | * |
||
913 | * No more than 50 results per query are allowed. |
||
914 | * |
||
915 | * @link https://core.telegram.org/bots/api#answerinlinequery |
||
916 | * |
||
917 | * @param array $data |
||
918 | * |
||
919 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
920 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
921 | */ |
||
922 | public static function answerInlineQuery(array $data) |
||
926 | |||
927 | /** |
||
928 | * Return an empty Server Response |
||
929 | * |
||
930 | * No request to telegram are sent, this function is used in commands that |
||
931 | * don't need to fire a message after execution |
||
932 | * |
||
933 | * @return \Longman\TelegramBot\Entities\ServerResponse |
||
934 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
935 | */ |
||
936 | public static function emptyResponse() |
||
940 | |||
941 | /** |
||
942 | * Send message to all active chats |
||
943 | * |
||
944 | * @param string $callback_function |
||
945 | * @param array $data |
||
946 | * @param boolean $send_groups |
||
947 | * @param boolean $send_super_groups |
||
948 | * @param boolean $send_users |
||
949 | * @param string $date_from |
||
950 | * @param string $date_to |
||
951 | * |
||
952 | * @return array |
||
953 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
954 | */ |
||
955 | public static function sendToActiveChats( |
||
981 | |||
982 | /** |
||
983 | * Use this method to get current webhook status. |
||
984 | * |
||
985 | * @link https://core.telegram.org/bots/api#getwebhookinfo |
||
986 | * |
||
987 | * @return Entities\ServerResponse |
||
988 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
989 | */ |
||
990 | public static function getWebhookInfo() |
||
995 | |||
996 | /** |
||
997 | * Enable request limiter |
||
998 | * |
||
999 | * @param boolean $value |
||
1000 | * @param array $options |
||
1001 | * |
||
1002 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
1003 | */ |
||
1004 | public static function setLimiter($value = true, array $options = []) |
||
1021 | |||
1022 | /** |
||
1023 | * This functions delays API requests to prevent reaching Telegram API limits |
||
1024 | * Can be disabled while in execution by 'Request::setLimiter(false)' |
||
1025 | * |
||
1026 | * @link https://core.telegram.org/bots/faq#my-bot-is-hitting-limits-how-do-i-avoid-this |
||
1027 | * |
||
1028 | * @param string $action |
||
1029 | * @param array $data |
||
1030 | * |
||
1031 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
1032 | */ |
||
1033 | private static function limitTelegramRequests($action, array $data = []) |
||
1081 | } |
||
1082 |
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..