@@ -30,7 +30,7 @@ |
||
| 30 | 30 | public string $post_code; |
| 31 | 31 | |
| 32 | 32 | |
| 33 | - public function __construct(stdClass|null $object = null) { |
|
| 33 | + public function __construct(stdClass | null $object = null) { |
|
| 34 | 34 | if ($object != null) { |
| 35 | 35 | parent::__construct($object, self::subs); |
| 36 | 36 | } |
@@ -79,7 +79,7 @@ |
||
| 79 | 79 | public string $hash; |
| 80 | 80 | |
| 81 | 81 | |
| 82 | - public function __construct(stdClass|null $object = null) { |
|
| 82 | + public function __construct(stdClass | null $object = null) { |
|
| 83 | 83 | if ($object != null) { |
| 84 | 84 | parent::__construct($object, self::subs); |
| 85 | 85 | } |
@@ -48,7 +48,7 @@ |
||
| 48 | 48 | public array $allowed_updates; |
| 49 | 49 | |
| 50 | 50 | |
| 51 | - public function __construct(stdClass|null $object = null) { |
|
| 51 | + public function __construct(stdClass | null $object = null) { |
|
| 52 | 52 | if ($object != null) { |
| 53 | 53 | parent::__construct($object, self::subs); |
| 54 | 54 | } |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | public shippingAddress $shipping_address; |
| 25 | 25 | |
| 26 | 26 | |
| 27 | - public function __construct(stdClass|null $object = null) { |
|
| 27 | + public function __construct(stdClass | null $object = null) { |
|
| 28 | 28 | if ($object != null) { |
| 29 | 29 | parent::__construct($object, self::subs); |
| 30 | 30 | } |
@@ -53,7 +53,7 @@ |
||
| 53 | 53 | public int $duration; |
| 54 | 54 | |
| 55 | 55 | |
| 56 | - public function __construct(stdClass|null $object = null) { |
|
| 56 | + public function __construct(stdClass | null $object = null) { |
|
| 57 | 57 | if ($object != null) { |
| 58 | 58 | parent::__construct($object, self::subs); |
| 59 | 59 | } |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | public int $score; |
| 22 | 22 | |
| 23 | 23 | |
| 24 | - public function __construct(stdClass|null $object = null) { |
|
| 24 | + public function __construct(stdClass | null $object = null) { |
|
| 25 | 25 | if ($object != null) { |
| 26 | 26 | parent::__construct($object, self::subs); |
| 27 | 27 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the |
| 53 | 53 | * thumbnail was uploaded using multipart/form-data under <file_attach_name>. |
| 54 | 54 | */ |
| 55 | - public CURLFile|string $thumb; |
|
| 55 | + public CURLFile | string $thumb; |
|
| 56 | 56 | |
| 57 | 57 | /** `video` and `animation` only. width */ |
| 58 | 58 | public int $width; |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | public bool $disable_content_type_detection; |
| 80 | 80 | |
| 81 | 81 | |
| 82 | - public function __construct(stdClass|null $object = null) { |
|
| 82 | + public function __construct(stdClass | null $object = null) { |
|
| 83 | 83 | if ($object != null) { |
| 84 | 84 | parent::__construct($object, self::subs); |
| 85 | 85 | } |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | use CURLFile; |
| 14 | 14 | |
| 15 | 15 | class webhook extends receiver { |
| 16 | - public static function init () { |
|
| 16 | + public static function init() { |
|
| 17 | 17 | if (settings::$multi) { |
| 18 | 18 | multi::init(); |
| 19 | 19 | } |
@@ -42,26 +42,26 @@ discard block |
||
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - protected static function setWebhook(string $url,string $secret = '') { |
|
| 45 | + protected static function setWebhook(string $url, string $secret = '') { |
|
| 46 | 46 | $res = telegram::setWebhook($url, settings::$certificate, max_connections: settings::$max_connection, allowed_updates: settings::$allowed_updates, drop_pending_updates: settings::$skip_old_updates, secret_token: $secret); |
| 47 | 47 | if (telegram::$status) { |
| 48 | - logger::write('Webhook was set successfully',loggerTypes::INFO); |
|
| 48 | + logger::write('Webhook was set successfully', loggerTypes::INFO); |
|
| 49 | 49 | } |
| 50 | 50 | else { |
| 51 | - logger::write("There is some problem happened , telegram response : \n".json_encode($res),loggerTypes::ERROR); |
|
| 52 | - BPT::exit(print_r($res,true)); |
|
| 51 | + logger::write("There is some problem happened , telegram response : \n".json_encode($res), loggerTypes::ERROR); |
|
| 52 | + BPT::exit(print_r($res, true)); |
|
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | protected static function checkURL() { |
| 57 | 57 | if (!(isset($_SERVER['SERVER_NAME']) && isset($_SERVER['REQUEST_URI']))) { |
| 58 | - logger::write('For using webhook receiver , you should open this file in your webserver(by domain)',loggerTypes::ERROR); |
|
| 58 | + logger::write('For using webhook receiver , you should open this file in your webserver(by domain)', loggerTypes::ERROR); |
|
| 59 | 59 | throw new bptException('WEBHOOK_NEED_URL'); |
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | private static function setURL(): string { |
| 64 | - return (isset(settings::$certificate) ? 'http://' : 'https://') . $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME']; |
|
| 64 | + return (isset(settings::$certificate) ? 'http://' : 'https://').$_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME']; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | protected static function setCertificate() { |
@@ -83,15 +83,15 @@ discard block |
||
| 83 | 83 | self::setCertificate(); |
| 84 | 84 | $url = self::setURL(); |
| 85 | 85 | $secret = settings::$secret ?? tools::randomString(64); |
| 86 | - self::setWebhook($url,$secret); |
|
| 87 | - lock::save('BPT-HOOK',$secret); |
|
| 86 | + self::setWebhook($url, $secret); |
|
| 87 | + lock::save('BPT-HOOK', $secret); |
|
| 88 | 88 | BPT::exit('Done'); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | private static function checkSecret() { |
| 92 | 92 | $secret = lock::read('BPT-HOOK'); |
| 93 | 93 | if ($secret !== self::getSecret()) { |
| 94 | - logger::write('This is not webhook set by BPT, webhook will reset',loggerTypes::WARNING); |
|
| 94 | + logger::write('This is not webhook set by BPT, webhook will reset', loggerTypes::WARNING); |
|
| 95 | 95 | self::processSetWebhook(); |
| 96 | 96 | } |
| 97 | 97 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * |
| 21 | 21 | * @return bool |
| 22 | 22 | */ |
| 23 | - public static function isUsername (string $username): bool { |
|
| 23 | + public static function isUsername(string $username): bool { |
|
| 24 | 24 | $length = strlen($username); |
| 25 | 25 | return !str_contains($username, '__') && $length >= 5 && $length <= 33 && preg_match('/^@?([a-zA-Z])(\w{4,31})$/', $username); |
| 26 | 26 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * |
| 38 | 38 | * @return bool |
| 39 | 39 | */ |
| 40 | - public static function ipInRange (string $ip, string $range): bool { |
|
| 40 | + public static function ipInRange(string $ip, string $range): bool { |
|
| 41 | 41 | if (!str_contains($range, '/')) { |
| 42 | 42 | $range .= '/32'; |
| 43 | 43 | } |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @return bool |
| 59 | 59 | */ |
| 60 | - public static function isTelegram (string $ip): bool { |
|
| 60 | + public static function isTelegram(string $ip): bool { |
|
| 61 | 61 | return tools::ipInRange($ip, '149.154.160.0/20') || tools::ipInRange($ip, '91.108.4.0/22'); |
| 62 | 62 | } |
| 63 | 63 | |
@@ -72,10 +72,10 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @return bool |
| 74 | 74 | */ |
| 75 | - public static function isCloudFlare (string $ip): bool { |
|
| 75 | + public static function isCloudFlare(string $ip): bool { |
|
| 76 | 76 | $cf_ips = ['173.245.48.0/20', '103.21.244.0/22', '103.22.200.0/22', '103.31.4.0/22', '141.101.64.0/18', '108.162.192.0/18', '190.93.240.0/20', '188.114.96.0/20', '197.234.240.0/22', '198.41.128.0/17', '162.158.0.0/15', '104.16.0.0/12', '172.64.0.0/13', '131.0.72.0/22']; |
| 77 | 77 | foreach ($cf_ips as $cf_ip) { |
| 78 | - if (self::ipInRange($ip,$cf_ip)) { |
|
| 78 | + if (self::ipInRange($ip, $cf_ip)) { |
|
| 79 | 79 | return true; |
| 80 | 80 | } |
| 81 | 81 | } |
@@ -95,9 +95,9 @@ discard block |
||
| 95 | 95 | * |
| 96 | 96 | * @return bool|user return array when verify is active and token is true array of telegram getMe result |
| 97 | 97 | */ |
| 98 | - public static function isToken (string $token, bool $verify = false): bool|user { |
|
| 98 | + public static function isToken(string $token, bool $verify = false): bool | user { |
|
| 99 | 99 | if (preg_match('/^(\d{8,10}):[\w\-]{35}$/', $token)) { |
| 100 | - if ($verify){ |
|
| 100 | + if ($verify) { |
|
| 101 | 101 | $res = telegram::me($token); |
| 102 | 102 | if (telegram::$status) { |
| 103 | 103 | return $res; |
@@ -129,14 +129,14 @@ discard block |
||
| 129 | 129 | * |
| 130 | 130 | * @return bool |
| 131 | 131 | */ |
| 132 | - public static function isJoined (array|string|int $ids , int|null $user_id = null): bool { |
|
| 132 | + public static function isJoined(array | string | int $ids, int | null $user_id = null): bool { |
|
| 133 | 133 | if (!is_array($ids)) { |
| 134 | 134 | $ids = [$ids]; |
| 135 | 135 | } |
| 136 | 136 | $user_id = $user_id ?? request::catchFields('user_id'); |
| 137 | 137 | |
| 138 | 138 | foreach ($ids as $id) { |
| 139 | - $check = telegram::getChatMember($id,$user_id); |
|
| 139 | + $check = telegram::getChatMember($id, $user_id); |
|
| 140 | 140 | if (telegram::$status) { |
| 141 | 141 | $check = $check->status; |
| 142 | 142 | if ($check === chatMemberStatus::LEFT || $check === chatMemberStatus::KICKED) { |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | * |
| 164 | 164 | * @return array keys will be id and values will be bool(null for not founded ids) |
| 165 | 165 | */ |
| 166 | - public static function joinChecker (array|string|int $ids , int|null $user_id = null): array { |
|
| 166 | + public static function joinChecker(array | string | int $ids, int | null $user_id = null): array { |
|
| 167 | 167 | if (!is_array($ids)) { |
| 168 | 168 | $ids = [$ids]; |
| 169 | 169 | } |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | |
| 172 | 172 | $result = []; |
| 173 | 173 | foreach ($ids as $id) { |
| 174 | - $check = telegram::getChatMember($id,$user_id); |
|
| 174 | + $check = telegram::getChatMember($id, $user_id); |
|
| 175 | 175 | if (telegram::$status) { |
| 176 | 176 | $check = $check->status; |
| 177 | 177 | $result[$id] = $check !== chatMemberStatus::LEFT && $check !== chatMemberStatus::KICKED; |
@@ -191,6 +191,6 @@ discard block |
||
| 191 | 191 | * @return bool |
| 192 | 192 | */ |
| 193 | 193 | public static function isShorted(string $text): bool{ |
| 194 | - return preg_match('/^[a-zA-Z0-9]+$/',$text); |
|
| 194 | + return preg_match('/^[a-zA-Z0-9]+$/', $text); |
|
| 195 | 195 | } |
| 196 | 196 | } |
| 197 | 197 | \ No newline at end of file |