@@ -32,13 +32,13 @@ discard block |
||
32 | 32 | if (settings::$telegram_verify) { |
33 | 33 | $ip = $ip ?? tools::remoteIP(); |
34 | 34 | if (!tools::isTelegram($ip)) { |
35 | - logger::write('not authorized access denied. IP : '. $ip ?? 'unknown',loggerTypes::WARNING); |
|
35 | + logger::write('not authorized access denied. IP : '.$ip ?? 'unknown', loggerTypes::WARNING); |
|
36 | 36 | BPT::exit(); |
37 | 37 | } |
38 | 38 | } |
39 | 39 | } |
40 | 40 | |
41 | - protected static function processUpdate(string|stdClass|update $update = null): void { |
|
41 | + protected static function processUpdate(string | stdClass | update $update = null): void { |
|
42 | 42 | if (!is_object($update)) { |
43 | 43 | $update = json_decode($update ?? file_get_contents("php://input")); |
44 | 44 | if (!$update) { |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | } |
47 | 47 | } |
48 | 48 | |
49 | - if (!is_a($update,'update')) { |
|
49 | + if (!is_a($update, 'update')) { |
|
50 | 50 | $update = new update($update); |
51 | 51 | } |
52 | 52 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | db::save(); |
58 | 58 | } |
59 | 59 | |
60 | - protected static function setMessageExtra (update &$update): void { |
|
60 | + protected static function setMessageExtra(update & $update): void { |
|
61 | 61 | if ((isset($update->message) && isset($update->message->text)) || (isset($update->edited_message) && isset($update->edited_message->text))) { |
62 | 62 | $type = isset($update->message) ? 'message' : 'edited_message'; |
63 | 63 | $text = &$update->$type->text; |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | BPT::$handler->something_else(BPT::$update); |
131 | 131 | } |
132 | 132 | else { |
133 | - logger::write('Update received but handlers are not set',loggerTypes::WARNING); |
|
133 | + logger::write('Update received but handlers are not set', loggerTypes::WARNING); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | } |
@@ -85,51 +85,41 @@ |
||
85 | 85 | if (self::handlerExist('message')) { |
86 | 86 | BPT::$handler->message(BPT::$update->message); |
87 | 87 | } |
88 | - } |
|
89 | - elseif (isset(BPT::$update->edited_message)) { |
|
88 | + } elseif (isset(BPT::$update->edited_message)) { |
|
90 | 89 | if (self::handlerExist('edited_message')) { |
91 | 90 | BPT::$handler->edited_message(BPT::$update->edited_message); |
92 | 91 | } |
93 | - } |
|
94 | - elseif (isset(BPT::$update->channel_post)) { |
|
92 | + } elseif (isset(BPT::$update->channel_post)) { |
|
95 | 93 | if (self::handlerExist('channel_post')) { |
96 | 94 | BPT::$handler->channel_post(BPT::$update->channel_post); |
97 | 95 | } |
98 | - } |
|
99 | - elseif (isset(BPT::$update->edited_channel_post)) { |
|
96 | + } elseif (isset(BPT::$update->edited_channel_post)) { |
|
100 | 97 | if (self::handlerExist('edited_channel_post')) { |
101 | 98 | BPT::$handler->edited_channel_post(BPT::$update->edited_channel_post); |
102 | 99 | } |
103 | - } |
|
104 | - elseif (isset(BPT::$update->inline_query)) { |
|
100 | + } elseif (isset(BPT::$update->inline_query)) { |
|
105 | 101 | if (self::handlerExist('inline_query')) { |
106 | 102 | BPT::$handler->inline_query(BPT::$update->inline_query); |
107 | 103 | } |
108 | - } |
|
109 | - elseif (isset(BPT::$update->callback_query)) { |
|
104 | + } elseif (isset(BPT::$update->callback_query)) { |
|
110 | 105 | if (self::handlerExist('callback_query')) { |
111 | 106 | BPT::$handler->callback_query(BPT::$update->callback_query); |
112 | 107 | } |
113 | - } |
|
114 | - elseif (isset(BPT::$update->my_chat_member)) { |
|
108 | + } elseif (isset(BPT::$update->my_chat_member)) { |
|
115 | 109 | if (self::handlerExist('my_chat_member')) { |
116 | 110 | BPT::$handler->my_chat_member(BPT::$update->my_chat_member); |
117 | 111 | } |
118 | - } |
|
119 | - elseif (isset(BPT::$update->chat_member)) { |
|
112 | + } elseif (isset(BPT::$update->chat_member)) { |
|
120 | 113 | if (self::handlerExist('chat_member')) { |
121 | 114 | BPT::$handler->chat_member(BPT::$update->chat_member); |
122 | 115 | } |
123 | - } |
|
124 | - elseif (isset(BPT::$update->chat_join_request)) { |
|
116 | + } elseif (isset(BPT::$update->chat_join_request)) { |
|
125 | 117 | if (self::handlerExist('chat_join_request')) { |
126 | 118 | BPT::$handler->chat_join_request(BPT::$update->chat_join_request); |
127 | 119 | } |
128 | - } |
|
129 | - elseif (self::handlerExist('something_else')) { |
|
120 | + } elseif (self::handlerExist('something_else')) { |
|
130 | 121 | BPT::$handler->something_else(BPT::$update); |
131 | - } |
|
132 | - else { |
|
122 | + } else { |
|
133 | 123 | logger::write('Update received but handlers are not set',loggerTypes::WARNING); |
134 | 124 | } |
135 | 125 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | /** |
30 | 30 | * tools class , gather what ever you need |
31 | 31 | */ |
32 | -class tools{ |
|
32 | +class tools { |
|
33 | 33 | /** |
34 | 34 | * Check the given username format |
35 | 35 | * |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @return bool |
43 | 43 | */ |
44 | - public static function isUsername (string $username): bool { |
|
44 | + public static function isUsername(string $username): bool { |
|
45 | 45 | $length = strlen($username); |
46 | 46 | return !str_contains($username, '__') && $length >= 5 && $length <= 33 && preg_match('/^@?([a-zA-Z])(\w{4,31})$/', $username); |
47 | 47 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * |
59 | 59 | * @return bool |
60 | 60 | */ |
61 | - public static function ipInRange (string $ip, string $range): bool { |
|
61 | + public static function ipInRange(string $ip, string $range): bool { |
|
62 | 62 | if (!str_contains($range, '/')) { |
63 | 63 | $range .= '/32'; |
64 | 64 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @return bool |
80 | 80 | */ |
81 | - public static function isTelegram (string $ip): bool { |
|
81 | + public static function isTelegram(string $ip): bool { |
|
82 | 82 | return tools::ipInRange($ip, '149.154.160.0/20') || tools::ipInRange($ip, '91.108.4.0/22'); |
83 | 83 | } |
84 | 84 | |
@@ -93,10 +93,10 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @return bool |
95 | 95 | */ |
96 | - public static function isCloudFlare (string $ip): bool { |
|
96 | + public static function isCloudFlare(string $ip): bool { |
|
97 | 97 | $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']; |
98 | 98 | foreach ($cf_ips as $cf_ip) { |
99 | - if (self::ipInRange($ip,$cf_ip)) { |
|
99 | + if (self::ipInRange($ip, $cf_ip)) { |
|
100 | 100 | return true; |
101 | 101 | } |
102 | 102 | } |
@@ -114,10 +114,10 @@ discard block |
||
114 | 114 | * |
115 | 115 | * @return bool |
116 | 116 | */ |
117 | - public static function isArvanCloud (string $ip): bool { |
|
117 | + public static function isArvanCloud(string $ip): bool { |
|
118 | 118 | $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']; |
119 | 119 | foreach ($ar_ips as $ar_ip) { |
120 | - if (self::ipInRange($ip,$ar_ip)) { |
|
120 | + if (self::ipInRange($ip, $ar_ip)) { |
|
121 | 121 | return true; |
122 | 122 | } |
123 | 123 | } |
@@ -137,11 +137,11 @@ discard block |
||
137 | 137 | * |
138 | 138 | * @return bool|user return array when verify is active and token is true array of telegram getMe result |
139 | 139 | */ |
140 | - public static function isToken (string $token, bool $verify = false): bool|user { |
|
140 | + public static function isToken(string $token, bool $verify = false): bool | user { |
|
141 | 141 | if (!preg_match('/^(\d{8,10}):[\w\-]{35}$/', $token)) { |
142 | 142 | return false; |
143 | 143 | } |
144 | - if (!$verify){ |
|
144 | + if (!$verify) { |
|
145 | 145 | return true; |
146 | 146 | } |
147 | 147 | $res = telegram::me($token); |
@@ -171,14 +171,14 @@ discard block |
||
171 | 171 | * |
172 | 172 | * @return bool |
173 | 173 | */ |
174 | - public static function isJoined (array|string|int $ids , int|null $user_id = null): bool { |
|
174 | + public static function isJoined(array | string | int $ids, int | null $user_id = null): bool { |
|
175 | 175 | if (!is_array($ids)) { |
176 | 176 | $ids = [$ids]; |
177 | 177 | } |
178 | 178 | $user_id = $user_id ?? request::catchFields('user_id'); |
179 | 179 | |
180 | 180 | foreach ($ids as $id) { |
181 | - $check = telegram::getChatMember($id,$user_id); |
|
181 | + $check = telegram::getChatMember($id, $user_id); |
|
182 | 182 | if (telegram::$status) { |
183 | 183 | $check = $check->status; |
184 | 184 | if ($check === chatMemberStatus::LEFT || $check === chatMemberStatus::KICKED) { |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | * |
206 | 206 | * @return array keys will be id and values will be bool(null for not founded ids) |
207 | 207 | */ |
208 | - public static function joinChecker (array|string|int $ids , int|null $user_id = null): array { |
|
208 | + public static function joinChecker(array | string | int $ids, int | null $user_id = null): array { |
|
209 | 209 | if (!is_array($ids)) { |
210 | 210 | $ids = [$ids]; |
211 | 211 | } |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | |
214 | 214 | $result = []; |
215 | 215 | foreach ($ids as $id) { |
216 | - $check = telegram::getChatMember($id,$user_id); |
|
216 | + $check = telegram::getChatMember($id, $user_id); |
|
217 | 217 | if (telegram::$status) { |
218 | 218 | $check = $check->status; |
219 | 219 | $result[$id] = $check !== chatMemberStatus::LEFT && $check !== chatMemberStatus::KICKED; |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | * @return bool |
234 | 234 | */ |
235 | 235 | public static function isShorted(string $text): bool{ |
236 | - return preg_match('/^[a-zA-Z0-9]+$/',$text); |
|
236 | + return preg_match('/^[a-zA-Z0-9]+$/', $text); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | /** |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * |
251 | 251 | * @return string|int|false string for formatted data , int for normal data , false when size can not be found(file not found or ...) |
252 | 252 | */ |
253 | - public static function size (string $path, bool $format = true): string|int|false { |
|
253 | + public static function size(string $path, bool $format = true): string | int | false { |
|
254 | 254 | if (filter_var($path, FILTER_VALIDATE_URL)) { |
255 | 255 | $ch = curl_init($path); |
256 | 256 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | * @return bool |
284 | 284 | * @throws bptException |
285 | 285 | */ |
286 | - public static function delete (string $path, bool $sub = true): bool { |
|
286 | + public static function delete(string $path, bool $sub = true): bool { |
|
287 | 287 | $path = realpath($path); |
288 | 288 | if (!is_dir($path)) { |
289 | 289 | return unlink($path); |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | return rmdir($path); |
293 | 293 | } |
294 | 294 | if (!$sub) { |
295 | - logger::write("tools::delete function used\ndelete function cannot delete folder because its have subFiles and sub parameter haven't true value",loggerTypes::ERROR); |
|
295 | + logger::write("tools::delete function used\ndelete function cannot delete folder because its have subFiles and sub parameter haven't true value", loggerTypes::ERROR); |
|
296 | 296 | throw new bptException('DELETE_FOLDER_HAS_SUB'); |
297 | 297 | } |
298 | 298 | $it = new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS); |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | * @return bool |
315 | 315 | * @throws bptException when zip extension not found |
316 | 316 | */ |
317 | - public static function zip (string $path, string $destination): bool { |
|
317 | + public static function zip(string $path, string $destination): bool { |
|
318 | 318 | if (!extension_loaded('zip')) { |
319 | 319 | logger::write("tools::zip function used\nzip extension is not found , It may not be installed or enabled", loggerTypes::ERROR); |
320 | 320 | throw new bptException('ZIP_EXTENSION_MISSING'); |
@@ -349,14 +349,14 @@ discard block |
||
349 | 349 | * |
350 | 350 | * @return bool true on success and false in failure |
351 | 351 | */ |
352 | - public static function downloadFile (string $url, string $path,int $chunk_size = 512): bool { |
|
352 | + public static function downloadFile(string $url, string $path, int $chunk_size = 512): bool { |
|
353 | 353 | $file = fopen($url, 'rb'); |
354 | 354 | if (!$file) return false; |
355 | 355 | $path = fopen($path, 'wb'); |
356 | 356 | if (!$path) return false; |
357 | 357 | |
358 | 358 | $length = $chunk_size * 1024; |
359 | - while (!feof($file)){ |
|
359 | + while (!feof($file)) { |
|
360 | 360 | fwrite($path, fread($file, $length), $length); |
361 | 361 | } |
362 | 362 | fclose($path); |
@@ -379,10 +379,10 @@ discard block |
||
379 | 379 | * |
380 | 380 | * @return string |
381 | 381 | */ |
382 | - public static function byteFormat (int $byte, int $precision = 2, bool $space_between = true): string { |
|
382 | + public static function byteFormat(int $byte, int $precision = 2, bool $space_between = true): string { |
|
383 | 383 | $rate_counter = 0; |
384 | 384 | |
385 | - while ($byte > 1024){ |
|
385 | + while ($byte > 1024) { |
|
386 | 386 | $byte /= 1024; |
387 | 387 | $rate_counter++; |
388 | 388 | } |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | $byte = round($byte, $precision); |
392 | 392 | } |
393 | 393 | |
394 | - return $byte . ($space_between ? ' ' : '') . ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'][$rate_counter]; |
|
394 | + return $byte.($space_between ? ' ' : '').['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'][$rate_counter]; |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | /** |
@@ -408,10 +408,10 @@ discard block |
||
408 | 408 | * |
409 | 409 | * @return string|false return false when mode is incorrect |
410 | 410 | */ |
411 | - public static function modeEscape (string $text, string $mode = parseMode::HTML): string|false { |
|
411 | + public static function modeEscape(string $text, string $mode = parseMode::HTML): string | false { |
|
412 | 412 | return match ($mode) { |
413 | - parseMode::HTML => str_replace(['&', '<', '>',], ["&", "<", ">",], $text), |
|
414 | - parseMode::MARKDOWN => str_replace(['\\', '_', '*', '`', '['], ['\\\\', '\_', '\*', '\`', '\[',], $text), |
|
413 | + parseMode::HTML => str_replace(['&', '<', '>', ], ["&", "<", ">", ], $text), |
|
414 | + parseMode::MARKDOWN => str_replace(['\\', '_', '*', '`', '['], ['\\\\', '\_', '\*', '\`', '\[', ], $text), |
|
415 | 415 | parseMode::MARKDOWNV2 => str_replace( |
416 | 416 | ['_', '*', '[', ']', '(', ')', '~', '`', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!', '\\'], |
417 | 417 | ['\_', '\*', '\[', '\]', '\(', '\)', '\~', '\`', '\>', '\#', '\+', '\-', '\=', '\|', '\{', '\}', '\.', '\!', '\\\\'], |
@@ -450,9 +450,9 @@ discard block |
||
450 | 450 | * @return array{status: string,year: string,month: string,day: string,hour: string,minute: string,second: string} |
451 | 451 | * @throws Exception |
452 | 452 | */ |
453 | - public static function timeDiff (int|string $target_time, int|string|null $base_time = null): array { |
|
453 | + public static function timeDiff(int | string $target_time, int | string | null $base_time = null): array { |
|
454 | 454 | $base_time = new DateTime($base_time ?? '@'.time()); |
455 | - $target_time = new DateTime(is_numeric($target_time) ? '@' . $target_time : $target_time . ' +00:00'); |
|
455 | + $target_time = new DateTime(is_numeric($target_time) ? '@'.$target_time : $target_time.' +00:00'); |
|
456 | 456 | |
457 | 457 | $diff = $base_time->diff($target_time); |
458 | 458 | |
@@ -479,12 +479,12 @@ discard block |
||
479 | 479 | * |
480 | 480 | * @return string[]|string |
481 | 481 | */ |
482 | - public static function realEscapeString(string|array $input): string|array { |
|
483 | - if(is_array($input)) { |
|
482 | + public static function realEscapeString(string | array $input): string | array { |
|
483 | + if (is_array($input)) { |
|
484 | 484 | return array_map(__METHOD__, $input); |
485 | 485 | } |
486 | 486 | |
487 | - if(!empty($input) && is_string($input)) { |
|
487 | + if (!empty($input) && is_string($input)) { |
|
488 | 488 | return str_replace(['\\', "\0", "\n", "\r", "'", '"', "\x1a"], ['\\\\', '\\0', '\\n', '\\r', "\\'", '\\"', '\\Z'], $input); |
489 | 489 | } |
490 | 490 | |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | * |
503 | 503 | * @return string[]|string |
504 | 504 | */ |
505 | - public static function strReplaceFirst(string|array $search, string|array $replace, string|array $subject): string|array { |
|
505 | + public static function strReplaceFirst(string | array $search, string | array $replace, string | array $subject): string | array { |
|
506 | 506 | $pos = strpos($subject, $search); |
507 | 507 | if ($pos !== false) { |
508 | 508 | return substr_replace($subject, $replace, $pos, strlen($search)); |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | * |
520 | 520 | * @return string see possible values in fileType class |
521 | 521 | */ |
522 | - public static function fileType (string $file_id): string { |
|
522 | + public static function fileType(string $file_id): string { |
|
523 | 523 | $data = base64_decode(str_pad(strtr($file_id, '-_', '+/'), strlen($file_id) % 4, '=')); |
524 | 524 | $new = ''; |
525 | 525 | $last = ''; |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | $last = $char; |
534 | 534 | } |
535 | 535 | } |
536 | - $data = unpack('VtypeId/Vdc_id', $new . $last); |
|
536 | + $data = unpack('VtypeId/Vdc_id', $new.$last); |
|
537 | 537 | $data['typeId'] = $data['typeId'] & ~33554432 & ~16777216; |
538 | 538 | return [ |
539 | 539 | fileTypes::THUMBNAIL, |
@@ -571,10 +571,10 @@ discard block |
||
571 | 571 | * |
572 | 572 | * @return string |
573 | 573 | */ |
574 | - public static function randomString (int $length = 16, string $characters = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'): string { |
|
574 | + public static function randomString(int $length = 16, string $characters = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'): string { |
|
575 | 575 | $rand_string = ''; |
576 | 576 | $char_len = strlen($characters) - 1; |
577 | - for ($i = 0; $i < $length; $i ++) { |
|
577 | + for ($i = 0; $i < $length; $i++) { |
|
578 | 578 | $rand_string .= $characters[rand(0, $char_len)]; |
579 | 579 | } |
580 | 580 | return $rand_string; |
@@ -603,7 +603,7 @@ discard block |
||
603 | 603 | * @return inlineKeyboardMarkup|replyKeyboardMarkup replyKeyboardMarkup for keyboard and inlineKeyboardMarkup for inline |
604 | 604 | * @throws bptException |
605 | 605 | */ |
606 | - public static function easyKey(array $keyboard = [], array $inline = []): inlineKeyboardMarkup|replyKeyboardMarkup { |
|
606 | + public static function easyKey(array $keyboard = [], array $inline = []): inlineKeyboardMarkup | replyKeyboardMarkup { |
|
607 | 607 | if (!empty($keyboard)) { |
608 | 608 | $keyboard_object = new replyKeyboardMarkup(); |
609 | 609 | $keyboard_object->setResize_keyboard($keyboard['resize'] ?? true); |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | return $keyboard_object; |
668 | 668 | } |
669 | 669 | else { |
670 | - logger::write("tools::eKey function used\nkeyboard or inline parameter must be set",loggerTypes::ERROR); |
|
670 | + logger::write("tools::eKey function used\nkeyboard or inline parameter must be set", loggerTypes::ERROR); |
|
671 | 671 | throw new bptException('ARGUMENT_NOT_FOUND_KEYBOARD_INLINE'); |
672 | 672 | } |
673 | 673 | } |
@@ -684,10 +684,10 @@ discard block |
||
684 | 684 | * |
685 | 685 | * @return string |
686 | 686 | */ |
687 | - public static function inviteLink (int $user_id = null, string $bot_username = null): string { |
|
687 | + public static function inviteLink(int $user_id = null, string $bot_username = null): string { |
|
688 | 688 | if (empty($user_id)) $user_id = telegram::catchFields(fields::USER_ID); |
689 | 689 | if (empty($bot_username)) $bot_username = telegram::getMe()->username; |
690 | - return 'https://t.me/' . str_replace('@', '', $bot_username) . '?start=ref_' . tools::shortEncode($user_id); |
|
690 | + return 'https://t.me/'.str_replace('@', '', $bot_username).'?start=ref_'.tools::shortEncode($user_id); |
|
691 | 691 | } |
692 | 692 | |
693 | 693 | /** |
@@ -711,9 +711,9 @@ discard block |
||
711 | 711 | * @return string|bool|array{hash:string, key:string, iv:string} |
712 | 712 | * @throws bptException |
713 | 713 | */ |
714 | - public static function codec (string $action, string $text, string $key = null, string $iv = null): bool|array|string { |
|
714 | + public static function codec(string $action, string $text, string $key = null, string $iv = null): bool | array | string { |
|
715 | 715 | if (!extension_loaded('openssl')) { |
716 | - logger::write("tools::codec function used\nopenssl extension is not found , It may not be installed or enabled",loggerTypes::ERROR); |
|
716 | + logger::write("tools::codec function used\nopenssl extension is not found , It may not be installed or enabled", loggerTypes::ERROR); |
|
717 | 717 | throw new bptException('OPENSSL_EXTENSION_MISSING'); |
718 | 718 | } |
719 | 719 | if ($action === codecAction::ENCRYPT) { |
@@ -724,17 +724,17 @@ discard block |
||
724 | 724 | } |
725 | 725 | elseif ($action === codecAction::DECRYPT) { |
726 | 726 | if (empty($key)) { |
727 | - logger::write("tools::codec function used\nkey parameter is not set",loggerTypes::ERROR); |
|
727 | + logger::write("tools::codec function used\nkey parameter is not set", loggerTypes::ERROR); |
|
728 | 728 | throw new bptException('ARGUMENT_NOT_FOUND_KEY'); |
729 | 729 | } |
730 | 730 | if (empty($iv)) { |
731 | - logger::write("tools::codec function used\niv parameter is not set",loggerTypes::ERROR); |
|
731 | + logger::write("tools::codec function used\niv parameter is not set", loggerTypes::ERROR); |
|
732 | 732 | throw new bptException('ARGUMENT_NOT_FOUND_IV'); |
733 | 733 | } |
734 | 734 | return openssl_decrypt(base64_decode($text), 'AES-256-CBC', $key, 1, $iv); |
735 | 735 | } |
736 | 736 | else { |
737 | - logger::write("tools::codec function used\naction is not right, its must be `encode` or `decode`",loggerTypes::WARNING); |
|
737 | + logger::write("tools::codec function used\naction is not right, its must be `encode` or `decode`", loggerTypes::WARNING); |
|
738 | 738 | return false; |
739 | 739 | } |
740 | 740 | } |
@@ -742,8 +742,8 @@ discard block |
||
742 | 742 | /** |
743 | 743 | * @deprecated use tools::codec() instead , will remove in 1.6.0 |
744 | 744 | */ |
745 | - public static function crypto (string $action, string $text, string $key = null, string $iv = null): bool|array|string { |
|
746 | - return self::codec($action,$text,$key,$iv); |
|
745 | + public static function crypto(string $action, string $text, string $key = null, string $iv = null): bool | array | string { |
|
746 | + return self::codec($action, $text, $key, $iv); |
|
747 | 747 | } |
748 | 748 | |
749 | 749 | /** |
@@ -758,7 +758,7 @@ discard block |
||
758 | 758 | public static function shortEncode(int $num): string { |
759 | 759 | $codes = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; |
760 | 760 | $array = []; |
761 | - while ($num > 0){ |
|
761 | + while ($num > 0) { |
|
762 | 762 | $array[] = $num % 62; |
763 | 763 | $num = floor($num / 62); |
764 | 764 | } |
@@ -766,7 +766,7 @@ discard block |
||
766 | 766 | foreach ($array as &$value) { |
767 | 767 | $value = $codes[$value]; |
768 | 768 | } |
769 | - return strrev(implode('',$array)); |
|
769 | + return strrev(implode('', $array)); |
|
770 | 770 | } |
771 | 771 | |
772 | 772 | /** |
@@ -783,7 +783,7 @@ discard block |
||
783 | 783 | $num = 0; |
784 | 784 | $text = str_split(strrev($text)); |
785 | 785 | foreach ($text as $key=>$value) { |
786 | - $num += strpos($codes,$value) * pow(62,$key); |
|
786 | + $num += strpos($codes, $value) * pow(62, $key); |
|
787 | 787 | } |
788 | 788 | return $num; |
789 | 789 | } |
@@ -217,8 +217,9 @@ discard block |
||
217 | 217 | if (telegram::$status) { |
218 | 218 | $check = $check->status; |
219 | 219 | $result[$id] = $check !== chatMemberStatus::LEFT && $check !== chatMemberStatus::KICKED; |
220 | + } else { |
|
221 | + $result[$id] = null; |
|
220 | 222 | } |
221 | - else $result[$id] = null; |
|
222 | 223 | } |
223 | 224 | return $result; |
224 | 225 | } |
@@ -259,8 +260,7 @@ discard block |
||
259 | 260 | curl_exec($ch); |
260 | 261 | $size = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD); |
261 | 262 | curl_close($ch); |
262 | - } |
|
263 | - else { |
|
263 | + } else { |
|
264 | 264 | $path = realpath($path); |
265 | 265 | $size = file_exists($path) ? filesize($path) : false; |
266 | 266 | } |
@@ -331,8 +331,7 @@ discard block |
||
331 | 331 | $zip->addFile($filePath, substr($filePath, $root_len)); |
332 | 332 | } |
333 | 333 | } |
334 | - } |
|
335 | - else { |
|
334 | + } else { |
|
336 | 335 | $zip->addFile($path, basename($path)); |
337 | 336 | } |
338 | 337 | return $zip->close(); |
@@ -351,9 +350,13 @@ discard block |
||
351 | 350 | */ |
352 | 351 | public static function downloadFile (string $url, string $path,int $chunk_size = 512): bool { |
353 | 352 | $file = fopen($url, 'rb'); |
354 | - if (!$file) return false; |
|
353 | + if (!$file) { |
|
354 | + return false; |
|
355 | + } |
|
355 | 356 | $path = fopen($path, 'wb'); |
356 | - if (!$path) return false; |
|
357 | + if (!$path) { |
|
358 | + return false; |
|
359 | + } |
|
357 | 360 | |
358 | 361 | $length = $chunk_size * 1024; |
359 | 362 | while (!feof($file)){ |
@@ -460,8 +463,9 @@ discard block |
||
460 | 463 | foreach ($string as $k => &$v) { |
461 | 464 | if ($diff->$v) { |
462 | 465 | $v = $diff->$v; |
466 | + } else { |
|
467 | + unset($string[$k]); |
|
463 | 468 | } |
464 | - else unset($string[$k]); |
|
465 | 469 | } |
466 | 470 | $string['status'] = $base_time < $target_time ? 'later' : 'ago'; |
467 | 471 | |
@@ -527,8 +531,7 @@ discard block |
||
527 | 531 | if ($last === "\0") { |
528 | 532 | $new .= str_repeat($last, ord($char)); |
529 | 533 | $last = ''; |
530 | - } |
|
531 | - else { |
|
534 | + } else { |
|
532 | 535 | $new .= $last; |
533 | 536 | $last = $char; |
534 | 537 | } |
@@ -612,7 +615,9 @@ discard block |
||
612 | 615 | } |
613 | 616 | $rows = []; |
614 | 617 | foreach ($keyboard as $row) { |
615 | - if (!is_array($row)) continue; |
|
618 | + if (!is_array($row)) { |
|
619 | + continue; |
|
620 | + } |
|
616 | 621 | $buttons = []; |
617 | 622 | foreach ($row as $base_button) { |
618 | 623 | $button_info = explode('||', $base_button); |
@@ -621,15 +626,12 @@ discard block |
||
621 | 626 | if (count($button_info) > 1) { |
622 | 627 | if ($button_info[1] === 'con') { |
623 | 628 | $button->setRequest_contact(true); |
624 | - } |
|
625 | - elseif ($button_info[1] === 'loc') { |
|
629 | + } elseif ($button_info[1] === 'loc') { |
|
626 | 630 | $button->setRequest_location(true); |
627 | - } |
|
628 | - elseif ($button_info[1] === 'poll') { |
|
631 | + } elseif ($button_info[1] === 'poll') { |
|
629 | 632 | $type = $button_info[2] === pollType::QUIZ ? pollType::QUIZ : pollType::REGULAR; |
630 | 633 | $button->setRequest_poll((new keyboardButtonPollType())->setType($type)); |
631 | - } |
|
632 | - elseif ($button_info[1] === 'web' && isset($button_info[2])) { |
|
634 | + } elseif ($button_info[1] === 'web' && isset($button_info[2])) { |
|
633 | 635 | $url = $button_info[2]; |
634 | 636 | $button->setWeb_app((new webAppInfo())->setUrl($url)); |
635 | 637 | } |
@@ -640,8 +642,7 @@ discard block |
||
640 | 642 | } |
641 | 643 | $keyboard_object->setKeyboard($rows); |
642 | 644 | return $keyboard_object; |
643 | - } |
|
644 | - elseif (!empty($inline)) { |
|
645 | + } elseif (!empty($inline)) { |
|
645 | 646 | $keyboard_object = new inlineKeyboardMarkup(); |
646 | 647 | $rows = []; |
647 | 648 | foreach ($inline as $row) { |
@@ -651,12 +652,10 @@ discard block |
||
651 | 652 | if (isset($button_info[1])) { |
652 | 653 | if (filter_var($button_info[1], FILTER_VALIDATE_URL) && str_starts_with($button_info[1], 'http')) { |
653 | 654 | $button->setText($button_info[0])->setUrl($button_info[1]); |
654 | - } |
|
655 | - else { |
|
655 | + } else { |
|
656 | 656 | $button->setText($button_info[0])->setCallback_data($button_info[1]); |
657 | 657 | } |
658 | - } |
|
659 | - else { |
|
658 | + } else { |
|
660 | 659 | $button->setText($button_info[0])->setUrl('https://t.me/BPT_CH'); |
661 | 660 | } |
662 | 661 | $buttons[] = $button; |
@@ -665,8 +664,7 @@ discard block |
||
665 | 664 | } |
666 | 665 | $keyboard_object->setInline_keyboard($rows); |
667 | 666 | return $keyboard_object; |
668 | - } |
|
669 | - else { |
|
667 | + } else { |
|
670 | 668 | logger::write("tools::eKey function used\nkeyboard or inline parameter must be set",loggerTypes::ERROR); |
671 | 669 | throw new bptException('ARGUMENT_NOT_FOUND_KEYBOARD_INLINE'); |
672 | 670 | } |
@@ -685,8 +683,12 @@ discard block |
||
685 | 683 | * @return string |
686 | 684 | */ |
687 | 685 | public static function inviteLink (int $user_id = null, string $bot_username = null): string { |
688 | - if (empty($user_id)) $user_id = telegram::catchFields(fields::USER_ID); |
|
689 | - if (empty($bot_username)) $bot_username = telegram::getMe()->username; |
|
686 | + if (empty($user_id)) { |
|
687 | + $user_id = telegram::catchFields(fields::USER_ID); |
|
688 | + } |
|
689 | + if (empty($bot_username)) { |
|
690 | + $bot_username = telegram::getMe()->username; |
|
691 | + } |
|
690 | 692 | return 'https://t.me/' . str_replace('@', '', $bot_username) . '?start=ref_' . tools::shortEncode($user_id); |
691 | 693 | } |
692 | 694 | |
@@ -721,8 +723,7 @@ discard block |
||
721 | 723 | $iv = self::randomString(); |
722 | 724 | $output = base64_encode(openssl_encrypt($text, 'AES-256-CBC', $key, 1, $iv)); |
723 | 725 | return ['hash' => $output, 'key' => $key, 'iv' => $iv]; |
724 | - } |
|
725 | - elseif ($action === codecAction::DECRYPT) { |
|
726 | + } elseif ($action === codecAction::DECRYPT) { |
|
726 | 727 | if (empty($key)) { |
727 | 728 | logger::write("tools::codec function used\nkey parameter is not set",loggerTypes::ERROR); |
728 | 729 | throw new bptException('ARGUMENT_NOT_FOUND_KEY'); |
@@ -732,8 +733,7 @@ discard block |
||
732 | 733 | throw new bptException('ARGUMENT_NOT_FOUND_IV'); |
733 | 734 | } |
734 | 735 | return openssl_decrypt(base64_decode($text), 'AES-256-CBC', $key, 1, $iv); |
735 | - } |
|
736 | - else { |
|
736 | + } else { |
|
737 | 737 | logger::write("tools::codec function used\naction is not right, its must be `encode` or `decode`",loggerTypes::WARNING); |
738 | 738 | return false; |
739 | 739 | } |
@@ -762,7 +762,9 @@ discard block |
||
762 | 762 | $array[] = $num % 62; |
763 | 763 | $num = floor($num / 62); |
764 | 764 | } |
765 | - if (count($array) < 1) $array = [0]; |
|
765 | + if (count($array) < 1) { |
|
766 | + $array = [0]; |
|
767 | + } |
|
766 | 768 | foreach ($array as &$value) { |
767 | 769 | $value = $codes[$value]; |
768 | 770 | } |
@@ -797,8 +799,7 @@ discard block |
||
797 | 799 | $ip = $_SERVER['REMOTE_ADDR']; |
798 | 800 | if (settings::$cloudflare_verify && isset($_SERVER['HTTP_CF_CONNECTING_IP']) && tools::isCloudFlare($ip)) { |
799 | 801 | $ip = $_SERVER['HTTP_CF_CONNECTING_IP']; |
800 | - } |
|
801 | - elseif (settings::$arvancloud_verify && isset($_SERVER['HTTP_AR_REAL_IP']) && tools::isArvanCloud($ip)) { |
|
802 | + } elseif (settings::$arvancloud_verify && isset($_SERVER['HTTP_AR_REAL_IP']) && tools::isArvanCloud($ip)) { |
|
802 | 803 | $ip = $_SERVER['HTTP_AR_REAL_IP']; |
803 | 804 | } |
804 | 805 | return $ip; |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | |
22 | 22 | private static CurlHandle $session; |
23 | 23 | |
24 | - public static function init (): void { |
|
24 | + public static function init(): void { |
|
25 | 25 | self::$api_key = settings::$pay['crypto']['api_key'] ?? ''; |
26 | 26 | self::$ipn_secret = settings::$pay['crypto']['ipn_secret'] ?? ''; |
27 | 27 | self::$session = curl_init(); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | curl_setopt(self::$session, CURLOPT_SSL_VERIFYHOST, 2); |
31 | 31 | } |
32 | 32 | |
33 | - private static function execute (string $method, string $endpoint, string|array $data = '') { |
|
33 | + private static function execute(string $method, string $endpoint, string | array $data = '') { |
|
34 | 34 | if (is_array($data)) { |
35 | 35 | foreach ($data as $key => $value) { |
36 | 36 | if (empty($value)) { |
@@ -41,17 +41,17 @@ discard block |
||
41 | 41 | |
42 | 42 | $session = self::$session; |
43 | 43 | curl_setopt($session, CURLOPT_HTTPHEADER, [ |
44 | - 'X-API-KEY: ' . self::$api_key, |
|
44 | + 'X-API-KEY: '.self::$api_key, |
|
45 | 45 | 'Content-Type: application/json' |
46 | 46 | ]); |
47 | 47 | switch ($method) { |
48 | 48 | case 'GET': |
49 | - curl_setopt($session, CURLOPT_URL, self::API_BASE . $endpoint . !empty($data) && is_array($data) ? ('?' . http_build_query($data)) : ''); |
|
49 | + curl_setopt($session, CURLOPT_URL, self::API_BASE.$endpoint.!empty($data) && is_array($data) ? ('?'.http_build_query($data)) : ''); |
|
50 | 50 | break; |
51 | 51 | case 'POST': |
52 | 52 | curl_setopt($session, CURLOPT_POST, true); |
53 | 53 | curl_setopt($session, CURLOPT_POSTFIELDS, json_encode($data)); |
54 | - curl_setopt($session, CURLOPT_URL, self::API_BASE . $endpoint); |
|
54 | + curl_setopt($session, CURLOPT_URL, self::API_BASE.$endpoint); |
|
55 | 55 | break; |
56 | 56 | default: |
57 | 57 | return false; |
@@ -59,14 +59,14 @@ discard block |
||
59 | 59 | return json_decode(curl_exec($session)); |
60 | 60 | } |
61 | 61 | |
62 | - public static function status (): bool { |
|
62 | + public static function status(): bool { |
|
63 | 63 | return self::execute('GET', 'status')->message === 'OK'; |
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
67 | 67 | * @return estimatePriceInterface|mixed |
68 | 68 | */ |
69 | - public static function getEstimatePrice (int|float $amount, string $currency_from, string $currency_to) { |
|
69 | + public static function getEstimatePrice(int | float $amount, string $currency_from, string $currency_to) { |
|
70 | 70 | return self::execute('GET', 'estimate', [ |
71 | 71 | 'amount' => $amount, |
72 | 72 | 'currency_from' => $currency_from, |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | /** |
78 | 78 | * @return invoicePaymentInterface|mixed |
79 | 79 | */ |
80 | - public static function createPayment (int|float $price_amount, string $price_currency, string $pay_currency, int|float $pay_amount = null, string $ipn_callback_url = null, string $order_id = null, string $order_description = null, string $purchase_id = null, string $payout_address = null, string $payout_currency = null, string $payout_extra_id = null, bool $fixed_rate = null) { |
|
80 | + public static function createPayment(int | float $price_amount, string $price_currency, string $pay_currency, int | float $pay_amount = null, string $ipn_callback_url = null, string $order_id = null, string $order_description = null, string $purchase_id = null, string $payout_address = null, string $payout_currency = null, string $payout_extra_id = null, bool $fixed_rate = null) { |
|
81 | 81 | return self::execute('POST', 'payment', [ |
82 | 82 | 'price_amount' => $price_amount, |
83 | 83 | 'price_currency' => $price_currency, |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | /** |
98 | 98 | * @return invoicePaymentInterface|mixed |
99 | 99 | */ |
100 | - public static function createInvoicePayment (string $iid, string $pay_currency, string $purchase_id = null, string $order_description = null, string $customer_email = null, string $payout_address = null, string $payout_extra_id = null, string $payout_currency = null) { |
|
100 | + public static function createInvoicePayment(string $iid, string $pay_currency, string $purchase_id = null, string $order_description = null, string $customer_email = null, string $payout_address = null, string $payout_extra_id = null, string $payout_currency = null) { |
|
101 | 101 | return self::execute('POST', 'invoice', [ |
102 | 102 | 'iid' => $iid, |
103 | 103 | 'pay_currency' => $pay_currency, |
@@ -113,18 +113,18 @@ discard block |
||
113 | 113 | /** |
114 | 114 | * @return estimateUpdateInterface|mixed |
115 | 115 | */ |
116 | - public static function updateEstimatePrice (int $paymentID) { |
|
117 | - return self::execute('POST', 'payment/' . $paymentID . '/update-merchant-estimate'); |
|
116 | + public static function updateEstimatePrice(int $paymentID) { |
|
117 | + return self::execute('POST', 'payment/'.$paymentID.'/update-merchant-estimate'); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
121 | 121 | * @return paymentInterface|mixed |
122 | 122 | */ |
123 | - public static function getPaymentStatus (int $paymentID) { |
|
124 | - return self::execute('GET', 'payment/' . $paymentID); |
|
123 | + public static function getPaymentStatus(int $paymentID) { |
|
124 | + return self::execute('GET', 'payment/'.$paymentID); |
|
125 | 125 | } |
126 | 126 | |
127 | - public static function getMinimumPaymentAmount (string $currency_from, string $currency_to): float { |
|
127 | + public static function getMinimumPaymentAmount(string $currency_from, string $currency_to): float { |
|
128 | 128 | return self::execute('GET', 'min-amount', [ |
129 | 129 | 'currency_from' => $currency_from, |
130 | 130 | 'currency_to' => $currency_to |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | /** |
135 | 135 | * @return invoiceResponseInterface|mixed |
136 | 136 | */ |
137 | - public static function createInvoice (int|float $price_amount, string $price_currency, string $pay_currency, int|float $pay_amount = null, string $ipn_callback_url = null, string $order_id = null, string $order_description = null, string $success_url = null, string $cancel_url = null) { |
|
137 | + public static function createInvoice(int | float $price_amount, string $price_currency, string $pay_currency, int | float $pay_amount = null, string $ipn_callback_url = null, string $order_id = null, string $order_description = null, string $success_url = null, string $cancel_url = null) { |
|
138 | 138 | return self::execute('POST', 'invoice', [ |
139 | 139 | 'price_amount' => $price_amount, |
140 | 140 | 'price_currency' => $price_currency, |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | ]); |
149 | 149 | } |
150 | 150 | |
151 | - public static function getCurrencies (): array { |
|
151 | + public static function getCurrencies(): array { |
|
152 | 152 | return self::execute('GET', 'currencies')->currencies; |
153 | 153 | } |
154 | 154 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | return tools::remoteIP() === '144.76.201.30'; |
157 | 157 | } |
158 | 158 | |
159 | - public static function isIPNRequestValid (): bool { |
|
159 | + public static function isIPNRequestValid(): bool { |
|
160 | 160 | if (empty($_SERVER['HTTP_X_NOWPAYMENTS_SIG'])) { |
161 | 161 | return false; |
162 | 162 | } |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | /** |
177 | 177 | * @return ipnDataInterface|mixed |
178 | 178 | */ |
179 | - public static function getIPN () { |
|
179 | + public static function getIPN() { |
|
180 | 180 | if (!self::isIPNRequestValid()) { |
181 | 181 | return false; |
182 | 182 | } |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * telegram class , Adding normal method call to request class and a simple name for being easy to call |
16 | 16 | */ |
17 | 17 | class telegram extends request { |
18 | - public function __call (string $name, array $arguments) { |
|
18 | + public function __call(string $name, array $arguments) { |
|
19 | 19 | return request::$name(...$arguments); |
20 | 20 | } |
21 | 21 | |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @return bool |
35 | 35 | */ |
36 | - public static function downloadFile (string|null $destination = null, string|null $file_id = null): bool { |
|
36 | + public static function downloadFile(string | null $destination = null, string | null $file_id = null): bool { |
|
37 | 37 | return tools::downloadFile(self::fileLink($file_id), $destination); |
38 | 38 | } |
39 | 39 | |
40 | - public static function fileLink(string|null $file_id = null): bool|string { |
|
40 | + public static function fileLink(string | null $file_id = null): bool | string { |
|
41 | 41 | $file = self::getFile($file_id); |
42 | 42 | if (!isset($file->file_path)) { |
43 | 43 | return false; |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @return message|bool|responseError |
61 | 61 | */ |
62 | - public static function sendFile (string $file_id, int|string $chat_id = null, int $message_thread_id = null, string $caption = null, string $parse_mode = null, array $caption_entities = null, bool $disable_notification = null, bool $protect_content = null, int $reply_to_message_id = null, bool $allow_sending_without_reply = null, inlineKeyboardMarkup|replyKeyboardMarkup|replyKeyboardRemove|forceReply|stdClass|array $reply_markup = null, string $token = null, bool $forgot = null, bool $answer = null): message|bool|responseError { |
|
62 | + public static function sendFile(string $file_id, int | string $chat_id = null, int $message_thread_id = null, string $caption = null, string $parse_mode = null, array $caption_entities = null, bool $disable_notification = null, bool $protect_content = null, int $reply_to_message_id = null, bool $allow_sending_without_reply = null, inlineKeyboardMarkup | replyKeyboardMarkup | replyKeyboardRemove | forceReply | stdClass | array $reply_markup = null, string $token = null, bool $forgot = null, bool $answer = null): message | bool | responseError { |
|
63 | 63 | $type = tools::fileType($file_id); |
64 | 64 | return match ($type) { |
65 | 65 | fileTypes::VIDEO => self::sendVideo($file_id, $chat_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, $message_thread_id), |
@@ -502,95 +502,95 @@ discard block |
||
502 | 502 | ]; |
503 | 503 | |
504 | 504 | private const METHODS_KEYS = [ |
505 | - 'getUpdates' => ['offset','limit','timeout','allowed_updates','token','forgot','answer'], |
|
506 | - 'setWebhook' => ['url','certificate','ip_address','max_connections','allowed_updates','drop_pending_updates','secret_token','token','forgot','answer'], |
|
507 | - 'deleteWebhook' => ['drop_pending_updates','token','forgot','answer'], |
|
508 | - 'getWebhookInfo' => ['token','forgot','answer'], |
|
509 | - 'getMe' => ['token','forgot','answer'], |
|
510 | - 'logOut' => ['token','forgot','answer'], |
|
511 | - 'close' => ['token','forgot','answer'], |
|
512 | - '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','forgot','answer','message_thread_id'], |
|
513 | - 'forwardMessage' => ['chat_id','from_chat_id','disable_notification','protect_content','message_id','token','forgot','answer','message_thread_id'], |
|
514 | - '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','forgot','answer','message_thread_id'], |
|
515 | - 'sendPhoto' => ['photo','chat_id','caption','parse_mode','caption_entities','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','has_spoiler','message_thread_id'], |
|
516 | - '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','forgot','answer','message_thread_id'], |
|
517 | - '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','forgot','answer','message_thread_id'], |
|
518 | - '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','forgot','answer','has_spoiler','message_thread_id'], |
|
519 | - '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','forgot','answer','has_spoiler','message_thread_id'], |
|
520 | - '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','forgot','answer','message_thread_id'], |
|
521 | - 'sendVideoNote' => ['video_note','chat_id','duration','length','thumb','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
522 | - 'sendMediaGroup' => ['media','chat_id','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','token','forgot','answer','message_thread_id'], |
|
523 | - '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','forgot','answer','message_thread_id'], |
|
524 | - 'editMessageLiveLocation' => ['latitude','longitude','chat_id','message_id','inline_message_id','horizontal_accuracy','heading','proximity_alert_radius','reply_markup','token','forgot','answer'], |
|
525 | - 'stopMessageLiveLocation' => ['chat_id','message_id','inline_message_id','reply_markup','token','forgot','answer'], |
|
526 | - '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','forgot','answer','message_thread_id'], |
|
527 | - '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','forgot','answer','message_thread_id'], |
|
528 | - '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','forgot','answer','message_thread_id'], |
|
529 | - 'sendDice' => ['chat_id','emoji','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
530 | - 'sendChatAction' => ['chat_id','action','token','forgot','answer','message_thread_id'], |
|
531 | - 'getUserProfilePhotos' => ['user_id','offset','limit','token','forgot','answer'], |
|
532 | - 'getFile' => ['file_id','token','forgot','answer'], |
|
533 | - 'banChatMember' => ['chat_id','user_id','until_date','revoke_messages','token','forgot','answer'], |
|
534 | - 'unbanChatMember' => ['chat_id','user_id','only_if_banned','token','forgot','answer'], |
|
535 | - 'restrictChatMember' => ['permissions','chat_id','user_id','until_date','token','forgot','answer'], |
|
536 | - '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','can_manage_topics','token','forgot','answer'], |
|
537 | - 'setChatAdministratorCustomTitle' => ['custom_title','chat_id','user_id','token','forgot','answer'], |
|
538 | - 'banChatSenderChat' => ['sender_chat_id','chat_id','token','forgot','answer'], |
|
539 | - 'unbanChatSenderChat' => ['sender_chat_id','chat_id','token','forgot','answer'], |
|
540 | - 'setChatPermissions' => ['permissions','chat_id','token','forgot','answer'], |
|
541 | - 'exportChatInviteLink' => ['chat_id','token','forgot','answer'], |
|
542 | - 'createChatInviteLink' => ['chat_id','name','expire_date','member_limit','creates_join_request','token','forgot','answer'], |
|
543 | - 'editChatInviteLink' => ['invite_link','chat_id','name','expire_date','member_limit','creates_join_request','token','forgot','answer'], |
|
544 | - 'revokeChatInviteLink' => ['invite_link','chat_id','token','forgot','answer'], |
|
545 | - 'approveChatJoinRequest' => ['chat_id','user_id','token','forgot','answer'], |
|
546 | - 'declineChatJoinRequest' => ['chat_id','user_id','token','forgot','answer'], |
|
547 | - 'setChatPhoto' => ['photo','chat_id','token','forgot','answer'], |
|
548 | - 'deleteChatPhoto' => ['chat_id','token','forgot','answer'], |
|
549 | - 'setChatTitle' => ['title','chat_id','token','forgot','answer'], |
|
550 | - 'setChatDescription' => ['chat_id','description','token','forgot','answer'], |
|
551 | - 'pinChatMessage' => ['message_id','chat_id','disable_notification','token','forgot','answer'], |
|
552 | - 'unpinChatMessage' => ['chat_id','message_id','token','forgot','answer'], |
|
553 | - 'unpinAllChatMessages' => ['chat_id','token','forgot','answer'], |
|
554 | - 'leaveChat' => ['chat_id','token','forgot','answer'], |
|
555 | - 'getChat' => ['chat_id','token','forgot','answer'], |
|
556 | - 'getChatAdministrators' => ['chat_id','token','forgot','answer'], |
|
557 | - 'getChatMemberCount' => ['chat_id','token','forgot','answer'], |
|
558 | - 'getChatMember' => ['chat_id','user_id','token','forgot','answer'], |
|
559 | - 'setChatStickerSet' => ['sticker_set_name','chat_id','token','forgot','answer'], |
|
560 | - 'deleteChatStickerSet' => ['chat_id','token','forgot','answer'], |
|
561 | - 'answerCallbackQuery' => ['callback_query_id','text','show_alert','url','cache_time','token','forgot','answer'], |
|
562 | - 'setMyCommands' => ['commands','scope','language_code','token','forgot','answer'], |
|
563 | - 'deleteMyCommands' => ['scope','language_code','token','forgot','answer'], |
|
564 | - 'getMyCommands' => ['scope','language_code','token','forgot','answer'], |
|
565 | - 'setChatMenuButton' => ['chat_id','menu_button','token','forgot','answer'], |
|
566 | - 'getChatMenuButton' => ['chat_id','token','forgot','answer'], |
|
567 | - 'setMyDefaultAdministratorRights' => ['rights','for_channels','token','forgot','answer'], |
|
568 | - 'getMyDefaultAdministratorRights' => ['for_channels','token','forgot','answer'], |
|
569 | - 'editMessageText' => ['text','chat_id','message_id','inline_message_id','parse_mode','entities','disable_web_page_preview','reply_markup','token','forgot','answer'], |
|
570 | - 'editMessageCaption' => ['chat_id','message_id','inline_message_id','caption','parse_mode','caption_entities','reply_markup','token','forgot','answer'], |
|
571 | - 'editMessageMedia' => ['media','chat_id','message_id','inline_message_id','reply_markup','token','forgot','answer'], |
|
572 | - 'editMessageReplyMarkup' => ['chat_id','message_id','inline_message_id','reply_markup','token','forgot','answer'], |
|
573 | - 'stopPoll' => ['chat_id','message_id','reply_markup','token','forgot','answer'], |
|
574 | - 'deleteMessage' => ['chat_id','message_id','token','forgot','answer'], |
|
575 | - 'sendSticker' => ['sticker','chat_id','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
576 | - 'getStickerSet' => ['name','token','forgot','answer'], |
|
505 | + 'getUpdates' => ['offset', 'limit', 'timeout', 'allowed_updates', 'token', 'forgot', 'answer'], |
|
506 | + 'setWebhook' => ['url', 'certificate', 'ip_address', 'max_connections', 'allowed_updates', 'drop_pending_updates', 'secret_token', 'token', 'forgot', 'answer'], |
|
507 | + 'deleteWebhook' => ['drop_pending_updates', 'token', 'forgot', 'answer'], |
|
508 | + 'getWebhookInfo' => ['token', 'forgot', 'answer'], |
|
509 | + 'getMe' => ['token', 'forgot', 'answer'], |
|
510 | + 'logOut' => ['token', 'forgot', 'answer'], |
|
511 | + 'close' => ['token', 'forgot', 'answer'], |
|
512 | + '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', 'forgot', 'answer', 'message_thread_id'], |
|
513 | + 'forwardMessage' => ['chat_id', 'from_chat_id', 'disable_notification', 'protect_content', 'message_id', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
514 | + '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', 'forgot', 'answer', 'message_thread_id'], |
|
515 | + 'sendPhoto' => ['photo', 'chat_id', 'caption', 'parse_mode', 'caption_entities', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'has_spoiler', 'message_thread_id'], |
|
516 | + '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', 'forgot', 'answer', 'message_thread_id'], |
|
517 | + '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', 'forgot', 'answer', 'message_thread_id'], |
|
518 | + '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', 'forgot', 'answer', 'has_spoiler', 'message_thread_id'], |
|
519 | + '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', 'forgot', 'answer', 'has_spoiler', 'message_thread_id'], |
|
520 | + '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', 'forgot', 'answer', 'message_thread_id'], |
|
521 | + 'sendVideoNote' => ['video_note', 'chat_id', 'duration', 'length', 'thumb', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
522 | + 'sendMediaGroup' => ['media', 'chat_id', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
523 | + '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', 'forgot', 'answer', 'message_thread_id'], |
|
524 | + 'editMessageLiveLocation' => ['latitude', 'longitude', 'chat_id', 'message_id', 'inline_message_id', 'horizontal_accuracy', 'heading', 'proximity_alert_radius', 'reply_markup', 'token', 'forgot', 'answer'], |
|
525 | + 'stopMessageLiveLocation' => ['chat_id', 'message_id', 'inline_message_id', 'reply_markup', 'token', 'forgot', 'answer'], |
|
526 | + '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', 'forgot', 'answer', 'message_thread_id'], |
|
527 | + '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', 'forgot', 'answer', 'message_thread_id'], |
|
528 | + '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', 'forgot', 'answer', 'message_thread_id'], |
|
529 | + 'sendDice' => ['chat_id', 'emoji', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
530 | + 'sendChatAction' => ['chat_id', 'action', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
531 | + 'getUserProfilePhotos' => ['user_id', 'offset', 'limit', 'token', 'forgot', 'answer'], |
|
532 | + 'getFile' => ['file_id', 'token', 'forgot', 'answer'], |
|
533 | + 'banChatMember' => ['chat_id', 'user_id', 'until_date', 'revoke_messages', 'token', 'forgot', 'answer'], |
|
534 | + 'unbanChatMember' => ['chat_id', 'user_id', 'only_if_banned', 'token', 'forgot', 'answer'], |
|
535 | + 'restrictChatMember' => ['permissions', 'chat_id', 'user_id', 'until_date', 'token', 'forgot', 'answer'], |
|
536 | + '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', 'can_manage_topics', 'token', 'forgot', 'answer'], |
|
537 | + 'setChatAdministratorCustomTitle' => ['custom_title', 'chat_id', 'user_id', 'token', 'forgot', 'answer'], |
|
538 | + 'banChatSenderChat' => ['sender_chat_id', 'chat_id', 'token', 'forgot', 'answer'], |
|
539 | + 'unbanChatSenderChat' => ['sender_chat_id', 'chat_id', 'token', 'forgot', 'answer'], |
|
540 | + 'setChatPermissions' => ['permissions', 'chat_id', 'token', 'forgot', 'answer'], |
|
541 | + 'exportChatInviteLink' => ['chat_id', 'token', 'forgot', 'answer'], |
|
542 | + 'createChatInviteLink' => ['chat_id', 'name', 'expire_date', 'member_limit', 'creates_join_request', 'token', 'forgot', 'answer'], |
|
543 | + 'editChatInviteLink' => ['invite_link', 'chat_id', 'name', 'expire_date', 'member_limit', 'creates_join_request', 'token', 'forgot', 'answer'], |
|
544 | + 'revokeChatInviteLink' => ['invite_link', 'chat_id', 'token', 'forgot', 'answer'], |
|
545 | + 'approveChatJoinRequest' => ['chat_id', 'user_id', 'token', 'forgot', 'answer'], |
|
546 | + 'declineChatJoinRequest' => ['chat_id', 'user_id', 'token', 'forgot', 'answer'], |
|
547 | + 'setChatPhoto' => ['photo', 'chat_id', 'token', 'forgot', 'answer'], |
|
548 | + 'deleteChatPhoto' => ['chat_id', 'token', 'forgot', 'answer'], |
|
549 | + 'setChatTitle' => ['title', 'chat_id', 'token', 'forgot', 'answer'], |
|
550 | + 'setChatDescription' => ['chat_id', 'description', 'token', 'forgot', 'answer'], |
|
551 | + 'pinChatMessage' => ['message_id', 'chat_id', 'disable_notification', 'token', 'forgot', 'answer'], |
|
552 | + 'unpinChatMessage' => ['chat_id', 'message_id', 'token', 'forgot', 'answer'], |
|
553 | + 'unpinAllChatMessages' => ['chat_id', 'token', 'forgot', 'answer'], |
|
554 | + 'leaveChat' => ['chat_id', 'token', 'forgot', 'answer'], |
|
555 | + 'getChat' => ['chat_id', 'token', 'forgot', 'answer'], |
|
556 | + 'getChatAdministrators' => ['chat_id', 'token', 'forgot', 'answer'], |
|
557 | + 'getChatMemberCount' => ['chat_id', 'token', 'forgot', 'answer'], |
|
558 | + 'getChatMember' => ['chat_id', 'user_id', 'token', 'forgot', 'answer'], |
|
559 | + 'setChatStickerSet' => ['sticker_set_name', 'chat_id', 'token', 'forgot', 'answer'], |
|
560 | + 'deleteChatStickerSet' => ['chat_id', 'token', 'forgot', 'answer'], |
|
561 | + 'answerCallbackQuery' => ['callback_query_id', 'text', 'show_alert', 'url', 'cache_time', 'token', 'forgot', 'answer'], |
|
562 | + 'setMyCommands' => ['commands', 'scope', 'language_code', 'token', 'forgot', 'answer'], |
|
563 | + 'deleteMyCommands' => ['scope', 'language_code', 'token', 'forgot', 'answer'], |
|
564 | + 'getMyCommands' => ['scope', 'language_code', 'token', 'forgot', 'answer'], |
|
565 | + 'setChatMenuButton' => ['chat_id', 'menu_button', 'token', 'forgot', 'answer'], |
|
566 | + 'getChatMenuButton' => ['chat_id', 'token', 'forgot', 'answer'], |
|
567 | + 'setMyDefaultAdministratorRights' => ['rights', 'for_channels', 'token', 'forgot', 'answer'], |
|
568 | + 'getMyDefaultAdministratorRights' => ['for_channels', 'token', 'forgot', 'answer'], |
|
569 | + 'editMessageText' => ['text', 'chat_id', 'message_id', 'inline_message_id', 'parse_mode', 'entities', 'disable_web_page_preview', 'reply_markup', 'token', 'forgot', 'answer'], |
|
570 | + 'editMessageCaption' => ['chat_id', 'message_id', 'inline_message_id', 'caption', 'parse_mode', 'caption_entities', 'reply_markup', 'token', 'forgot', 'answer'], |
|
571 | + 'editMessageMedia' => ['media', 'chat_id', 'message_id', 'inline_message_id', 'reply_markup', 'token', 'forgot', 'answer'], |
|
572 | + 'editMessageReplyMarkup' => ['chat_id', 'message_id', 'inline_message_id', 'reply_markup', 'token', 'forgot', 'answer'], |
|
573 | + 'stopPoll' => ['chat_id', 'message_id', 'reply_markup', 'token', 'forgot', 'answer'], |
|
574 | + 'deleteMessage' => ['chat_id', 'message_id', 'token', 'forgot', 'answer'], |
|
575 | + 'sendSticker' => ['sticker', 'chat_id', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
576 | + 'getStickerSet' => ['name', 'token', 'forgot', 'answer'], |
|
577 | 577 | 'getCustomEmojiStickers' => ['custom_emoji_ids', 'token', 'return_array', 'forgot', 'answer'], |
578 | - 'uploadStickerFile' => ['png_sticker','user_id','token','forgot','answer'], |
|
579 | - 'createNewStickerSet' => ['name','title','emojis','user_id','png_sticker','tgs_sticker','webm_sticker','sticker_type','contains_masks','mask_position','token','forgot','answer'], |
|
580 | - 'addStickerToSet' => ['name','emojis','user_id','png_sticker','tgs_sticker','webm_sticker','mask_position','token','forgot','answer'], |
|
581 | - 'setStickerPositionInSet' => ['sticker','position','token','forgot','answer'], |
|
582 | - 'deleteStickerFromSet' => ['sticker','token','forgot','answer'], |
|
583 | - 'setStickerSetThumb' => ['name','user_id','thumb','token','forgot','answer'], |
|
584 | - 'answerInlineQuery' => ['results','inline_query_id','cache_time','is_personal','next_offset','switch_pm_text','switch_pm_parameter','token','forgot','answer'], |
|
585 | - 'answerWebAppQuery' => ['web_app_query_id','result','token','forgot','answer'], |
|
586 | - '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','forgot','answer','message_thread_id'], |
|
587 | - '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','forgot','answer'], |
|
588 | - 'answerShippingQuery' => ['ok','shipping_query_id','shipping_options','error_message','token','forgot','answer'], |
|
589 | - 'answerPreCheckoutQuery' => ['ok','pre_checkout_query_id','error_message','token','forgot','answer'], |
|
590 | - 'setPassportDataErrors' => ['errors','user_id','token','forgot','answer'], |
|
591 | - 'sendGame' => ['game_short_name','chat_id','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer', 'message_thread_id'], |
|
592 | - 'setGameScore' => ['score','user_id','force','disable_edit_message','chat_id','message_id','inline_message_id','token','forgot','answer'], |
|
593 | - 'getGameHighScores' => ['user_id','chat_id','message_id','inline_message_id','token','forgot','answer'], |
|
578 | + 'uploadStickerFile' => ['png_sticker', 'user_id', 'token', 'forgot', 'answer'], |
|
579 | + 'createNewStickerSet' => ['name', 'title', 'emojis', 'user_id', 'png_sticker', 'tgs_sticker', 'webm_sticker', 'sticker_type', 'contains_masks', 'mask_position', 'token', 'forgot', 'answer'], |
|
580 | + 'addStickerToSet' => ['name', 'emojis', 'user_id', 'png_sticker', 'tgs_sticker', 'webm_sticker', 'mask_position', 'token', 'forgot', 'answer'], |
|
581 | + 'setStickerPositionInSet' => ['sticker', 'position', 'token', 'forgot', 'answer'], |
|
582 | + 'deleteStickerFromSet' => ['sticker', 'token', 'forgot', 'answer'], |
|
583 | + 'setStickerSetThumb' => ['name', 'user_id', 'thumb', 'token', 'forgot', 'answer'], |
|
584 | + 'answerInlineQuery' => ['results', 'inline_query_id', 'cache_time', 'is_personal', 'next_offset', 'switch_pm_text', 'switch_pm_parameter', 'token', 'forgot', 'answer'], |
|
585 | + 'answerWebAppQuery' => ['web_app_query_id', 'result', 'token', 'forgot', 'answer'], |
|
586 | + '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', 'forgot', 'answer', 'message_thread_id'], |
|
587 | + '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', 'forgot', 'answer'], |
|
588 | + 'answerShippingQuery' => ['ok', 'shipping_query_id', 'shipping_options', 'error_message', 'token', 'forgot', 'answer'], |
|
589 | + 'answerPreCheckoutQuery' => ['ok', 'pre_checkout_query_id', 'error_message', 'token', 'forgot', 'answer'], |
|
590 | + 'setPassportDataErrors' => ['errors', 'user_id', 'token', 'forgot', 'answer'], |
|
591 | + 'sendGame' => ['game_short_name', 'chat_id', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
592 | + 'setGameScore' => ['score', 'user_id', 'force', 'disable_edit_message', 'chat_id', 'message_id', 'inline_message_id', 'token', 'forgot', 'answer'], |
|
593 | + 'getGameHighScores' => ['user_id', 'chat_id', 'message_id', 'inline_message_id', 'token', 'forgot', 'answer'], |
|
594 | 594 | 'getForumTopicIconStickers' => ['token', 'return_array', 'forgot', 'answer'], |
595 | 595 | 'createForumTopic' => ['chat_id', 'name', 'icon_color', 'icon_custom_emoji_id', 'token', 'return_array', 'forgot', 'answer'], |
596 | 596 | 'editForumTopic' => ['chat_id', 'name', 'icon_custom_emoji_id', 'token', 'return_array', 'forgot', 'answer', 'message_thread_id'], |
@@ -631,8 +631,8 @@ discard block |
||
631 | 631 | 'logOut' => [], |
632 | 632 | 'close' => [], |
633 | 633 | 'sendMessage' => ['chat_id'], |
634 | - 'forwardMessage' => ['from_chat_id','message_id'], |
|
635 | - 'copyMessage' => ['from_chat_id','message_id'], |
|
634 | + 'forwardMessage' => ['from_chat_id', 'message_id'], |
|
635 | + 'copyMessage' => ['from_chat_id', 'message_id'], |
|
636 | 636 | 'sendPhoto' => ['chat_id'], |
637 | 637 | 'sendAudio' => ['chat_id'], |
638 | 638 | 'sendDocument' => ['chat_id'], |
@@ -648,15 +648,15 @@ discard block |
||
648 | 648 | 'sendContact' => ['chat_id'], |
649 | 649 | 'sendPoll' => ['chat_id'], |
650 | 650 | 'sendDice' => ['chat_id'], |
651 | - 'sendChatAction' => ['chat_id','action'], |
|
651 | + 'sendChatAction' => ['chat_id', 'action'], |
|
652 | 652 | 'getUserProfilePhotos' => ['user_id'], |
653 | 653 | 'getFile' => ['file_id'], |
654 | - 'banChatMember' => ['chat_id','user_id'], |
|
655 | - 'kickChatMember' => ['chat_id','user_id'], |
|
656 | - 'unbanChatMember' => ['chat_id','user_id'], |
|
657 | - 'restrictChatMember' => ['chat_id','user_id'], |
|
658 | - 'promoteChatMember' => ['chat_id','user_id'], |
|
659 | - 'setChatAdministratorCustomTitle' => ['chat_id','user_id'], |
|
654 | + 'banChatMember' => ['chat_id', 'user_id'], |
|
655 | + 'kickChatMember' => ['chat_id', 'user_id'], |
|
656 | + 'unbanChatMember' => ['chat_id', 'user_id'], |
|
657 | + 'restrictChatMember' => ['chat_id', 'user_id'], |
|
658 | + 'promoteChatMember' => ['chat_id', 'user_id'], |
|
659 | + 'setChatAdministratorCustomTitle' => ['chat_id', 'user_id'], |
|
660 | 660 | 'banChatSenderChat' => ['chat_id'], |
661 | 661 | 'unbanChatSenderChat' => ['chat_id'], |
662 | 662 | 'setChatPermissions' => ['chat_id'], |
@@ -664,8 +664,8 @@ discard block |
||
664 | 664 | 'createChatInviteLink' => ['chat_id'], |
665 | 665 | 'editChatInviteLink' => ['chat_id'], |
666 | 666 | 'revokeChatInviteLink' => ['chat_id'], |
667 | - 'approveChatJoinRequest' => ['chat_id','user_id'], |
|
668 | - 'declineChatJoinRequest' => ['chat_id','user_id'], |
|
667 | + 'approveChatJoinRequest' => ['chat_id', 'user_id'], |
|
668 | + 'declineChatJoinRequest' => ['chat_id', 'user_id'], |
|
669 | 669 | 'setChatPhoto' => ['chat_id'], |
670 | 670 | 'deleteChatPhoto' => ['chat_id'], |
671 | 671 | 'setChatTitle' => ['chat_id'], |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | 'getChat' => ['chat_id'], |
678 | 678 | 'getChatAdministrators' => ['chat_id'], |
679 | 679 | 'getChatMembersCount' => ['chat_id'], |
680 | - 'getChatMember' => ['chat_id','user_id'], |
|
680 | + 'getChatMember' => ['chat_id', 'user_id'], |
|
681 | 681 | 'setChatStickerSet' => ['chat_id'], |
682 | 682 | 'deleteChatStickerSet' => ['chat_id'], |
683 | 683 | 'answerCallbackQuery' => ['callback_query_id'], |
@@ -688,12 +688,12 @@ discard block |
||
688 | 688 | 'getChatMenuButton' => [], |
689 | 689 | 'setMyDefaultAdministratorRights' => [], |
690 | 690 | 'getMyDefaultAdministratorRights' => [], |
691 | - 'editMessageText' => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
692 | - 'editMessageCaption' => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
693 | - 'editMessageMedia' => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
694 | - 'editMessageReplyMarkup' => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
695 | - 'stopPoll' => ['chat_id','message_id'], |
|
696 | - 'deleteMessage' => ['chat_id','message_id'], |
|
691 | + 'editMessageText' => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
692 | + 'editMessageCaption' => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
693 | + 'editMessageMedia' => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
694 | + 'editMessageReplyMarkup' => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
695 | + 'stopPoll' => ['chat_id', 'message_id'], |
|
696 | + 'deleteMessage' => ['chat_id', 'message_id'], |
|
697 | 697 | 'sendSticker' => ['chat_id'], |
698 | 698 | 'getStickerSet' => [], |
699 | 699 | 'uploadStickerFile' => ['user_id'], |
@@ -709,8 +709,8 @@ discard block |
||
709 | 709 | 'answerPreCheckoutQuery' => ['pre_checkout_query_id'], |
710 | 710 | 'setPassportDataErrors' => ['user_id'], |
711 | 711 | 'sendGame' => ['chat_id'], |
712 | - 'setGameScore' => ['user_id','inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
713 | - 'getGameHighScores' => ['user_id','inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']] |
|
712 | + 'setGameScore' => ['user_id', 'inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
713 | + 'getGameHighScores' => ['user_id', 'inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']] |
|
714 | 714 | ]; |
715 | 715 | |
716 | 716 | private const METHODS_RETURN = [ |
@@ -764,24 +764,24 @@ discard block |
||
764 | 764 | 'getGameHighScores' => ['BPT\types\gameHighScore'] |
765 | 765 | ]; |
766 | 766 | |
767 | - public static function __callStatic (string $name, array $arguments) { |
|
767 | + public static function __callStatic(string $name, array $arguments) { |
|
768 | 768 | if (!$action = self::methodAction($name)) { |
769 | - logger::write("$name method is not supported",loggerTypes::ERROR); |
|
769 | + logger::write("$name method is not supported", loggerTypes::ERROR); |
|
770 | 770 | throw new bptException('METHOD_NOT_FOUND'); |
771 | 771 | } |
772 | 772 | self::checkArguments($arguments); |
773 | - self::keysName($action,$arguments); |
|
774 | - self::readyFile($action,$arguments); |
|
775 | - self::setDefaults($action,$arguments); |
|
773 | + self::keysName($action, $arguments); |
|
774 | + self::readyFile($action, $arguments); |
|
775 | + self::setDefaults($action, $arguments); |
|
776 | 776 | if (isset($arguments['answer'])) { |
777 | - return answer::init($action,$arguments); |
|
777 | + return answer::init($action, $arguments); |
|
778 | 778 | } |
779 | 779 | else { |
780 | - $result = curl::init($action,$arguments); |
|
780 | + $result = curl::init($action, $arguments); |
|
781 | 781 | if (!is_object($result)) { |
782 | 782 | return false; |
783 | 783 | } |
784 | - return self::processResponse($action,$result); |
|
784 | + return self::processResponse($action, $result); |
|
785 | 785 | } |
786 | 786 | } |
787 | 787 | |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | } |
792 | 792 | } |
793 | 793 | |
794 | - private static function keysName (string $name, array &$arguments): void { |
|
794 | + private static function keysName(string $name, array &$arguments): void { |
|
795 | 795 | foreach ($arguments as $key => $argument) { |
796 | 796 | if (is_numeric($key) && isset(self::METHODS_KEYS[$name][$key])) { |
797 | 797 | $arguments[self::METHODS_KEYS[$name][$key]] = $argument; |
@@ -800,7 +800,7 @@ discard block |
||
800 | 800 | } |
801 | 801 | } |
802 | 802 | |
803 | - private static function methodAction(string $name): string|false { |
|
803 | + private static function methodAction(string $name): string | false { |
|
804 | 804 | return self::METHODS_ACTION[str_replace('_', '', strtolower($name))] ?? false; |
805 | 805 | } |
806 | 806 | |
@@ -821,11 +821,11 @@ discard block |
||
821 | 821 | } |
822 | 822 | } |
823 | 823 | |
824 | - private static function methodFile(string $name): array|false { |
|
824 | + private static function methodFile(string $name): array | false { |
|
825 | 825 | return self::METHODS_WITH_FILE[$name] ?? false; |
826 | 826 | } |
827 | 827 | |
828 | - private static function methodReturn(string $name,stdClass $response) { |
|
828 | + private static function methodReturn(string $name, stdClass $response) { |
|
829 | 829 | if (isset(self::METHODS_RETURN[$name])) { |
830 | 830 | $return = self::METHODS_RETURN[$name]; |
831 | 831 | if (is_array($return)) { |
@@ -848,13 +848,13 @@ discard block |
||
848 | 848 | $defaults = self::METHODS_EXTRA_DEFAULTS[$name]; |
849 | 849 | foreach ($defaults as $key => $default) { |
850 | 850 | if (is_numeric($key)) { |
851 | - if (!isset($arguments[$default])){ |
|
851 | + if (!isset($arguments[$default])) { |
|
852 | 852 | $arguments[$default] = self::catchFields($default); |
853 | 853 | } |
854 | 854 | } |
855 | 855 | elseif (isset(BPT::$update->$key) || $key === 'other') { |
856 | 856 | foreach ($default as $def) { |
857 | - if (!isset($arguments[$def])){ |
|
857 | + if (!isset($arguments[$def])) { |
|
858 | 858 | $arguments[$def] = self::catchFields($def); |
859 | 859 | } |
860 | 860 | } |
@@ -867,7 +867,7 @@ discard block |
||
867 | 867 | self::$status = $response->ok; |
868 | 868 | self::$pure_response = $response; |
869 | 869 | if ($response->ok) { |
870 | - return self::methodReturn($name,$response); |
|
870 | + return self::methodReturn($name, $response); |
|
871 | 871 | } |
872 | 872 | else { |
873 | 873 | return new responseError($response); |
@@ -881,7 +881,7 @@ discard block |
||
881 | 881 | * |
882 | 882 | * @return int|string|bool |
883 | 883 | */ |
884 | - public static function catchFields (string $field): int|string|bool { |
|
884 | + public static function catchFields(string $field): int | string | bool { |
|
885 | 885 | switch ($field) { |
886 | 886 | case fields::CHAT_ID : |
887 | 887 | case fields::FROM_CHAT_ID : |
@@ -1017,7 +1017,7 @@ discard block |
||
1017 | 1017 | default => false |
1018 | 1018 | }; |
1019 | 1019 | case fields::URL : |
1020 | - return 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; |
|
1020 | + return 'https://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; |
|
1021 | 1021 | default: |
1022 | 1022 | return false; |
1023 | 1023 | } |
@@ -775,8 +775,7 @@ discard block |
||
775 | 775 | self::setDefaults($action,$arguments); |
776 | 776 | if (isset($arguments['answer'])) { |
777 | 777 | return answer::init($action,$arguments); |
778 | - } |
|
779 | - else { |
|
778 | + } else { |
|
780 | 779 | $result = curl::init($action,$arguments); |
781 | 780 | if (!is_object($result)) { |
782 | 781 | return false; |
@@ -811,8 +810,7 @@ discard block |
||
811 | 810 | $arguments['media'][$key]['media'] = new CURLFile($media['media']); |
812 | 811 | } |
813 | 812 | } |
814 | - } |
|
815 | - elseif ($file_params = self::methodFile($name)) { |
|
813 | + } elseif ($file_params = self::methodFile($name)) { |
|
816 | 814 | foreach ($file_params as $param) { |
817 | 815 | if (isset($arguments[$param]) && is_string($arguments[$param]) && file_exists(realpath($arguments[$param]))) { |
818 | 816 | $arguments[$param] = new CURLFile($arguments[$param]); |
@@ -834,12 +832,10 @@ discard block |
||
834 | 832 | $value = new ($return[0]) ($value); |
835 | 833 | } |
836 | 834 | return $response; |
837 | - } |
|
838 | - else { |
|
835 | + } else { |
|
839 | 836 | return new ($return) ($response->result); |
840 | 837 | } |
841 | - } |
|
842 | - else { |
|
838 | + } else { |
|
843 | 839 | return $response->result; |
844 | 840 | } |
845 | 841 | } |
@@ -851,8 +847,7 @@ discard block |
||
851 | 847 | if (!isset($arguments[$default])){ |
852 | 848 | $arguments[$default] = self::catchFields($default); |
853 | 849 | } |
854 | - } |
|
855 | - elseif (isset(BPT::$update->$key) || $key === 'other') { |
|
850 | + } elseif (isset(BPT::$update->$key) || $key === 'other') { |
|
856 | 851 | foreach ($default as $def) { |
857 | 852 | if (!isset($arguments[$def])){ |
858 | 853 | $arguments[$def] = self::catchFields($def); |
@@ -868,8 +863,7 @@ discard block |
||
868 | 863 | self::$pure_response = $response; |
869 | 864 | if ($response->ok) { |
870 | 865 | return self::methodReturn($name,$response); |
871 | - } |
|
872 | - else { |
|
866 | + } else { |
|
873 | 867 | return new responseError($response); |
874 | 868 | } |
875 | 869 | } |
@@ -910,9 +904,13 @@ discard block |
||
910 | 904 | default => false |
911 | 905 | }; |
912 | 906 | case fields::FILE_ID : |
913 | - if (isset(BPT::$update->message)) $type = 'message'; |
|
914 | - elseif (isset(BPT::$update->edited_message)) $type = 'edited_message'; |
|
915 | - else return false; |
|
907 | + if (isset(BPT::$update->message)) { |
|
908 | + $type = 'message'; |
|
909 | + } elseif (isset(BPT::$update->edited_message)) { |
|
910 | + $type = 'edited_message'; |
|
911 | + } else { |
|
912 | + return false; |
|
913 | + } |
|
916 | 914 | |
917 | 915 | return match(true) { |
918 | 916 | isset(BPT::$update->$type->animation) => BPT::$update->$type->animation->file_id, |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | /** |
28 | 28 | * @internal Only for BPT self usage , Don't use it in your source! |
29 | 29 | */ |
30 | - public static function init (): void { |
|
30 | + public static function init(): void { |
|
31 | 31 | $host = settings::$db['host'] ?? 'localhost'; |
32 | 32 | $port = settings::$db['port'] ?? 3306; |
33 | 33 | $user = settings::$db['user'] ?? settings::$db['username'] ?? 'root'; |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $dbname = settings::$db['dbname']; |
37 | 37 | self::$connection = new mysqli($host, $user, $pass, $dbname, $port); |
38 | 38 | if (self::$connection->connect_errno) { |
39 | - logger::write('SQL connection has problem : ' . self::$connection->connect_error, loggerTypes::ERROR); |
|
39 | + logger::write('SQL connection has problem : '.self::$connection->connect_error, loggerTypes::ERROR); |
|
40 | 40 | throw new bptException('SQL_CONNECTION_PROBLEM'); |
41 | 41 | } |
42 | 42 | if (self::$auto_process && !lock::exist('BPT-MYSQL')) { |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | } |
45 | 45 | } |
46 | 46 | |
47 | - private static function install (): void { |
|
47 | + private static function install(): void { |
|
48 | 48 | self::pureQuery(" |
49 | 49 | CREATE TABLE `users` |
50 | 50 | ( |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | /** |
66 | 66 | * @internal Only for BPT self usage , Don't use it in your source! |
67 | 67 | */ |
68 | - public static function process (): void { |
|
68 | + public static function process(): void { |
|
69 | 69 | if (self::$auto_process) { |
70 | 70 | if (isset(BPT::$update->message)) { |
71 | 71 | self::processMessage(BPT::$update->message); |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
88 | - private static function processMessage (message $update): void { |
|
88 | + private static function processMessage(message $update): void { |
|
89 | 89 | $type = $update->chat->type; |
90 | 90 | if ($type === chatType::PRIVATE) { |
91 | 91 | $user_id = $update->from->id; |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | } |
112 | 112 | } |
113 | 113 | |
114 | - private static function processCallbackQuery (callbackQuery $update): void { |
|
114 | + private static function processCallbackQuery(callbackQuery $update): void { |
|
115 | 115 | $type = $update->message->chat->type; |
116 | 116 | if ($type === chatType::PRIVATE) { |
117 | 117 | $user_id = $update->from->id; |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | } |
122 | 122 | } |
123 | 123 | |
124 | - private static function processInlineQuery (inlineQuery $update): void { |
|
124 | + private static function processInlineQuery(inlineQuery $update): void { |
|
125 | 125 | $type = $update->chat_type; |
126 | 126 | if ($type === chatType::PRIVATE || $type === chatType::SENDER) { |
127 | 127 | $user_id = $update->from->id; |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
134 | - private static function processMyChatMember (chatMemberUpdated $update): void { |
|
134 | + private static function processMyChatMember(chatMemberUpdated $update): void { |
|
135 | 135 | $type = $update->chat->type; |
136 | 136 | if ($type === chatType::PRIVATE) { |
137 | 137 | if ($update->new_chat_member->status === chatMemberStatus::MEMBER) { |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @return mysqli |
150 | 150 | */ |
151 | - public static function getMysqli (): mysqli { |
|
151 | + public static function getMysqli(): mysqli { |
|
152 | 152 | return self::$connection; |
153 | 153 | } |
154 | 154 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * |
158 | 158 | * @return int|string |
159 | 159 | */ |
160 | - public static function affected_rows (): int|string { |
|
160 | + public static function affected_rows(): int | string { |
|
161 | 161 | return self::$connection->affected_rows; |
162 | 162 | } |
163 | 163 | |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * |
167 | 167 | * @return int|string |
168 | 168 | */ |
169 | - public static function insert_id (): int|string { |
|
169 | + public static function insert_id(): int | string { |
|
170 | 170 | return self::$connection->insert_id; |
171 | 171 | } |
172 | 172 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * |
178 | 178 | * @return string |
179 | 179 | */ |
180 | - public static function escapeString (string $text): string { |
|
180 | + public static function escapeString(string $text): string { |
|
181 | 181 | return self::$connection->real_escape_string($text); |
182 | 182 | } |
183 | 183 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * |
193 | 193 | * @return mysqli_result|bool |
194 | 194 | */ |
195 | - public static function pureQuery (string $query): mysqli_result|bool { |
|
195 | + public static function pureQuery(string $query): mysqli_result | bool { |
|
196 | 196 | return self::$connection->query($query); |
197 | 197 | } |
198 | 198 | |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | * |
212 | 212 | * @return mysqli_result|bool |
213 | 213 | */ |
214 | - public static function query (string $query, array $vars = [], bool $need_result = true): mysqli_result|bool { |
|
214 | + public static function query(string $query, array $vars = [], bool $need_result = true): mysqli_result | bool { |
|
215 | 215 | $prepare = self::$connection->prepare($query); |
216 | 216 | $types = ''; |
217 | 217 | foreach ($vars as $var) { |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | } |
227 | 227 | } |
228 | 228 | if (!empty($types)) { |
229 | - $prepare->bind_param($types,...$vars); |
|
229 | + $prepare->bind_param($types, ...$vars); |
|
230 | 230 | } |
231 | 231 | if (!$prepare->execute()) { |
232 | 232 | logger::write(loggerTypes::WARNING, $prepare->error); |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | return $need_result ? $prepare->get_result() : true; |
236 | 236 | } |
237 | 237 | |
238 | - private static function makeArrayReady (string &$query, array $array, string $operator = ' AND '): array { |
|
238 | + private static function makeArrayReady(string &$query, array $array, string $operator = ' AND '): array { |
|
239 | 239 | $first = true; |
240 | 240 | $values = []; |
241 | 241 | foreach ($array as $name => $value) { |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | return $values; |
252 | 252 | } |
253 | 253 | |
254 | - private static function makeQueryReady (string &$query, array $where = null, int $count = null, int $offset = null): array { |
|
254 | + private static function makeQueryReady(string &$query, array $where = null, int $count = null, int $offset = null): array { |
|
255 | 255 | $values = []; |
256 | 256 | if (!empty($where)) { |
257 | 257 | $query .= " WHERE"; |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * |
279 | 279 | * @return mysqli_result|bool |
280 | 280 | */ |
281 | - public static function delete (string $table, array $where = null, int $count = null, int $offset = null): mysqli_result|bool { |
|
281 | + public static function delete(string $table, array $where = null, int $count = null, int $offset = null): mysqli_result | bool { |
|
282 | 282 | $query = "DELETE FROM `$table`"; |
283 | 283 | $res = self::makeQueryReady($query, $where, $count, $offset); |
284 | 284 | return self::query($query, $res, false); |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | * |
298 | 298 | * @return mysqli_result|bool |
299 | 299 | */ |
300 | - public static function update (string $table, array $modify, array $where = null, int $count = null, int $offset = null): mysqli_result|bool { |
|
300 | + public static function update(string $table, array $modify, array $where = null, int $count = null, int $offset = null): mysqli_result | bool { |
|
301 | 301 | $query = "UPDATE `$table` SET"; |
302 | 302 | $values = self::makeArrayReady($query, $modify, ', '); |
303 | 303 | $res = self::makeQueryReady($query, $where, $count, $offset); |
@@ -315,11 +315,11 @@ discard block |
||
315 | 315 | * |
316 | 316 | * @return mysqli_result|bool |
317 | 317 | */ |
318 | - public static function insert (string $table, string|array $columns, array|string $values): mysqli_result|bool { |
|
318 | + public static function insert(string $table, string | array $columns, array | string $values): mysqli_result | bool { |
|
319 | 319 | $query = "INSERT INTO `$table`("; |
320 | - $query .= '`' . (is_string($columns) ? $columns : implode('`,`', $columns)) . '`) VALUES ('; |
|
320 | + $query .= '`'.(is_string($columns) ? $columns : implode('`,`', $columns)).'`) VALUES ('; |
|
321 | 321 | if (is_string($values)) $values = [$values]; |
322 | - $query .= '?' . str_repeat(',?', count($values) - 1) . ')'; |
|
322 | + $query .= '?'.str_repeat(',?', count($values) - 1).')'; |
|
323 | 323 | return self::query($query, $values, false); |
324 | 324 | } |
325 | 325 | |
@@ -338,13 +338,13 @@ discard block |
||
338 | 338 | * |
339 | 339 | * @return mysqli_result|bool |
340 | 340 | */ |
341 | - public static function select (string $table, array|string $columns = '*', array $where = null, int $count = null, int $offset = null): mysqli_result|bool { |
|
341 | + public static function select(string $table, array | string $columns = '*', array $where = null, int $count = null, int $offset = null): mysqli_result | bool { |
|
342 | 342 | $query = "SELECT "; |
343 | 343 | if ($columns == '*') { |
344 | 344 | $query .= "* "; |
345 | 345 | } |
346 | 346 | else { |
347 | - $query .= '`' . (is_string($columns) ? $columns : implode('`,`', $columns)) . '` '; |
|
347 | + $query .= '`'.(is_string($columns) ? $columns : implode('`,`', $columns)).'` '; |
|
348 | 348 | } |
349 | 349 | $query .= "FROM `$table`"; |
350 | 350 | $res = self::makeQueryReady($query, $where, $count, $offset); |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | * |
363 | 363 | * @return null|bool|array |
364 | 364 | */ |
365 | - public static function selectArray (string $table, array|string $columns = '*', array $where = null): bool|array|null { |
|
365 | + public static function selectArray(string $table, array | string $columns = '*', array $where = null): bool | array | null { |
|
366 | 366 | $res = self::select($table, $columns, $where, 1); |
367 | 367 | if ($res) { |
368 | 368 | return $res->fetch_assoc(); |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | * @param array|string $columns sets column that you want to retrieve , set '*' to retrieve all , default : '*' |
380 | 380 | * @param array|null $where Set your ifs default : null |
381 | 381 | */ |
382 | - public static function selectObject (string $table, array|string $columns = '*', array $where = null) { |
|
382 | + public static function selectObject(string $table, array | string $columns = '*', array $where = null) { |
|
383 | 383 | $res = self::select($table, $columns, $where, 1); |
384 | 384 | if ($res) { |
385 | 385 | return $res->fetch_object(); |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | * |
402 | 402 | * @return bool|Generator |
403 | 403 | */ |
404 | - public static function selectEach (string $table, array|string $columns = '*', array $where = null, int $count = null, int $offset = null): bool|Generator { |
|
404 | + public static function selectEach(string $table, array | string $columns = '*', array $where = null, int $count = null, int $offset = null): bool | Generator { |
|
405 | 405 | $res = self::select($table, $columns, $where, $count, $offset); |
406 | 406 | if ($res) { |
407 | 407 | while ($row = $res->fetch_assoc()) yield $row; |