@@ -16,17 +16,17 @@ discard block |
||
| 16 | 16 | /** |
| 17 | 17 | * @internal Only for BPT self usage , Don't use it in your source! |
| 18 | 18 | */ |
| 19 | - public static function init(string $method,array $data) { |
|
| 19 | + public static function init(string $method, array $data) { |
|
| 20 | 20 | $info = self::getInfo($data); |
| 21 | 21 | $data = $info['data']; |
| 22 | 22 | $handler = $info['handler']; |
| 23 | - self::setTimeout($data,$handler,$method); |
|
| 23 | + self::setTimeout($data, $handler, $method); |
|
| 24 | 24 | self::setData($data); |
| 25 | 25 | $data['method'] = $method; |
| 26 | 26 | curl_setopt($handler, CURLOPT_POSTFIELDS, $data); |
| 27 | 27 | $result = curl_exec($handler); |
| 28 | 28 | if (curl_errno($handler)) { |
| 29 | - logger::write(curl_error($handler),loggerTypes::WARNING); |
|
| 29 | + logger::write(curl_error($handler), loggerTypes::WARNING); |
|
| 30 | 30 | } |
| 31 | 31 | if ($info['token'] != settings::$token) { |
| 32 | 32 | curl_close($handler); |
@@ -42,9 +42,9 @@ discard block |
||
| 42 | 42 | curl_setopt($curl_handler, CURLOPT_RETURNTRANSFER, true); |
| 43 | 43 | curl_setopt($curl_handler, CURLOPT_SSL_VERIFYPEER, false); |
| 44 | 44 | } |
| 45 | - else{ |
|
| 45 | + else { |
|
| 46 | 46 | $token = settings::$token; |
| 47 | - if (!isset(self::$curl_handler)){ |
|
| 47 | + if (!isset(self::$curl_handler)) { |
|
| 48 | 48 | self::$curl_handler = curl_init(settings::$base_url."/bot$token/"); |
| 49 | 49 | curl_setopt(self::$curl_handler, CURLOPT_RETURNTRANSFER, true); |
| 50 | 50 | curl_setopt(self::$curl_handler, CURLOPT_SSL_VERIFYPEER, false); |
@@ -60,22 +60,22 @@ discard block |
||
| 60 | 60 | ]; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - private static function setTimeout(array &$data , CurlHandle $curl_handler,string $method): void { |
|
| 63 | + private static function setTimeout(array &$data, CurlHandle $curl_handler, string $method): void { |
|
| 64 | 64 | if (isset($data['forgot'])) { |
| 65 | 65 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, settings::$forgot_time); |
| 66 | 66 | unset($data['forgot']); |
| 67 | 67 | } |
| 68 | - elseif ($method === 'getUpdates'){ |
|
| 68 | + elseif ($method === 'getUpdates') { |
|
| 69 | 69 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, 5000); |
| 70 | 70 | } |
| 71 | - else{ |
|
| 71 | + else { |
|
| 72 | 72 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, settings::$base_timeout); |
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | private static function setData(array &$data): void { |
| 77 | - foreach ($data as &$value){ |
|
| 78 | - if (is_array($value) || (is_object($value) && !is_a($value,'CURLFile'))){ |
|
| 77 | + foreach ($data as &$value) { |
|
| 78 | + if (is_array($value) || (is_object($value) && !is_a($value, 'CURLFile'))) { |
|
| 79 | 79 | $value = json_encode($value); |
| 80 | 80 | } |
| 81 | 81 | } |
@@ -41,8 +41,7 @@ discard block |
||
| 41 | 41 | $curl_handler = curl_init(settings::$base_url."/bot$token/"); |
| 42 | 42 | curl_setopt($curl_handler, CURLOPT_RETURNTRANSFER, true); |
| 43 | 43 | curl_setopt($curl_handler, CURLOPT_SSL_VERIFYPEER, false); |
| 44 | - } |
|
| 45 | - else{ |
|
| 44 | + } else{ |
|
| 46 | 45 | $token = settings::$token; |
| 47 | 46 | if (!isset(self::$curl_handler)){ |
| 48 | 47 | self::$curl_handler = curl_init(settings::$base_url."/bot$token/"); |
@@ -64,11 +63,9 @@ discard block |
||
| 64 | 63 | if (isset($data['forgot'])) { |
| 65 | 64 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, settings::$forgot_time); |
| 66 | 65 | unset($data['forgot']); |
| 67 | - } |
|
| 68 | - elseif ($method === 'getUpdates'){ |
|
| 66 | + } elseif ($method === 'getUpdates'){ |
|
| 69 | 67 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, 5000); |
| 70 | - } |
|
| 71 | - else{ |
|
| 68 | + } else{ |
|
| 72 | 69 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, settings::$base_timeout); |
| 73 | 70 | } |
| 74 | 71 | } |
@@ -454,95 +454,95 @@ discard block |
||
| 454 | 454 | ]; |
| 455 | 455 | |
| 456 | 456 | private const METHODS_KEYS = [ |
| 457 | - 'getUpdates' => ['offset','limit','timeout','allowed_updates','token','return_array','forgot','answer'], |
|
| 458 | - 'setWebhook' => ['url','certificate','ip_address','max_connections','allowed_updates','drop_pending_updates','secret_token','token','return_array','forgot','answer'], |
|
| 459 | - 'deleteWebhook' => ['drop_pending_updates','token','return_array','forgot','answer'], |
|
| 460 | - 'getWebhookInfo' => ['token','return_array','forgot','answer'], |
|
| 461 | - 'getMe' => ['token','return_array','forgot','answer'], |
|
| 462 | - 'logOut' => ['token','return_array','forgot','answer'], |
|
| 463 | - 'close' => ['token','return_array','forgot','answer'], |
|
| 464 | - 'sendMessage' => ['text','chat_id','parse_mode','entities','disable_web_page_preview','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
|
| 465 | - 'forwardMessage' => ['chat_id','from_chat_id','disable_notification','protect_content','message_id','token','return_array','forgot','answer'], |
|
| 466 | - 'copyMessage' => ['chat_id','from_chat_id','message_id','caption','parse_mode','caption_entities','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
|
| 467 | - 'sendPhoto' => ['photo','chat_id','caption','parse_mode','caption_entities','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
|
| 468 | - 'sendAudio' => ['audio','chat_id','caption','parse_mode','caption_entities','duration','performer','title','thumb','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
|
| 469 | - 'sendDocument' => ['document','chat_id','thumb','caption','parse_mode','caption_entities','disable_content_type_detection','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
|
| 470 | - 'sendVideo' => ['video','chat_id','duration','width','height','thumb','caption','parse_mode','caption_entities','supports_streaming','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
|
| 471 | - 'sendAnimation' => ['animation','chat_id','duration','width','height','thumb','caption','parse_mode','caption_entities','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
|
| 472 | - 'sendVoice' => ['voice','chat_id','caption','parse_mode','caption_entities','duration','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
|
| 473 | - 'sendVideoNote' => ['video_note','chat_id','duration','length','thumb','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
|
| 474 | - 'sendMediaGroup' => ['media','chat_id','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','token','return_array','forgot','answer'], |
|
| 475 | - 'sendLocation' => ['latitude','longitude','chat_id','horizontal_accuracy','live_period','heading','proximity_alert_radius','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
|
| 476 | - 'editMessageLiveLocation' => ['latitude','longitude','chat_id','message_id','inline_message_id','horizontal_accuracy','heading','proximity_alert_radius','reply_markup','token','return_array','forgot','answer'], |
|
| 477 | - 'stopMessageLiveLocation' => ['chat_id','message_id','inline_message_id','reply_markup','token','return_array','forgot','answer'], |
|
| 478 | - 'sendVenue' => ['chat_id','latitude','longitude','title','address','foursquare_id','foursquare_type','google_place_id','google_place_type','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
|
| 479 | - 'sendContact' => ['phone_number','first_name','chat_id','last_name','vcard','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
|
| 480 | - 'sendPoll' => ['question','options','chat_id','is_anonymous','type','allows_multiple_answers','correct_option_id','explanation','explanation_parse_mode','explanation_entities','open_period','close_date','is_closed','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
|
| 481 | - 'sendDice' => ['chat_id','emoji','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
|
| 482 | - 'sendChatAction' => ['chat_id','action','token','return_array','forgot','answer'], |
|
| 483 | - 'getUserProfilePhotos' => ['user_id','offset','limit','token','return_array','forgot','answer'], |
|
| 484 | - 'getFile' => ['file_id','token','return_array','forgot','answer'], |
|
| 485 | - 'banChatMember' => ['chat_id','user_id','until_date','revoke_messages','token','return_array','forgot','answer'], |
|
| 486 | - 'unbanChatMember' => ['chat_id','user_id','only_if_banned','token','return_array','forgot','answer'], |
|
| 487 | - 'restrictChatMember' => ['permissions','chat_id','user_id','until_date','token','return_array','forgot','answer'], |
|
| 488 | - 'promoteChatMember' => ['chat_id','user_id','is_anonymous','can_manage_chat','can_post_messages','can_edit_messages','can_delete_messages','can_manage_video_chats','can_restrict_members','can_promote_members','can_change_info','can_invite_users','can_pin_messages','token','return_array','forgot','answer'], |
|
| 489 | - 'setChatAdministratorCustomTitle' => ['custom_title','chat_id','user_id','token','return_array','forgot','answer'], |
|
| 490 | - 'banChatSenderChat' => ['sender_chat_id','chat_id','token','return_array','forgot','answer'], |
|
| 491 | - 'unbanChatSenderChat' => ['sender_chat_id','chat_id','token','return_array','forgot','answer'], |
|
| 492 | - 'setChatPermissions' => ['permissions','chat_id','token','return_array','forgot','answer'], |
|
| 493 | - 'exportChatInviteLink' => ['chat_id','token','return_array','forgot','answer'], |
|
| 494 | - 'createChatInviteLink' => ['chat_id','name','expire_date','member_limit','creates_join_request','token','return_array','forgot','answer'], |
|
| 495 | - 'editChatInviteLink' => ['invite_link','chat_id','name','expire_date','member_limit','creates_join_request','token','return_array','forgot','answer'], |
|
| 496 | - 'revokeChatInviteLink' => ['invite_link','chat_id','token','return_array','forgot','answer'], |
|
| 497 | - 'approveChatJoinRequest' => ['chat_id','user_id','token','return_array','forgot','answer'], |
|
| 498 | - 'declineChatJoinRequest' => ['chat_id','user_id','token','return_array','forgot','answer'], |
|
| 499 | - 'setChatPhoto' => ['photo','chat_id','token','return_array','forgot','answer'], |
|
| 500 | - 'deleteChatPhoto' => ['chat_id','token','return_array','forgot','answer'], |
|
| 501 | - 'setChatTitle' => ['title','chat_id','token','return_array','forgot','answer'], |
|
| 502 | - 'setChatDescription' => ['chat_id','description','token','return_array','forgot','answer'], |
|
| 503 | - 'pinChatMessage' => ['message_id','chat_id','disable_notification','token','return_array','forgot','answer'], |
|
| 504 | - 'unpinChatMessage' => ['chat_id','message_id','token','return_array','forgot','answer'], |
|
| 505 | - 'unpinAllChatMessages' => ['chat_id','token','return_array','forgot','answer'], |
|
| 506 | - 'leaveChat' => ['chat_id','token','return_array','forgot','answer'], |
|
| 507 | - 'getChat' => ['chat_id','token','return_array','forgot','answer'], |
|
| 508 | - 'getChatAdministrators' => ['chat_id','token','return_array','forgot','answer'], |
|
| 509 | - 'getChatMemberCount' => ['chat_id','token','return_array','forgot','answer'], |
|
| 510 | - 'getChatMember' => ['chat_id','user_id','token','return_array','forgot','answer'], |
|
| 511 | - 'setChatStickerSet' => ['sticker_set_name','chat_id','token','return_array','forgot','answer'], |
|
| 512 | - 'deleteChatStickerSet' => ['chat_id','token','return_array','forgot','answer'], |
|
| 513 | - 'answerCallbackQuery' => ['callback_query_id','text','show_alert','url','cache_time','token','return_array','forgot','answer'], |
|
| 514 | - 'setMyCommands' => ['commands','scope','language_code','token','return_array','forgot','answer'], |
|
| 515 | - 'deleteMyCommands' => ['scope','language_code','token','return_array','forgot','answer'], |
|
| 516 | - 'getMyCommands' => ['scope','language_code','token','return_array','forgot','answer'], |
|
| 517 | - 'setChatMenuButton' => ['chat_id','menu_button','token','return_array','forgot','answer'], |
|
| 518 | - 'getChatMenuButton' => ['chat_id','token','return_array','forgot','answer'], |
|
| 519 | - 'setMyDefaultAdministratorRights' => ['rights','for_channels','token','return_array','forgot','answer'], |
|
| 520 | - 'getMyDefaultAdministratorRights' => ['for_channels','token','return_array','forgot','answer'], |
|
| 521 | - 'editMessageText' => ['text','chat_id','message_id','inline_message_id','parse_mode','entities','disable_web_page_preview','reply_markup','token','return_array','forgot','answer'], |
|
| 522 | - 'editMessageCaption' => ['chat_id','message_id','inline_message_id','caption','parse_mode','caption_entities','reply_markup','token','return_array','forgot','answer'], |
|
| 523 | - 'editMessageMedia' => ['media','chat_id','message_id','inline_message_id','reply_markup','token','return_array','forgot','answer'], |
|
| 524 | - 'editMessageReplyMarkup' => ['chat_id','message_id','inline_message_id','reply_markup','token','return_array','forgot','answer'], |
|
| 525 | - 'stopPoll' => ['chat_id','message_id','reply_markup','token','return_array','forgot','answer'], |
|
| 526 | - 'deleteMessage' => ['chat_id','message_id','token','return_array','forgot','answer'], |
|
| 527 | - 'sendSticker' => ['sticker','chat_id','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
|
| 528 | - 'getStickerSet' => ['name','token','return_array','forgot','answer'], |
|
| 457 | + 'getUpdates' => ['offset', 'limit', 'timeout', 'allowed_updates', 'token', 'return_array', 'forgot', 'answer'], |
|
| 458 | + 'setWebhook' => ['url', 'certificate', 'ip_address', 'max_connections', 'allowed_updates', 'drop_pending_updates', 'secret_token', 'token', 'return_array', 'forgot', 'answer'], |
|
| 459 | + 'deleteWebhook' => ['drop_pending_updates', 'token', 'return_array', 'forgot', 'answer'], |
|
| 460 | + 'getWebhookInfo' => ['token', 'return_array', 'forgot', 'answer'], |
|
| 461 | + 'getMe' => ['token', 'return_array', 'forgot', 'answer'], |
|
| 462 | + 'logOut' => ['token', 'return_array', 'forgot', 'answer'], |
|
| 463 | + 'close' => ['token', 'return_array', 'forgot', 'answer'], |
|
| 464 | + 'sendMessage' => ['text', 'chat_id', 'parse_mode', 'entities', 'disable_web_page_preview', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
| 465 | + 'forwardMessage' => ['chat_id', 'from_chat_id', 'disable_notification', 'protect_content', 'message_id', 'token', 'return_array', 'forgot', 'answer'], |
|
| 466 | + 'copyMessage' => ['chat_id', 'from_chat_id', 'message_id', 'caption', 'parse_mode', 'caption_entities', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
| 467 | + 'sendPhoto' => ['photo', 'chat_id', 'caption', 'parse_mode', 'caption_entities', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
| 468 | + 'sendAudio' => ['audio', 'chat_id', 'caption', 'parse_mode', 'caption_entities', 'duration', 'performer', 'title', 'thumb', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
| 469 | + 'sendDocument' => ['document', 'chat_id', 'thumb', 'caption', 'parse_mode', 'caption_entities', 'disable_content_type_detection', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
| 470 | + 'sendVideo' => ['video', 'chat_id', 'duration', 'width', 'height', 'thumb', 'caption', 'parse_mode', 'caption_entities', 'supports_streaming', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
| 471 | + 'sendAnimation' => ['animation', 'chat_id', 'duration', 'width', 'height', 'thumb', 'caption', 'parse_mode', 'caption_entities', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
| 472 | + 'sendVoice' => ['voice', 'chat_id', 'caption', 'parse_mode', 'caption_entities', 'duration', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
| 473 | + 'sendVideoNote' => ['video_note', 'chat_id', 'duration', 'length', 'thumb', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
| 474 | + 'sendMediaGroup' => ['media', 'chat_id', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'token', 'return_array', 'forgot', 'answer'], |
|
| 475 | + 'sendLocation' => ['latitude', 'longitude', 'chat_id', 'horizontal_accuracy', 'live_period', 'heading', 'proximity_alert_radius', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
| 476 | + 'editMessageLiveLocation' => ['latitude', 'longitude', 'chat_id', 'message_id', 'inline_message_id', 'horizontal_accuracy', 'heading', 'proximity_alert_radius', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
| 477 | + 'stopMessageLiveLocation' => ['chat_id', 'message_id', 'inline_message_id', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
| 478 | + 'sendVenue' => ['chat_id', 'latitude', 'longitude', 'title', 'address', 'foursquare_id', 'foursquare_type', 'google_place_id', 'google_place_type', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
| 479 | + 'sendContact' => ['phone_number', 'first_name', 'chat_id', 'last_name', 'vcard', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
| 480 | + 'sendPoll' => ['question', 'options', 'chat_id', 'is_anonymous', 'type', 'allows_multiple_answers', 'correct_option_id', 'explanation', 'explanation_parse_mode', 'explanation_entities', 'open_period', 'close_date', 'is_closed', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
| 481 | + 'sendDice' => ['chat_id', 'emoji', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
| 482 | + 'sendChatAction' => ['chat_id', 'action', 'token', 'return_array', 'forgot', 'answer'], |
|
| 483 | + 'getUserProfilePhotos' => ['user_id', 'offset', 'limit', 'token', 'return_array', 'forgot', 'answer'], |
|
| 484 | + 'getFile' => ['file_id', 'token', 'return_array', 'forgot', 'answer'], |
|
| 485 | + 'banChatMember' => ['chat_id', 'user_id', 'until_date', 'revoke_messages', 'token', 'return_array', 'forgot', 'answer'], |
|
| 486 | + 'unbanChatMember' => ['chat_id', 'user_id', 'only_if_banned', 'token', 'return_array', 'forgot', 'answer'], |
|
| 487 | + 'restrictChatMember' => ['permissions', 'chat_id', 'user_id', 'until_date', 'token', 'return_array', 'forgot', 'answer'], |
|
| 488 | + 'promoteChatMember' => ['chat_id', 'user_id', 'is_anonymous', 'can_manage_chat', 'can_post_messages', 'can_edit_messages', 'can_delete_messages', 'can_manage_video_chats', 'can_restrict_members', 'can_promote_members', 'can_change_info', 'can_invite_users', 'can_pin_messages', 'token', 'return_array', 'forgot', 'answer'], |
|
| 489 | + 'setChatAdministratorCustomTitle' => ['custom_title', 'chat_id', 'user_id', 'token', 'return_array', 'forgot', 'answer'], |
|
| 490 | + 'banChatSenderChat' => ['sender_chat_id', 'chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
| 491 | + 'unbanChatSenderChat' => ['sender_chat_id', 'chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
| 492 | + 'setChatPermissions' => ['permissions', 'chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
| 493 | + 'exportChatInviteLink' => ['chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
| 494 | + 'createChatInviteLink' => ['chat_id', 'name', 'expire_date', 'member_limit', 'creates_join_request', 'token', 'return_array', 'forgot', 'answer'], |
|
| 495 | + 'editChatInviteLink' => ['invite_link', 'chat_id', 'name', 'expire_date', 'member_limit', 'creates_join_request', 'token', 'return_array', 'forgot', 'answer'], |
|
| 496 | + 'revokeChatInviteLink' => ['invite_link', 'chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
| 497 | + 'approveChatJoinRequest' => ['chat_id', 'user_id', 'token', 'return_array', 'forgot', 'answer'], |
|
| 498 | + 'declineChatJoinRequest' => ['chat_id', 'user_id', 'token', 'return_array', 'forgot', 'answer'], |
|
| 499 | + 'setChatPhoto' => ['photo', 'chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
| 500 | + 'deleteChatPhoto' => ['chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
| 501 | + 'setChatTitle' => ['title', 'chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
| 502 | + 'setChatDescription' => ['chat_id', 'description', 'token', 'return_array', 'forgot', 'answer'], |
|
| 503 | + 'pinChatMessage' => ['message_id', 'chat_id', 'disable_notification', 'token', 'return_array', 'forgot', 'answer'], |
|
| 504 | + 'unpinChatMessage' => ['chat_id', 'message_id', 'token', 'return_array', 'forgot', 'answer'], |
|
| 505 | + 'unpinAllChatMessages' => ['chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
| 506 | + 'leaveChat' => ['chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
| 507 | + 'getChat' => ['chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
| 508 | + 'getChatAdministrators' => ['chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
| 509 | + 'getChatMemberCount' => ['chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
| 510 | + 'getChatMember' => ['chat_id', 'user_id', 'token', 'return_array', 'forgot', 'answer'], |
|
| 511 | + 'setChatStickerSet' => ['sticker_set_name', 'chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
| 512 | + 'deleteChatStickerSet' => ['chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
| 513 | + 'answerCallbackQuery' => ['callback_query_id', 'text', 'show_alert', 'url', 'cache_time', 'token', 'return_array', 'forgot', 'answer'], |
|
| 514 | + 'setMyCommands' => ['commands', 'scope', 'language_code', 'token', 'return_array', 'forgot', 'answer'], |
|
| 515 | + 'deleteMyCommands' => ['scope', 'language_code', 'token', 'return_array', 'forgot', 'answer'], |
|
| 516 | + 'getMyCommands' => ['scope', 'language_code', 'token', 'return_array', 'forgot', 'answer'], |
|
| 517 | + 'setChatMenuButton' => ['chat_id', 'menu_button', 'token', 'return_array', 'forgot', 'answer'], |
|
| 518 | + 'getChatMenuButton' => ['chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
| 519 | + 'setMyDefaultAdministratorRights' => ['rights', 'for_channels', 'token', 'return_array', 'forgot', 'answer'], |
|
| 520 | + 'getMyDefaultAdministratorRights' => ['for_channels', 'token', 'return_array', 'forgot', 'answer'], |
|
| 521 | + 'editMessageText' => ['text', 'chat_id', 'message_id', 'inline_message_id', 'parse_mode', 'entities', 'disable_web_page_preview', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
| 522 | + 'editMessageCaption' => ['chat_id', 'message_id', 'inline_message_id', 'caption', 'parse_mode', 'caption_entities', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
| 523 | + 'editMessageMedia' => ['media', 'chat_id', 'message_id', 'inline_message_id', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
| 524 | + 'editMessageReplyMarkup' => ['chat_id', 'message_id', 'inline_message_id', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
| 525 | + 'stopPoll' => ['chat_id', 'message_id', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
| 526 | + 'deleteMessage' => ['chat_id', 'message_id', 'token', 'return_array', 'forgot', 'answer'], |
|
| 527 | + 'sendSticker' => ['sticker', 'chat_id', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
| 528 | + 'getStickerSet' => ['name', 'token', 'return_array', 'forgot', 'answer'], |
|
| 529 | 529 | "getCustomEmojiStickers" => ["custom_emoji_ids", "token", "return_array", "forgot", "answer"], |
| 530 | - 'uploadStickerFile' => ['png_sticker','user_id','token','return_array','forgot','answer'], |
|
| 531 | - 'createNewStickerSet' => ['name','title','emojis','user_id','png_sticker','tgs_sticker','webm_sticker','sticker_type','contains_masks','mask_position','token','return_array','forgot','answer'], |
|
| 532 | - 'addStickerToSet' => ['name','emojis','user_id','png_sticker','tgs_sticker','webm_sticker','mask_position','token','return_array','forgot','answer'], |
|
| 533 | - 'setStickerPositionInSet' => ['sticker','position','token','return_array','forgot','answer'], |
|
| 534 | - 'deleteStickerFromSet' => ['sticker','token','return_array','forgot','answer'], |
|
| 535 | - 'setStickerSetThumb' => ['name','user_id','thumb','token','return_array','forgot','answer'], |
|
| 536 | - 'answerInlineQuery' => ['results','inline_query_id','cache_time','is_personal','next_offset','switch_pm_text','switch_pm_parameter','token','return_array','forgot','answer'], |
|
| 537 | - 'answerWebAppQuery' => ['web_app_query_id','result','token','return_array','forgot','answer'], |
|
| 538 | - 'sendInvoice' => ['title','description','payload','provider_token','currency','prices','chat_id','max_tip_amount','suggested_tip_amounts','start_parameter','provider_data','photo_url','photo_size','photo_width','photo_height','need_name','need_phone_number','need_email','need_shipping_address','send_phone_number_to_provider','send_email_to_provider','is_flexible','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
|
| 539 | - 'createInvoiceLink' => ['title','description','payload','provider_token','currency','prices','max_tip_amount','suggested_tip_amounts','provider_data','photo_url','photo_size','photo_width','photo_height','need_name','need_phone_number','need_email','need_shipping_address','send_phone_number_to_provider','send_email_to_provider','is_flexible','token','return_array','forgot','answer'], |
|
| 540 | - 'answerShippingQuery' => ['ok','shipping_query_id','shipping_options','error_message','token','return_array','forgot','answer'], |
|
| 541 | - 'answerPreCheckoutQuery' => ['ok','pre_checkout_query_id','error_message','token','return_array','forgot','answer'], |
|
| 542 | - 'setPassportDataErrors' => ['errors','user_id','token','return_array','forgot','answer'], |
|
| 543 | - 'sendGame' => ['game_short_name','chat_id','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
|
| 544 | - 'setGameScore' => ['score','user_id','force','disable_edit_message','chat_id','message_id','inline_message_id','token','return_array','forgot','answer'], |
|
| 545 | - 'getGameHighScores' => ['user_id','chat_id','message_id','inline_message_id','token','return_array','forgot','answer'], |
|
| 530 | + 'uploadStickerFile' => ['png_sticker', 'user_id', 'token', 'return_array', 'forgot', 'answer'], |
|
| 531 | + 'createNewStickerSet' => ['name', 'title', 'emojis', 'user_id', 'png_sticker', 'tgs_sticker', 'webm_sticker', 'sticker_type', 'contains_masks', 'mask_position', 'token', 'return_array', 'forgot', 'answer'], |
|
| 532 | + 'addStickerToSet' => ['name', 'emojis', 'user_id', 'png_sticker', 'tgs_sticker', 'webm_sticker', 'mask_position', 'token', 'return_array', 'forgot', 'answer'], |
|
| 533 | + 'setStickerPositionInSet' => ['sticker', 'position', 'token', 'return_array', 'forgot', 'answer'], |
|
| 534 | + 'deleteStickerFromSet' => ['sticker', 'token', 'return_array', 'forgot', 'answer'], |
|
| 535 | + 'setStickerSetThumb' => ['name', 'user_id', 'thumb', 'token', 'return_array', 'forgot', 'answer'], |
|
| 536 | + 'answerInlineQuery' => ['results', 'inline_query_id', 'cache_time', 'is_personal', 'next_offset', 'switch_pm_text', 'switch_pm_parameter', 'token', 'return_array', 'forgot', 'answer'], |
|
| 537 | + 'answerWebAppQuery' => ['web_app_query_id', 'result', 'token', 'return_array', 'forgot', 'answer'], |
|
| 538 | + 'sendInvoice' => ['title', 'description', 'payload', 'provider_token', 'currency', 'prices', 'chat_id', 'max_tip_amount', 'suggested_tip_amounts', 'start_parameter', 'provider_data', 'photo_url', 'photo_size', 'photo_width', 'photo_height', 'need_name', 'need_phone_number', 'need_email', 'need_shipping_address', 'send_phone_number_to_provider', 'send_email_to_provider', 'is_flexible', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
| 539 | + 'createInvoiceLink' => ['title', 'description', 'payload', 'provider_token', 'currency', 'prices', 'max_tip_amount', 'suggested_tip_amounts', 'provider_data', 'photo_url', 'photo_size', 'photo_width', 'photo_height', 'need_name', 'need_phone_number', 'need_email', 'need_shipping_address', 'send_phone_number_to_provider', 'send_email_to_provider', 'is_flexible', 'token', 'return_array', 'forgot', 'answer'], |
|
| 540 | + 'answerShippingQuery' => ['ok', 'shipping_query_id', 'shipping_options', 'error_message', 'token', 'return_array', 'forgot', 'answer'], |
|
| 541 | + 'answerPreCheckoutQuery' => ['ok', 'pre_checkout_query_id', 'error_message', 'token', 'return_array', 'forgot', 'answer'], |
|
| 542 | + 'setPassportDataErrors' => ['errors', 'user_id', 'token', 'return_array', 'forgot', 'answer'], |
|
| 543 | + 'sendGame' => ['game_short_name', 'chat_id', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
| 544 | + 'setGameScore' => ['score', 'user_id', 'force', 'disable_edit_message', 'chat_id', 'message_id', 'inline_message_id', 'token', 'return_array', 'forgot', 'answer'], |
|
| 545 | + 'getGameHighScores' => ['user_id', 'chat_id', 'message_id', 'inline_message_id', 'token', 'return_array', 'forgot', 'answer'], |
|
| 546 | 546 | ]; |
| 547 | 547 | |
| 548 | 548 | private const METHODS_WITH_FILE = [ |
@@ -571,8 +571,8 @@ discard block |
||
| 571 | 571 | 'logOut' => [], |
| 572 | 572 | 'close' => [], |
| 573 | 573 | 'sendMessage' => ['chat_id'], |
| 574 | - 'forwardMessage' => ['from_chat_id','message_id'], |
|
| 575 | - 'copyMessage' => ['from_chat_id','message_id'], |
|
| 574 | + 'forwardMessage' => ['from_chat_id', 'message_id'], |
|
| 575 | + 'copyMessage' => ['from_chat_id', 'message_id'], |
|
| 576 | 576 | 'sendPhoto' => ['chat_id'], |
| 577 | 577 | 'sendAudio' => ['chat_id'], |
| 578 | 578 | 'sendDocument' => ['chat_id'], |
@@ -588,15 +588,15 @@ discard block |
||
| 588 | 588 | 'sendContact' => ['chat_id'], |
| 589 | 589 | 'sendPoll' => ['chat_id'], |
| 590 | 590 | 'sendDice' => ['chat_id'], |
| 591 | - 'sendChatAction' => ['chat_id','action'], |
|
| 591 | + 'sendChatAction' => ['chat_id', 'action'], |
|
| 592 | 592 | 'getUserProfilePhotos' => ['user_id'], |
| 593 | 593 | 'getFile' => ['file_id'], |
| 594 | - 'banChatMember' => ['chat_id','user_id'], |
|
| 595 | - 'kickChatMember' => ['chat_id','user_id'], |
|
| 596 | - 'unbanChatMember' => ['chat_id','user_id'], |
|
| 597 | - 'restrictChatMember' => ['chat_id','user_id'], |
|
| 598 | - 'promoteChatMember' => ['chat_id','user_id'], |
|
| 599 | - 'setChatAdministratorCustomTitle' => ['chat_id','user_id'], |
|
| 594 | + 'banChatMember' => ['chat_id', 'user_id'], |
|
| 595 | + 'kickChatMember' => ['chat_id', 'user_id'], |
|
| 596 | + 'unbanChatMember' => ['chat_id', 'user_id'], |
|
| 597 | + 'restrictChatMember' => ['chat_id', 'user_id'], |
|
| 598 | + 'promoteChatMember' => ['chat_id', 'user_id'], |
|
| 599 | + 'setChatAdministratorCustomTitle' => ['chat_id', 'user_id'], |
|
| 600 | 600 | 'banChatSenderChat' => ['chat_id'], |
| 601 | 601 | 'unbanChatSenderChat' => ['chat_id'], |
| 602 | 602 | 'setChatPermissions' => ['chat_id'], |
@@ -604,8 +604,8 @@ discard block |
||
| 604 | 604 | 'createChatInviteLink' => ['chat_id'], |
| 605 | 605 | 'editChatInviteLink' => ['chat_id'], |
| 606 | 606 | 'revokeChatInviteLink' => ['chat_id'], |
| 607 | - 'approveChatJoinRequest' => ['chat_id','user_id'], |
|
| 608 | - 'declineChatJoinRequest' => ['chat_id','user_id'], |
|
| 607 | + 'approveChatJoinRequest' => ['chat_id', 'user_id'], |
|
| 608 | + 'declineChatJoinRequest' => ['chat_id', 'user_id'], |
|
| 609 | 609 | 'setChatPhoto' => ['chat_id'], |
| 610 | 610 | 'deleteChatPhoto' => ['chat_id'], |
| 611 | 611 | 'setChatTitle' => ['chat_id'], |
@@ -617,7 +617,7 @@ discard block |
||
| 617 | 617 | 'getChat' => ['chat_id'], |
| 618 | 618 | 'getChatAdministrators' => ['chat_id'], |
| 619 | 619 | 'getChatMembersCount' => ['chat_id'], |
| 620 | - 'getChatMember' => ['chat_id','user_id'], |
|
| 620 | + 'getChatMember' => ['chat_id', 'user_id'], |
|
| 621 | 621 | 'setChatStickerSet' => ['chat_id'], |
| 622 | 622 | 'deleteChatStickerSet' => ['chat_id'], |
| 623 | 623 | 'answerCallbackQuery' => ['callback_query_id'], |
@@ -628,12 +628,12 @@ discard block |
||
| 628 | 628 | 'getChatMenuButton' => [], |
| 629 | 629 | 'setMyDefaultAdministratorRights' => [], |
| 630 | 630 | 'getMyDefaultAdministratorRights' => [], |
| 631 | - 'editMessageText' => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
| 632 | - 'editMessageCaption' => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
| 633 | - 'editMessageMedia' => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
| 634 | - 'editMessageReplyMarkup' => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
| 635 | - 'stopPoll' => ['chat_id','message_id'], |
|
| 636 | - 'deleteMessage' => ['chat_id','message_id'], |
|
| 631 | + 'editMessageText' => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
| 632 | + 'editMessageCaption' => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
| 633 | + 'editMessageMedia' => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
| 634 | + 'editMessageReplyMarkup' => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
| 635 | + 'stopPoll' => ['chat_id', 'message_id'], |
|
| 636 | + 'deleteMessage' => ['chat_id', 'message_id'], |
|
| 637 | 637 | 'sendSticker' => ['chat_id'], |
| 638 | 638 | 'getStickerSet' => [], |
| 639 | 639 | 'uploadStickerFile' => ['user_id'], |
@@ -649,8 +649,8 @@ discard block |
||
| 649 | 649 | 'answerPreCheckoutQuery' => ['pre_checkout_query_id'], |
| 650 | 650 | 'setPassportDataErrors' => ['user_id'], |
| 651 | 651 | 'sendGame' => ['chat_id'], |
| 652 | - 'setGameScore' => ['user_id','inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
| 653 | - 'getGameHighScores' => ['user_id','inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']] |
|
| 652 | + 'setGameScore' => ['user_id', 'inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
| 653 | + 'getGameHighScores' => ['user_id', 'inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']] |
|
| 654 | 654 | ]; |
| 655 | 655 | |
| 656 | 656 | private const METHODS_RETURN = [ |
@@ -702,29 +702,29 @@ discard block |
||
| 702 | 702 | 'getGameHighScores' => ['BPT\types\gameHighScore'] |
| 703 | 703 | ]; |
| 704 | 704 | |
| 705 | - public static function __callStatic (string $name, array $arguments) { |
|
| 705 | + public static function __callStatic(string $name, array $arguments) { |
|
| 706 | 706 | if ($action = self::methodAction($name)) { |
| 707 | - self::keysName($action,$arguments); |
|
| 708 | - self::readyFile($action,$arguments); |
|
| 709 | - self::setDefaults($action,$arguments); |
|
| 707 | + self::keysName($action, $arguments); |
|
| 708 | + self::readyFile($action, $arguments); |
|
| 709 | + self::setDefaults($action, $arguments); |
|
| 710 | 710 | if (isset($arguments['answer'])) { |
| 711 | - return answer::init($action,$arguments); |
|
| 711 | + return answer::init($action, $arguments); |
|
| 712 | 712 | } |
| 713 | 713 | else { |
| 714 | - $result = curl::init($action,$arguments); |
|
| 714 | + $result = curl::init($action, $arguments); |
|
| 715 | 715 | if (is_object($result)) { |
| 716 | - return self::processResponse($action,$result); |
|
| 716 | + return self::processResponse($action, $result); |
|
| 717 | 717 | } |
| 718 | 718 | return false; |
| 719 | 719 | } |
| 720 | 720 | } |
| 721 | 721 | else { |
| 722 | - logger::write("$name method is not supported",loggerTypes::ERROR); |
|
| 722 | + logger::write("$name method is not supported", loggerTypes::ERROR); |
|
| 723 | 723 | throw new bptException('METHOD_NOT_FOUND'); |
| 724 | 724 | } |
| 725 | 725 | } |
| 726 | 726 | |
| 727 | - private static function keysName (string $name, array &$arguments): void { |
|
| 727 | + private static function keysName(string $name, array &$arguments): void { |
|
| 728 | 728 | foreach ($arguments as $key => $argument) { |
| 729 | 729 | if (is_numeric($key) && isset(self::METHODS_KEYS[$name][$key])) { |
| 730 | 730 | $arguments[self::METHODS_KEYS[$name][$key]] = $argument; |
@@ -733,7 +733,7 @@ discard block |
||
| 733 | 733 | } |
| 734 | 734 | } |
| 735 | 735 | |
| 736 | - private static function methodAction(string $name): string|false { |
|
| 736 | + private static function methodAction(string $name): string | false { |
|
| 737 | 737 | return self::METHODS_ACTION[str_replace('_', '', strtolower($name))] ?? false; |
| 738 | 738 | } |
| 739 | 739 | |
@@ -754,11 +754,11 @@ discard block |
||
| 754 | 754 | } |
| 755 | 755 | } |
| 756 | 756 | |
| 757 | - private static function methodFile(string $name): array|false { |
|
| 757 | + private static function methodFile(string $name): array | false { |
|
| 758 | 758 | return self::METHODS_WITH_FILE[$name] ?? false; |
| 759 | 759 | } |
| 760 | 760 | |
| 761 | - private static function methodReturn(string $name,stdClass $response) { |
|
| 761 | + private static function methodReturn(string $name, stdClass $response) { |
|
| 762 | 762 | if (isset(self::METHODS_RETURN[$name])) { |
| 763 | 763 | $return = self::METHODS_RETURN[$name]; |
| 764 | 764 | if (is_array($return)) { |
@@ -781,13 +781,13 @@ discard block |
||
| 781 | 781 | $defaults = self::METHODS_EXTRA_DEFAULTS[$name]; |
| 782 | 782 | foreach ($defaults as $key => $default) { |
| 783 | 783 | if (is_numeric($key)) { |
| 784 | - if (!isset($arguments[$default])){ |
|
| 784 | + if (!isset($arguments[$default])) { |
|
| 785 | 785 | $arguments[$default] = self::catchFields($default); |
| 786 | 786 | } |
| 787 | 787 | } |
| 788 | 788 | elseif (isset(BPT::$update->$key) || $key === 'other') { |
| 789 | 789 | foreach ($default as $def) { |
| 790 | - if (!isset($arguments[$def])){ |
|
| 790 | + if (!isset($arguments[$def])) { |
|
| 791 | 791 | $arguments[$def] = self::catchFields($def); |
| 792 | 792 | } |
| 793 | 793 | } |
@@ -800,7 +800,7 @@ discard block |
||
| 800 | 800 | if ($response->ok) { |
| 801 | 801 | self::$status = true; |
| 802 | 802 | self::$pure_response = $response; |
| 803 | - return self::methodReturn($name,$response); |
|
| 803 | + return self::methodReturn($name, $response); |
|
| 804 | 804 | } |
| 805 | 805 | else { |
| 806 | 806 | self::$status = false; |
@@ -816,7 +816,7 @@ discard block |
||
| 816 | 816 | * |
| 817 | 817 | * @return int|string|bool |
| 818 | 818 | */ |
| 819 | - public static function catchFields (string $field): int|string|bool { |
|
| 819 | + public static function catchFields(string $field): int | string | bool { |
|
| 820 | 820 | switch ($field) { |
| 821 | 821 | case fields::CHAT_ID : |
| 822 | 822 | case fields::FROM_CHAT_ID : |
@@ -952,7 +952,7 @@ discard block |
||
| 952 | 952 | default => false |
| 953 | 953 | }; |
| 954 | 954 | case fields::URL : |
| 955 | - return 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; |
|
| 955 | + return 'https://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; |
|
| 956 | 956 | default: |
| 957 | 957 | return false; |
| 958 | 958 | } |
@@ -709,16 +709,14 @@ discard block |
||
| 709 | 709 | self::setDefaults($action,$arguments); |
| 710 | 710 | if (isset($arguments['answer'])) { |
| 711 | 711 | return answer::init($action,$arguments); |
| 712 | - } |
|
| 713 | - else { |
|
| 712 | + } else { |
|
| 714 | 713 | $result = curl::init($action,$arguments); |
| 715 | 714 | if (is_object($result)) { |
| 716 | 715 | return self::processResponse($action,$result); |
| 717 | 716 | } |
| 718 | 717 | return false; |
| 719 | 718 | } |
| 720 | - } |
|
| 721 | - else { |
|
| 719 | + } else { |
|
| 722 | 720 | logger::write("$name method is not supported",loggerTypes::ERROR); |
| 723 | 721 | throw new bptException('METHOD_NOT_FOUND'); |
| 724 | 722 | } |
@@ -744,8 +742,7 @@ discard block |
||
| 744 | 742 | $arguments['media'][$key]['media'] = new CURLFile($media['media']); |
| 745 | 743 | } |
| 746 | 744 | } |
| 747 | - } |
|
| 748 | - elseif ($file_params = self::methodFile($name)) { |
|
| 745 | + } elseif ($file_params = self::methodFile($name)) { |
|
| 749 | 746 | foreach ($file_params as $param) { |
| 750 | 747 | if (isset($arguments[$param]) && file_exists($arguments[$param])) { |
| 751 | 748 | $arguments[$param] = new CURLFile($arguments[$param]); |
@@ -767,12 +764,10 @@ discard block |
||
| 767 | 764 | $value = new ($return[0]) ($value); |
| 768 | 765 | } |
| 769 | 766 | return $response; |
| 770 | - } |
|
| 771 | - else { |
|
| 767 | + } else { |
|
| 772 | 768 | return new ($return) ($response->result); |
| 773 | 769 | } |
| 774 | - } |
|
| 775 | - else { |
|
| 770 | + } else { |
|
| 776 | 771 | return $response->result; |
| 777 | 772 | } |
| 778 | 773 | } |
@@ -784,8 +779,7 @@ discard block |
||
| 784 | 779 | if (!isset($arguments[$default])){ |
| 785 | 780 | $arguments[$default] = self::catchFields($default); |
| 786 | 781 | } |
| 787 | - } |
|
| 788 | - elseif (isset(BPT::$update->$key) || $key === 'other') { |
|
| 782 | + } elseif (isset(BPT::$update->$key) || $key === 'other') { |
|
| 789 | 783 | foreach ($default as $def) { |
| 790 | 784 | if (!isset($arguments[$def])){ |
| 791 | 785 | $arguments[$def] = self::catchFields($def); |
@@ -801,8 +795,7 @@ discard block |
||
| 801 | 795 | self::$status = true; |
| 802 | 796 | self::$pure_response = $response; |
| 803 | 797 | return self::methodReturn($name,$response); |
| 804 | - } |
|
| 805 | - else { |
|
| 798 | + } else { |
|
| 806 | 799 | self::$status = false; |
| 807 | 800 | self::$pure_response = $response; |
| 808 | 801 | return new responseError($response); |
@@ -845,9 +838,13 @@ discard block |
||
| 845 | 838 | default => false |
| 846 | 839 | }; |
| 847 | 840 | case fields::FILE_ID : |
| 848 | - if (isset(BPT::$update->message)) $type = 'message'; |
|
| 849 | - elseif (isset(BPT::$update->edited_message)) $type = 'edited_message'; |
|
| 850 | - else return false; |
|
| 841 | + if (isset(BPT::$update->message)) { |
|
| 842 | + $type = 'message'; |
|
| 843 | + } elseif (isset(BPT::$update->edited_message)) { |
|
| 844 | + $type = 'edited_message'; |
|
| 845 | + } else { |
|
| 846 | + return false; |
|
| 847 | + } |
|
| 851 | 848 | |
| 852 | 849 | return match(true) { |
| 853 | 850 | isset(BPT::$update->$type->animation) => BPT::$update->$type->animation->file_id, |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | * telegram class , Adding normal method call to request class and a simple name for being easy to call |
| 9 | 9 | */ |
| 10 | 10 | class telegram extends request { |
| 11 | - public function __call (string $name, array $arguments) { |
|
| 11 | + public function __call(string $name, array $arguments) { |
|
| 12 | 12 | if (!isset($arguments[1]) && isset($arguments[0]) && is_array($arguments[0])) { |
| 13 | 13 | return request::$name(...$arguments[0]); |
| 14 | 14 | } |
@@ -31,11 +31,11 @@ discard block |
||
| 31 | 31 | * |
| 32 | 32 | * @return bool |
| 33 | 33 | */ |
| 34 | - public static function downloadFile(string|null $destination = null, string|null $file_id = null): bool { |
|
| 34 | + public static function downloadFile(string | null $destination = null, string | null $file_id = null): bool { |
|
| 35 | 35 | $file = telegram::getFile(); |
| 36 | 36 | if (isset($file->file_path)) { |
| 37 | 37 | $file_path = settings::$down_url.'bot'.settings::$token.'/'.$file->file_path; |
| 38 | - return tools::downloadFile($file_path,$destination); |
|
| 38 | + return tools::downloadFile($file_path, $destination); |
|
| 39 | 39 | } |
| 40 | 40 | else { |
| 41 | 41 | return false; |
@@ -11,8 +11,7 @@ discard block |
||
| 11 | 11 | public function __call (string $name, array $arguments) { |
| 12 | 12 | if (!isset($arguments[1]) && isset($arguments[0]) && is_array($arguments[0])) { |
| 13 | 13 | return request::$name(...$arguments[0]); |
| 14 | - } |
|
| 15 | - else { |
|
| 14 | + } else { |
|
| 16 | 15 | return request::$name(...$arguments); |
| 17 | 16 | } |
| 18 | 17 | } |
@@ -36,8 +35,7 @@ discard block |
||
| 36 | 35 | if (isset($file->file_path)) { |
| 37 | 36 | $file_path = settings::$down_url.'bot'.settings::$token.'/'.$file->file_path; |
| 38 | 37 | return tools::downloadFile($file_path,$destination); |
| 39 | - } |
|
| 40 | - else { |
|
| 38 | + } else { |
|
| 41 | 39 | return false; |
| 42 | 40 | } |
| 43 | 41 | } |