@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @return bool |
37 | 37 | */ |
38 | - public static function isUsername (string $username): bool { |
|
38 | + public static function isUsername(string $username): bool { |
|
39 | 39 | $length = strlen($username); |
40 | 40 | return !str_contains($username, '__') && $length >= 5 && $length <= 33 && preg_match('/^@?([a-zA-Z])(\w{4,31})$/', $username); |
41 | 41 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return bool |
54 | 54 | */ |
55 | - public static function ipInRange (string $ip, string $range): bool { |
|
55 | + public static function ipInRange(string $ip, string $range): bool { |
|
56 | 56 | if (!str_contains($range, '/')) { |
57 | 57 | $range .= '/32'; |
58 | 58 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @return bool |
74 | 74 | */ |
75 | - public static function isTelegram (string $ip): bool { |
|
75 | + public static function isTelegram(string $ip): bool { |
|
76 | 76 | return self::ipInRange($ip, '149.154.160.0/20') || self::ipInRange($ip, '91.108.4.0/22'); |
77 | 77 | } |
78 | 78 | |
@@ -87,10 +87,10 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @return bool |
89 | 89 | */ |
90 | - public static function isCloudFlare (string $ip): bool { |
|
90 | + public static function isCloudFlare(string $ip): bool { |
|
91 | 91 | $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', '172.64.0.0/13', '131.0.72.0/22']; |
92 | 92 | foreach ($cf_ips as $cf_ip) { |
93 | - if (self::ipInRange($ip,$cf_ip)) { |
|
93 | + if (self::ipInRange($ip, $cf_ip)) { |
|
94 | 94 | return true; |
95 | 95 | } |
96 | 96 | } |
@@ -110,9 +110,9 @@ discard block |
||
110 | 110 | * |
111 | 111 | * @return bool|types\user return array when verify is active and token is true array of telegram getMe result |
112 | 112 | */ |
113 | - public static function isToken (string $token, bool $verify = false): bool|types\user { |
|
113 | + public static function isToken(string $token, bool $verify = false): bool | types\user { |
|
114 | 114 | if (preg_match('/^(\d{8,10}):[\w\-]{35}$/', $token)) { |
115 | - if ($verify){ |
|
115 | + if ($verify) { |
|
116 | 116 | $res = telegram::me($token); |
117 | 117 | if (telegram::$status) { |
118 | 118 | return $res; |
@@ -144,14 +144,14 @@ discard block |
||
144 | 144 | * |
145 | 145 | * @return bool |
146 | 146 | */ |
147 | - public static function isJoined (array|string|int $ids , int|null $user_id = null): bool { |
|
147 | + public static function isJoined(array | string | int $ids, int | null $user_id = null): bool { |
|
148 | 148 | if (!is_array($ids)) { |
149 | 149 | $ids = [$ids]; |
150 | 150 | } |
151 | 151 | $user_id = $user_id ?? request::catchFields('user_id'); |
152 | 152 | |
153 | 153 | foreach ($ids as $id) { |
154 | - $check = telegram::getChatMember($id,$user_id); |
|
154 | + $check = telegram::getChatMember($id, $user_id); |
|
155 | 155 | if (telegram::$status) { |
156 | 156 | $check = $check->status; |
157 | 157 | if ($check === chatMemberStatus::LEFT || $check === chatMemberStatus::KICKED) { |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | * |
179 | 179 | * @return array keys will be id and values will be bool(null for not founded ids) |
180 | 180 | */ |
181 | - public static function joinChecker (array|string|int $ids , int|null $user_id = null): array { |
|
181 | + public static function joinChecker(array | string | int $ids, int | null $user_id = null): array { |
|
182 | 182 | if (!is_array($ids)) { |
183 | 183 | $ids = [$ids]; |
184 | 184 | } |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | |
187 | 187 | $result = []; |
188 | 188 | foreach ($ids as $id) { |
189 | - $check = telegram::getChatMember($id,$user_id); |
|
189 | + $check = telegram::getChatMember($id, $user_id); |
|
190 | 190 | if (telegram::$status) { |
191 | 191 | $check = $check->status; |
192 | 192 | $result[$id] = $check !== chatMemberStatus::LEFT && $check !== chatMemberStatus::KICKED; |
@@ -210,10 +210,10 @@ discard block |
||
210 | 210 | * |
211 | 211 | * @return string |
212 | 212 | */ |
213 | - public static function randomString (int $length = 16, string $characters = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'): string { |
|
213 | + public static function randomString(int $length = 16, string $characters = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'): string { |
|
214 | 214 | $rand_string = ''; |
215 | 215 | $char_len = strlen($characters) - 1; |
216 | - for ($i = 0; $i < $length; $i ++) { |
|
216 | + for ($i = 0; $i < $length; $i++) { |
|
217 | 217 | $rand_string .= $characters[rand(0, $char_len)]; |
218 | 218 | } |
219 | 219 | return $rand_string; |
@@ -233,10 +233,10 @@ discard block |
||
233 | 233 | * |
234 | 234 | * @return string|false return false when mode is incorrect |
235 | 235 | */ |
236 | - public static function modeEscape (string $text, string $mode = parseMode::HTML): string|false { |
|
236 | + public static function modeEscape(string $text, string $mode = parseMode::HTML): string | false { |
|
237 | 237 | return match ($mode) { |
238 | - parseMode::HTML => str_replace(['&', '<', '>',], ["&", "<", ">",], $text), |
|
239 | - parseMode::MARKDOWN => str_replace(['\\', '_', '*', '`', '['], ['\\\\', '\_', '\*', '\`', '\[',], $text), |
|
238 | + parseMode::HTML => str_replace(['&', '<', '>', ], ["&", "<", ">", ], $text), |
|
239 | + parseMode::MARKDOWN => str_replace(['\\', '_', '*', '`', '['], ['\\\\', '\_', '\*', '\`', '\[', ], $text), |
|
240 | 240 | parseMode::MARKDOWNV2 => str_replace( |
241 | 241 | ['_', '*', '[', ']', '(', ')', '~', '`', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!', '\\'], |
242 | 242 | ['\_', '\*', '\[', '\]', '\(', '\)', '\~', '\`', '\>', '\#', '\+', '\-', '\=', '\|', '\{', '\}', '\.', '\!', '\\\\'], |
@@ -259,10 +259,10 @@ discard block |
||
259 | 259 | * |
260 | 260 | * @return string |
261 | 261 | */ |
262 | - public static function byteFormat (int $byte, int $precision = 2): string { |
|
262 | + public static function byteFormat(int $byte, int $precision = 2): string { |
|
263 | 263 | $rate_counter = 0; |
264 | 264 | |
265 | - while ($byte > 1024){ |
|
265 | + while ($byte > 1024) { |
|
266 | 266 | $byte /= 1024; |
267 | 267 | $rate_counter++; |
268 | 268 | } |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | $byte = round($byte, $precision); |
272 | 272 | } |
273 | 273 | |
274 | - return $byte . ' ' . ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'][$rate_counter]; |
|
274 | + return $byte.' '.['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'][$rate_counter]; |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | /** |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | * |
289 | 289 | * @return string|int|false string for formatted data , int for normal data , false when size can not be found(file not found or ...) |
290 | 290 | */ |
291 | - public static function size (string $path, bool $format = true): string|int|false { |
|
291 | + public static function size(string $path, bool $format = true): string | int | false { |
|
292 | 292 | if (filter_var($path, FILTER_VALIDATE_URL)) { |
293 | 293 | $ch = curl_init($path); |
294 | 294 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | * @return bool |
322 | 322 | * @throws bptException |
323 | 323 | */ |
324 | - public static function delete (string $path, bool $sub = true): bool { |
|
324 | + public static function delete(string $path, bool $sub = true): bool { |
|
325 | 325 | if (is_dir($path)) { |
326 | 326 | if (count(scandir($path)) > 2) { |
327 | 327 | if ($sub) { |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | return rmdir($path); |
334 | 334 | } |
335 | 335 | else { |
336 | - logger::write("tools::delete function used\ndelete function cannot delete folder because its have subFiles and sub parameter haven't true value",loggerTypes::ERROR); |
|
336 | + logger::write("tools::delete function used\ndelete function cannot delete folder because its have subFiles and sub parameter haven't true value", loggerTypes::ERROR); |
|
337 | 337 | throw new bptException('DELETE_FOLDER_HAS_SUB'); |
338 | 338 | } |
339 | 339 | } |
@@ -357,12 +357,12 @@ discard block |
||
357 | 357 | * @return array{status: string,year: string,month: string,day: string,hour: string,minute: string,second: string} |
358 | 358 | * @throws Exception |
359 | 359 | */ |
360 | - public static function timeDiff (int|string $target_time, int|string|null $base_time = null): array { |
|
360 | + public static function timeDiff(int | string $target_time, int | string | null $base_time = null): array { |
|
361 | 361 | if (empty($base_time)) { |
362 | 362 | $base_time = '@'.time(); |
363 | 363 | } |
364 | 364 | $base_time = new DateTime($base_time); |
365 | - $target_time = new DateTime(is_numeric($target_time) ? '@' . $target_time : $target_time . ' +00:00'); |
|
365 | + $target_time = new DateTime(is_numeric($target_time) ? '@'.$target_time : $target_time.' +00:00'); |
|
366 | 366 | |
367 | 367 | $status = $base_time < $target_time ? 'later' : 'ago'; |
368 | 368 | $diff = $base_time->diff($target_time); |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | * @return array|string|bool |
416 | 416 | * @throws bptException |
417 | 417 | */ |
418 | - public static function crypto (string $action, string $text, string $key = null, string $iv = null): bool|array|string { |
|
418 | + public static function crypto(string $action, string $text, string $key = null, string $iv = null): bool | array | string { |
|
419 | 419 | |
420 | 420 | if (extension_loaded('openssl')) { |
421 | 421 | if ($action === cryptoAction::ENCRYPT) { |
@@ -426,11 +426,11 @@ discard block |
||
426 | 426 | } |
427 | 427 | elseif ($action === cryptoAction::DECRYPT) { |
428 | 428 | if (empty($key)) { |
429 | - logger::write("tools::crypto function used\nkey parameter is not set",loggerTypes::ERROR); |
|
429 | + logger::write("tools::crypto function used\nkey parameter is not set", loggerTypes::ERROR); |
|
430 | 430 | throw new bptException('ARGUMENT_NOT_FOUND_KEY'); |
431 | 431 | } |
432 | 432 | if (empty($iv)) { |
433 | - logger::write("tools::crypto function used\niv parameter is not set",loggerTypes::ERROR); |
|
433 | + logger::write("tools::crypto function used\niv parameter is not set", loggerTypes::ERROR); |
|
434 | 434 | throw new bptException('ARGUMENT_NOT_FOUND_IV'); |
435 | 435 | } |
436 | 436 | return openssl_decrypt(base64_decode($text), 'AES-256-CBC', $key, 1, $iv); |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | } |
442 | 442 | } |
443 | 443 | else { |
444 | - logger::write("tools::crypto function used\nopenssl extension is not found , It may not be installed or enabled",loggerTypes::ERROR); |
|
444 | + logger::write("tools::crypto function used\nopenssl extension is not found , It may not be installed or enabled", loggerTypes::ERROR); |
|
445 | 445 | throw new bptException('OPENSSL_EXTENSION_MISSING'); |
446 | 446 | } |
447 | 447 | } |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | * @return bool |
460 | 460 | * @throws bptException when zip extension not found |
461 | 461 | */ |
462 | - public static function zip (string $path, string $destination, bool $self = true, bool $sub_folder = true): bool { |
|
462 | + public static function zip(string $path, string $destination, bool $self = true, bool $sub_folder = true): bool { |
|
463 | 463 | if (extension_loaded('zip')) { |
464 | 464 | if (file_exists($destination)) unlink($destination); |
465 | 465 | |
@@ -467,15 +467,15 @@ discard block |
||
467 | 467 | $zip = new ZipArchive(); |
468 | 468 | $zip->open($destination, ZipArchive::CREATE); |
469 | 469 | |
470 | - if (is_dir($path)){ |
|
471 | - if ($self){ |
|
472 | - $dirs = explode('\\',$path); |
|
470 | + if (is_dir($path)) { |
|
471 | + if ($self) { |
|
472 | + $dirs = explode('\\', $path); |
|
473 | 473 | $dir_count = count($dirs); |
474 | - $main_dir = $dirs[$dir_count-1]; |
|
474 | + $main_dir = $dirs[$dir_count - 1]; |
|
475 | 475 | |
476 | 476 | $path = ''; |
477 | - for ($i=0; $i < $dir_count - 1; $i++) { |
|
478 | - $path .= '\\' . $dirs[$i]; |
|
477 | + for ($i = 0; $i < $dir_count - 1; $i++) { |
|
478 | + $path .= '\\'.$dirs[$i]; |
|
479 | 479 | } |
480 | 480 | $path = substr($path, 1); |
481 | 481 | $zip->addEmptyDir($main_dir); |
@@ -484,27 +484,27 @@ discard block |
||
484 | 484 | $it = new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS); |
485 | 485 | $files = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::SELF_FIRST); |
486 | 486 | foreach ($files as $file) { |
487 | - if ($file->isFile()){ |
|
488 | - if ($sub_folder){ |
|
489 | - $zip->addFile($file, str_replace($path . '\\', '', $file)); |
|
487 | + if ($file->isFile()) { |
|
488 | + if ($sub_folder) { |
|
489 | + $zip->addFile($file, str_replace($path.'\\', '', $file)); |
|
490 | 490 | } |
491 | - else{ |
|
491 | + else { |
|
492 | 492 | $zip->addFile($file, basename($file)); |
493 | 493 | } |
494 | 494 | } |
495 | 495 | elseif ($file->isDir() && $sub_folder) { |
496 | - $zip->addEmptyDir(str_replace($path . '\\', '', $file . '\\')); |
|
496 | + $zip->addEmptyDir(str_replace($path.'\\', '', $file.'\\')); |
|
497 | 497 | } |
498 | 498 | } |
499 | 499 | } |
500 | - else{ |
|
500 | + else { |
|
501 | 501 | $zip->addFile($path, basename($path)); |
502 | 502 | } |
503 | 503 | |
504 | 504 | return $zip->close(); |
505 | 505 | } |
506 | 506 | else { |
507 | - logger::write("tools::zip function used\nzip extension is not found , It may not be installed or enabled",loggerTypes::ERROR); |
|
507 | + logger::write("tools::zip function used\nzip extension is not found , It may not be installed or enabled", loggerTypes::ERROR); |
|
508 | 508 | throw new bptException('ZIP_EXTENSION_MISSING'); |
509 | 509 | } |
510 | 510 | } |
@@ -532,12 +532,12 @@ discard block |
||
532 | 532 | * @return inlineKeyboardMarkup|replyKeyboardMarkup replyKeyboardMarkup for keyboard and inlineKeyboardMarkup for inline |
533 | 533 | * @throws exception |
534 | 534 | */ |
535 | - public static function easyKey(array $keyboard = [], array $inline = []): inlineKeyboardMarkup|replyKeyboardMarkup { |
|
535 | + public static function easyKey(array $keyboard = [], array $inline = []): inlineKeyboardMarkup | replyKeyboardMarkup { |
|
536 | 536 | if (!empty($keyboard)) { |
537 | 537 | $keyboard_object = new replyKeyboardMarkup(); |
538 | 538 | $keyboard_object->setResize_keyboard($keyboard['resize'] ?? true); |
539 | 539 | if (isset($keyboard['one_time'])) { |
540 | - $keyboard_object->setOne_time_keyboard($keyboard['one_time']) ; |
|
540 | + $keyboard_object->setOne_time_keyboard($keyboard['one_time']); |
|
541 | 541 | } |
542 | 542 | foreach ($keyboard as $row) { |
543 | 543 | $buttons = []; |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | return $keyboard_object; |
591 | 591 | } |
592 | 592 | else { |
593 | - logger::write("tools::eKey function used\nkeyboard or inline parameter must be set",loggerTypes::ERROR); |
|
593 | + logger::write("tools::eKey function used\nkeyboard or inline parameter must be set", loggerTypes::ERROR); |
|
594 | 594 | throw new bptException('ARGUMENT_NOT_FOUND_KEYBOARD_INLINE'); |
595 | 595 | } |
596 | 596 | } |
@@ -190,8 +190,9 @@ discard block |
||
190 | 190 | if (telegram::$status) { |
191 | 191 | $check = $check->status; |
192 | 192 | $result[$id] = $check !== chatMemberStatus::LEFT && $check !== chatMemberStatus::KICKED; |
193 | - } |
|
194 | - else $result[$id] = null; |
|
193 | + } else { |
|
194 | + $result[$id] = null; |
|
195 | + } |
|
195 | 196 | } |
196 | 197 | return $result; |
197 | 198 | } |
@@ -297,15 +298,15 @@ discard block |
||
297 | 298 | curl_exec($ch); |
298 | 299 | $size = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD); |
299 | 300 | curl_close($ch); |
300 | - } |
|
301 | - else { |
|
301 | + } else { |
|
302 | 302 | $size = file_exists($path) ? filesize($path) : false; |
303 | 303 | } |
304 | 304 | |
305 | 305 | if (isset($size) && is_numeric($size)) { |
306 | 306 | return $format ? tools::byteFormat($size) : $size; |
307 | - } |
|
308 | - else return false; |
|
307 | + } else { |
|
308 | + return false; |
|
309 | + } |
|
309 | 310 | } |
310 | 311 | |
311 | 312 | /** |
@@ -331,15 +332,16 @@ discard block |
||
331 | 332 | $file->isDir() ? rmdir($file->getRealPath()) : unlink($file->getRealPath()); |
332 | 333 | } |
333 | 334 | return rmdir($path); |
334 | - } |
|
335 | - else { |
|
335 | + } else { |
|
336 | 336 | logger::write("tools::delete function used\ndelete function cannot delete folder because its have subFiles and sub parameter haven't true value",loggerTypes::ERROR); |
337 | 337 | throw new bptException('DELETE_FOLDER_HAS_SUB'); |
338 | 338 | } |
339 | - } |
|
340 | - else return rmdir($path); |
|
341 | - } |
|
342 | - else return unlink($path); |
|
339 | + } else { |
|
340 | + return rmdir($path); |
|
341 | + } |
|
342 | + } else { |
|
343 | + return unlink($path); |
|
344 | + } |
|
343 | 345 | } |
344 | 346 | |
345 | 347 | /** |
@@ -371,8 +373,9 @@ discard block |
||
371 | 373 | foreach ($string as $k => &$v) { |
372 | 374 | if ($diff->$v) { |
373 | 375 | $v = $diff->$v; |
374 | - } |
|
375 | - else unset($string[$k]); |
|
376 | + } else { |
|
377 | + unset($string[$k]); |
|
378 | + } |
|
376 | 379 | } |
377 | 380 | $string['status'] = $status; |
378 | 381 | |
@@ -423,8 +426,7 @@ discard block |
||
423 | 426 | $iv = self::randomString(); |
424 | 427 | $output = base64_encode(openssl_encrypt($text, 'AES-256-CBC', $key, 1, $iv)); |
425 | 428 | return ['hash' => $output, 'key' => $key, 'iv' => $iv]; |
426 | - } |
|
427 | - elseif ($action === cryptoAction::DECRYPT) { |
|
429 | + } elseif ($action === cryptoAction::DECRYPT) { |
|
428 | 430 | if (empty($key)) { |
429 | 431 | logger::write("tools::crypto function used\nkey parameter is not set",loggerTypes::ERROR); |
430 | 432 | throw new bptException('ARGUMENT_NOT_FOUND_KEY'); |
@@ -434,13 +436,11 @@ discard block |
||
434 | 436 | throw new bptException('ARGUMENT_NOT_FOUND_IV'); |
435 | 437 | } |
436 | 438 | return openssl_decrypt(base64_decode($text), 'AES-256-CBC', $key, 1, $iv); |
437 | - } |
|
438 | - else { |
|
439 | + } else { |
|
439 | 440 | logger::write("tools::crypto function used\naction is not right, its must be `encode` or `decode`"); |
440 | 441 | return false; |
441 | 442 | } |
442 | - } |
|
443 | - else { |
|
443 | + } else { |
|
444 | 444 | logger::write("tools::crypto function used\nopenssl extension is not found , It may not be installed or enabled",loggerTypes::ERROR); |
445 | 445 | throw new bptException('OPENSSL_EXTENSION_MISSING'); |
446 | 446 | } |
@@ -461,7 +461,9 @@ discard block |
||
461 | 461 | */ |
462 | 462 | public static function zip (string $path, string $destination, bool $self = true, bool $sub_folder = true): bool { |
463 | 463 | if (extension_loaded('zip')) { |
464 | - if (file_exists($destination)) unlink($destination); |
|
464 | + if (file_exists($destination)) { |
|
465 | + unlink($destination); |
|
466 | + } |
|
465 | 467 | |
466 | 468 | $path = realpath($path); |
467 | 469 | $zip = new ZipArchive(); |
@@ -487,23 +489,19 @@ discard block |
||
487 | 489 | if ($file->isFile()){ |
488 | 490 | if ($sub_folder){ |
489 | 491 | $zip->addFile($file, str_replace($path . '\\', '', $file)); |
490 | - } |
|
491 | - else{ |
|
492 | + } else{ |
|
492 | 493 | $zip->addFile($file, basename($file)); |
493 | 494 | } |
494 | - } |
|
495 | - elseif ($file->isDir() && $sub_folder) { |
|
495 | + } elseif ($file->isDir() && $sub_folder) { |
|
496 | 496 | $zip->addEmptyDir(str_replace($path . '\\', '', $file . '\\')); |
497 | 497 | } |
498 | 498 | } |
499 | - } |
|
500 | - else{ |
|
499 | + } else{ |
|
501 | 500 | $zip->addFile($path, basename($path)); |
502 | 501 | } |
503 | 502 | |
504 | 503 | return $zip->close(); |
505 | - } |
|
506 | - else { |
|
504 | + } else { |
|
507 | 505 | logger::write("tools::zip function used\nzip extension is not found , It may not be installed or enabled",loggerTypes::ERROR); |
508 | 506 | throw new bptException('ZIP_EXTENSION_MISSING'); |
509 | 507 | } |
@@ -548,15 +546,12 @@ discard block |
||
548 | 546 | if (count($button_info) > 1) { |
549 | 547 | if ($button_info[1] === 'con') { |
550 | 548 | $button->setRequest_contact(true); |
551 | - } |
|
552 | - elseif ($button_info[1] === 'loc') { |
|
549 | + } elseif ($button_info[1] === 'loc') { |
|
553 | 550 | $button->setRequest_location(true); |
554 | - } |
|
555 | - elseif ($button_info[1] === 'poll') { |
|
551 | + } elseif ($button_info[1] === 'poll') { |
|
556 | 552 | $type = $button_info[2] === pollType::QUIZ ? pollType::QUIZ : pollType::REGULAR; |
557 | 553 | $button->setRequest_poll((new keyboardButtonPollType())->setType($type)); |
558 | - } |
|
559 | - elseif ($button_info[1] === 'web' && isset($button_info[2])) { |
|
554 | + } elseif ($button_info[1] === 'web' && isset($button_info[2])) { |
|
560 | 555 | $url = $button_info[2]; |
561 | 556 | $button->setWeb_app((new webAppInfo())->setUrl($url)); |
562 | 557 | } |
@@ -566,8 +561,7 @@ discard block |
||
566 | 561 | $keyboard_object->setKeyboard([$buttons]); |
567 | 562 | } |
568 | 563 | return $keyboard_object; |
569 | - } |
|
570 | - elseif (!empty($inline)) { |
|
564 | + } elseif (!empty($inline)) { |
|
571 | 565 | $keyboard_object = new inlineKeyboardMarkup(); |
572 | 566 | foreach ($inline as $row) { |
573 | 567 | $buttons = []; |
@@ -576,20 +570,17 @@ discard block |
||
576 | 570 | if (isset($button_info[1])) { |
577 | 571 | if (filter_var($button_info[1], FILTER_VALIDATE_URL) && str_starts_with($button_info[1], 'http')) { |
578 | 572 | $button->setText($button_info[0])->setUrl($button_info[1]); |
579 | - } |
|
580 | - else { |
|
573 | + } else { |
|
581 | 574 | $button->setText($button_info[0])->setCallback_data($button_info[1]); |
582 | 575 | } |
583 | - } |
|
584 | - else { |
|
576 | + } else { |
|
585 | 577 | $button->setText($button_info[0])->setUrl('https://t.me/BPT_CH'); |
586 | 578 | } |
587 | 579 | } |
588 | 580 | $keyboard_object->setInline_keyboard([$buttons]); |
589 | 581 | } |
590 | 582 | return $keyboard_object; |
591 | - } |
|
592 | - else { |
|
583 | + } else { |
|
593 | 584 | logger::write("tools::eKey function used\nkeyboard or inline parameter must be set",loggerTypes::ERROR); |
594 | 585 | throw new bptException('ARGUMENT_NOT_FOUND_KEYBOARD_INLINE'); |
595 | 586 | } |