@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | /** |
| 18 | 18 | * @internal Only for BPT self usage , Don't use it in your source! |
| 19 | 19 | */ |
| 20 | - public static function init (int $log_size = 10): void { |
|
| 20 | + public static function init(int $log_size = 10): void { |
|
| 21 | 21 | self::$log_size = $log_size; |
| 22 | 22 | $log_file = realpath(settings::$name.'BPT.log'); |
| 23 | 23 | if (file_exists($log_file) && !(filesize($log_file) > self::$log_size * 1024 * 1024)) { |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | self::$handler = fopen($log_file, $mode); |
| 32 | 32 | |
| 33 | 33 | if ($write) { |
| 34 | - fwrite(self::$handler,"♥♥♥♥♥♥♥♥♥♥♥♥♥♥ BPT Library ♥♥♥♥♥♥♥♥♥♥♥♥♥♥\nTnx for using our library\nSome information about us :\nAuthor : @Im_Miaad\nHelper : @A_LiReza_ME\nChannel : @BPT_CH\nOur Website : https://bptlib.ir\n\nIf you have any problem with our library\nContact to our supports\n♥♥♥♥♥♥♥♥♥♥♥♥♥♥ BPT Library ♥♥♥♥♥♥♥♥♥♥♥♥♥♥\nINFO : BPT Library LOG STARTED ...\nwarning : this file automatically deleted when its size reached log_size setting, do not delete it manually\n\n"); |
|
| 34 | + fwrite(self::$handler, "♥♥♥♥♥♥♥♥♥♥♥♥♥♥ BPT Library ♥♥♥♥♥♥♥♥♥♥♥♥♥♥\nTnx for using our library\nSome information about us :\nAuthor : @Im_Miaad\nHelper : @A_LiReza_ME\nChannel : @BPT_CH\nOur Website : https://bptlib.ir\n\nIf you have any problem with our library\nContact to our supports\n♥♥♥♥♥♥♥♥♥♥♥♥♥♥ BPT Library ♥♥♥♥♥♥♥♥♥♥♥♥♥♥\nINFO : BPT Library LOG STARTED ...\nwarning : this file automatically deleted when its size reached log_size setting, do not delete it manually\n\n"); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | if (self::$waited_logs != []) { |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * @return void |
| 53 | 53 | */ |
| 54 | 54 | public static function write(string $data, string $type = loggerTypes::NONE): void { |
| 55 | - $text = date('Y/m/d H:i:s') . ( $type === loggerTypes::NONE ? " : $data\n\n" : " : ⤵\n$type : $data\n\n" ); |
|
| 55 | + $text = date('Y/m/d H:i:s').($type === loggerTypes::NONE ? " : $data\n\n" : " : ⤵\n$type : $data\n\n"); |
|
| 56 | 56 | if (!is_null(self::$handler)) { |
| 57 | 57 | fwrite(self::$handler, $text); |
| 58 | 58 | } |
@@ -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,12 +450,12 @@ 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 | if (!isset($base_time)) { |
| 455 | 455 | $base_time = '@'.time(); |
| 456 | 456 | } |
| 457 | 457 | $base_time = new DateTime($base_time); |
| 458 | - $target_time = new DateTime(is_numeric($target_time) ? '@' . $target_time : $target_time . ' +00:00'); |
|
| 458 | + $target_time = new DateTime(is_numeric($target_time) ? '@'.$target_time : $target_time.' +00:00'); |
|
| 459 | 459 | |
| 460 | 460 | $diff = $base_time->diff($target_time); |
| 461 | 461 | |
@@ -482,12 +482,12 @@ discard block |
||
| 482 | 482 | * |
| 483 | 483 | * @return string[]|string |
| 484 | 484 | */ |
| 485 | - public static function realEscapeString(string|array $input): string|array { |
|
| 486 | - if(is_array($input)) { |
|
| 485 | + public static function realEscapeString(string | array $input): string | array { |
|
| 486 | + if (is_array($input)) { |
|
| 487 | 487 | return array_map(__METHOD__, $input); |
| 488 | 488 | } |
| 489 | 489 | |
| 490 | - if(!empty($input) && is_string($input)) { |
|
| 490 | + if (!empty($input) && is_string($input)) { |
|
| 491 | 491 | return str_replace(['\\', "\0", "\n", "\r", "'", '"', "\x1a"], ['\\\\', '\\0', '\\n', '\\r', "\\'", '\\"', '\\Z'], $input); |
| 492 | 492 | } |
| 493 | 493 | |
@@ -505,7 +505,7 @@ discard block |
||
| 505 | 505 | * |
| 506 | 506 | * @return string[]|string |
| 507 | 507 | */ |
| 508 | - public static function strReplaceFirst(string|array $search, string|array $replace, string|array $subject): string|array { |
|
| 508 | + public static function strReplaceFirst(string | array $search, string | array $replace, string | array $subject): string | array { |
|
| 509 | 509 | $pos = strpos($subject, $search); |
| 510 | 510 | if ($pos !== false) { |
| 511 | 511 | return substr_replace($subject, $replace, $pos, strlen($search)); |
@@ -522,7 +522,7 @@ discard block |
||
| 522 | 522 | * |
| 523 | 523 | * @return string see possible values in fileType class |
| 524 | 524 | */ |
| 525 | - public static function fileType (string $file_id): string { |
|
| 525 | + public static function fileType(string $file_id): string { |
|
| 526 | 526 | $data = base64_decode(str_pad(strtr($file_id, '-_', '+/'), strlen($file_id) % 4, '=')); |
| 527 | 527 | $new = ''; |
| 528 | 528 | $last = ''; |
@@ -536,7 +536,7 @@ discard block |
||
| 536 | 536 | $last = $char; |
| 537 | 537 | } |
| 538 | 538 | } |
| 539 | - $data = unpack('VtypeId/Vdc_id', $new . $last); |
|
| 539 | + $data = unpack('VtypeId/Vdc_id', $new.$last); |
|
| 540 | 540 | $data['typeId'] = $data['typeId'] & ~33554432 & ~16777216; |
| 541 | 541 | return [ |
| 542 | 542 | fileTypes::THUMBNAIL, |
@@ -574,10 +574,10 @@ discard block |
||
| 574 | 574 | * |
| 575 | 575 | * @return string |
| 576 | 576 | */ |
| 577 | - public static function randomString (int $length = 16, string $characters = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'): string { |
|
| 577 | + public static function randomString(int $length = 16, string $characters = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'): string { |
|
| 578 | 578 | $rand_string = ''; |
| 579 | 579 | $char_len = strlen($characters) - 1; |
| 580 | - for ($i = 0; $i < $length; $i ++) { |
|
| 580 | + for ($i = 0; $i < $length; $i++) { |
|
| 581 | 581 | $rand_string .= $characters[rand(0, $char_len)]; |
| 582 | 582 | } |
| 583 | 583 | return $rand_string; |
@@ -606,7 +606,7 @@ discard block |
||
| 606 | 606 | * @return inlineKeyboardMarkup|replyKeyboardMarkup replyKeyboardMarkup for keyboard and inlineKeyboardMarkup for inline |
| 607 | 607 | * @throws bptException |
| 608 | 608 | */ |
| 609 | - public static function easyKey(array $keyboard = [], array $inline = []): inlineKeyboardMarkup|replyKeyboardMarkup { |
|
| 609 | + public static function easyKey(array $keyboard = [], array $inline = []): inlineKeyboardMarkup | replyKeyboardMarkup { |
|
| 610 | 610 | if (!empty($keyboard)) { |
| 611 | 611 | $keyboard_object = new replyKeyboardMarkup(); |
| 612 | 612 | $keyboard_object->setResize_keyboard($keyboard['resize'] ?? true); |
@@ -670,7 +670,7 @@ discard block |
||
| 670 | 670 | return $keyboard_object; |
| 671 | 671 | } |
| 672 | 672 | else { |
| 673 | - logger::write("tools::eKey function used\nkeyboard or inline parameter must be set",loggerTypes::ERROR); |
|
| 673 | + logger::write("tools::eKey function used\nkeyboard or inline parameter must be set", loggerTypes::ERROR); |
|
| 674 | 674 | throw new bptException('ARGUMENT_NOT_FOUND_KEYBOARD_INLINE'); |
| 675 | 675 | } |
| 676 | 676 | } |
@@ -687,10 +687,10 @@ discard block |
||
| 687 | 687 | * |
| 688 | 688 | * @return string |
| 689 | 689 | */ |
| 690 | - public static function inviteLink (int $user_id = null, string $bot_username = null): string { |
|
| 690 | + public static function inviteLink(int $user_id = null, string $bot_username = null): string { |
|
| 691 | 691 | if (empty($user_id)) $user_id = telegram::catchFields(fields::USER_ID); |
| 692 | 692 | if (empty($bot_username)) $bot_username = telegram::getMe()->username; |
| 693 | - return 'https://t.me/' . str_replace('@', '', $bot_username) . '?start=ref_' . tools::shortEncode($user_id); |
|
| 693 | + return 'https://t.me/'.str_replace('@', '', $bot_username).'?start=ref_'.tools::shortEncode($user_id); |
|
| 694 | 694 | } |
| 695 | 695 | |
| 696 | 696 | /** |
@@ -714,9 +714,9 @@ discard block |
||
| 714 | 714 | * @return string|bool|array{hash:string, key:string, iv:string} |
| 715 | 715 | * @throws bptException |
| 716 | 716 | */ |
| 717 | - public static function codec (string $action, string $text, string $key = null, string $iv = null): bool|array|string { |
|
| 717 | + public static function codec(string $action, string $text, string $key = null, string $iv = null): bool | array | string { |
|
| 718 | 718 | if (!extension_loaded('openssl')) { |
| 719 | - logger::write("tools::codec function used\nopenssl extension is not found , It may not be installed or enabled",loggerTypes::ERROR); |
|
| 719 | + logger::write("tools::codec function used\nopenssl extension is not found , It may not be installed or enabled", loggerTypes::ERROR); |
|
| 720 | 720 | throw new bptException('OPENSSL_EXTENSION_MISSING'); |
| 721 | 721 | } |
| 722 | 722 | if ($action === codecAction::ENCRYPT) { |
@@ -727,17 +727,17 @@ discard block |
||
| 727 | 727 | } |
| 728 | 728 | elseif ($action === codecAction::DECRYPT) { |
| 729 | 729 | if (empty($key)) { |
| 730 | - logger::write("tools::codec function used\nkey parameter is not set",loggerTypes::ERROR); |
|
| 730 | + logger::write("tools::codec function used\nkey parameter is not set", loggerTypes::ERROR); |
|
| 731 | 731 | throw new bptException('ARGUMENT_NOT_FOUND_KEY'); |
| 732 | 732 | } |
| 733 | 733 | if (empty($iv)) { |
| 734 | - logger::write("tools::codec function used\niv parameter is not set",loggerTypes::ERROR); |
|
| 734 | + logger::write("tools::codec function used\niv parameter is not set", loggerTypes::ERROR); |
|
| 735 | 735 | throw new bptException('ARGUMENT_NOT_FOUND_IV'); |
| 736 | 736 | } |
| 737 | 737 | return openssl_decrypt(base64_decode($text), 'AES-256-CBC', $key, 1, $iv); |
| 738 | 738 | } |
| 739 | 739 | else { |
| 740 | - logger::write("tools::codec function used\naction is not right, its must be `encode` or `decode`",loggerTypes::WARNING); |
|
| 740 | + logger::write("tools::codec function used\naction is not right, its must be `encode` or `decode`", loggerTypes::WARNING); |
|
| 741 | 741 | return false; |
| 742 | 742 | } |
| 743 | 743 | } |
@@ -745,8 +745,8 @@ discard block |
||
| 745 | 745 | /** |
| 746 | 746 | * @deprecated use tools::codec() instead , will remove in 1.6.0 |
| 747 | 747 | */ |
| 748 | - public static function crypto (string $action, string $text, string $key = null, string $iv = null): bool|array|string { |
|
| 749 | - return self::codec($action,$text,$key,$iv); |
|
| 748 | + public static function crypto(string $action, string $text, string $key = null, string $iv = null): bool | array | string { |
|
| 749 | + return self::codec($action, $text, $key, $iv); |
|
| 750 | 750 | } |
| 751 | 751 | |
| 752 | 752 | /** |
@@ -761,7 +761,7 @@ discard block |
||
| 761 | 761 | public static function shortEncode(int $num): string { |
| 762 | 762 | $codes = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; |
| 763 | 763 | $array = []; |
| 764 | - while ($num > 0){ |
|
| 764 | + while ($num > 0) { |
|
| 765 | 765 | $array[] = $num % 62; |
| 766 | 766 | $num = floor($num / 62); |
| 767 | 767 | } |
@@ -769,7 +769,7 @@ discard block |
||
| 769 | 769 | foreach ($array as &$value) { |
| 770 | 770 | $value = $codes[$value]; |
| 771 | 771 | } |
| 772 | - return strrev(implode('',$array)); |
|
| 772 | + return strrev(implode('', $array)); |
|
| 773 | 773 | } |
| 774 | 774 | |
| 775 | 775 | /** |
@@ -786,7 +786,7 @@ discard block |
||
| 786 | 786 | $num = 0; |
| 787 | 787 | $text = str_split(strrev($text)); |
| 788 | 788 | foreach ($text as $key=>$value) { |
| 789 | - $num += strpos($codes,$value) * pow(62,$key); |
|
| 789 | + $num += strpos($codes, $value) * pow(62, $key); |
|
| 790 | 790 | } |
| 791 | 791 | return $num; |
| 792 | 792 | } |
@@ -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 | if ($response->ok) { |
| 868 | 868 | self::$status = true; |
| 869 | 869 | self::$pure_response = $response; |
| 870 | - return self::methodReturn($name,$response); |
|
| 870 | + return self::methodReturn($name, $response); |
|
| 871 | 871 | } |
| 872 | 872 | else { |
| 873 | 873 | self::$status = false; |
@@ -883,7 +883,7 @@ discard block |
||
| 883 | 883 | * |
| 884 | 884 | * @return int|string|bool |
| 885 | 885 | */ |
| 886 | - public static function catchFields (string $field): int|string|bool { |
|
| 886 | + public static function catchFields(string $field): int | string | bool { |
|
| 887 | 887 | switch ($field) { |
| 888 | 888 | case fields::CHAT_ID : |
| 889 | 889 | case fields::FROM_CHAT_ID : |
@@ -1019,7 +1019,7 @@ discard block |
||
| 1019 | 1019 | default => false |
| 1020 | 1020 | }; |
| 1021 | 1021 | case fields::URL : |
| 1022 | - return 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; |
|
| 1022 | + return 'https://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; |
|
| 1023 | 1023 | default: |
| 1024 | 1024 | return false; |
| 1025 | 1025 | } |
@@ -41,13 +41,13 @@ discard block |
||
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | if (!tools::isTelegram($ip ?? '')) { |
| 44 | - logger::write('not authorized access denied. IP : '. $ip ?? 'unknown',loggerTypes::WARNING); |
|
| 44 | + logger::write('not authorized access denied. IP : '.$ip ?? 'unknown', loggerTypes::WARNING); |
|
| 45 | 45 | BPT::exit(); |
| 46 | 46 | } |
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - protected static function processUpdate(string|stdClass|update $update = null): void { |
|
| 50 | + protected static function processUpdate(string | stdClass | update $update = null): void { |
|
| 51 | 51 | if (!is_object($update)) { |
| 52 | 52 | $update = json_decode($update ?? file_get_contents("php://input")); |
| 53 | 53 | if (!$update) { |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - if (!is_a($update,'update')) { |
|
| 58 | + if (!is_a($update, 'update')) { |
|
| 59 | 59 | $update = new update($update); |
| 60 | 60 | } |
| 61 | 61 | |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | db::save(); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - protected static function setMessageExtra (update &$update): void { |
|
| 69 | + protected static function setMessageExtra(update & $update): void { |
|
| 70 | 70 | if ((isset($update->message) && isset($update->message->text)) || (isset($update->edited_message) && isset($update->edited_message->text))) { |
| 71 | 71 | $type = isset($update->message) ? 'message' : 'edited_message'; |
| 72 | 72 | $text = &$update->$type->text; |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | BPT::$handler->something_else(BPT::$update); |
| 140 | 140 | } |
| 141 | 141 | else { |
| 142 | - logger::write('Update received but handlers are not set',loggerTypes::WARNING); |
|
| 142 | + logger::write('Update received but handlers are not set', loggerTypes::WARNING); |
|
| 143 | 143 | } |
| 144 | 144 | } |
| 145 | 145 | } |
@@ -16,24 +16,24 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | class getUpdates extends receiver { |
| 18 | 18 | #[NoReturn] |
| 19 | - public static function init () { |
|
| 19 | + public static function init() { |
|
| 20 | 20 | $last_update_id = self::loadData(); |
| 21 | 21 | lock::set('getUpdateHook'); |
| 22 | - while(true) { |
|
| 22 | + while (true) { |
|
| 23 | 23 | if (lock::exist('getUpdateHook')) { |
| 24 | - $updates = telegram::getUpdates($last_update_id,allowed_updates: settings::$allowed_updates); |
|
| 24 | + $updates = telegram::getUpdates($last_update_id, allowed_updates: settings::$allowed_updates); |
|
| 25 | 25 | if (!telegram::$status) { |
| 26 | - logger::write("There is some problem happened , telegram response : \n".json_encode($updates),loggerTypes::ERROR); |
|
| 27 | - BPT::exit(print_r($updates,true)); |
|
| 26 | + logger::write("There is some problem happened , telegram response : \n".json_encode($updates), loggerTypes::ERROR); |
|
| 27 | + BPT::exit(print_r($updates, true)); |
|
| 28 | 28 | } |
| 29 | 29 | self::handleUpdates($updates); |
| 30 | - lock::save('getUpdate',BPT::$update->update_id+1); |
|
| 31 | - $last_update_id = BPT::$update->update_id+1; |
|
| 30 | + lock::save('getUpdate', BPT::$update->update_id + 1); |
|
| 31 | + $last_update_id = BPT::$update->update_id + 1; |
|
| 32 | 32 | } |
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - private static function loadData(): bool|int|string { |
|
| 36 | + private static function loadData(): bool | int | string { |
|
| 37 | 37 | if (lock::exist('getUpdate')) { |
| 38 | 38 | $last_update_id = lock::read('getUpdate'); |
| 39 | 39 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | self::deleteOldLocks(); |
| 42 | 42 | telegram::deleteWebhook(); |
| 43 | 43 | $last_update_id = 0; |
| 44 | - lock::save('getUpdate',0); |
|
| 44 | + lock::save('getUpdate', 0); |
|
| 45 | 45 | } |
| 46 | 46 | return $last_update_id; |
| 47 | 47 | } |
@@ -5,7 +5,7 @@ |
||
| 5 | 5 | use BPT\settings; |
| 6 | 6 | |
| 7 | 7 | class pay { |
| 8 | - public static function init (): void { |
|
| 8 | + public static function init(): void { |
|
| 9 | 9 | if (!isset(settings::$pay['crypto'])) { |
| 10 | 10 | return; |
| 11 | 11 | } |
@@ -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) && !empty($vars)) { |
| 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; |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | /** |
| 18 | 18 | * @internal Only for BPT self usage , Don't use it in your source! |
| 19 | 19 | */ |
| 20 | - public static function init (): void { |
|
| 20 | + public static function init(): void { |
|
| 21 | 21 | if (!isset(settings::$db['type'])) { |
| 22 | 22 | settings::$db['type'] = dbTypes::JSON; |
| 23 | 23 | } |
@@ -268,13 +268,13 @@ discard block |
||
| 268 | 268 | * @method bool|responseError unhideGeneralForumTopic (int|string|array $chat_id, string|null $token = null, bool|null $forgot = null, bool|null $answer = null) Use this method to unhide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success. |
| 269 | 269 | * @method bool|responseError unhideGeneralTopic (int|string|array $chat_id, string|null $token = null, bool|null $forgot = null, bool|null $answer = null) Use this method to unhide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success. |
| 270 | 270 | */ |
| 271 | -class BPT extends telegram{ |
|
| 271 | +class BPT extends telegram { |
|
| 272 | 272 | public static update $update; |
| 273 | 273 | |
| 274 | 274 | public static BPT $handler; |
| 275 | 275 | |
| 276 | 276 | |
| 277 | - public function __construct (array|stdClass $settings) { |
|
| 277 | + public function __construct(array | stdClass $settings) { |
|
| 278 | 278 | static::$handler = &$this; |
| 279 | 279 | settings::init($settings); |
| 280 | 280 | } |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | #[NoReturn] |
| 287 | - public static function exit (string|null $message = null) { |
|
| 287 | + public static function exit (string | null $message = null) { |
|
| 288 | 288 | die($message ?? "<div style='width:98vw;height:98vh;display:flex;justify-content:center;align-items:center;font-size:25vw'>BPT</div>"); |
| 289 | 289 | } |
| 290 | 290 | } |