@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | * |
32 | 32 | * @return string |
33 | 33 | */ |
34 | - public static function randomString (int $length = 16, string $characters = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'): string { |
|
34 | + public static function randomString(int $length = 16, string $characters = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'): string { |
|
35 | 35 | $rand_string = ''; |
36 | 36 | $char_len = strlen($characters) - 1; |
37 | - for ($i = 0; $i < $length; $i ++) { |
|
37 | + for ($i = 0; $i < $length; $i++) { |
|
38 | 38 | $rand_string .= $characters[rand(0, $char_len)]; |
39 | 39 | } |
40 | 40 | return $rand_string; |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @return inlineKeyboardMarkup|replyKeyboardMarkup replyKeyboardMarkup for keyboard and inlineKeyboardMarkup for inline |
64 | 64 | * @throws bptException |
65 | 65 | */ |
66 | - public static function easyKey(array $keyboard = [], array $inline = []): inlineKeyboardMarkup|replyKeyboardMarkup { |
|
66 | + public static function easyKey(array $keyboard = [], array $inline = []): inlineKeyboardMarkup | replyKeyboardMarkup { |
|
67 | 67 | if (!empty($keyboard)) { |
68 | 68 | $keyboard_object = new replyKeyboardMarkup(); |
69 | 69 | $keyboard_object->setResize_keyboard($keyboard['resize'] ?? true); |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | return $keyboard_object; |
123 | 123 | } |
124 | 124 | else { |
125 | - logger::write("tools::eKey function used\nkeyboard or inline parameter must be set",loggerTypes::ERROR); |
|
125 | + logger::write("tools::eKey function used\nkeyboard or inline parameter must be set", loggerTypes::ERROR); |
|
126 | 126 | throw new bptException('ARGUMENT_NOT_FOUND_KEYBOARD_INLINE'); |
127 | 127 | } |
128 | 128 | } |
@@ -139,9 +139,9 @@ discard block |
||
139 | 139 | * |
140 | 140 | * @return string |
141 | 141 | */ |
142 | - public static function inviteLink (int $user_id = null, string $bot_username = null): string { |
|
142 | + public static function inviteLink(int $user_id = null, string $bot_username = null): string { |
|
143 | 143 | if (empty($user_id)) $user_id = telegram::catchFields(fields::USER_ID); |
144 | 144 | if (empty($bot_username)) $bot_username = telegram::getMe()->username; |
145 | - return 'https://t.me/' . str_replace('@', '', $bot_username) . '?start=ref_' . tools::shortEncode($user_id); |
|
145 | + return 'https://t.me/'.str_replace('@', '', $bot_username).'?start=ref_'.tools::shortEncode($user_id); |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | \ No newline at end of file |
@@ -71,7 +71,9 @@ discard block |
||
71 | 71 | $keyboard_object->setOne_time_keyboard($keyboard['one_time']); |
72 | 72 | } |
73 | 73 | foreach ($keyboard as $row) { |
74 | - if (!is_array($row)) continue; |
|
74 | + if (!is_array($row)) { |
|
75 | + continue; |
|
76 | + } |
|
75 | 77 | $buttons = []; |
76 | 78 | foreach ($row as $base_button) { |
77 | 79 | $button_info = explode('||', $base_button); |
@@ -80,15 +82,12 @@ discard block |
||
80 | 82 | if (count($button_info) > 1) { |
81 | 83 | if ($button_info[1] === 'con') { |
82 | 84 | $button->setRequest_contact(true); |
83 | - } |
|
84 | - elseif ($button_info[1] === 'loc') { |
|
85 | + } elseif ($button_info[1] === 'loc') { |
|
85 | 86 | $button->setRequest_location(true); |
86 | - } |
|
87 | - elseif ($button_info[1] === 'poll') { |
|
87 | + } elseif ($button_info[1] === 'poll') { |
|
88 | 88 | $type = $button_info[2] === pollType::QUIZ ? pollType::QUIZ : pollType::REGULAR; |
89 | 89 | $button->setRequest_poll((new keyboardButtonPollType())->setType($type)); |
90 | - } |
|
91 | - elseif ($button_info[1] === 'web' && isset($button_info[2])) { |
|
90 | + } elseif ($button_info[1] === 'web' && isset($button_info[2])) { |
|
92 | 91 | $url = $button_info[2]; |
93 | 92 | $button->setWeb_app((new webAppInfo())->setUrl($url)); |
94 | 93 | } |
@@ -98,8 +97,7 @@ discard block |
||
98 | 97 | $keyboard_object->setKeyboard([$buttons]); |
99 | 98 | } |
100 | 99 | return $keyboard_object; |
101 | - } |
|
102 | - elseif (!empty($inline)) { |
|
100 | + } elseif (!empty($inline)) { |
|
103 | 101 | $keyboard_object = new inlineKeyboardMarkup(); |
104 | 102 | foreach ($inline as $row) { |
105 | 103 | $buttons = []; |
@@ -108,20 +106,17 @@ discard block |
||
108 | 106 | if (isset($button_info[1])) { |
109 | 107 | if (filter_var($button_info[1], FILTER_VALIDATE_URL) && str_starts_with($button_info[1], 'http')) { |
110 | 108 | $button->setText($button_info[0])->setUrl($button_info[1]); |
111 | - } |
|
112 | - else { |
|
109 | + } else { |
|
113 | 110 | $button->setText($button_info[0])->setCallback_data($button_info[1]); |
114 | 111 | } |
115 | - } |
|
116 | - else { |
|
112 | + } else { |
|
117 | 113 | $button->setText($button_info[0])->setUrl('https://t.me/BPT_CH'); |
118 | 114 | } |
119 | 115 | } |
120 | 116 | $keyboard_object->setInline_keyboard([$buttons]); |
121 | 117 | } |
122 | 118 | return $keyboard_object; |
123 | - } |
|
124 | - else { |
|
119 | + } else { |
|
125 | 120 | logger::write("tools::eKey function used\nkeyboard or inline parameter must be set",loggerTypes::ERROR); |
126 | 121 | throw new bptException('ARGUMENT_NOT_FOUND_KEYBOARD_INLINE'); |
127 | 122 | } |
@@ -140,8 +135,12 @@ discard block |
||
140 | 135 | * @return string |
141 | 136 | */ |
142 | 137 | public static function inviteLink (int $user_id = null, string $bot_username = null): string { |
143 | - if (empty($user_id)) $user_id = telegram::catchFields(fields::USER_ID); |
|
144 | - if (empty($bot_username)) $bot_username = telegram::getMe()->username; |
|
138 | + if (empty($user_id)) { |
|
139 | + $user_id = telegram::catchFields(fields::USER_ID); |
|
140 | + } |
|
141 | + if (empty($bot_username)) { |
|
142 | + $bot_username = telegram::getMe()->username; |
|
143 | + } |
|
145 | 144 | return 'https://t.me/' . str_replace('@', '', $bot_username) . '?start=ref_' . tools::shortEncode($user_id); |
146 | 145 | } |
147 | 146 | } |
148 | 147 | \ No newline at end of file |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @return bool |
22 | 22 | */ |
23 | - public static function isUsername (string $username): bool { |
|
23 | + public static function isUsername(string $username): bool { |
|
24 | 24 | $length = strlen($username); |
25 | 25 | return !str_contains($username, '__') && $length >= 5 && $length <= 33 && preg_match('/^@?([a-zA-Z])(\w{4,31})$/', $username); |
26 | 26 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * |
38 | 38 | * @return bool |
39 | 39 | */ |
40 | - public static function ipInRange (string $ip, string $range): bool { |
|
40 | + public static function ipInRange(string $ip, string $range): bool { |
|
41 | 41 | if (!str_contains($range, '/')) { |
42 | 42 | $range .= '/32'; |
43 | 43 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @return bool |
59 | 59 | */ |
60 | - public static function isTelegram (string $ip): bool { |
|
60 | + public static function isTelegram(string $ip): bool { |
|
61 | 61 | return tools::ipInRange($ip, '149.154.160.0/20') || tools::ipInRange($ip, '91.108.4.0/22'); |
62 | 62 | } |
63 | 63 | |
@@ -72,10 +72,10 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @return bool |
74 | 74 | */ |
75 | - public static function isCloudFlare (string $ip): bool { |
|
75 | + public static function isCloudFlare(string $ip): bool { |
|
76 | 76 | $cf_ips = ['173.245.48.0/20', '103.21.244.0/22', '103.22.200.0/22', '103.31.4.0/22', '141.101.64.0/18', '108.162.192.0/18', '190.93.240.0/20', '188.114.96.0/20', '197.234.240.0/22', '198.41.128.0/17', '162.158.0.0/15', '104.16.0.0/12', '104.24.0.0/14', '172.64.0.0/13', '131.0.72.0/22']; |
77 | 77 | foreach ($cf_ips as $cf_ip) { |
78 | - if (self::ipInRange($ip,$cf_ip)) { |
|
78 | + if (self::ipInRange($ip, $cf_ip)) { |
|
79 | 79 | return true; |
80 | 80 | } |
81 | 81 | } |
@@ -93,10 +93,10 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @return bool |
95 | 95 | */ |
96 | - public static function isArvanCloud (string $ip): bool { |
|
96 | + public static function isArvanCloud(string $ip): bool { |
|
97 | 97 | $ar_ips = ['185.143.232.0/22', '92.114.16.80/28', '2.146.0.0/28', '46.224.2.32/29', '89.187.178.96/29', '195.181.173.128/29', '89.187.169.88/29', '188.229.116.16/29', '83.123.255.56/31', '164.138.128.28/31', '94.182.182.28/30', '185.17.115.176/30', '5.213.255.36/31', '138.128.139.144/29', '5.200.14.8/29', '188.122.68.224/29', '188.122.83.176/29', '213.179.217.16/29', '185.179.201.192/29', '43.239.139.192/29', '213.179.197.16/29', '213.179.201.192/29', '109.200.214.248/29', '138.128.141.16/29', '188.122.78.136/29', '213.179.211.32/29', '103.194.164.24/29', '185.50.105.136/29', '213.179.213.16/29', '162.244.52.120/29', '188.122.80.240/29', '109.200.195.64/29', '109.200.199.224/29', '185.228.238.0/28', '94.182.153.24/29', '94.101.182.0/27', '37.152.184.208/28', '78.39.156.192/28', '158.255.77.238/31', '81.12.28.16/29', '176.65.192.202/31', '2.144.3.128/28', '89.45.48.64/28', '37.32.16.0/27', '37.32.17.0/27', '37.32.18.0/27']; |
98 | 98 | foreach ($ar_ips as $ar_ip) { |
99 | - if (self::ipInRange($ip,$ar_ip)) { |
|
99 | + if (self::ipInRange($ip, $ar_ip)) { |
|
100 | 100 | return true; |
101 | 101 | } |
102 | 102 | } |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | * |
117 | 117 | * @return bool|user return array when verify is active and token is true array of telegram getMe result |
118 | 118 | */ |
119 | - public static function isToken (string $token, bool $verify = false): bool|user { |
|
119 | + public static function isToken(string $token, bool $verify = false): bool | user { |
|
120 | 120 | if (preg_match('/^(\d{8,10}):[\w\-]{35}$/', $token)) { |
121 | - if ($verify){ |
|
121 | + if ($verify) { |
|
122 | 122 | $res = telegram::me($token); |
123 | 123 | if (telegram::$status) { |
124 | 124 | return $res; |
@@ -150,14 +150,14 @@ discard block |
||
150 | 150 | * |
151 | 151 | * @return bool |
152 | 152 | */ |
153 | - public static function isJoined (array|string|int $ids , int|null $user_id = null): bool { |
|
153 | + public static function isJoined(array | string | int $ids, int | null $user_id = null): bool { |
|
154 | 154 | if (!is_array($ids)) { |
155 | 155 | $ids = [$ids]; |
156 | 156 | } |
157 | 157 | $user_id = $user_id ?? request::catchFields('user_id'); |
158 | 158 | |
159 | 159 | foreach ($ids as $id) { |
160 | - $check = telegram::getChatMember($id,$user_id); |
|
160 | + $check = telegram::getChatMember($id, $user_id); |
|
161 | 161 | if (telegram::$status) { |
162 | 162 | $check = $check->status; |
163 | 163 | if ($check === chatMemberStatus::LEFT || $check === chatMemberStatus::KICKED) { |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | * |
185 | 185 | * @return array keys will be id and values will be bool(null for not founded ids) |
186 | 186 | */ |
187 | - public static function joinChecker (array|string|int $ids , int|null $user_id = null): array { |
|
187 | + public static function joinChecker(array | string | int $ids, int | null $user_id = null): array { |
|
188 | 188 | if (!is_array($ids)) { |
189 | 189 | $ids = [$ids]; |
190 | 190 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | |
193 | 193 | $result = []; |
194 | 194 | foreach ($ids as $id) { |
195 | - $check = telegram::getChatMember($id,$user_id); |
|
195 | + $check = telegram::getChatMember($id, $user_id); |
|
196 | 196 | if (telegram::$status) { |
197 | 197 | $check = $check->status; |
198 | 198 | $result[$id] = $check !== chatMemberStatus::LEFT && $check !== chatMemberStatus::KICKED; |
@@ -212,6 +212,6 @@ discard block |
||
212 | 212 | * @return bool |
213 | 213 | */ |
214 | 214 | public static function isShorted(string $text): bool{ |
215 | - return preg_match('/^[a-zA-Z0-9]+$/',$text); |
|
215 | + return preg_match('/^[a-zA-Z0-9]+$/', $text); |
|
216 | 216 | } |
217 | 217 | } |
218 | 218 | \ No newline at end of file |
@@ -21,10 +21,10 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @return string |
23 | 23 | */ |
24 | - public static function byteFormat (int $byte, int $precision = 2): string { |
|
24 | + public static function byteFormat(int $byte, int $precision = 2): string { |
|
25 | 25 | $rate_counter = 0; |
26 | 26 | |
27 | - while ($byte > 1024){ |
|
27 | + while ($byte > 1024) { |
|
28 | 28 | $byte /= 1024; |
29 | 29 | $rate_counter++; |
30 | 30 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $byte = round($byte, $precision); |
34 | 34 | } |
35 | 35 | |
36 | - return $byte . ' ' . ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'][$rate_counter]; |
|
36 | + return $byte.' '.['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'][$rate_counter]; |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | * |
51 | 51 | * @return string|false return false when mode is incorrect |
52 | 52 | */ |
53 | - public static function modeEscape (string $text, string $mode = parseMode::HTML): string|false { |
|
53 | + public static function modeEscape(string $text, string $mode = parseMode::HTML): string | false { |
|
54 | 54 | return match ($mode) { |
55 | - parseMode::HTML => str_replace(['&', '<', '>',], ["&", "<", ">",], $text), |
|
56 | - parseMode::MARKDOWN => str_replace(['\\', '_', '*', '`', '['], ['\\\\', '\_', '\*', '\`', '\[',], $text), |
|
55 | + parseMode::HTML => str_replace(['&', '<', '>', ], ["&", "<", ">", ], $text), |
|
56 | + parseMode::MARKDOWN => str_replace(['\\', '_', '*', '`', '['], ['\\\\', '\_', '\*', '\`', '\[', ], $text), |
|
57 | 57 | parseMode::MARKDOWNV2 => str_replace( |
58 | 58 | ['_', '*', '[', ']', '(', ')', '~', '`', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!', '\\'], |
59 | 59 | ['\_', '\*', '\[', '\]', '\(', '\)', '\~', '\`', '\>', '\#', '\+', '\-', '\=', '\|', '\{', '\}', '\.', '\!', '\\\\'], |
@@ -92,12 +92,12 @@ discard block |
||
92 | 92 | * @return array{status: string,year: string,month: string,day: string,hour: string,minute: string,second: string} |
93 | 93 | * @throws Exception |
94 | 94 | */ |
95 | - public static function timeDiff (int|string $target_time, int|string|null $base_time = null): array { |
|
95 | + public static function timeDiff(int | string $target_time, int | string | null $base_time = null): array { |
|
96 | 96 | if (!isset($base_time)) { |
97 | 97 | $base_time = '@'.time(); |
98 | 98 | } |
99 | 99 | $base_time = new DateTime($base_time); |
100 | - $target_time = new DateTime(is_numeric($target_time) ? '@' . $target_time : $target_time . ' +00:00'); |
|
100 | + $target_time = new DateTime(is_numeric($target_time) ? '@'.$target_time : $target_time.' +00:00'); |
|
101 | 101 | |
102 | 102 | $diff = $base_time->diff($target_time); |
103 | 103 | |
@@ -124,12 +124,12 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @return string[]|string |
126 | 126 | */ |
127 | - public static function realEscapeString(string|array $input): string|array { |
|
128 | - if(is_array($input)) { |
|
127 | + public static function realEscapeString(string | array $input): string | array { |
|
128 | + if (is_array($input)) { |
|
129 | 129 | return array_map(__METHOD__, $input); |
130 | 130 | } |
131 | 131 | |
132 | - if(!empty($input) && is_string($input)) { |
|
132 | + if (!empty($input) && is_string($input)) { |
|
133 | 133 | return str_replace(['\\', "\0", "\n", "\r", "'", '"', "\x1a"], ['\\\\', '\\0', '\\n', '\\r', "\\'", '\\"', '\\Z'], $input); |
134 | 134 | } |
135 | 135 | |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * |
148 | 148 | * @return string[]|string |
149 | 149 | */ |
150 | - public static function strReplaceFirst(string|array $search, string|array $replace, string|array $subject): string|array { |
|
150 | + public static function strReplaceFirst(string | array $search, string | array $replace, string | array $subject): string | array { |
|
151 | 151 | $pos = strpos($subject, $search); |
152 | 152 | if ($pos !== false) { |
153 | 153 | return substr_replace($subject, $replace, $pos, strlen($search)); |
@@ -16,15 +16,13 @@ discard block |
||
16 | 16 | public static function init () { |
17 | 17 | if (settings::$multi) { |
18 | 18 | multi::init(); |
19 | - } |
|
20 | - else { |
|
19 | + } else { |
|
21 | 20 | if (lock::exist('BPT-HOOK')) { |
22 | 21 | receiver::telegramVerify(); |
23 | 22 | self::checkSecret(); |
24 | 23 | logger::write('Update received , lets process it ;)'); |
25 | 24 | receiver::processUpdate(); |
26 | - } |
|
27 | - else { |
|
25 | + } else { |
|
28 | 26 | self::processSetWebhook(); |
29 | 27 | } |
30 | 28 | } |
@@ -46,8 +44,7 @@ discard block |
||
46 | 44 | $res = telegram::setWebhook($url, settings::$certificate, max_connections: settings::$max_connection, allowed_updates: settings::$allowed_updates, drop_pending_updates: settings::$skip_old_updates, secret_token: $secret); |
47 | 45 | if (telegram::$status) { |
48 | 46 | logger::write('Webhook was set successfully',loggerTypes::INFO); |
49 | - } |
|
50 | - else { |
|
47 | + } else { |
|
51 | 48 | logger::write("There is some problem happened , telegram response : \n".json_encode($res),loggerTypes::ERROR); |
52 | 49 | BPT::exit(print_r($res,true)); |
53 | 50 | } |
@@ -69,8 +66,7 @@ discard block |
||
69 | 66 | if (is_string(settings::$certificate)) { |
70 | 67 | if (file_exists(settings::$certificate)) { |
71 | 68 | settings::$certificate = new CURLFile(settings::$certificate); |
72 | - } |
|
73 | - else { |
|
69 | + } else { |
|
74 | 70 | settings::$certificate = null; |
75 | 71 | } |
76 | 72 | } |
@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | } |
36 | 36 | |
37 | 37 | if (!tools::isTelegram($ip ?? '')) { |
38 | - logger::write('not authorized access denied. IP : '. $ip ?? 'unknown',loggerTypes::WARNING); |
|
38 | + logger::write('not authorized access denied. IP : '.$ip ?? 'unknown', loggerTypes::WARNING); |
|
39 | 39 | BPT::exit(); |
40 | 40 | } |
41 | 41 | } |
42 | 42 | } |
43 | 43 | |
44 | - protected static function processUpdate(string|stdClass|update $update = null): void { |
|
44 | + protected static function processUpdate(string | stdClass | update $update = null): void { |
|
45 | 45 | if (!is_object($update)) { |
46 | 46 | $update = json_decode($update ?? file_get_contents("php://input")); |
47 | 47 | if (!$update) { |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
52 | - if (!is_a($update,'update')) { |
|
52 | + if (!is_a($update, 'update')) { |
|
53 | 53 | $update = new update($update); |
54 | 54 | } |
55 | 55 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | self::processHandler(); |
60 | 60 | } |
61 | 61 | |
62 | - protected static function setMessageExtra (update &$update): void { |
|
62 | + protected static function setMessageExtra(update & $update): void { |
|
63 | 63 | if ((isset($update->message) && isset($update->message->text)) || (isset($update->edited_message) && isset($update->edited_message->text))) { |
64 | 64 | $type = isset($update->message) ? 'message' : 'edited_message'; |
65 | 65 | $text = &$update->$type->text; |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | BPT::$handler->something_else(BPT::$update); |
128 | 128 | } |
129 | 129 | else { |
130 | - logger::write('Update received but handlers does not set',loggerTypes::WARNING); |
|
130 | + logger::write('Update received but handlers does not set', loggerTypes::WARNING); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | } |
@@ -27,8 +27,7 @@ discard block |
||
27 | 27 | if (isset($_SERVER['HTTP_CF_CONNECTING_IP']) && tools::isCloudFlare($ip)) { |
28 | 28 | $ip = $_SERVER['HTTP_CF_CONNECTING_IP']; |
29 | 29 | } |
30 | - } |
|
31 | - elseif (settings::$arvancloud_verify) { |
|
30 | + } elseif (settings::$arvancloud_verify) { |
|
32 | 31 | if (isset($_SERVER['HTTP_AR_REAL_IP']) && tools::isArvanCloud($ip)) { |
33 | 32 | $ip = $_SERVER['HTTP_AR_REAL_IP']; |
34 | 33 | } |
@@ -87,46 +86,37 @@ discard block |
||
87 | 86 | if (self::handlerExist('message')) { |
88 | 87 | BPT::$handler->message(BPT::$update->message); |
89 | 88 | } |
90 | - } |
|
91 | - elseif (isset(BPT::$update->edited_message)) { |
|
89 | + } elseif (isset(BPT::$update->edited_message)) { |
|
92 | 90 | if (self::handlerExist('edited_message')) { |
93 | 91 | BPT::$handler->edited_message(BPT::$update->edited_message); |
94 | 92 | } |
95 | - } |
|
96 | - elseif (isset(BPT::$update->channel_post)) { |
|
93 | + } elseif (isset(BPT::$update->channel_post)) { |
|
97 | 94 | if (self::handlerExist('channel_post')) { |
98 | 95 | BPT::$handler->channel_post(BPT::$update->channel_post); |
99 | 96 | } |
100 | - } |
|
101 | - elseif (isset(BPT::$update->edited_channel_post)) { |
|
97 | + } elseif (isset(BPT::$update->edited_channel_post)) { |
|
102 | 98 | if (self::handlerExist('edited_channel_post')) { |
103 | 99 | BPT::$handler->edited_channel_post(BPT::$update->edited_channel_post); |
104 | 100 | } |
105 | - } |
|
106 | - elseif (isset(BPT::$update->inline_query)) { |
|
101 | + } elseif (isset(BPT::$update->inline_query)) { |
|
107 | 102 | if (self::handlerExist('inline_query')) { |
108 | 103 | BPT::$handler->inline_query(BPT::$update->inline_query); |
109 | 104 | } |
110 | - } |
|
111 | - elseif (isset(BPT::$update->callback_query)) { |
|
105 | + } elseif (isset(BPT::$update->callback_query)) { |
|
112 | 106 | if (self::handlerExist('callback_query')) { |
113 | 107 | BPT::$handler->callback_query(BPT::$update->callback_query); |
114 | 108 | } |
115 | - } |
|
116 | - elseif (isset(BPT::$update->my_chat_member)) { |
|
109 | + } elseif (isset(BPT::$update->my_chat_member)) { |
|
117 | 110 | if (self::handlerExist('my_chat_member')) { |
118 | 111 | BPT::$handler->my_chat_member(BPT::$update->my_chat_member); |
119 | 112 | } |
120 | - } |
|
121 | - elseif (isset(BPT::$update->chat_member)) { |
|
113 | + } elseif (isset(BPT::$update->chat_member)) { |
|
122 | 114 | if (self::handlerExist('chat_member')) { |
123 | 115 | BPT::$handler->chat_member(BPT::$update->chat_member); |
124 | 116 | } |
125 | - } |
|
126 | - elseif (self::handlerExist('something_else')) { |
|
117 | + } elseif (self::handlerExist('something_else')) { |
|
127 | 118 | BPT::$handler->something_else(BPT::$update); |
128 | - } |
|
129 | - else { |
|
119 | + } else { |
|
130 | 120 | logger::write('Update received but handlers does not set',loggerTypes::WARNING); |
131 | 121 | } |
132 | 122 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | public static int $log_size = 10; |
26 | 26 | |
27 | - public static string|CURLFile|null $certificate = null; |
|
27 | + public static string | CURLFile | null $certificate = null; |
|
28 | 28 | |
29 | 29 | public static bool $handler = true; |
30 | 30 | |
@@ -56,14 +56,14 @@ discard block |
||
56 | 56 | |
57 | 57 | public static array $allowed_updates = ['message', 'edited_channel_post', 'callback_query', 'inline_query']; |
58 | 58 | |
59 | - public static array|null $db = ['type' => 'json', 'file_name' => 'BPT-DB.json']; |
|
59 | + public static array | null $db = ['type' => 'json', 'file_name' => 'BPT-DB.json']; |
|
60 | 60 | |
61 | 61 | |
62 | - public static function init (array|stdClass $settings): void { |
|
62 | + public static function init(array | stdClass $settings): void { |
|
63 | 63 | $settings = (array) $settings; |
64 | 64 | |
65 | 65 | foreach ($settings as $setting => $value) { |
66 | - try{ |
|
66 | + try { |
|
67 | 67 | if ($setting === 'name') { |
68 | 68 | if (!is_dir('bots_files')) { |
69 | 69 | mkdir('bots_files'); |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | } |
76 | 76 | self::$$setting = $value; |
77 | 77 | } |
78 | - catch (TypeError){ |
|
79 | - logger::write("$setting setting has wrong type , its set to default value",loggerTypes::WARNING); |
|
78 | + catch (TypeError) { |
|
79 | + logger::write("$setting setting has wrong type , its set to default value", loggerTypes::WARNING); |
|
80 | 80 | } |
81 | - catch (Error){ |
|
82 | - logger::write("$setting setting is not one of library settings",loggerTypes::WARNING); |
|
81 | + catch (Error) { |
|
82 | + logger::write("$setting setting is not one of library settings", loggerTypes::WARNING); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
@@ -97,19 +97,19 @@ discard block |
||
97 | 97 | } |
98 | 98 | } |
99 | 99 | else { |
100 | - logger::write('token format is not right, check it and try again',loggerTypes::ERROR); |
|
100 | + logger::write('token format is not right, check it and try again', loggerTypes::ERROR); |
|
101 | 101 | throw new bptException('TOKEN_NOT_TRUE'); |
102 | 102 | } |
103 | 103 | } |
104 | 104 | else { |
105 | - logger::write('You must specify token parameter in settings',loggerTypes::ERROR); |
|
105 | + logger::write('You must specify token parameter in settings', loggerTypes::ERROR); |
|
106 | 106 | throw new bptException('TOKEN_NOT_FOUND'); |
107 | 107 | } |
108 | 108 | } |
109 | 109 | |
110 | 110 | public static function done(): void { |
111 | 111 | if (self::$logger) { |
112 | - $estimated = round((microtime(true)-$_SERVER['REQUEST_TIME_FLOAT'])*1000,2); |
|
112 | + $estimated = round((microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']) * 1000, 2); |
|
113 | 113 | $status_message = match (true) { |
114 | 114 | $estimated < 100 => 'Excellent', |
115 | 115 | $estimated < 500 => 'Very good', |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | if (self::$secure_folder) { |
142 | 142 | $address = explode('/', $_SERVER['REQUEST_URI']); |
143 | 143 | unset($address[count($address) - 1]); |
144 | - $address = implode('/', $address) . '/BPT.php'; |
|
144 | + $address = implode('/', $address).'/BPT.php'; |
|
145 | 145 | $text = "ErrorDocument 404 $address\nErrorDocument 403 $address\n Options -Indexes\n Order Deny,Allow\nDeny from all\nAllow from 127.0.0.1\n<Files *.php>\n Order Allow,Deny\n Allow from all\n</Files>"; |
146 | 146 | if (!file_exists('.htaccess') || filesize('.htaccess') != strlen($text)) { |
147 | 147 | file_put_contents('.htaccess', $text); |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | getUpdates::init(); |
159 | 159 | } |
160 | 160 | else { |
161 | - logger::write('You can\'t use getUpdates receiver when handler is off , use webhook or use handler',loggerTypes::ERROR); |
|
161 | + logger::write('You can\'t use getUpdates receiver when handler is off , use webhook or use handler', loggerTypes::ERROR); |
|
162 | 162 | throw new bptException('GETUPDATE_NEED_HANDLER'); |
163 | 163 | } |
164 | 164 | } |