@@ -38,10 +38,10 @@ discard block |
||
38 | 38 | * Optional. Chat invite link, which was used by the user to join the chat; for joining by invite link events |
39 | 39 | * only. |
40 | 40 | */ |
41 | - public null|chatInviteLink $invite_link = null; |
|
41 | + public null | chatInviteLink $invite_link = null; |
|
42 | 42 | |
43 | 43 | |
44 | - public function __construct(stdClass|null $object = null) { |
|
44 | + public function __construct(stdClass | null $object = null) { |
|
45 | 45 | if ($object != null) { |
46 | 46 | parent::__construct($object, self::subs); |
47 | 47 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | return $this->chat->isPrivate() && $this->isMe() && $this->isKicked(); |
56 | 56 | } |
57 | 57 | |
58 | - public function isMe (): bool { |
|
58 | + public function isMe(): bool { |
|
59 | 59 | return $this->new_chat_member->user->id == settings::$bot_id; |
60 | 60 | } |
61 | 61 | |
@@ -71,19 +71,19 @@ discard block |
||
71 | 71 | return $this->isJoined() && !empty($this->invite_link); |
72 | 72 | } |
73 | 73 | |
74 | - public function isLeaved (): bool { |
|
74 | + public function isLeaved(): bool { |
|
75 | 75 | return $this->new_chat_member->status === chatMemberStatus::LEFT; |
76 | 76 | } |
77 | 77 | |
78 | - public function isKicked (): bool { |
|
78 | + public function isKicked(): bool { |
|
79 | 79 | return $this->new_chat_member->status === chatMemberStatus::KICKED; |
80 | 80 | } |
81 | 81 | |
82 | - public function isOldAdmin (): bool { |
|
82 | + public function isOldAdmin(): bool { |
|
83 | 83 | return $this->old_chat_member->status === chatMemberStatus::ADMINISTRATOR && $this->isJoined(); |
84 | 84 | } |
85 | 85 | |
86 | - public function isNewAdmin (): bool { |
|
86 | + public function isNewAdmin(): bool { |
|
87 | 87 | return $this->new_chat_member->status === chatMemberStatus::ADMINISTRATOR; |
88 | 88 | } |
89 | 89 | } |
@@ -32,19 +32,19 @@ |
||
32 | 32 | public string $invoice_payload; |
33 | 33 | |
34 | 34 | /** Optional. Identifier of the shipping option chosen by the user */ |
35 | - public null|string $shipping_option_id = null; |
|
35 | + public null | string $shipping_option_id = null; |
|
36 | 36 | |
37 | 37 | /** Optional. Order information provided by the user */ |
38 | - public null|orderInfo $order_info = null; |
|
38 | + public null | orderInfo $order_info = null; |
|
39 | 39 | |
40 | 40 | |
41 | - public function __construct(stdClass|null $object = null) { |
|
41 | + public function __construct(stdClass | null $object = null) { |
|
42 | 42 | if ($object != null) { |
43 | 43 | parent::__construct($object, self::subs); |
44 | 44 | } |
45 | 45 | } |
46 | 46 | |
47 | - public function answer (bool $ok, string|null $error_message = null): responseError|bool { |
|
47 | + public function answer(bool $ok, string | null $error_message = null): responseError | bool { |
|
48 | 48 | return telegram::answerPreCheckoutQuery($ok, $this->id, $error_message); |
49 | 49 | } |
50 | 50 | } |
@@ -25,50 +25,50 @@ |
||
25 | 25 | * Optional. Message with the callback button that originated the query. Note that message content and message |
26 | 26 | * date will not be available if the message is too old |
27 | 27 | */ |
28 | - public null|message $message = null; |
|
28 | + public null | message $message = null; |
|
29 | 29 | |
30 | 30 | /** Optional. Identifier of the message sent via the bot in inline mode, that originated the query. */ |
31 | - public null|string $inline_message_id = null; |
|
31 | + public null | string $inline_message_id = null; |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Global identifier, uniquely corresponding to the chat to which the message with the callback button was sent. |
35 | 35 | * Useful for high scores in games. |
36 | 36 | */ |
37 | - public null|string $chat_instance = null; |
|
37 | + public null | string $chat_instance = null; |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * Optional. Data associated with the callback button. Be aware that the message originated the query can contain |
41 | 41 | * no callback buttons with this data. |
42 | 42 | */ |
43 | - public null|string $data = null; |
|
43 | + public null | string $data = null; |
|
44 | 44 | |
45 | 45 | /** Optional. Short name of a Game to be returned, serves as the unique identifier for the game */ |
46 | - public null|string $game_short_name = null; |
|
46 | + public null | string $game_short_name = null; |
|
47 | 47 | |
48 | 48 | |
49 | - public function __construct(stdClass|null $object = null) { |
|
49 | + public function __construct(stdClass | null $object = null) { |
|
50 | 50 | if ($object != null) { |
51 | 51 | parent::__construct($object, self::subs); |
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | - public function answer (string|null $text = null, bool|null $show_alert = null, string|null $url = null, int|null $cache_time = null): responseError|bool { |
|
55 | + public function answer(string | null $text = null, bool | null $show_alert = null, string | null $url = null, int | null $cache_time = null): responseError | bool { |
|
56 | 56 | return telegram::answerCallbackQuery($this->id, $text, $show_alert, $url, $cache_time); |
57 | 57 | } |
58 | 58 | |
59 | - public function editText (string $text): message|responseError|bool { |
|
59 | + public function editText(string $text): message | responseError | bool { |
|
60 | 60 | return telegram::editMessageText($text); |
61 | 61 | } |
62 | 62 | |
63 | - public function editCaption (string $text = ''): message|responseError|bool { |
|
63 | + public function editCaption(string $text = ''): message | responseError | bool { |
|
64 | 64 | return telegram::editMessageCaption(caption: $text); |
65 | 65 | } |
66 | 66 | |
67 | - public function editKeyboard (inlineKeyboardMarkup|stdClass|array $reply_markup = null): message|responseError|bool { |
|
67 | + public function editKeyboard(inlineKeyboardMarkup | stdClass | array $reply_markup = null): message | responseError | bool { |
|
68 | 68 | return telegram::editMessageReplyMarkup(reply_markup: $reply_markup); |
69 | 69 | } |
70 | 70 | |
71 | - public function editMedia (inputMedia|array|stdClass $media): message|responseError|bool { |
|
71 | + public function editMedia(inputMedia | array | stdClass $media): message | responseError | bool { |
|
72 | 72 | return telegram::editMessageMedia($media); |
73 | 73 | } |
74 | 74 | } |
@@ -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 | } |
@@ -751,7 +751,7 @@ discard block |
||
751 | 751 | public static function shortEncode(int $num): string { |
752 | 752 | $codes = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; |
753 | 753 | $array = []; |
754 | - while ($num > 0){ |
|
754 | + while ($num > 0) { |
|
755 | 755 | $array[] = $num % 62; |
756 | 756 | $num = floor($num / 62); |
757 | 757 | } |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | foreach ($array as &$value) { |
760 | 760 | $value = $codes[$value]; |
761 | 761 | } |
762 | - return strrev(implode('',$array)); |
|
762 | + return strrev(implode('', $array)); |
|
763 | 763 | } |
764 | 764 | |
765 | 765 | /** |
@@ -776,7 +776,7 @@ discard block |
||
776 | 776 | $num = 0; |
777 | 777 | $text = str_split(strrev($text)); |
778 | 778 | foreach ($text as $key=>$value) { |
779 | - $num += strpos($codes,$value) * pow(62,$key); |
|
779 | + $num += strpos($codes, $value) * pow(62, $key); |
|
780 | 780 | } |
781 | 781 | return $num; |
782 | 782 | } |
@@ -503,95 +503,95 @@ discard block |
||
503 | 503 | ]; |
504 | 504 | |
505 | 505 | private const METHODS_KEYS = [ |
506 | - 'getUpdates' => ['offset','limit','timeout','allowed_updates','token','forgot','answer'], |
|
507 | - 'setWebhook' => ['url','certificate','ip_address','max_connections','allowed_updates','drop_pending_updates','secret_token','token','forgot','answer'], |
|
508 | - 'deleteWebhook' => ['drop_pending_updates','token','forgot','answer'], |
|
509 | - 'getWebhookInfo' => ['token','forgot','answer'], |
|
510 | - 'getMe' => ['token','forgot','answer'], |
|
511 | - 'logOut' => ['token','forgot','answer'], |
|
512 | - 'close' => ['token','forgot','answer'], |
|
513 | - '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'], |
|
514 | - 'forwardMessage' => ['chat_id','from_chat_id','disable_notification','protect_content','message_id','token','forgot','answer','message_thread_id'], |
|
515 | - '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'], |
|
516 | - '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'], |
|
517 | - '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'], |
|
518 | - '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'], |
|
519 | - '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'], |
|
520 | - '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'], |
|
521 | - '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'], |
|
522 | - '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'], |
|
523 | - 'sendMediaGroup' => ['media','chat_id','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','token','forgot','answer','message_thread_id'], |
|
524 | - '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'], |
|
525 | - 'editMessageLiveLocation' => ['latitude','longitude','chat_id','message_id','inline_message_id','horizontal_accuracy','heading','proximity_alert_radius','reply_markup','token','forgot','answer'], |
|
526 | - 'stopMessageLiveLocation' => ['chat_id','message_id','inline_message_id','reply_markup','token','forgot','answer'], |
|
527 | - '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'], |
|
528 | - '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'], |
|
529 | - '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'], |
|
530 | - 'sendDice' => ['chat_id','emoji','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
531 | - 'sendChatAction' => ['chat_id','action','token','forgot','answer','message_thread_id'], |
|
532 | - 'getUserProfilePhotos' => ['user_id','offset','limit','token','forgot','answer'], |
|
533 | - 'getFile' => ['file_id','token','forgot','answer'], |
|
534 | - 'banChatMember' => ['chat_id','user_id','until_date','revoke_messages','token','forgot','answer'], |
|
535 | - 'unbanChatMember' => ['chat_id','user_id','only_if_banned','token','forgot','answer'], |
|
536 | - 'restrictChatMember' => ['permissions','chat_id','user_id','until_date','token','forgot','answer','use_independent_chat_permissions'], |
|
537 | - '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'], |
|
538 | - 'setChatAdministratorCustomTitle' => ['custom_title','chat_id','user_id','token','forgot','answer'], |
|
539 | - 'banChatSenderChat' => ['sender_chat_id','chat_id','token','forgot','answer'], |
|
540 | - 'unbanChatSenderChat' => ['sender_chat_id','chat_id','token','forgot','answer'], |
|
541 | - 'setChatPermissions' => ['permissions','chat_id','token','forgot','answer','use_independent_chat_permissions'], |
|
542 | - 'exportChatInviteLink' => ['chat_id','token','forgot','answer'], |
|
543 | - 'createChatInviteLink' => ['chat_id','name','expire_date','member_limit','creates_join_request','token','forgot','answer'], |
|
544 | - 'editChatInviteLink' => ['invite_link','chat_id','name','expire_date','member_limit','creates_join_request','token','forgot','answer'], |
|
545 | - 'revokeChatInviteLink' => ['invite_link','chat_id','token','forgot','answer'], |
|
546 | - 'approveChatJoinRequest' => ['chat_id','user_id','token','forgot','answer'], |
|
547 | - 'declineChatJoinRequest' => ['chat_id','user_id','token','forgot','answer'], |
|
548 | - 'setChatPhoto' => ['photo','chat_id','token','forgot','answer'], |
|
549 | - 'deleteChatPhoto' => ['chat_id','token','forgot','answer'], |
|
550 | - 'setChatTitle' => ['title','chat_id','token','forgot','answer'], |
|
551 | - 'setChatDescription' => ['chat_id','description','token','forgot','answer'], |
|
552 | - 'pinChatMessage' => ['message_id','chat_id','disable_notification','token','forgot','answer'], |
|
553 | - 'unpinChatMessage' => ['chat_id','message_id','token','forgot','answer'], |
|
554 | - 'unpinAllChatMessages' => ['chat_id','token','forgot','answer'], |
|
555 | - 'leaveChat' => ['chat_id','token','forgot','answer'], |
|
556 | - 'getChat' => ['chat_id','token','forgot','answer'], |
|
557 | - 'getChatAdministrators' => ['chat_id','token','forgot','answer'], |
|
558 | - 'getChatMemberCount' => ['chat_id','token','forgot','answer'], |
|
559 | - 'getChatMember' => ['chat_id','user_id','token','forgot','answer'], |
|
560 | - 'setChatStickerSet' => ['sticker_set_name','chat_id','token','forgot','answer'], |
|
561 | - 'deleteChatStickerSet' => ['chat_id','token','forgot','answer'], |
|
562 | - 'answerCallbackQuery' => ['callback_query_id','text','show_alert','url','cache_time','token','forgot','answer'], |
|
563 | - 'setMyCommands' => ['commands','scope','language_code','token','forgot','answer'], |
|
564 | - 'deleteMyCommands' => ['scope','language_code','token','forgot','answer'], |
|
565 | - 'getMyCommands' => ['scope','language_code','token','forgot','answer'], |
|
566 | - 'setChatMenuButton' => ['chat_id','menu_button','token','forgot','answer'], |
|
567 | - 'getChatMenuButton' => ['chat_id','token','forgot','answer'], |
|
568 | - 'setMyDefaultAdministratorRights' => ['rights','for_channels','token','forgot','answer'], |
|
569 | - 'getMyDefaultAdministratorRights' => ['for_channels','token','forgot','answer'], |
|
570 | - 'editMessageText' => ['text','chat_id','message_id','inline_message_id','parse_mode','entities','disable_web_page_preview','reply_markup','token','forgot','answer'], |
|
571 | - 'editMessageCaption' => ['chat_id','message_id','inline_message_id','caption','parse_mode','caption_entities','reply_markup','token','forgot','answer'], |
|
572 | - 'editMessageMedia' => ['media','chat_id','message_id','inline_message_id','reply_markup','token','forgot','answer'], |
|
573 | - 'editMessageReplyMarkup' => ['chat_id','message_id','inline_message_id','reply_markup','token','forgot','answer'], |
|
574 | - 'stopPoll' => ['chat_id','message_id','reply_markup','token','forgot','answer'], |
|
575 | - 'deleteMessage' => ['chat_id','message_id','token','forgot','answer'], |
|
576 | - 'sendSticker' => ['sticker','chat_id','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
577 | - 'getStickerSet' => ['name','token','forgot','answer'], |
|
506 | + 'getUpdates' => ['offset', 'limit', 'timeout', 'allowed_updates', 'token', 'forgot', 'answer'], |
|
507 | + 'setWebhook' => ['url', 'certificate', 'ip_address', 'max_connections', 'allowed_updates', 'drop_pending_updates', 'secret_token', 'token', 'forgot', 'answer'], |
|
508 | + 'deleteWebhook' => ['drop_pending_updates', 'token', 'forgot', 'answer'], |
|
509 | + 'getWebhookInfo' => ['token', 'forgot', 'answer'], |
|
510 | + 'getMe' => ['token', 'forgot', 'answer'], |
|
511 | + 'logOut' => ['token', 'forgot', 'answer'], |
|
512 | + 'close' => ['token', 'forgot', 'answer'], |
|
513 | + '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'], |
|
514 | + 'forwardMessage' => ['chat_id', 'from_chat_id', 'disable_notification', 'protect_content', 'message_id', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
515 | + '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'], |
|
516 | + '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'], |
|
517 | + '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'], |
|
518 | + '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'], |
|
519 | + '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'], |
|
520 | + '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'], |
|
521 | + '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'], |
|
522 | + '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'], |
|
523 | + 'sendMediaGroup' => ['media', 'chat_id', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
524 | + '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'], |
|
525 | + 'editMessageLiveLocation' => ['latitude', 'longitude', 'chat_id', 'message_id', 'inline_message_id', 'horizontal_accuracy', 'heading', 'proximity_alert_radius', 'reply_markup', 'token', 'forgot', 'answer'], |
|
526 | + 'stopMessageLiveLocation' => ['chat_id', 'message_id', 'inline_message_id', 'reply_markup', 'token', 'forgot', 'answer'], |
|
527 | + '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'], |
|
528 | + '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'], |
|
529 | + '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'], |
|
530 | + 'sendDice' => ['chat_id', 'emoji', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
531 | + 'sendChatAction' => ['chat_id', 'action', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
532 | + 'getUserProfilePhotos' => ['user_id', 'offset', 'limit', 'token', 'forgot', 'answer'], |
|
533 | + 'getFile' => ['file_id', 'token', 'forgot', 'answer'], |
|
534 | + 'banChatMember' => ['chat_id', 'user_id', 'until_date', 'revoke_messages', 'token', 'forgot', 'answer'], |
|
535 | + 'unbanChatMember' => ['chat_id', 'user_id', 'only_if_banned', 'token', 'forgot', 'answer'], |
|
536 | + 'restrictChatMember' => ['permissions', 'chat_id', 'user_id', 'until_date', 'token', 'forgot', 'answer', 'use_independent_chat_permissions'], |
|
537 | + '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'], |
|
538 | + 'setChatAdministratorCustomTitle' => ['custom_title', 'chat_id', 'user_id', 'token', 'forgot', 'answer'], |
|
539 | + 'banChatSenderChat' => ['sender_chat_id', 'chat_id', 'token', 'forgot', 'answer'], |
|
540 | + 'unbanChatSenderChat' => ['sender_chat_id', 'chat_id', 'token', 'forgot', 'answer'], |
|
541 | + 'setChatPermissions' => ['permissions', 'chat_id', 'token', 'forgot', 'answer', 'use_independent_chat_permissions'], |
|
542 | + 'exportChatInviteLink' => ['chat_id', 'token', 'forgot', 'answer'], |
|
543 | + 'createChatInviteLink' => ['chat_id', 'name', 'expire_date', 'member_limit', 'creates_join_request', 'token', 'forgot', 'answer'], |
|
544 | + 'editChatInviteLink' => ['invite_link', 'chat_id', 'name', 'expire_date', 'member_limit', 'creates_join_request', 'token', 'forgot', 'answer'], |
|
545 | + 'revokeChatInviteLink' => ['invite_link', 'chat_id', 'token', 'forgot', 'answer'], |
|
546 | + 'approveChatJoinRequest' => ['chat_id', 'user_id', 'token', 'forgot', 'answer'], |
|
547 | + 'declineChatJoinRequest' => ['chat_id', 'user_id', 'token', 'forgot', 'answer'], |
|
548 | + 'setChatPhoto' => ['photo', 'chat_id', 'token', 'forgot', 'answer'], |
|
549 | + 'deleteChatPhoto' => ['chat_id', 'token', 'forgot', 'answer'], |
|
550 | + 'setChatTitle' => ['title', 'chat_id', 'token', 'forgot', 'answer'], |
|
551 | + 'setChatDescription' => ['chat_id', 'description', 'token', 'forgot', 'answer'], |
|
552 | + 'pinChatMessage' => ['message_id', 'chat_id', 'disable_notification', 'token', 'forgot', 'answer'], |
|
553 | + 'unpinChatMessage' => ['chat_id', 'message_id', 'token', 'forgot', 'answer'], |
|
554 | + 'unpinAllChatMessages' => ['chat_id', 'token', 'forgot', 'answer'], |
|
555 | + 'leaveChat' => ['chat_id', 'token', 'forgot', 'answer'], |
|
556 | + 'getChat' => ['chat_id', 'token', 'forgot', 'answer'], |
|
557 | + 'getChatAdministrators' => ['chat_id', 'token', 'forgot', 'answer'], |
|
558 | + 'getChatMemberCount' => ['chat_id', 'token', 'forgot', 'answer'], |
|
559 | + 'getChatMember' => ['chat_id', 'user_id', 'token', 'forgot', 'answer'], |
|
560 | + 'setChatStickerSet' => ['sticker_set_name', 'chat_id', 'token', 'forgot', 'answer'], |
|
561 | + 'deleteChatStickerSet' => ['chat_id', 'token', 'forgot', 'answer'], |
|
562 | + 'answerCallbackQuery' => ['callback_query_id', 'text', 'show_alert', 'url', 'cache_time', 'token', 'forgot', 'answer'], |
|
563 | + 'setMyCommands' => ['commands', 'scope', 'language_code', 'token', 'forgot', 'answer'], |
|
564 | + 'deleteMyCommands' => ['scope', 'language_code', 'token', 'forgot', 'answer'], |
|
565 | + 'getMyCommands' => ['scope', 'language_code', 'token', 'forgot', 'answer'], |
|
566 | + 'setChatMenuButton' => ['chat_id', 'menu_button', 'token', 'forgot', 'answer'], |
|
567 | + 'getChatMenuButton' => ['chat_id', 'token', 'forgot', 'answer'], |
|
568 | + 'setMyDefaultAdministratorRights' => ['rights', 'for_channels', 'token', 'forgot', 'answer'], |
|
569 | + 'getMyDefaultAdministratorRights' => ['for_channels', 'token', 'forgot', 'answer'], |
|
570 | + 'editMessageText' => ['text', 'chat_id', 'message_id', 'inline_message_id', 'parse_mode', 'entities', 'disable_web_page_preview', 'reply_markup', 'token', 'forgot', 'answer'], |
|
571 | + 'editMessageCaption' => ['chat_id', 'message_id', 'inline_message_id', 'caption', 'parse_mode', 'caption_entities', 'reply_markup', 'token', 'forgot', 'answer'], |
|
572 | + 'editMessageMedia' => ['media', 'chat_id', 'message_id', 'inline_message_id', 'reply_markup', 'token', 'forgot', 'answer'], |
|
573 | + 'editMessageReplyMarkup' => ['chat_id', 'message_id', 'inline_message_id', 'reply_markup', 'token', 'forgot', 'answer'], |
|
574 | + 'stopPoll' => ['chat_id', 'message_id', 'reply_markup', 'token', 'forgot', 'answer'], |
|
575 | + 'deleteMessage' => ['chat_id', 'message_id', 'token', 'forgot', 'answer'], |
|
576 | + 'sendSticker' => ['sticker', 'chat_id', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
577 | + 'getStickerSet' => ['name', 'token', 'forgot', 'answer'], |
|
578 | 578 | 'getCustomEmojiStickers' => ['custom_emoji_ids', 'token', 'return_array', 'forgot', 'answer'], |
579 | - 'uploadStickerFile' => ['png_sticker','user_id','token','forgot','answer'], |
|
580 | - 'createNewStickerSet' => ['name','title','emojis','user_id','png_sticker','tgs_sticker','webm_sticker','sticker_type','contains_masks','mask_position','token','forgot','answer'], |
|
581 | - 'addStickerToSet' => ['name','emojis','user_id','png_sticker','tgs_sticker','webm_sticker','mask_position','token','forgot','answer'], |
|
582 | - 'setStickerPositionInSet' => ['sticker','position','token','forgot','answer'], |
|
583 | - 'deleteStickerFromSet' => ['sticker','token','forgot','answer'], |
|
584 | - 'setStickerSetThumb' => ['name','user_id','thumb','token','forgot','answer'], |
|
585 | - 'answerInlineQuery' => ['results','inline_query_id','cache_time','is_personal','next_offset','switch_pm_text','switch_pm_parameter','token','forgot','answer'], |
|
586 | - 'answerWebAppQuery' => ['web_app_query_id','result','token','forgot','answer'], |
|
587 | - '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'], |
|
588 | - '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'], |
|
589 | - 'answerShippingQuery' => ['ok','shipping_query_id','shipping_options','error_message','token','forgot','answer'], |
|
590 | - 'answerPreCheckoutQuery' => ['ok','pre_checkout_query_id','error_message','token','forgot','answer'], |
|
591 | - 'setPassportDataErrors' => ['errors','user_id','token','forgot','answer'], |
|
592 | - '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'], |
|
593 | - 'setGameScore' => ['score','user_id','force','disable_edit_message','chat_id','message_id','inline_message_id','token','forgot','answer'], |
|
594 | - 'getGameHighScores' => ['user_id','chat_id','message_id','inline_message_id','token','forgot','answer'], |
|
579 | + 'uploadStickerFile' => ['png_sticker', 'user_id', 'token', 'forgot', 'answer'], |
|
580 | + 'createNewStickerSet' => ['name', 'title', 'emojis', 'user_id', 'png_sticker', 'tgs_sticker', 'webm_sticker', 'sticker_type', 'contains_masks', 'mask_position', 'token', 'forgot', 'answer'], |
|
581 | + 'addStickerToSet' => ['name', 'emojis', 'user_id', 'png_sticker', 'tgs_sticker', 'webm_sticker', 'mask_position', 'token', 'forgot', 'answer'], |
|
582 | + 'setStickerPositionInSet' => ['sticker', 'position', 'token', 'forgot', 'answer'], |
|
583 | + 'deleteStickerFromSet' => ['sticker', 'token', 'forgot', 'answer'], |
|
584 | + 'setStickerSetThumb' => ['name', 'user_id', 'thumb', 'token', 'forgot', 'answer'], |
|
585 | + 'answerInlineQuery' => ['results', 'inline_query_id', 'cache_time', 'is_personal', 'next_offset', 'switch_pm_text', 'switch_pm_parameter', 'token', 'forgot', 'answer'], |
|
586 | + 'answerWebAppQuery' => ['web_app_query_id', 'result', 'token', 'forgot', 'answer'], |
|
587 | + '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'], |
|
588 | + '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'], |
|
589 | + 'answerShippingQuery' => ['ok', 'shipping_query_id', 'shipping_options', 'error_message', 'token', 'forgot', 'answer'], |
|
590 | + 'answerPreCheckoutQuery' => ['ok', 'pre_checkout_query_id', 'error_message', 'token', 'forgot', 'answer'], |
|
591 | + 'setPassportDataErrors' => ['errors', 'user_id', 'token', 'forgot', 'answer'], |
|
592 | + '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'], |
|
593 | + 'setGameScore' => ['score', 'user_id', 'force', 'disable_edit_message', 'chat_id', 'message_id', 'inline_message_id', 'token', 'forgot', 'answer'], |
|
594 | + 'getGameHighScores' => ['user_id', 'chat_id', 'message_id', 'inline_message_id', 'token', 'forgot', 'answer'], |
|
595 | 595 | 'getForumTopicIconStickers' => ['token', 'return_array', 'forgot', 'answer'], |
596 | 596 | 'createForumTopic' => ['chat_id', 'name', 'icon_color', 'icon_custom_emoji_id', 'token', 'return_array', 'forgot', 'answer'], |
597 | 597 | 'editForumTopic' => ['chat_id', 'name', 'icon_custom_emoji_id', 'token', 'return_array', 'forgot', 'answer', 'message_thread_id'], |
@@ -632,8 +632,8 @@ discard block |
||
632 | 632 | 'logOut' => [], |
633 | 633 | 'close' => [], |
634 | 634 | 'sendMessage' => ['chat_id'], |
635 | - 'forwardMessage' => ['from_chat_id','message_id'], |
|
636 | - 'copyMessage' => ['from_chat_id','message_id'], |
|
635 | + 'forwardMessage' => ['from_chat_id', 'message_id'], |
|
636 | + 'copyMessage' => ['from_chat_id', 'message_id'], |
|
637 | 637 | 'sendPhoto' => ['chat_id'], |
638 | 638 | 'sendAudio' => ['chat_id'], |
639 | 639 | 'sendDocument' => ['chat_id'], |
@@ -649,15 +649,15 @@ discard block |
||
649 | 649 | 'sendContact' => ['chat_id'], |
650 | 650 | 'sendPoll' => ['chat_id'], |
651 | 651 | 'sendDice' => ['chat_id'], |
652 | - 'sendChatAction' => ['chat_id','action'], |
|
652 | + 'sendChatAction' => ['chat_id', 'action'], |
|
653 | 653 | 'getUserProfilePhotos' => ['user_id'], |
654 | 654 | 'getFile' => ['file_id'], |
655 | - 'banChatMember' => ['chat_id','user_id'], |
|
656 | - 'kickChatMember' => ['chat_id','user_id'], |
|
657 | - 'unbanChatMember' => ['chat_id','user_id'], |
|
658 | - 'restrictChatMember' => ['chat_id','user_id'], |
|
659 | - 'promoteChatMember' => ['chat_id','user_id'], |
|
660 | - 'setChatAdministratorCustomTitle' => ['chat_id','user_id'], |
|
655 | + 'banChatMember' => ['chat_id', 'user_id'], |
|
656 | + 'kickChatMember' => ['chat_id', 'user_id'], |
|
657 | + 'unbanChatMember' => ['chat_id', 'user_id'], |
|
658 | + 'restrictChatMember' => ['chat_id', 'user_id'], |
|
659 | + 'promoteChatMember' => ['chat_id', 'user_id'], |
|
660 | + 'setChatAdministratorCustomTitle' => ['chat_id', 'user_id'], |
|
661 | 661 | 'banChatSenderChat' => ['chat_id'], |
662 | 662 | 'unbanChatSenderChat' => ['chat_id'], |
663 | 663 | 'setChatPermissions' => ['chat_id'], |
@@ -665,8 +665,8 @@ discard block |
||
665 | 665 | 'createChatInviteLink' => ['chat_id'], |
666 | 666 | 'editChatInviteLink' => ['chat_id'], |
667 | 667 | 'revokeChatInviteLink' => ['chat_id'], |
668 | - 'approveChatJoinRequest' => ['chat_id','user_id'], |
|
669 | - 'declineChatJoinRequest' => ['chat_id','user_id'], |
|
668 | + 'approveChatJoinRequest' => ['chat_id', 'user_id'], |
|
669 | + 'declineChatJoinRequest' => ['chat_id', 'user_id'], |
|
670 | 670 | 'setChatPhoto' => ['chat_id'], |
671 | 671 | 'deleteChatPhoto' => ['chat_id'], |
672 | 672 | 'setChatTitle' => ['chat_id'], |
@@ -678,7 +678,7 @@ discard block |
||
678 | 678 | 'getChat' => ['chat_id'], |
679 | 679 | 'getChatAdministrators' => ['chat_id'], |
680 | 680 | 'getChatMembersCount' => ['chat_id'], |
681 | - 'getChatMember' => ['chat_id','user_id'], |
|
681 | + 'getChatMember' => ['chat_id', 'user_id'], |
|
682 | 682 | 'setChatStickerSet' => ['chat_id'], |
683 | 683 | 'deleteChatStickerSet' => ['chat_id'], |
684 | 684 | 'answerCallbackQuery' => ['callback_query_id'], |
@@ -689,12 +689,12 @@ discard block |
||
689 | 689 | 'getChatMenuButton' => [], |
690 | 690 | 'setMyDefaultAdministratorRights' => [], |
691 | 691 | 'getMyDefaultAdministratorRights' => [], |
692 | - 'editMessageText' => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
693 | - 'editMessageCaption' => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
694 | - 'editMessageMedia' => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
695 | - 'editMessageReplyMarkup' => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
696 | - 'stopPoll' => ['chat_id','message_id'], |
|
697 | - 'deleteMessage' => ['chat_id','message_id'], |
|
692 | + 'editMessageText' => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
693 | + 'editMessageCaption' => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
694 | + 'editMessageMedia' => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
695 | + 'editMessageReplyMarkup' => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
696 | + 'stopPoll' => ['chat_id', 'message_id'], |
|
697 | + 'deleteMessage' => ['chat_id', 'message_id'], |
|
698 | 698 | 'sendSticker' => ['chat_id'], |
699 | 699 | 'getStickerSet' => [], |
700 | 700 | 'uploadStickerFile' => ['user_id'], |
@@ -710,8 +710,8 @@ discard block |
||
710 | 710 | 'answerPreCheckoutQuery' => ['pre_checkout_query_id'], |
711 | 711 | 'setPassportDataErrors' => ['user_id'], |
712 | 712 | 'sendGame' => ['chat_id'], |
713 | - 'setGameScore' => ['user_id','inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
714 | - 'getGameHighScores' => ['user_id','inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']] |
|
713 | + 'setGameScore' => ['user_id', 'inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
714 | + 'getGameHighScores' => ['user_id', 'inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']] |
|
715 | 715 | ]; |
716 | 716 | |
717 | 717 | private const METHODS_RETURN = [ |
@@ -765,29 +765,29 @@ discard block |
||
765 | 765 | 'getGameHighScores' => ['BPT\types\gameHighScore'] |
766 | 766 | ]; |
767 | 767 | |
768 | - public static function __callStatic (string $name, array $arguments) { |
|
768 | + public static function __callStatic(string $name, array $arguments) { |
|
769 | 769 | if (!$action = self::methodAction($name)) { |
770 | - logger::write("$name method is not supported",loggerTypes::ERROR); |
|
770 | + logger::write("$name method is not supported", loggerTypes::ERROR); |
|
771 | 771 | throw new bptException('METHOD_NOT_FOUND'); |
772 | 772 | } |
773 | 773 | self::checkArguments($arguments); |
774 | - self::keysName($action,$arguments); |
|
775 | - self::readyFile($action,$arguments); |
|
776 | - self::setDefaults($action,$arguments); |
|
774 | + self::keysName($action, $arguments); |
|
775 | + self::readyFile($action, $arguments); |
|
776 | + self::setDefaults($action, $arguments); |
|
777 | 777 | self::cleanArguments($arguments); |
778 | 778 | |
779 | 779 | if (isset($arguments['answer']) && $arguments['answer'] === true) { |
780 | 780 | unset($arguments['answer']); |
781 | 781 | if (!answer::isAnswered()) { |
782 | - return answer::init($action,$arguments); |
|
782 | + return answer::init($action, $arguments); |
|
783 | 783 | } |
784 | - logger::write('you can use answer mode only once for each webhook update, Others will be called like normal',loggerTypes::WARNING); |
|
784 | + logger::write('you can use answer mode only once for each webhook update, Others will be called like normal', loggerTypes::WARNING); |
|
785 | 785 | } |
786 | - $result = curl::init($action,$arguments); |
|
786 | + $result = curl::init($action, $arguments); |
|
787 | 787 | if (!is_object($result)) { |
788 | 788 | return false; |
789 | 789 | } |
790 | - return self::processResponse($action,$result); |
|
790 | + return self::processResponse($action, $result); |
|
791 | 791 | } |
792 | 792 | |
793 | 793 | private static function checkArguments(array &$arguments): void { |
@@ -796,7 +796,7 @@ discard block |
||
796 | 796 | } |
797 | 797 | } |
798 | 798 | |
799 | - private static function keysName (string $name, array &$arguments): void { |
|
799 | + private static function keysName(string $name, array &$arguments): void { |
|
800 | 800 | foreach ($arguments as $key => $argument) { |
801 | 801 | if (is_numeric($key) && isset(self::METHODS_KEYS[$name][$key])) { |
802 | 802 | $arguments[self::METHODS_KEYS[$name][$key]] = $argument; |
@@ -805,7 +805,7 @@ discard block |
||
805 | 805 | } |
806 | 806 | } |
807 | 807 | |
808 | - private static function methodAction(string $name): string|false { |
|
808 | + private static function methodAction(string $name): string | false { |
|
809 | 809 | return self::METHODS_ACTION[str_replace('_', '', strtolower($name))] ?? false; |
810 | 810 | } |
811 | 811 | |
@@ -838,11 +838,11 @@ discard block |
||
838 | 838 | } |
839 | 839 | } |
840 | 840 | |
841 | - private static function methodFile(string $name): array|false { |
|
841 | + private static function methodFile(string $name): array | false { |
|
842 | 842 | return self::METHODS_WITH_FILE[$name] ?? false; |
843 | 843 | } |
844 | 844 | |
845 | - private static function methodReturn(string $name,stdClass $response) { |
|
845 | + private static function methodReturn(string $name, stdClass $response) { |
|
846 | 846 | if (!isset(self::METHODS_RETURN[$name])) { |
847 | 847 | return $response->result; |
848 | 848 | } |
@@ -861,13 +861,13 @@ discard block |
||
861 | 861 | $defaults = self::METHODS_EXTRA_DEFAULTS[$name]; |
862 | 862 | foreach ($defaults as $key => $default) { |
863 | 863 | if (is_numeric($key)) { |
864 | - if (!isset($arguments[$default])){ |
|
864 | + if (!isset($arguments[$default])) { |
|
865 | 865 | $arguments[$default] = self::catchFields($default); |
866 | 866 | } |
867 | 867 | } |
868 | 868 | elseif (isset(BPT::$update->$key) || $key === 'other') { |
869 | 869 | foreach ($default as $def) { |
870 | - if (!isset($arguments[$def])){ |
|
870 | + if (!isset($arguments[$def])) { |
|
871 | 871 | $arguments[$def] = self::catchFields($def); |
872 | 872 | } |
873 | 873 | } |
@@ -880,13 +880,13 @@ discard block |
||
880 | 880 | self::$status = $response->ok; |
881 | 881 | self::$pure_response = $response; |
882 | 882 | if (!$response->ok) { |
883 | - logger::write("Telegram $name method failed : " . json_encode($response), loggerTypes::WARNING); |
|
883 | + logger::write("Telegram $name method failed : ".json_encode($response), loggerTypes::WARNING); |
|
884 | 884 | return new responseError($response); |
885 | 885 | } |
886 | - return self::methodReturn($name,$response); |
|
886 | + return self::methodReturn($name, $response); |
|
887 | 887 | } |
888 | 888 | |
889 | - private static function cleanArguments (array &$arguments): void { |
|
889 | + private static function cleanArguments(array &$arguments): void { |
|
890 | 890 | foreach ($arguments as $key => $argument) { |
891 | 891 | if ($argument == [] || $argument === null) { |
892 | 892 | unset($arguments[$key]); |
@@ -900,7 +900,7 @@ discard block |
||
900 | 900 | * |
901 | 901 | * @return int|string|bool |
902 | 902 | */ |
903 | - public static function catchFields (string $field): int|string|bool { |
|
903 | + public static function catchFields(string $field): int | string | bool { |
|
904 | 904 | switch ($field) { |
905 | 905 | case fields::CHAT_ID : |
906 | 906 | case fields::FROM_CHAT_ID : |
@@ -1036,13 +1036,13 @@ discard block |
||
1036 | 1036 | default => false |
1037 | 1037 | }; |
1038 | 1038 | case fields::URL : |
1039 | - return 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; |
|
1039 | + return 'https://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; |
|
1040 | 1040 | default: |
1041 | 1041 | return false; |
1042 | 1042 | } |
1043 | 1043 | } |
1044 | 1044 | |
1045 | - public static function fileLink (string|null $file_id = null): bool|string { |
|
1045 | + public static function fileLink(string | null $file_id = null): bool | string { |
|
1046 | 1046 | $file = request::getFile($file_id); |
1047 | 1047 | if (!isset($file->file_path)) { |
1048 | 1048 | return false; |
@@ -1064,7 +1064,7 @@ discard block |
||
1064 | 1064 | * |
1065 | 1065 | * @return bool |
1066 | 1066 | */ |
1067 | - public static function downloadFile (string|null $destination = null, string|null $file_id = null): bool { |
|
1067 | + public static function downloadFile(string | null $destination = null, string | null $file_id = null): bool { |
|
1068 | 1068 | return tools::downloadFile(self::fileLink($file_id), $destination); |
1069 | 1069 | } |
1070 | 1070 | |
@@ -1082,7 +1082,7 @@ discard block |
||
1082 | 1082 | * |
1083 | 1083 | * @return message|bool|responseError |
1084 | 1084 | */ |
1085 | - 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 { |
|
1085 | + 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 { |
|
1086 | 1086 | $type = tools::fileType($file_id); |
1087 | 1087 | return match ($type) { |
1088 | 1088 | fileTypes::VIDEO => request::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), |
@@ -6,7 +6,7 @@ |
||
6 | 6 | * telegram class , Adding normal method call to request class and a simple name for being easy to call |
7 | 7 | */ |
8 | 8 | class telegram extends request { |
9 | - public function __call (string $name, array $arguments) { |
|
9 | + public function __call(string $name, array $arguments) { |
|
10 | 10 | return request::$name(...$arguments); |
11 | 11 | } |
12 | 12 | } |
13 | 13 | \ No newline at end of file |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | /** |
21 | 21 | * @internal Only for BPT self usage , Don't use it in your source! |
22 | 22 | */ |
23 | - public static function init () { |
|
23 | + public static function init() { |
|
24 | 24 | if (settings::$multi) { |
25 | 25 | multi::init(); |
26 | 26 | } |
@@ -52,24 +52,24 @@ discard block |
||
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | - protected static function setWebhook(string $url,string $secret = '') { |
|
55 | + protected static function setWebhook(string $url, string $secret = '') { |
|
56 | 56 | $res = telegram::setWebhook($url, settings::$certificate, max_connections: settings::$max_connection, allowed_updates: settings::$allowed_updates, drop_pending_updates: settings::$skip_old_updates, secret_token: $secret); |
57 | 57 | if (!telegram::$status) { |
58 | - logger::write("There is some problem happened , telegram response : \n".json_encode($res),loggerTypes::ERROR); |
|
59 | - BPT::exit(print_r($res,true)); |
|
58 | + logger::write("There is some problem happened , telegram response : \n".json_encode($res), loggerTypes::ERROR); |
|
59 | + BPT::exit(print_r($res, true)); |
|
60 | 60 | } |
61 | - logger::write('Webhook was set successfully',loggerTypes::INFO); |
|
61 | + logger::write('Webhook was set successfully', loggerTypes::INFO); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | protected static function checkURL() { |
65 | 65 | if (!(isset($_SERVER['SERVER_NAME']) && isset($_SERVER['REQUEST_URI']))) { |
66 | - logger::write('For using webhook receiver , you should open this file in your webserver(by domain)',loggerTypes::ERROR); |
|
66 | + logger::write('For using webhook receiver , you should open this file in your webserver(by domain)', loggerTypes::ERROR); |
|
67 | 67 | throw new bptException('WEBHOOK_NEED_URL'); |
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
71 | 71 | private static function setURL(): string { |
72 | - return (isset(settings::$certificate) ? 'http://' : 'https://') . $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME']; |
|
72 | + return (isset(settings::$certificate) ? 'http://' : 'https://').$_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME']; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | protected static function setCertificate() { |
@@ -92,15 +92,15 @@ discard block |
||
92 | 92 | self::setCertificate(); |
93 | 93 | $url = self::setURL(); |
94 | 94 | $secret = !empty(settings::$secret) ? settings::$secret : tools::randomString(64); |
95 | - self::setWebhook($url,$secret); |
|
96 | - lock::save('BPT-HOOK',$secret); |
|
95 | + self::setWebhook($url, $secret); |
|
96 | + lock::save('BPT-HOOK', $secret); |
|
97 | 97 | BPT::exit('Done'); |
98 | 98 | } |
99 | 99 | |
100 | 100 | private static function checkSecret() { |
101 | 101 | $secret = lock::read('BPT-HOOK'); |
102 | 102 | if ($secret !== self::getSecret()) { |
103 | - logger::write('This is not webhook set by BPT, webhook will reset',loggerTypes::WARNING); |
|
103 | + logger::write('This is not webhook set by BPT, webhook will reset', loggerTypes::WARNING); |
|
104 | 104 | self::processSetWebhook(); |
105 | 105 | } |
106 | 106 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * |
119 | 119 | * @return bool |
120 | 120 | */ |
121 | - public static function fastClose (int $timeout = 86400): bool { |
|
121 | + public static function fastClose(int $timeout = 86400): bool { |
|
122 | 122 | if (settings::$multi || !lock::exist('BPT-HOOK') || settings::$receiver !== \BPT\constants\receiver::WEBHOOK) { |
123 | 123 | return false; |
124 | 124 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | /** |
28 | 28 | * If you want to use it in standalone mode , you MUST set `auto_process` to `false` |
29 | 29 | */ |
30 | - public static function init (string $host = 'localhost', string $username = 'root', string $password = '', string $dbname = '', bool $auto_process = null, int $port = 3306): void { |
|
30 | + public static function init(string $host = 'localhost', string $username = 'root', string $password = '', string $dbname = '', bool $auto_process = null, int $port = 3306): void { |
|
31 | 31 | $host = settings::$db['host'] ?? $host; |
32 | 32 | $port = settings::$db['port'] ?? $port; |
33 | 33 | $user = settings::$db['user'] ?? settings::$db['username'] ?? $username; |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $dbname = settings::$db['dbname'] ?? $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 | |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | * |
187 | 187 | * @return string |
188 | 188 | */ |
189 | - public static function error (): string { |
|
189 | + public static function error(): string { |
|
190 | 190 | return self::$connection->error; |
191 | 191 | } |
192 | 192 | |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * |
196 | 196 | * @return int |
197 | 197 | */ |
198 | - public static function errno (): int { |
|
198 | + public static function errno(): int { |
|
199 | 199 | return self::$connection->errno; |
200 | 200 | } |
201 | 201 | |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | * |
207 | 207 | * @return bool |
208 | 208 | */ |
209 | - public static function setCharset (string $charset): bool { |
|
209 | + public static function setCharset(string $charset): bool { |
|
210 | 210 | return self::$connection->set_charset($charset); |
211 | 211 | } |
212 | 212 | |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @return mysqli_result|bool |
223 | 223 | */ |
224 | - public static function pureQuery (string $query): mysqli_result|bool { |
|
224 | + public static function pureQuery(string $query): mysqli_result | bool { |
|
225 | 225 | return self::$connection->query($query); |
226 | 226 | } |
227 | 227 | |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * |
243 | 243 | * @return mysqli_result|bool |
244 | 244 | */ |
245 | - public static function query (string $query, array $vars = [], bool $need_result = true): mysqli_result|bool { |
|
245 | + public static function query(string $query, array $vars = [], bool $need_result = true): mysqli_result | bool { |
|
246 | 246 | if (empty($vars)) { |
247 | 247 | return self::pureQuery($query); |
248 | 248 | } |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | $types .= 's'; |
260 | 260 | } |
261 | 261 | } |
262 | - $prepare->bind_param($types,...$vars); |
|
262 | + $prepare->bind_param($types, ...$vars); |
|
263 | 263 | if (!$prepare->execute()) { |
264 | 264 | logger::write(loggerTypes::WARNING, $prepare->error); |
265 | 265 | return false; |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | return $need_result ? $prepare->get_result() : true; |
268 | 268 | } |
269 | 269 | |
270 | - private static function makeArrayReady (string &$query, array $array, string $operator = ' AND ', bool $is_update = false): array { |
|
270 | + private static function makeArrayReady(string &$query, array $array, string $operator = ' AND ', bool $is_update = false): array { |
|
271 | 271 | $first = true; |
272 | 272 | $values = []; |
273 | 273 | foreach ($array as $name => $value) { |
@@ -277,9 +277,9 @@ discard block |
||
277 | 277 | else { |
278 | 278 | $query .= $operator; |
279 | 279 | } |
280 | - if ($is_update && str_starts_with($value, '.=') && is_numeric(substr($value,2))) { |
|
280 | + if ($is_update && str_starts_with($value, '.=') && is_numeric(substr($value, 2))) { |
|
281 | 281 | $query .= " `$name` = `$name` + ?"; |
282 | - $values[] = substr($value,2); |
|
282 | + $values[] = substr($value, 2); |
|
283 | 283 | } |
284 | 284 | else { |
285 | 285 | $query .= " `$name` = ?"; |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | return $values; |
291 | 291 | } |
292 | 292 | |
293 | - private static function makeQueryReady (string &$query, array $where = null, int $count = null, int $offset = null): array { |
|
293 | + private static function makeQueryReady(string &$query, array $where = null, int $count = null, int $offset = null): array { |
|
294 | 294 | $values = []; |
295 | 295 | if (!empty($where)) { |
296 | 296 | $query .= " WHERE"; |
@@ -322,8 +322,8 @@ discard block |
||
322 | 322 | $query .= ' AND'; |
323 | 323 | } |
324 | 324 | |
325 | - $operator = substr($value,0,2); |
|
326 | - $operator_value = substr($value,2); |
|
325 | + $operator = substr($value, 0, 2); |
|
326 | + $operator_value = substr($value, 2); |
|
327 | 327 | switch ($operator) { |
328 | 328 | case '>=': |
329 | 329 | $query .= " `$name` >= ?"; |
@@ -360,17 +360,17 @@ discard block |
||
360 | 360 | return $values; |
361 | 361 | } |
362 | 362 | |
363 | - private static function groupByBuilder(string &$query, string|array $group_by = []): void { |
|
363 | + private static function groupByBuilder(string &$query, string | array $group_by = []): void { |
|
364 | 364 | if (empty($group_by)) { |
365 | 365 | return; |
366 | 366 | } |
367 | 367 | if (is_string($group_by)) { |
368 | 368 | $group_by = [$group_by]; |
369 | 369 | } |
370 | - $query .= ' GROUP BY `' . implode('`, `',$group_by) . '`'; |
|
370 | + $query .= ' GROUP BY `'.implode('`, `', $group_by).'`'; |
|
371 | 371 | } |
372 | 372 | |
373 | - private static function orderByBuilder(string &$query, string|array $order_by = []): void { |
|
373 | + private static function orderByBuilder(string &$query, string | array $order_by = []): void { |
|
374 | 374 | if (empty($order_by)) { |
375 | 375 | return; |
376 | 376 | } |
@@ -417,8 +417,8 @@ discard block |
||
417 | 417 | $query .= ' ,'; |
418 | 418 | } |
419 | 419 | |
420 | - $operator = substr($value,0,2); |
|
421 | - $operator_value = substr($value,2); |
|
420 | + $operator = substr($value, 0, 2); |
|
421 | + $operator_value = substr($value, 2); |
|
422 | 422 | switch ($operator) { |
423 | 423 | case '+=': |
424 | 424 | $query .= " `$name` = `$name` + ?"; |
@@ -451,19 +451,19 @@ discard block |
||
451 | 451 | return $values; |
452 | 452 | } |
453 | 453 | |
454 | - private static function insertBuilder(string &$query, string|array $columns, array|string $values): array { |
|
455 | - $query .= '(`' . (is_string($columns) ? $columns : implode('`,`', $columns)) . '`) VALUES ('; |
|
454 | + private static function insertBuilder(string &$query, string | array $columns, array | string $values): array { |
|
455 | + $query .= '(`'.(is_string($columns) ? $columns : implode('`,`', $columns)).'`) VALUES ('; |
|
456 | 456 | if (is_string($values)) $values = [$values]; |
457 | - $query .= '?' . str_repeat(',?', count($values) - 1) . ')'; |
|
457 | + $query .= '?'.str_repeat(',?', count($values) - 1).')'; |
|
458 | 458 | return $values; |
459 | 459 | } |
460 | 460 | |
461 | - private static function selectBuilder(string &$query, string|array $columns): void { |
|
461 | + private static function selectBuilder(string &$query, string | array $columns): void { |
|
462 | 462 | if ($columns == '*') { |
463 | 463 | $query .= " * "; |
464 | 464 | } |
465 | 465 | else { |
466 | - $query .= ' `' . (is_string($columns) ? $columns : implode('`,`', $columns)) . '` '; |
|
466 | + $query .= ' `'.(is_string($columns) ? $columns : implode('`,`', $columns)).'` '; |
|
467 | 467 | } |
468 | 468 | } |
469 | 469 | |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | * |
480 | 480 | * @return mysqli_result|bool |
481 | 481 | */ |
482 | - public static function delete (string $table, array $where = null, int $count = null, int $offset = null): bool { |
|
482 | + public static function delete(string $table, array $where = null, int $count = null, int $offset = null): bool { |
|
483 | 483 | $query = "DELETE FROM `$table`"; |
484 | 484 | $vars = self::whereBuilder($query, $where); |
485 | 485 | return self::query($query, $vars, false); |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | * |
499 | 499 | * @return mysqli_result|bool |
500 | 500 | */ |
501 | - public static function update (string $table, array $modify, array $where = null, int $count = null, int $offset = null): bool { |
|
501 | + public static function update(string $table, array $modify, array $where = null, int $count = null, int $offset = null): bool { |
|
502 | 502 | $query = "UPDATE `$table` SET"; |
503 | 503 | $modify_vars = self::updateBuilder($query, $modify); |
504 | 504 | $where_vars = self::whereBuilder($query, $where); |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | * |
518 | 518 | * @return mysqli_result|bool |
519 | 519 | */ |
520 | - public static function insert (string $table, string|array $columns, array|string $values): bool { |
|
520 | + public static function insert(string $table, string | array $columns, array | string $values): bool { |
|
521 | 521 | $query = "INSERT INTO `$table`"; |
522 | 522 | $values = self::insertBuilder($query, $columns, $values); |
523 | 523 | return self::query($query, $values, false); |
@@ -540,14 +540,14 @@ discard block |
||
540 | 540 | * |
541 | 541 | * @return mysqli_result|bool |
542 | 542 | */ |
543 | - public static function select (string $table, array|string $columns = '*', array $where = null, int $count = null, int $offset = null, array|string $group_by = [], array|string $order_by = []): mysqli_result|bool { |
|
543 | + public static function select(string $table, array | string $columns = '*', array $where = null, int $count = null, int $offset = null, array | string $group_by = [], array | string $order_by = []): mysqli_result | bool { |
|
544 | 544 | $query = "SELECT"; |
545 | 545 | self::selectBuilder($query, $columns); |
546 | 546 | $query .= "FROM `$table`"; |
547 | - $var = self::whereBuilder($query,$where); |
|
547 | + $var = self::whereBuilder($query, $where); |
|
548 | 548 | self::groupByBuilder($query, $group_by); |
549 | 549 | self::orderByBuilder($query, $order_by); |
550 | - self::countBuilder($query,$count,$offset); |
|
550 | + self::countBuilder($query, $count, $offset); |
|
551 | 551 | return self::query($query, $var); |
552 | 552 | } |
553 | 553 | |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | * |
563 | 563 | * @return null|bool|array |
564 | 564 | */ |
565 | - public static function selectArray (string $table, array|string $columns = '*', array $where = null): bool|array|null { |
|
565 | + public static function selectArray(string $table, array | string $columns = '*', array $where = null): bool | array | null { |
|
566 | 566 | $res = self::select($table, $columns, $where, 1); |
567 | 567 | if ($res) { |
568 | 568 | return $res->fetch_assoc(); |
@@ -579,7 +579,7 @@ discard block |
||
579 | 579 | * @param array|string $columns sets column that you want to retrieve , set '*' to retrieve all , default : '*' |
580 | 580 | * @param array|null $where Set your ifs default : null |
581 | 581 | */ |
582 | - public static function selectObject (string $table, array|string $columns = '*', array $where = null) { |
|
582 | + public static function selectObject(string $table, array | string $columns = '*', array $where = null) { |
|
583 | 583 | $res = self::select($table, $columns, $where, 1); |
584 | 584 | if ($res) { |
585 | 585 | return $res->fetch_object(); |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | * |
602 | 602 | * @return bool|Generator |
603 | 603 | */ |
604 | - public static function selectEach (string $table, array|string $columns = '*', array $where = null, int $count = null, int $offset = null): bool|Generator { |
|
604 | + public static function selectEach(string $table, array | string $columns = '*', array $where = null, int $count = null, int $offset = null): bool | Generator { |
|
605 | 605 | $res = self::select($table, $columns, $where, $count, $offset); |
606 | 606 | if ($res) { |
607 | 607 | while ($row = $res->fetch_assoc()) yield $row; |
@@ -619,21 +619,21 @@ discard block |
||
619 | 619 | * |
620 | 620 | * @return string if save is true , return file name otherwise return sql data |
621 | 621 | */ |
622 | - public static function backup (array $wanted_tables = null, bool $table_data = true, bool $save = true, string $file_name = ''): string { |
|
622 | + public static function backup(array $wanted_tables = null, bool $table_data = true, bool $save = true, string $file_name = ''): string { |
|
623 | 623 | self::setCharset('utf8mb4'); |
624 | - $tables = array_column(self::query('SHOW TABLES')->fetch_all(),0); |
|
624 | + $tables = array_column(self::query('SHOW TABLES')->fetch_all(), 0); |
|
625 | 625 | if (!empty($wanted_tables)) { |
626 | 626 | $tables = array_intersect($tables, $wanted_tables); |
627 | 627 | } |
628 | 628 | $sql = ''; |
629 | 629 | foreach ($tables as $table) { |
630 | - $sql .= self::query("SHOW CREATE TABLE `$table`")->fetch_row()[1] . ";\n\n"; |
|
630 | + $sql .= self::query("SHOW CREATE TABLE `$table`")->fetch_row()[1].";\n\n"; |
|
631 | 631 | |
632 | 632 | if ($table_data) { |
633 | 633 | $total_rows = self::query("SELECT COUNT(*) as `cnt` FROM `$table`")->fetch_object()->cnt; |
634 | 634 | for ($i = 0; $i < $total_rows; $i = $i + 1000) { |
635 | - $sql .= "INSERT INTO " . $table . " VALUES"; |
|
636 | - $result = self::select($table, '*' , null, 1000, $i); |
|
635 | + $sql .= "INSERT INTO ".$table." VALUES"; |
|
636 | + $result = self::select($table, '*', null, 1000, $i); |
|
637 | 637 | $field_count = $result->field_count; |
638 | 638 | $affected_rows = self::affected_rows(); |
639 | 639 | $counter = 1; |
@@ -641,12 +641,12 @@ discard block |
||
641 | 641 | $sql .= "\n("; |
642 | 642 | for ($column = 0; $column < $field_count; $column++) { |
643 | 643 | $row[$column] = str_replace("\n", "\\n", addslashes($row[$column])); |
644 | - $sql .= !empty($row[$column]) ? '"' . $row[$column] . '"' : '""'; |
|
644 | + $sql .= !empty($row[$column]) ? '"'.$row[$column].'"' : '""'; |
|
645 | 645 | if ($column < $field_count - 1) { |
646 | 646 | $sql .= ','; |
647 | 647 | } |
648 | 648 | } |
649 | - $sql .= ')' . ($counter == $affected_rows ? ';' : ','); |
|
649 | + $sql .= ')'.($counter == $affected_rows ? ';' : ','); |
|
650 | 650 | $counter++; |
651 | 651 | } |
652 | 652 | } |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | return $sql; |
661 | 661 | } |
662 | 662 | if (empty($file_name)) { |
663 | - $file_name = self::query('SELECT database() as `db_name`')->fetch_object()->db_name . time() . '.sql'; |
|
663 | + $file_name = self::query('SELECT database() as `db_name`')->fetch_object()->db_name.time().'.sql'; |
|
664 | 664 | } |
665 | 665 | file_put_contents($file_name, $sql); |
666 | 666 | return $file_name; |
@@ -271,13 +271,13 @@ discard block |
||
271 | 271 | * @method bool downloadFile(string|null $destination = null, string|null $file_id = null) download file by file_id and save it to destination |
272 | 272 | * @method message|bool|responseError 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) send file only with file_id |
273 | 273 | */ |
274 | -class BPT extends telegram{ |
|
274 | +class BPT extends telegram { |
|
275 | 275 | public static update $update; |
276 | 276 | |
277 | 277 | public static BPT $handler; |
278 | 278 | |
279 | 279 | |
280 | - public function __construct (array|stdClass $settings) { |
|
280 | + public function __construct(array | stdClass $settings) { |
|
281 | 281 | static::$handler = &$this; |
282 | 282 | settings::init($settings); |
283 | 283 | } |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | } |
288 | 288 | |
289 | 289 | #[NoReturn] |
290 | - public static function exit (string|null $message = null) { |
|
290 | + public static function exit (string | null $message = null) { |
|
291 | 291 | die($message ?? "<div style='width:98vw;height:98vh;display:flex;justify-content:center;align-items:center;font-size:25vw'>BPT</div>"); |
292 | 292 | } |
293 | 293 | } |