@@ -12,11 +12,9 @@ |
||
| 12 | 12 | public static function init() { |
| 13 | 13 | if (lock::exist('BPT-MULTI-EXEC')) { |
| 14 | 14 | self::setUpdate(exec::init()); |
| 15 | - } |
|
| 16 | - elseif(lock::exist('BPT-MULTI-CURL')) { |
|
| 15 | + } elseif(lock::exist('BPT-MULTI-CURL')) { |
|
| 17 | 16 | self::setUpdate(curl::init()); |
| 18 | - } |
|
| 19 | - else { |
|
| 17 | + } else { |
|
| 20 | 18 | self::deleteOldLocks(); |
| 21 | 19 | self::checkURL(); |
| 22 | 20 | self::setCertificate(); |
@@ -35,8 +35,7 @@ discard block |
||
| 35 | 35 | if (isset($_SERVER['HTTP_CF_CONNECTING_IP']) && tools::isCloudFlare($ip)) { |
| 36 | 36 | $ip = $_SERVER['HTTP_CF_CONNECTING_IP']; |
| 37 | 37 | } |
| 38 | - } |
|
| 39 | - elseif (settings::$arvancloud_verify && isset($_SERVER['HTTP_AR_REAL_IP']) && tools::isArvanCloud($ip)) { |
|
| 38 | + } elseif (settings::$arvancloud_verify && isset($_SERVER['HTTP_AR_REAL_IP']) && tools::isArvanCloud($ip)) { |
|
| 40 | 39 | $ip = $_SERVER['HTTP_AR_REAL_IP']; |
| 41 | 40 | } |
| 42 | 41 | |
@@ -94,51 +93,41 @@ discard block |
||
| 94 | 93 | if (self::handlerExist('message')) { |
| 95 | 94 | BPT::$handler->message(BPT::$update->message); |
| 96 | 95 | } |
| 97 | - } |
|
| 98 | - elseif (isset(BPT::$update->edited_message)) { |
|
| 96 | + } elseif (isset(BPT::$update->edited_message)) { |
|
| 99 | 97 | if (self::handlerExist('edited_message')) { |
| 100 | 98 | BPT::$handler->edited_message(BPT::$update->edited_message); |
| 101 | 99 | } |
| 102 | - } |
|
| 103 | - elseif (isset(BPT::$update->channel_post)) { |
|
| 100 | + } elseif (isset(BPT::$update->channel_post)) { |
|
| 104 | 101 | if (self::handlerExist('channel_post')) { |
| 105 | 102 | BPT::$handler->channel_post(BPT::$update->channel_post); |
| 106 | 103 | } |
| 107 | - } |
|
| 108 | - elseif (isset(BPT::$update->edited_channel_post)) { |
|
| 104 | + } elseif (isset(BPT::$update->edited_channel_post)) { |
|
| 109 | 105 | if (self::handlerExist('edited_channel_post')) { |
| 110 | 106 | BPT::$handler->edited_channel_post(BPT::$update->edited_channel_post); |
| 111 | 107 | } |
| 112 | - } |
|
| 113 | - elseif (isset(BPT::$update->inline_query)) { |
|
| 108 | + } elseif (isset(BPT::$update->inline_query)) { |
|
| 114 | 109 | if (self::handlerExist('inline_query')) { |
| 115 | 110 | BPT::$handler->inline_query(BPT::$update->inline_query); |
| 116 | 111 | } |
| 117 | - } |
|
| 118 | - elseif (isset(BPT::$update->callback_query)) { |
|
| 112 | + } elseif (isset(BPT::$update->callback_query)) { |
|
| 119 | 113 | if (self::handlerExist('callback_query')) { |
| 120 | 114 | BPT::$handler->callback_query(BPT::$update->callback_query); |
| 121 | 115 | } |
| 122 | - } |
|
| 123 | - elseif (isset(BPT::$update->my_chat_member)) { |
|
| 116 | + } elseif (isset(BPT::$update->my_chat_member)) { |
|
| 124 | 117 | if (self::handlerExist('my_chat_member')) { |
| 125 | 118 | BPT::$handler->my_chat_member(BPT::$update->my_chat_member); |
| 126 | 119 | } |
| 127 | - } |
|
| 128 | - elseif (isset(BPT::$update->chat_member)) { |
|
| 120 | + } elseif (isset(BPT::$update->chat_member)) { |
|
| 129 | 121 | if (self::handlerExist('chat_member')) { |
| 130 | 122 | BPT::$handler->chat_member(BPT::$update->chat_member); |
| 131 | 123 | } |
| 132 | - } |
|
| 133 | - elseif (isset(BPT::$update->chat_join_request)) { |
|
| 124 | + } elseif (isset(BPT::$update->chat_join_request)) { |
|
| 134 | 125 | if (self::handlerExist('chat_join_request')) { |
| 135 | 126 | BPT::$handler->chat_join_request(BPT::$update->chat_join_request); |
| 136 | 127 | } |
| 137 | - } |
|
| 138 | - elseif (self::handlerExist('something_else')) { |
|
| 128 | + } elseif (self::handlerExist('something_else')) { |
|
| 139 | 129 | BPT::$handler->something_else(BPT::$update); |
| 140 | - } |
|
| 141 | - else { |
|
| 130 | + } else { |
|
| 142 | 131 | logger::write('Update received but handlers does not set',loggerTypes::WARNING); |
| 143 | 132 | } |
| 144 | 133 | } |
@@ -17,24 +17,20 @@ discard block |
||
| 17 | 17 | foreach ($object as $key=>$value) { |
| 18 | 18 | if (isset($subs[$key])) { |
| 19 | 19 | $this->$key = new ($subs[$key]) ($value); |
| 20 | - } |
|
| 21 | - else { |
|
| 20 | + } else { |
|
| 22 | 21 | if (is_array($value) && isset($subs['array'])) { |
| 23 | 22 | foreach ($value as $sub_key=>$sub_value) { |
| 24 | 23 | if (is_array($sub_value) && isset($subs['array']['array'])) { |
| 25 | 24 | foreach ($sub_value as $sub2_value) { |
| 26 | 25 | $this->$key[$sub_key][] = new ($subs['array']['array'][$key]) ($sub2_value); |
| 27 | 26 | } |
| 28 | - } |
|
| 29 | - elseif(isset($subs['array'][$key])){ |
|
| 27 | + } elseif(isset($subs['array'][$key])){ |
|
| 30 | 28 | $this->$key[] = new ($subs['array'][$key]) ($sub_value); |
| 31 | - } |
|
| 32 | - else { |
|
| 29 | + } else { |
|
| 33 | 30 | $this->$key[] = $sub_value; |
| 34 | 31 | } |
| 35 | 32 | } |
| 36 | - } |
|
| 37 | - else{ |
|
| 33 | + } else{ |
|
| 38 | 34 | $this->$key = $value; |
| 39 | 35 | if (ucfirst($key) === basename(get_class($this)).'_id') { |
| 40 | 36 | $this->{'id'} = $value; |
@@ -51,8 +47,7 @@ discard block |
||
| 51 | 47 | $name = substr($name,3); |
| 52 | 48 | if (isset($arguments[0])) { |
| 53 | 49 | $this->$name = $arguments[0]; |
| 54 | - } |
|
| 55 | - elseif (isset($arguments['value'])) { |
|
| 50 | + } elseif (isset($arguments['value'])) { |
|
| 56 | 51 | $this->$name = $arguments['value']; |
| 57 | 52 | } |
| 58 | 53 | } |
@@ -34,8 +34,7 @@ discard block |
||
| 34 | 34 | if(settings::$receiver === receiver::GETUPDATES) { |
| 35 | 35 | logger::write('Answer mode only work when receiver is webhook',loggerTypes::ERROR); |
| 36 | 36 | throw new bptException('ANSWER_MODE_GETUPDATES'); |
| 37 | - } |
|
| 38 | - elseif(settings::$multi) { |
|
| 37 | + } elseif(settings::$multi) { |
|
| 39 | 38 | logger::write('You can not use answer mode when multi setting is on',loggerTypes::ERROR); |
| 40 | 39 | throw new bptException('ANSWER_MODE_MULTI'); |
| 41 | 40 | } |
@@ -49,8 +48,7 @@ discard block |
||
| 49 | 48 | foreach ($data as $key=>&$value){ |
| 50 | 49 | if (!isset($value)){ |
| 51 | 50 | unset($data[$key]); |
| 52 | - } |
|
| 53 | - elseif (is_array($value) || is_object($value)){ |
|
| 51 | + } elseif (is_array($value) || is_object($value)){ |
|
| 54 | 52 | $value = json_encode($value); |
| 55 | 53 | } |
| 56 | 54 | } |
@@ -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' || $method === 'setWebhook'){ |
|
| 66 | + } elseif ($method === 'getUpdates' || $method === 'setWebhook'){ |
|
| 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 | } |
@@ -78,11 +78,9 @@ |
||
| 78 | 78 | $value = 'bots_files/' . $value . '/'; |
| 79 | 79 | } |
| 80 | 80 | self::$$setting = $value; |
| 81 | - } |
|
| 82 | - catch (TypeError) { |
|
| 81 | + } catch (TypeError) { |
|
| 83 | 82 | logger::write("$setting setting has wrong type , its set to default value", loggerTypes::WARNING); |
| 84 | - } |
|
| 85 | - catch (Error) { |
|
| 83 | + } catch (Error) { |
|
| 86 | 84 | logger::write("$setting setting is not one of library settings", loggerTypes::WARNING); |
| 87 | 85 | } |
| 88 | 86 | } |
@@ -61,28 +61,22 @@ |
||
| 61 | 61 | $type = tools::fileType($file_id); |
| 62 | 62 | if ($type === fileTypes::VIDEO) { |
| 63 | 63 | return self::sendVideo($file_id,$chat_id,$message_thread_id,null,null,null,null,$caption,$parse_mode,$caption_entities,null,$disable_notification,$protect_content,$reply_to_message_id,$allow_sending_without_reply,$reply_markup,$token,$forgot,$answer); |
| 64 | - } |
|
| 65 | - elseif ($type === fileTypes::VIDEO_NOTE) { |
|
| 64 | + } elseif ($type === fileTypes::VIDEO_NOTE) { |
|
| 66 | 65 | return self::sendVideoNote($file_id,$chat_id,$message_thread_id,null,null,null,$disable_notification,$protect_content,$reply_to_message_id,$allow_sending_without_reply,$reply_markup,$token,$forgot,$answer); |
| 67 | - } |
|
| 68 | - elseif ($type === fileTypes::ANIMATION) { |
|
| 66 | + } elseif ($type === fileTypes::ANIMATION) { |
|
| 69 | 67 | return self::sendAnimation($file_id,$chat_id,$message_thread_id,null,null,null,null,$caption,$parse_mode,$caption_entities,$disable_notification,$protect_content,$reply_to_message_id,$allow_sending_without_reply,$reply_markup,$token,$forgot,$answer); |
| 70 | - } |
|
| 71 | - elseif ($type === fileTypes::AUDIO) { |
|
| 68 | + } elseif ($type === fileTypes::AUDIO) { |
|
| 72 | 69 | return self::sendAudio($file_id,$chat_id,$message_thread_id,$caption,$parse_mode,$caption_entities,null,null,null,null,$disable_notification,$protect_content,$reply_to_message_id,$allow_sending_without_reply,$reply_markup,$token,$forgot,$answer); |
| 73 | - } |
|
| 74 | - elseif ($type === fileTypes::PHOTO || $type === fileTypes::PROFILE_PHOTO) { |
|
| 70 | + } elseif ($type === fileTypes::PHOTO || $type === fileTypes::PROFILE_PHOTO) { |
|
| 75 | 71 | return self::sendPhoto($file_id,$chat_id,$message_thread_id,$caption,$parse_mode,$caption_entities,$disable_notification,$protect_content,$reply_to_message_id,$allow_sending_without_reply,$reply_markup,$token,$forgot,$answer); |
| 76 | - } |
|
| 77 | - elseif ($type === fileTypes::VOICE) { |
|
| 72 | + } elseif ($type === fileTypes::VOICE) { |
|
| 78 | 73 | return self::sendVoice($file_id,$chat_id,$message_thread_id,$caption,$parse_mode,$caption_entities,null,$disable_notification,$protect_content,$reply_to_message_id,$allow_sending_without_reply,$reply_markup,$token,$forgot,$answer); |
| 79 | - } |
|
| 80 | - elseif ($type === fileTypes::STICKER) { |
|
| 74 | + } elseif ($type === fileTypes::STICKER) { |
|
| 81 | 75 | return self::sendSticker($file_id,$chat_id,$message_thread_id,$disable_notification,$protect_content,$reply_to_message_id,$allow_sending_without_reply,$reply_markup,$token,$forgot,$answer); |
| 82 | - } |
|
| 83 | - elseif ($type === fileTypes::DOCUMENT) { |
|
| 76 | + } elseif ($type === fileTypes::DOCUMENT) { |
|
| 84 | 77 | return self::sendDocument($file_id,$chat_id,$message_thread_id,null,$caption,$parse_mode,$caption_entities,null,$disable_notification,$protect_content,$reply_to_message_id,$allow_sending_without_reply,$reply_markup,$token,$forgot,$answer); |
| 78 | + } else { |
|
| 79 | + return false; |
|
| 85 | 80 | } |
| 86 | - else return false; |
|
| 87 | 81 | } |
| 88 | 82 | } |
| 89 | 83 | \ No newline at end of file |
@@ -35,8 +35,7 @@ |
||
| 35 | 35 | private static function loadData(): bool|int|string { |
| 36 | 36 | if (lock::exist('getUpdate')) { |
| 37 | 37 | $last_update_id = lock::read('getUpdate'); |
| 38 | - } |
|
| 39 | - else { |
|
| 38 | + } else { |
|
| 40 | 39 | self::deleteOldLocks(); |
| 41 | 40 | telegram::deleteWebhook(); |
| 42 | 41 | $last_update_id = 0; |
@@ -748,8 +748,7 @@ discard block |
||
| 748 | 748 | self::setDefaults($action,$arguments); |
| 749 | 749 | if (isset($arguments['answer'])) { |
| 750 | 750 | return answer::init($action,$arguments); |
| 751 | - } |
|
| 752 | - else { |
|
| 751 | + } else { |
|
| 753 | 752 | $result = curl::init($action,$arguments); |
| 754 | 753 | if (!is_object($result)) { |
| 755 | 754 | return false; |
@@ -784,8 +783,7 @@ discard block |
||
| 784 | 783 | $arguments['media'][$key]['media'] = new CURLFile($media['media']); |
| 785 | 784 | } |
| 786 | 785 | } |
| 787 | - } |
|
| 788 | - elseif ($file_params = self::methodFile($name)) { |
|
| 786 | + } elseif ($file_params = self::methodFile($name)) { |
|
| 789 | 787 | foreach ($file_params as $param) { |
| 790 | 788 | if (isset($arguments[$param]) && is_string($arguments[$param]) && file_exists(realpath($arguments[$param]))) { |
| 791 | 789 | $arguments[$param] = new CURLFile($arguments[$param]); |
@@ -807,12 +805,10 @@ discard block |
||
| 807 | 805 | $value = new ($return[0]) ($value); |
| 808 | 806 | } |
| 809 | 807 | return $response; |
| 810 | - } |
|
| 811 | - else { |
|
| 808 | + } else { |
|
| 812 | 809 | return new ($return) ($response->result); |
| 813 | 810 | } |
| 814 | - } |
|
| 815 | - else { |
|
| 811 | + } else { |
|
| 816 | 812 | return $response->result; |
| 817 | 813 | } |
| 818 | 814 | } |
@@ -824,8 +820,7 @@ discard block |
||
| 824 | 820 | if (!isset($arguments[$default])){ |
| 825 | 821 | $arguments[$default] = self::catchFields($default); |
| 826 | 822 | } |
| 827 | - } |
|
| 828 | - elseif (isset(BPT::$update->$key) || $key === 'other') { |
|
| 823 | + } elseif (isset(BPT::$update->$key) || $key === 'other') { |
|
| 829 | 824 | foreach ($default as $def) { |
| 830 | 825 | if (!isset($arguments[$def])){ |
| 831 | 826 | $arguments[$def] = self::catchFields($def); |
@@ -841,8 +836,7 @@ discard block |
||
| 841 | 836 | self::$status = true; |
| 842 | 837 | self::$pure_response = $response; |
| 843 | 838 | return self::methodReturn($name,$response); |
| 844 | - } |
|
| 845 | - else { |
|
| 839 | + } else { |
|
| 846 | 840 | self::$status = false; |
| 847 | 841 | self::$pure_response = $response; |
| 848 | 842 | return new responseError($response); |
@@ -885,9 +879,13 @@ discard block |
||
| 885 | 879 | default => false |
| 886 | 880 | }; |
| 887 | 881 | case fields::FILE_ID : |
| 888 | - if (isset(BPT::$update->message)) $type = 'message'; |
|
| 889 | - elseif (isset(BPT::$update->edited_message)) $type = 'edited_message'; |
|
| 890 | - else return false; |
|
| 882 | + if (isset(BPT::$update->message)) { |
|
| 883 | + $type = 'message'; |
|
| 884 | + } elseif (isset(BPT::$update->edited_message)) { |
|
| 885 | + $type = 'edited_message'; |
|
| 886 | + } else { |
|
| 887 | + return false; |
|
| 888 | + } |
|
| 891 | 889 | |
| 892 | 890 | return match(true) { |
| 893 | 891 | isset(BPT::$update->$type->animation) => BPT::$update->$type->animation->file_id, |