@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | * @Version: 2.76 =>[ 1399/11/28 = 1442/07/04 = 2021/02/16 ] |
| 11 | 11 | */ |
| 12 | 12 | class jdf { |
| 13 | - public static function jdate ($format, $timestamp = '', $none = '', $time_zone = 'Asia/Tehran', $tr_num = 'fa') { |
|
| 13 | + public static function jdate($format, $timestamp = '', $none = '', $time_zone = 'Asia/Tehran', $tr_num = 'fa') { |
|
| 14 | 14 | $T_sec = 0; |
| 15 | 15 | if ($time_zone != 'local') { |
| 16 | 16 | date_default_timezone_set(empty($time_zone) ? 'Asia/Tehran' : $time_zone); |
@@ -56,13 +56,13 @@ discard block |
||
| 56 | 56 | $output .= (int) ($jalali_month / 3.1) + 1; |
| 57 | 57 | break; |
| 58 | 58 | case 'c': |
| 59 | - $output .= $jalali_year . '/' . $jalali_month . '/' . $jalali_day . ' ،' . $date[0] . ':' . $date[1] . ':' . $date[6] . ' ' . $date[5]; |
|
| 59 | + $output .= $jalali_year.'/'.$jalali_month.'/'.$jalali_day.' ،'.$date[0].':'.$date[1].':'.$date[6].' '.$date[5]; |
|
| 60 | 60 | break; |
| 61 | 61 | case 'C': |
| 62 | 62 | $output .= (int) (($jalali_year + 99) / 100); |
| 63 | 63 | break; |
| 64 | 64 | case 'd': |
| 65 | - $output .= $jalali_day < 10 ? '0' . $jalali_day : $jalali_day; |
|
| 65 | + $output .= $jalali_day < 10 ? '0'.$jalali_day : $jalali_day; |
|
| 66 | 66 | break; |
| 67 | 67 | case 'D': |
| 68 | 68 | $output .= self::jdate_words(['kh' => $date[7]], ' '); |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | $output .= $leap_year; |
| 99 | 99 | break; |
| 100 | 100 | case 'm': |
| 101 | - $output .= $jalali_month > 9 ? $jalali_month : '0' . $jalali_month; |
|
| 101 | + $output .= $jalali_month > 9 ? $jalali_month : '0'.$jalali_month; |
|
| 102 | 102 | break; |
| 103 | 103 | case 'M': |
| 104 | 104 | $output .= self::jdate_words(['km' => $jalali_month], ' '); |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | break; |
| 132 | 132 | case 'r': |
| 133 | 133 | $key = self::jdate_words(['rh' => $date[7], 'mm' => $jalali_month]); |
| 134 | - $output .= $date[0] . ':' . $date[1] . ':' . $date[6] . ' ' . $date[4] . ' ' . $key['rh'] . '، ' . $jalali_day . ' ' . $key['mm'] . ' ' . $jalali_year; |
|
| 134 | + $output .= $date[0].':'.$date[1].':'.$date[6].' '.$date[4].' '.$key['rh'].'، '.$jalali_day.' '.$key['mm'].' '.$jalali_year; |
|
| 135 | 135 | break; |
| 136 | 136 | case 's': |
| 137 | 137 | $output .= $date[6]; |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | if ($aks == 7) { |
| 169 | 169 | $aks = 0; |
| 170 | 170 | } |
| 171 | - $output .= ($leap_year + 363 - $doy < $aks and $aks < 3) ? '01' : ($num < 10 ? '0' . $num : $num); |
|
| 171 | + $output .= ($leap_year + 363 - $doy < $aks and $aks < 3) ? '01' : ($num < 10 ? '0'.$num : $num); |
|
| 172 | 172 | break; |
| 173 | 173 | case 'y': |
| 174 | 174 | $output .= substr($jalali_year, 2, 2); |
@@ -185,8 +185,8 @@ discard block |
||
| 185 | 185 | } |
| 186 | 186 | return $tr_num != 'en' ? self::tr_num($output, 'fa', '.') : $output; |
| 187 | 187 | } |
| 188 | - public static function jstrftime ($format, $timestamp = '', $none = '', $time_zone = 'Asia/Tehran', $tr_num = 'fa') { |
|
| 189 | - $T_sec = 0;/* <= رفع خطاي زمان سرور ، با اعداد '+' و '-' بر حسب ثانيه */ |
|
| 188 | + public static function jstrftime($format, $timestamp = '', $none = '', $time_zone = 'Asia/Tehran', $tr_num = 'fa') { |
|
| 189 | + $T_sec = 0; /* <= رفع خطاي زمان سرور ، با اعداد '+' و '-' بر حسب ثانيه */ |
|
| 190 | 190 | if ($time_zone != 'local') date_default_timezone_set(($time_zone === '') ? 'Asia/Tehran' : $time_zone); |
| 191 | 191 | $timestamp = $T_sec + (($timestamp === '') ? time() : self::tr_num($timestamp)); |
| 192 | 192 | $date = explode('_', date('h_H_i_j_n_s_w_Y', $timestamp)); |
@@ -213,10 +213,10 @@ discard block |
||
| 213 | 213 | $output .= self::jdate_words(['rh' => $date[6]], ' '); |
| 214 | 214 | break; |
| 215 | 215 | case 'd': |
| 216 | - $output .= ($jalali_day < 10) ? '0' . $jalali_day : $jalali_day; |
|
| 216 | + $output .= ($jalali_day < 10) ? '0'.$jalali_day : $jalali_day; |
|
| 217 | 217 | break; |
| 218 | 218 | case 'e': |
| 219 | - $output .= ($jalali_day < 10) ? ' ' . $jalali_day : $jalali_day; |
|
| 219 | + $output .= ($jalali_day < 10) ? ' '.$jalali_day : $jalali_day; |
|
| 220 | 220 | break; |
| 221 | 221 | case 'j': |
| 222 | 222 | $output .= str_pad($doy + 1, 3, 0, STR_PAD_LEFT); |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | if ($avs < 0) $avs += 7; |
| 233 | 233 | $num = (int) (($doy + $avs) / 7) + 1; |
| 234 | 234 | if ($avs > 3 or $avs == 1) $num--; |
| 235 | - $output .= ($num < 10) ? '0' . $num : $num; |
|
| 235 | + $output .= ($num < 10) ? '0'.$num : $num; |
|
| 236 | 236 | break; |
| 237 | 237 | case 'V': |
| 238 | 238 | $avs = (($date[6] == 6) ? 0 : $date[6] + 1) - ($doy % 7); |
@@ -246,14 +246,14 @@ discard block |
||
| 246 | 246 | } |
| 247 | 247 | $aks = $avs + $leap_year; |
| 248 | 248 | if ($aks == 7) $aks = 0; |
| 249 | - $output .= (($leap_year + 363 - $doy) < $aks and $aks < 3) ? '01' : (($num < 10) ? '0' . $num : $num); |
|
| 249 | + $output .= (($leap_year + 363 - $doy) < $aks and $aks < 3) ? '01' : (($num < 10) ? '0'.$num : $num); |
|
| 250 | 250 | break; |
| 251 | 251 | case 'W': |
| 252 | 252 | $avs = (($date[6] == 6) ? 0 : $date[6] + 1) - ($doy % 7); |
| 253 | 253 | if ($avs < 0) $avs += 7; |
| 254 | 254 | $num = (int) (($doy + $avs) / 7) + 1; |
| 255 | 255 | if ($avs > 3) $num--; |
| 256 | - $output .= ($num < 10) ? '0' . $num : $num; |
|
| 256 | + $output .= ($num < 10) ? '0'.$num : $num; |
|
| 257 | 257 | break; |
| 258 | 258 | /* Month */ case 'b': |
| 259 | 259 | case 'h': |
@@ -263,11 +263,11 @@ discard block |
||
| 263 | 263 | $output .= self::jdate_words(['mm' => $jalali_month], ' '); |
| 264 | 264 | break; |
| 265 | 265 | case 'm': |
| 266 | - $output .= ($jalali_month > 9) ? $jalali_month : '0' . $jalali_month; |
|
| 266 | + $output .= ($jalali_month > 9) ? $jalali_month : '0'.$jalali_month; |
|
| 267 | 267 | break; |
| 268 | 268 | /* Year */ case 'C': |
| 269 | 269 | $tmp = (int) ($jalali_year / 100); |
| 270 | - $output .= ($tmp > 9) ? $tmp : '0' . $tmp; |
|
| 270 | + $output .= ($tmp > 9) ? $tmp : '0'.$tmp; |
|
| 271 | 271 | break; |
| 272 | 272 | case 'g': |
| 273 | 273 | $jdw = ($date[6] == 6) ? 0 : $date[6] + 1; |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | $output .= $date[0]; |
| 293 | 293 | break; |
| 294 | 294 | case 'l': |
| 295 | - $output .= ($date[0] > 9) ? $date[0] : ' ' . (int) $date[0]; |
|
| 295 | + $output .= ($date[0] > 9) ? $date[0] : ' '.(int) $date[0]; |
|
| 296 | 296 | break; |
| 297 | 297 | case 'M': |
| 298 | 298 | $output .= $date[2]; |
@@ -304,19 +304,19 @@ discard block |
||
| 304 | 304 | $output .= ($date[1] < 12) ? 'ق.ظ' : 'ب.ظ'; |
| 305 | 305 | break; |
| 306 | 306 | case 'r': |
| 307 | - $output .= $date[0] . ':' . $date[2] . ':' . $date[5] . ' ' . (($date[1] < 12) ? 'قبل از ظهر' : 'بعد از ظهر'); |
|
| 307 | + $output .= $date[0].':'.$date[2].':'.$date[5].' '.(($date[1] < 12) ? 'قبل از ظهر' : 'بعد از ظهر'); |
|
| 308 | 308 | break; |
| 309 | 309 | case 'R': |
| 310 | - $output .= $date[1] . ':' . $date[2]; |
|
| 310 | + $output .= $date[1].':'.$date[2]; |
|
| 311 | 311 | break; |
| 312 | 312 | case 'S': |
| 313 | 313 | $output .= $date[5]; |
| 314 | 314 | break; |
| 315 | 315 | case 'T': |
| 316 | - $output .= $date[1] . ':' . $date[2] . ':' . $date[5]; |
|
| 316 | + $output .= $date[1].':'.$date[2].':'.$date[5]; |
|
| 317 | 317 | break; |
| 318 | 318 | case 'X': |
| 319 | - $output .= $date[0] . ':' . $date[2] . ':' . $date[5]; |
|
| 319 | + $output .= $date[0].':'.$date[2].':'.$date[5]; |
|
| 320 | 320 | break; |
| 321 | 321 | case 'z': |
| 322 | 322 | $output .= date('O', $timestamp); |
@@ -326,19 +326,19 @@ discard block |
||
| 326 | 326 | break; |
| 327 | 327 | /* Time and Date Stamps */ case 'c': |
| 328 | 328 | $key = self::jdate_words(['rh' => $date[6], 'mm' => $jalali_month]); |
| 329 | - $output .= $date[1] . ':' . $date[2] . ':' . $date[5] . ' ' . date('P', $timestamp) . ' ' . $key['rh'] . '، ' . $jalali_day . ' ' . $key['mm'] . ' ' . $jalali_year; |
|
| 329 | + $output .= $date[1].':'.$date[2].':'.$date[5].' '.date('P', $timestamp).' '.$key['rh'].'، '.$jalali_day.' '.$key['mm'].' '.$jalali_year; |
|
| 330 | 330 | break; |
| 331 | 331 | case 'D': |
| 332 | - $output .= substr($jalali_year, 2, 2) . '/' . (($jalali_month > 9) ? $jalali_month : '0' . $jalali_month) . '/' . (($jalali_day < 10) ? '0' . $jalali_day : $jalali_day); |
|
| 332 | + $output .= substr($jalali_year, 2, 2).'/'.(($jalali_month > 9) ? $jalali_month : '0'.$jalali_month).'/'.(($jalali_day < 10) ? '0'.$jalali_day : $jalali_day); |
|
| 333 | 333 | break; |
| 334 | 334 | case 'F': |
| 335 | - $output .= $jalali_year . '-' . (($jalali_month > 9) ? $jalali_month : '0' . $jalali_month) . '-' . (($jalali_day < 10) ? '0' . $jalali_day : $jalali_day); |
|
| 335 | + $output .= $jalali_year.'-'.(($jalali_month > 9) ? $jalali_month : '0'.$jalali_month).'-'.(($jalali_day < 10) ? '0'.$jalali_day : $jalali_day); |
|
| 336 | 336 | break; |
| 337 | 337 | case 's': |
| 338 | 338 | $output .= $timestamp; |
| 339 | 339 | break; |
| 340 | 340 | case 'x': |
| 341 | - $output .= substr($jalali_year, 2, 2) . '/' . (($jalali_month > 9) ? $jalali_month : '0' . $jalali_month) . '/' . (($jalali_day < 10) ? '0' . $jalali_day : $jalali_day); |
|
| 341 | + $output .= substr($jalali_year, 2, 2).'/'.(($jalali_month > 9) ? $jalali_month : '0'.$jalali_month).'/'.(($jalali_day < 10) ? '0'.$jalali_day : $jalali_day); |
|
| 342 | 342 | break; |
| 343 | 343 | /* Miscellaneous */ case 'n': |
| 344 | 344 | $output .= "\n"; |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | } |
| 356 | 356 | return ($tr_num != 'en') ? self::tr_num($output, 'fa', '.') : $output; |
| 357 | 357 | } |
| 358 | - public static function jmktime ($hour = '', $minute = '', $second = '', $jalali_month = '', $jalali_day = '', $jalali_year = '', $none = '', $timezone = 'Asia/Tehran'): bool|int { |
|
| 358 | + public static function jmktime($hour = '', $minute = '', $second = '', $jalali_month = '', $jalali_day = '', $jalali_year = '', $none = '', $timezone = 'Asia/Tehran'): bool | int { |
|
| 359 | 359 | if ($timezone != 'local') date_default_timezone_set($timezone); |
| 360 | 360 | if ($hour === '') { |
| 361 | 361 | return time(); |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | $jalali_month, |
| 369 | 369 | $jalali_day, |
| 370 | 370 | $jalali_year |
| 371 | - ] = explode('_', self::tr_num($hour . '_' . $minute . '_' . $second . '_' . $jalali_month . '_' . $jalali_day . '_' . $jalali_year)); |
|
| 371 | + ] = explode('_', self::tr_num($hour.'_'.$minute.'_'.$second.'_'.$jalali_month.'_'.$jalali_day.'_'.$jalali_year)); |
|
| 372 | 372 | if ($minute === '') { |
| 373 | 373 | return mktime($hour); |
| 374 | 374 | } |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | } |
| 414 | 414 | } |
| 415 | 415 | } |
| 416 | - public static function jgetdate ($timestamp = '', $none = '', $timezone = 'Asia/Tehran', $tn = 'en') { |
|
| 416 | + public static function jgetdate($timestamp = '', $none = '', $timezone = 'Asia/Tehran', $tn = 'en') { |
|
| 417 | 417 | $timestamp = ($timestamp === '') ? time() : self::tr_num($timestamp); |
| 418 | 418 | $jdate = explode('_', self::jdate('F_G_i_j_l_n_s_w_Y_z', $timestamp, '', $timezone, $tn)); |
| 419 | 419 | return [ |
@@ -430,17 +430,17 @@ discard block |
||
| 430 | 430 | 0 => self::tr_num($timestamp, $tn) |
| 431 | 431 | ]; |
| 432 | 432 | } |
| 433 | - public static function jcheckdate ($jalali_month, $jalali_day, $jalali_year): bool { |
|
| 434 | - [$jalali_month, $jalali_day, $jalali_year] = explode('_', self::tr_num($jalali_month . '_' . $jalali_day . '_' . $jalali_year)); |
|
| 433 | + public static function jcheckdate($jalali_month, $jalali_day, $jalali_year): bool { |
|
| 434 | + [$jalali_month, $jalali_day, $jalali_year] = explode('_', self::tr_num($jalali_month.'_'.$jalali_day.'_'.$jalali_year)); |
|
| 435 | 435 | $l_d = ($jalali_month == 12 and ($jalali_year + 12) % 33 % 4 != 1) ? 29 : 31 - (int) ($jalali_month / 6.5); |
| 436 | 436 | return !(($jalali_month > 12 or $jalali_day > $l_d or $jalali_month < 1 or $jalali_day < 1 or $jalali_year < 1)); |
| 437 | 437 | } |
| 438 | - public static function tr_num ($string, $mod = 'en', $mf = '٫'): array|string { |
|
| 438 | + public static function tr_num($string, $mod = 'en', $mf = '٫'): array | string { |
|
| 439 | 439 | $english_number = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.']; |
| 440 | 440 | $persian_number = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹', $mf]; |
| 441 | 441 | return $mod == 'fa' ? str_replace($english_number, $persian_number, $string) : str_replace($persian_number, $english_number, $string); |
| 442 | 442 | } |
| 443 | - public static function jdate_words ($array, $splitter = '') { |
|
| 443 | + public static function jdate_words($array, $splitter = '') { |
|
| 444 | 444 | foreach ($array as $type => $num) { |
| 445 | 445 | $num = (int) self::tr_num($num); |
| 446 | 446 | switch ($type) { |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | 'هزار و چهارصد', |
| 479 | 479 | 'هزار و نهصد', |
| 480 | 480 | 'دوهزار' |
| 481 | - ], substr($num, 0, 2)) . (substr($num, 2, 2) == '00' ? '' : ' و ') : '') . $h3 . $p34 . $h34 . $h4; |
|
| 481 | + ], substr($num, 0, 2)).(substr($num, 2, 2) == '00' ? '' : ' و ') : '').$h3.$p34.$h34.$h4; |
|
| 482 | 482 | break; |
| 483 | 483 | case 'mm': |
| 484 | 484 | $array[$type] = [ |
@@ -594,8 +594,8 @@ discard block |
||
| 594 | 594 | } |
| 595 | 595 | return $splitter === '' ? $array : implode($splitter, $array); |
| 596 | 596 | } |
| 597 | - public static function gregorian_to_jalali ($gregorian_year, $gregorian_month, $gregorian_day, $splitter = ''): array|string { |
|
| 598 | - [$gregorian_year, $gregorian_month, $gregorian_day] = explode('_', self::tr_num($gregorian_year . '_' . $gregorian_month . '_' . $gregorian_day));/* <= Extra :اين سطر ، جزء تابع اصلي نيست */ |
|
| 597 | + public static function gregorian_to_jalali($gregorian_year, $gregorian_month, $gregorian_day, $splitter = ''): array | string { |
|
| 598 | + [$gregorian_year, $gregorian_month, $gregorian_day] = explode('_', self::tr_num($gregorian_year.'_'.$gregorian_month.'_'.$gregorian_day)); /* <= Extra :اين سطر ، جزء تابع اصلي نيست */ |
|
| 599 | 599 | $g_d_m = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334]; |
| 600 | 600 | $gregorian_year2 = ($gregorian_month > 2) ? ($gregorian_year + 1) : $gregorian_year; |
| 601 | 601 | $days = 355666 + (365 * $gregorian_year) + ((int) (($gregorian_year2 + 3) / 4)) - ((int) (($gregorian_year2 + 99) / 100)) + ((int) (($gregorian_year2 + 399) / 400)) + $gregorian_day + $g_d_m[$gregorian_month - 1]; |
@@ -615,10 +615,10 @@ discard block |
||
| 615 | 615 | $jalali_month = 7 + (int) (($days - 186) / 30); |
| 616 | 616 | $jalali_day = 1 + (($days - 186) % 30); |
| 617 | 617 | } |
| 618 | - return $splitter == '' ? [$jalali_year, $jalali_month, $jalali_day] : $jalali_year . $splitter . $jalali_month . $splitter . $jalali_day; |
|
| 618 | + return $splitter == '' ? [$jalali_year, $jalali_month, $jalali_day] : $jalali_year.$splitter.$jalali_month.$splitter.$jalali_day; |
|
| 619 | 619 | } |
| 620 | - public static function jalali_to_gregorian ($jalali_year, $jalali_month, $jalali_day, $splitter = ''): array|string { |
|
| 621 | - [$jalali_year, $jalali_month, $jalali_day] = explode('_', self::tr_num($jalali_year . '_' . $jalali_month . '_' . $jalali_day)); |
|
| 620 | + public static function jalali_to_gregorian($jalali_year, $jalali_month, $jalali_day, $splitter = ''): array | string { |
|
| 621 | + [$jalali_year, $jalali_month, $jalali_day] = explode('_', self::tr_num($jalali_year.'_'.$jalali_month.'_'.$jalali_day)); |
|
| 622 | 622 | $jalali_year += 1595; |
| 623 | 623 | $days = -355668 + (365 * $jalali_year) + (((int) ($jalali_year / 33)) * 8) + ((int) ((($jalali_year % 33) + 3) / 4)) + $jalali_day + (($jalali_month < 7) ? ($jalali_month - 1) * 31 : (($jalali_month - 7) * 30) + 186); |
| 624 | 624 | $gregorian_year = 400 * (int) ($days / 146097); |
@@ -655,6 +655,6 @@ discard block |
||
| 655 | 655 | for ($gregorian_month = 0; $gregorian_month < 13 and $gregorian_day > $month_days[$gregorian_month]; $gregorian_month++) { |
| 656 | 656 | $gregorian_day -= $month_days[$gregorian_month]; |
| 657 | 657 | } |
| 658 | - return $splitter == '' ? [$gregorian_year, $gregorian_month, $gregorian_day] : $gregorian_year . $splitter . $gregorian_month . $splitter . $gregorian_day; |
|
| 658 | + return $splitter == '' ? [$gregorian_year, $gregorian_month, $gregorian_day] : $gregorian_year.$splitter.$gregorian_month.$splitter.$gregorian_day; |
|
| 659 | 659 | } |
| 660 | 660 | } |
| 661 | 661 | \ No newline at end of file |
@@ -156,12 +156,13 @@ discard block |
||
| 156 | 156 | break; |
| 157 | 157 | case 'W': |
| 158 | 158 | $avs = ($date[7] == 6 ? 0 : $date[7] + 1) - $doy % 7; |
| 159 | - if ($avs < 0) $avs += 7; |
|
| 159 | + if ($avs < 0) { |
|
| 160 | + $avs += 7; |
|
| 161 | + } |
|
| 160 | 162 | $num = (int) (($doy + $avs) / 7); |
| 161 | 163 | if ($avs < 4) { |
| 162 | 164 | $num++; |
| 163 | - } |
|
| 164 | - elseif ($num < 1) { |
|
| 165 | + } elseif ($num < 1) { |
|
| 165 | 166 | $num = ($avs == 4 or $avs == ($jalali_year % 33 % 4 - 2 == (int) ($jalali_year % 33 * 0.05) ? 5 : 4)) ? 53 : 52; |
| 166 | 167 | } |
| 167 | 168 | $aks = $avs + $leap_year; |
@@ -187,7 +188,9 @@ discard block |
||
| 187 | 188 | } |
| 188 | 189 | public static function jstrftime ($format, $timestamp = '', $none = '', $time_zone = 'Asia/Tehran', $tr_num = 'fa') { |
| 189 | 190 | $T_sec = 0;/* <= رفع خطاي زمان سرور ، با اعداد '+' و '-' بر حسب ثانيه */ |
| 190 | - if ($time_zone != 'local') date_default_timezone_set(($time_zone === '') ? 'Asia/Tehran' : $time_zone); |
|
| 191 | + if ($time_zone != 'local') { |
|
| 192 | + date_default_timezone_set(($time_zone === '') ? 'Asia/Tehran' : $time_zone); |
|
| 193 | + } |
|
| 191 | 194 | $timestamp = $T_sec + (($timestamp === '') ? time() : self::tr_num($timestamp)); |
| 192 | 195 | $date = explode('_', date('h_H_i_j_n_s_w_Y', $timestamp)); |
| 193 | 196 | [$jalali_year, $jalali_month, $jalali_day] = self::gregorian_to_jalali($date[7], $date[4], $date[3]); |
@@ -199,8 +202,7 @@ discard block |
||
| 199 | 202 | $sub = substr($format, $i, 1); |
| 200 | 203 | if ($sub == '%') { |
| 201 | 204 | $sub = substr($format, ++$i, 1); |
| 202 | - } |
|
| 203 | - else { |
|
| 205 | + } else { |
|
| 204 | 206 | $output .= $sub; |
| 205 | 207 | continue; |
| 206 | 208 | } |
@@ -229,30 +231,41 @@ discard block |
||
| 229 | 231 | break; |
| 230 | 232 | /* Week */ case 'U': |
| 231 | 233 | $avs = (($date[6] < 5) ? $date[6] + 2 : $date[6] - 5) - ($doy % 7); |
| 232 | - if ($avs < 0) $avs += 7; |
|
| 234 | + if ($avs < 0) { |
|
| 235 | + $avs += 7; |
|
| 236 | + } |
|
| 233 | 237 | $num = (int) (($doy + $avs) / 7) + 1; |
| 234 | - if ($avs > 3 or $avs == 1) $num--; |
|
| 238 | + if ($avs > 3 or $avs == 1) { |
|
| 239 | + $num--; |
|
| 240 | + } |
|
| 235 | 241 | $output .= ($num < 10) ? '0' . $num : $num; |
| 236 | 242 | break; |
| 237 | 243 | case 'V': |
| 238 | 244 | $avs = (($date[6] == 6) ? 0 : $date[6] + 1) - ($doy % 7); |
| 239 | - if ($avs < 0) $avs += 7; |
|
| 245 | + if ($avs < 0) { |
|
| 246 | + $avs += 7; |
|
| 247 | + } |
|
| 240 | 248 | $num = (int) (($doy + $avs) / 7); |
| 241 | 249 | if ($avs < 4) { |
| 242 | 250 | $num++; |
| 243 | - } |
|
| 244 | - elseif ($num < 1) { |
|
| 251 | + } elseif ($num < 1) { |
|
| 245 | 252 | $num = ($avs == 4 or $avs == ((((($jalali_year % 33) % 4) - 2) == ((int) (($jalali_year % 33) * 0.05))) ? 5 : 4)) ? 53 : 52; |
| 246 | 253 | } |
| 247 | 254 | $aks = $avs + $leap_year; |
| 248 | - if ($aks == 7) $aks = 0; |
|
| 255 | + if ($aks == 7) { |
|
| 256 | + $aks = 0; |
|
| 257 | + } |
|
| 249 | 258 | $output .= (($leap_year + 363 - $doy) < $aks and $aks < 3) ? '01' : (($num < 10) ? '0' . $num : $num); |
| 250 | 259 | break; |
| 251 | 260 | case 'W': |
| 252 | 261 | $avs = (($date[6] == 6) ? 0 : $date[6] + 1) - ($doy % 7); |
| 253 | - if ($avs < 0) $avs += 7; |
|
| 262 | + if ($avs < 0) { |
|
| 263 | + $avs += 7; |
|
| 264 | + } |
|
| 254 | 265 | $num = (int) (($doy + $avs) / 7) + 1; |
| 255 | - if ($avs > 3) $num--; |
|
| 266 | + if ($avs > 3) { |
|
| 267 | + $num--; |
|
| 268 | + } |
|
| 256 | 269 | $output .= ($num < 10) ? '0' . $num : $num; |
| 257 | 270 | break; |
| 258 | 271 | /* Month */ case 'b': |
@@ -356,11 +369,12 @@ discard block |
||
| 356 | 369 | return ($tr_num != 'en') ? self::tr_num($output, 'fa', '.') : $output; |
| 357 | 370 | } |
| 358 | 371 | public static function jmktime ($hour = '', $minute = '', $second = '', $jalali_month = '', $jalali_day = '', $jalali_year = '', $none = '', $timezone = 'Asia/Tehran'): bool|int { |
| 359 | - if ($timezone != 'local') date_default_timezone_set($timezone); |
|
| 372 | + if ($timezone != 'local') { |
|
| 373 | + date_default_timezone_set($timezone); |
|
| 374 | + } |
|
| 360 | 375 | if ($hour === '') { |
| 361 | 376 | return time(); |
| 362 | - } |
|
| 363 | - else { |
|
| 377 | + } else { |
|
| 364 | 378 | [ |
| 365 | 379 | $hour, |
| 366 | 380 | $minute, |
@@ -371,16 +385,13 @@ discard block |
||
| 371 | 385 | ] = explode('_', self::tr_num($hour . '_' . $minute . '_' . $second . '_' . $jalali_month . '_' . $jalali_day . '_' . $jalali_year)); |
| 372 | 386 | if ($minute === '') { |
| 373 | 387 | return mktime($hour); |
| 374 | - } |
|
| 375 | - else { |
|
| 388 | + } else { |
|
| 376 | 389 | if ($second === '') { |
| 377 | 390 | return mktime($hour, $minute); |
| 378 | - } |
|
| 379 | - else { |
|
| 391 | + } else { |
|
| 380 | 392 | if ($jalali_month === '') { |
| 381 | 393 | return mktime($hour, $minute, $second); |
| 382 | - } |
|
| 383 | - else { |
|
| 394 | + } else { |
|
| 384 | 395 | $jdate = explode('_', self::jdate('Y_j', '', '', $timezone, 'en')); |
| 385 | 396 | if ($jalali_day === '') { |
| 386 | 397 | [ |
@@ -389,8 +400,7 @@ discard block |
||
| 389 | 400 | $gregorian_day |
| 390 | 401 | ] = self::jalali_to_gregorian($jdate[0], $jalali_month, $jdate[1]); |
| 391 | 402 | return mktime($hour, $minute, $second, $gregorian_month); |
| 392 | - } |
|
| 393 | - else { |
|
| 403 | + } else { |
|
| 394 | 404 | if ($jalali_year === '') { |
| 395 | 405 | [ |
| 396 | 406 | $gregorian_year, |
@@ -398,8 +408,7 @@ discard block |
||
| 398 | 408 | $gregorian_day |
| 399 | 409 | ] = self::jalali_to_gregorian($jdate[0], $jalali_month, $jalali_day); |
| 400 | 410 | return mktime($hour, $minute, $second, $gregorian_month, $gregorian_day); |
| 401 | - } |
|
| 402 | - else { |
|
| 411 | + } else { |
|
| 403 | 412 | [ |
| 404 | 413 | $gregorian_year, |
| 405 | 414 | $gregorian_month, |
@@ -463,8 +472,7 @@ discard block |
||
| 463 | 472 | 'نوزده' |
| 464 | 473 | ]; |
| 465 | 474 | $h34 = $k34[substr($num, 2 - $length, 2) - 10]; |
| 466 | - } |
|
| 467 | - else { |
|
| 475 | + } else { |
|
| 468 | 476 | $xy4 = substr($num, 3 - $length, 1); |
| 469 | 477 | $p34 = ($xy3 == 0 or $xy4 == 0) ? '' : ' و '; |
| 470 | 478 | $k3 = ['', '', 'بیست', 'سی', 'چهل', 'پنجاه', 'شصت', 'هفتاد', 'هشتاد', 'نود']; |
@@ -610,8 +618,7 @@ discard block |
||
| 610 | 618 | if ($days < 186) { |
| 611 | 619 | $jalali_month = 1 + (int) ($days / 31); |
| 612 | 620 | $jalali_day = 1 + ($days % 31); |
| 613 | - } |
|
| 614 | - else { |
|
| 621 | + } else { |
|
| 615 | 622 | $jalali_month = 7 + (int) (($days - 186) / 30); |
| 616 | 623 | $jalali_day = 1 + (($days - 186) % 30); |
| 617 | 624 | } |
@@ -49,6 +49,6 @@ |
||
| 49 | 49 | * |
| 50 | 50 | * @return array|string |
| 51 | 51 | */ |
| 52 | -function strReplace(array $replacements, string|array $subject): array|string { |
|
| 52 | +function strReplace(array $replacements, string | array $subject): array | string { |
|
| 53 | 53 | return str_replace(array_keys($replacements), array_values($replacements), $subject); |
| 54 | 54 | } |
| 55 | 55 | \ No newline at end of file |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | const ADMIN = 123456789; |
| 20 | 20 | const SHOW_STATUS = true; |
| 21 | 21 | const UNKNOWN = 'I didnt understand it, Please use commands or reply to a user message'; |
| 22 | - const HELP = 'Hello dear admin |
|
| 22 | + const HELP = 'Hello dear admin |
|
| 23 | 23 | This is a simple messenger bot which also support reply for users and admin itself |
| 24 | 24 | For answering an user message , You must reply on it |
| 25 | 25 | If you want to reply , You must first use /reply_on command and this will apply on your next message |
@@ -34,11 +34,11 @@ discard block |
||
| 34 | 34 | const SEND_FAILED = 'Failed!'; |
| 35 | 35 | const SEND_SUCCESSFUL = 'Done!'; |
| 36 | 36 | |
| 37 | - public function __construct (array $settings) { |
|
| 37 | + public function __construct(array $settings) { |
|
| 38 | 38 | parent::__construct($settings); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - public function message (message $update) { |
|
| 41 | + public function message(message $update) { |
|
| 42 | 42 | $text = $update->text ?? ''; |
| 43 | 43 | $user_id = $update->from->id; |
| 44 | 44 | |
@@ -54,11 +54,11 @@ discard block |
||
| 54 | 54 | return $this->sendMessage(self::HELP, answer: true); |
| 55 | 55 | } |
| 56 | 56 | if ($text === '/reply_on') { |
| 57 | - mysql::update('users',['value'=>'reply_on'],['id'=>$user_id],1); |
|
| 57 | + mysql::update('users', ['value'=>'reply_on'], ['id'=>$user_id], 1); |
|
| 58 | 58 | return $this->sendMessage(self::REPLY_ON, answer: true); |
| 59 | 59 | } |
| 60 | 60 | if ($text === '/reply_off') { |
| 61 | - mysql::update('users',['value'=>'reply_off'],['id'=>$user_id],1); |
|
| 61 | + mysql::update('users', ['value'=>'reply_off'], ['id'=>$user_id], 1); |
|
| 62 | 62 | return $this->sendMessage(self::REPLY_OFF, answer: true); |
| 63 | 63 | } |
| 64 | 64 | if (!isset($update->reply_to_message)) { |
@@ -68,10 +68,10 @@ discard block |
||
| 68 | 68 | $reply_message_id = $update->reply_to_message->message_id; |
| 69 | 69 | |
| 70 | 70 | if ($update->reply_to_message->from->id === $user_id) { |
| 71 | - $check_message = mysql::select('messages', ['receiver_message_id','receiver_id'], [ |
|
| 71 | + $check_message = mysql::select('messages', ['receiver_message_id', 'receiver_id'], [ |
|
| 72 | 72 | 'sender_message_id' => $reply_message_id, |
| 73 | 73 | 'sender_id' => $user_id |
| 74 | - ],1); |
|
| 74 | + ], 1); |
|
| 75 | 75 | |
| 76 | 76 | if ($check_message->num_rows < 1) { |
| 77 | 77 | return $this->sendMessage(self::NOT_FOUND, answer: true); |
@@ -81,19 +81,19 @@ discard block |
||
| 81 | 81 | $result = $this->copyMessage($receiver_id, reply_to_message_id: $data->receiver_message_id); |
| 82 | 82 | } |
| 83 | 83 | else { |
| 84 | - $check_message = mysql::select('messages', ['sender_message_id','sender_id'], [ |
|
| 84 | + $check_message = mysql::select('messages', ['sender_message_id', 'sender_id'], [ |
|
| 85 | 85 | 'receiver_message_id' => $reply_message_id, |
| 86 | 86 | 'receiver_id' => $user_id |
| 87 | - ],1); |
|
| 87 | + ], 1); |
|
| 88 | 88 | |
| 89 | 89 | if ($check_message->num_rows < 1) { |
| 90 | 90 | return $this->sendMessage(self::NOT_FOUND, answer: true); |
| 91 | 91 | } |
| 92 | 92 | $data = $check_message->fetch_object(); |
| 93 | - $value = mysql::select('users','value',['id'=>$user_id])->fetch_object()->value; |
|
| 93 | + $value = mysql::select('users', 'value', ['id'=>$user_id])->fetch_object()->value; |
|
| 94 | 94 | $receiver_id = $data->sender_id; |
| 95 | 95 | if ($value === 'reply_on') { |
| 96 | - mysql::update('users',['value'=>''],['id'=>$user_id]); |
|
| 96 | + mysql::update('users', ['value'=>''], ['id'=>$user_id]); |
|
| 97 | 97 | $result = $this->copyMessage($receiver_id, reply_to_message_id: $data->sender_message_id); |
| 98 | 98 | } |
| 99 | 99 | else { |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | } |
| 118 | 118 | $username = $update->from->username; |
| 119 | 119 | if (empty($username)) { |
| 120 | - $name = $update->from->first_name . (!empty($update->from->last_name) ? (' ' . $update->from->last_name) : ''); |
|
| 120 | + $name = $update->from->first_name.(!empty($update->from->last_name) ? (' '.$update->from->last_name) : ''); |
|
| 121 | 121 | $keyboard = [ |
| 122 | 122 | 'inline_keyboard' => [ |
| 123 | 123 | [ |
@@ -155,33 +155,33 @@ discard block |
||
| 155 | 155 | } |
| 156 | 156 | if (isset($update->reply_to_message)) { |
| 157 | 157 | $reply_message_id = $update->reply_to_message->message_id; |
| 158 | - if ($update->reply_to_message->from->id === $user_id){ |
|
| 158 | + if ($update->reply_to_message->from->id === $user_id) { |
|
| 159 | 159 | $check_message = mysql::select('messages', 'receiver_message_id', [ |
| 160 | 160 | 'sender_message_id' => $reply_message_id, |
| 161 | 161 | 'sender_id' => $user_id |
| 162 | - ],1); |
|
| 162 | + ], 1); |
|
| 163 | 163 | if ($check_message->num_rows > 0) { |
| 164 | - $result = $this->copyMessage(self::ADMIN, reply_to_message_id: $check_message->fetch_object()->receiver_message_id,reply_markup: $keyboard); |
|
| 164 | + $result = $this->copyMessage(self::ADMIN, reply_to_message_id: $check_message->fetch_object()->receiver_message_id, reply_markup: $keyboard); |
|
| 165 | 165 | } |
| 166 | 166 | else { |
| 167 | - $result = $this->copyMessage(self::ADMIN,reply_markup: $keyboard); |
|
| 167 | + $result = $this->copyMessage(self::ADMIN, reply_markup: $keyboard); |
|
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | 170 | else { |
| 171 | 171 | $check_message = mysql::select('messages', 'sender_message_id', [ |
| 172 | 172 | 'receiver_message_id' => $reply_message_id, |
| 173 | 173 | 'receiver_id' => $user_id |
| 174 | - ],1); |
|
| 174 | + ], 1); |
|
| 175 | 175 | if ($check_message->num_rows > 0) { |
| 176 | - $result = $this->copyMessage(self::ADMIN, reply_to_message_id: $check_message->fetch_object()->sender_message_id,reply_markup: $keyboard); |
|
| 176 | + $result = $this->copyMessage(self::ADMIN, reply_to_message_id: $check_message->fetch_object()->sender_message_id, reply_markup: $keyboard); |
|
| 177 | 177 | } |
| 178 | 178 | else { |
| 179 | - $result = $this->copyMessage(self::ADMIN,reply_markup: $keyboard); |
|
| 179 | + $result = $this->copyMessage(self::ADMIN, reply_markup: $keyboard); |
|
| 180 | 180 | } |
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | else { |
| 184 | - $result = $this->copyMessage(self::ADMIN,reply_markup: $keyboard); |
|
| 184 | + $result = $this->copyMessage(self::ADMIN, reply_markup: $keyboard); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | /** |
@@ -7,8 +7,7 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | if (file_exists('vendor/autoload.php')) { |
| 9 | 9 | require 'vendor/autoload.php'; |
| 10 | -} |
|
| 11 | -else { |
|
| 10 | +} else { |
|
| 12 | 11 | if (!file_exists('BPT.phar')) { |
| 13 | 12 | copy('https://dl.bptlib.ir/BPT.phar', 'BPT.phar'); |
| 14 | 13 | } |
@@ -79,8 +78,7 @@ discard block |
||
| 79 | 78 | $data = $check_message->fetch_object(); |
| 80 | 79 | $receiver_id = $data->receiver_id; |
| 81 | 80 | $result = $this->copyMessage($receiver_id, reply_to_message_id: $data->receiver_message_id); |
| 82 | - } |
|
| 83 | - else { |
|
| 81 | + } else { |
|
| 84 | 82 | $check_message = mysql::select('messages', ['sender_message_id','sender_id'], [ |
| 85 | 83 | 'receiver_message_id' => $reply_message_id, |
| 86 | 84 | 'receiver_id' => $user_id |
@@ -95,8 +93,7 @@ discard block |
||
| 95 | 93 | if ($value === 'reply_on') { |
| 96 | 94 | mysql::update('users',['value'=>''],['id'=>$user_id]); |
| 97 | 95 | $result = $this->copyMessage($receiver_id, reply_to_message_id: $data->sender_message_id); |
| 98 | - } |
|
| 99 | - else { |
|
| 96 | + } else { |
|
| 100 | 97 | $result = $this->copyMessage($receiver_id); |
| 101 | 98 | } |
| 102 | 99 | } |
@@ -138,8 +135,7 @@ discard block |
||
| 138 | 135 | ] |
| 139 | 136 | ] |
| 140 | 137 | ]; |
| 141 | - } |
|
| 142 | - else { |
|
| 138 | + } else { |
|
| 143 | 139 | $keyboard = [ |
| 144 | 140 | 'inline_keyboard' => [ |
| 145 | 141 | [ |
@@ -162,25 +158,21 @@ discard block |
||
| 162 | 158 | ],1); |
| 163 | 159 | if ($check_message->num_rows > 0) { |
| 164 | 160 | $result = $this->copyMessage(self::ADMIN, reply_to_message_id: $check_message->fetch_object()->receiver_message_id,reply_markup: $keyboard); |
| 165 | - } |
|
| 166 | - else { |
|
| 161 | + } else { |
|
| 167 | 162 | $result = $this->copyMessage(self::ADMIN,reply_markup: $keyboard); |
| 168 | 163 | } |
| 169 | - } |
|
| 170 | - else { |
|
| 164 | + } else { |
|
| 171 | 165 | $check_message = mysql::select('messages', 'sender_message_id', [ |
| 172 | 166 | 'receiver_message_id' => $reply_message_id, |
| 173 | 167 | 'receiver_id' => $user_id |
| 174 | 168 | ],1); |
| 175 | 169 | if ($check_message->num_rows > 0) { |
| 176 | 170 | $result = $this->copyMessage(self::ADMIN, reply_to_message_id: $check_message->fetch_object()->sender_message_id,reply_markup: $keyboard); |
| 177 | - } |
|
| 178 | - else { |
|
| 171 | + } else { |
|
| 179 | 172 | $result = $this->copyMessage(self::ADMIN,reply_markup: $keyboard); |
| 180 | 173 | } |
| 181 | 174 | } |
| 182 | - } |
|
| 183 | - else { |
|
| 175 | + } else { |
|
| 184 | 176 | $result = $this->copyMessage(self::ADMIN,reply_markup: $keyboard); |
| 185 | 177 | } |
| 186 | 178 | |
@@ -97,51 +97,41 @@ |
||
| 97 | 97 | if (self::handlerExist('message')) { |
| 98 | 98 | BPT::$handler->message(BPT::$update->message); |
| 99 | 99 | } |
| 100 | - } |
|
| 101 | - elseif (isset(BPT::$update->edited_message)) { |
|
| 100 | + } elseif (isset(BPT::$update->edited_message)) { |
|
| 102 | 101 | if (self::handlerExist('edited_message')) { |
| 103 | 102 | BPT::$handler->edited_message(BPT::$update->edited_message); |
| 104 | 103 | } |
| 105 | - } |
|
| 106 | - elseif (isset(BPT::$update->channel_post)) { |
|
| 104 | + } elseif (isset(BPT::$update->channel_post)) { |
|
| 107 | 105 | if (self::handlerExist('channel_post')) { |
| 108 | 106 | BPT::$handler->channel_post(BPT::$update->channel_post); |
| 109 | 107 | } |
| 110 | - } |
|
| 111 | - elseif (isset(BPT::$update->edited_channel_post)) { |
|
| 108 | + } elseif (isset(BPT::$update->edited_channel_post)) { |
|
| 112 | 109 | if (self::handlerExist('edited_channel_post')) { |
| 113 | 110 | BPT::$handler->edited_channel_post(BPT::$update->edited_channel_post); |
| 114 | 111 | } |
| 115 | - } |
|
| 116 | - elseif (isset(BPT::$update->inline_query)) { |
|
| 112 | + } elseif (isset(BPT::$update->inline_query)) { |
|
| 117 | 113 | if (self::handlerExist('inline_query')) { |
| 118 | 114 | BPT::$handler->inline_query(BPT::$update->inline_query); |
| 119 | 115 | } |
| 120 | - } |
|
| 121 | - elseif (isset(BPT::$update->callback_query)) { |
|
| 116 | + } elseif (isset(BPT::$update->callback_query)) { |
|
| 122 | 117 | if (self::handlerExist('callback_query')) { |
| 123 | 118 | BPT::$handler->callback_query(BPT::$update->callback_query); |
| 124 | 119 | } |
| 125 | - } |
|
| 126 | - elseif (isset(BPT::$update->my_chat_member)) { |
|
| 120 | + } elseif (isset(BPT::$update->my_chat_member)) { |
|
| 127 | 121 | if (self::handlerExist('my_chat_member')) { |
| 128 | 122 | BPT::$handler->my_chat_member(BPT::$update->my_chat_member); |
| 129 | 123 | } |
| 130 | - } |
|
| 131 | - elseif (isset(BPT::$update->chat_member)) { |
|
| 124 | + } elseif (isset(BPT::$update->chat_member)) { |
|
| 132 | 125 | if (self::handlerExist('chat_member')) { |
| 133 | 126 | BPT::$handler->chat_member(BPT::$update->chat_member); |
| 134 | 127 | } |
| 135 | - } |
|
| 136 | - elseif (isset(BPT::$update->chat_join_request)) { |
|
| 128 | + } elseif (isset(BPT::$update->chat_join_request)) { |
|
| 137 | 129 | if (self::handlerExist('chat_join_request')) { |
| 138 | 130 | BPT::$handler->chat_join_request(BPT::$update->chat_join_request); |
| 139 | 131 | } |
| 140 | - } |
|
| 141 | - elseif (self::handlerExist('something_else')) { |
|
| 132 | + } elseif (self::handlerExist('something_else')) { |
|
| 142 | 133 | BPT::$handler->something_else(BPT::$update); |
| 143 | - } |
|
| 144 | - else { |
|
| 134 | + } else { |
|
| 145 | 135 | logger::write('Update received but handlers are not set',loggerTypes::WARNING); |
| 146 | 136 | } |
| 147 | 137 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | $ip = $ip ?? tools::remoteIP(); |
| 36 | 36 | if (!tools::isTelegram($ip)) { |
| 37 | 37 | if (!callback::process()) { |
| 38 | - logger::write('not authorized access denied. IP : '. $ip ?? 'unknown',loggerTypes::WARNING); |
|
| 38 | + logger::write('not authorized access denied. IP : '.$ip ?? 'unknown', loggerTypes::WARNING); |
|
| 39 | 39 | BPT::exit(); |
| 40 | 40 | } |
| 41 | 41 | die('callback handler stole the process :('); |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - protected static function processUpdate(string|stdClass|update $update = null): void { |
|
| 46 | + protected static function processUpdate(string | stdClass | update $update = null): void { |
|
| 47 | 47 | if (!is_object($update)) { |
| 48 | 48 | $update = json_decode($update ?? file_get_contents('php://input')); |
| 49 | 49 | if (!$update) { |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - if (settings::$use_types_classes && !is_a($update,'update')) { |
|
| 61 | + if (settings::$use_types_classes && !is_a($update, 'update')) { |
|
| 62 | 62 | $update = new update($update); |
| 63 | 63 | } |
| 64 | 64 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | db::save(); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - protected static function setMessageExtra (stdClass|update &$update): void { |
|
| 72 | + protected static function setMessageExtra(stdClass | update & $update): void { |
|
| 73 | 73 | if (!isset($update->message->text) && !isset($update->edited_message->text)) { |
| 74 | 74 | return; |
| 75 | 75 | } |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | BPT::$handler->something_else(BPT::$update); |
| 146 | 146 | } |
| 147 | 147 | else { |
| 148 | - logger::write('Update received but handlers are not set',loggerTypes::WARNING); |
|
| 148 | + logger::write('Update received but handlers are not set', loggerTypes::WARNING); |
|
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | |
@@ -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 >= 4 && $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 | /** |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | * |
| 252 | 252 | * @return string|int|false string for formatted data , int for normal data , false when size can not be found(file not found or ...) |
| 253 | 253 | */ |
| 254 | - public static function size (string $path, bool $format = true, bool $space_between = true): string|int|false { |
|
| 254 | + public static function size(string $path, bool $format = true, bool $space_between = true): string | int | false { |
|
| 255 | 255 | if (filter_var($path, FILTER_VALIDATE_URL)) { |
| 256 | 256 | $ch = curl_init($path); |
| 257 | 257 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | $size = file_exists($path) ? filesize($path) : false; |
| 267 | 267 | } |
| 268 | 268 | if (isset($size) && is_numeric($size)) { |
| 269 | - return $format ? tools::byteFormat($size, space_between: $space_between) : $size; |
|
| 269 | + return $format ? tools::byteFormat($size, space_between : $space_between) : $size; |
|
| 270 | 270 | } |
| 271 | 271 | return false; |
| 272 | 272 | } |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | * @return bool |
| 285 | 285 | * @throws bptException |
| 286 | 286 | */ |
| 287 | - public static function delete (string $path, bool $sub = true): bool { |
|
| 287 | + public static function delete(string $path, bool $sub = true): bool { |
|
| 288 | 288 | $path = realpath($path); |
| 289 | 289 | if (!is_dir($path)) { |
| 290 | 290 | return unlink($path); |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | return rmdir($path); |
| 294 | 294 | } |
| 295 | 295 | if (!$sub) { |
| 296 | - 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 | + logger::write("tools::delete function used\ndelete function cannot delete folder because its have subFiles and sub parameter haven't true value", loggerTypes::ERROR); |
|
| 297 | 297 | throw new bptException('DELETE_FOLDER_HAS_SUB'); |
| 298 | 298 | } |
| 299 | 299 | $it = new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS); |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | * @return bool |
| 316 | 316 | * @throws bptException when zip extension not found |
| 317 | 317 | */ |
| 318 | - public static function zip (string $path, string $destination): bool { |
|
| 318 | + public static function zip(string $path, string $destination): bool { |
|
| 319 | 319 | if (!extension_loaded('zip')) { |
| 320 | 320 | logger::write("tools::zip function used\nzip extension is not found , It may not be installed or enabled", loggerTypes::ERROR); |
| 321 | 321 | throw new bptException('ZIP_EXTENSION_MISSING'); |
@@ -350,14 +350,14 @@ discard block |
||
| 350 | 350 | * |
| 351 | 351 | * @return bool true on success and false in failure |
| 352 | 352 | */ |
| 353 | - public static function downloadFile (string $url, string $path, int $chunk_size = 512): bool { |
|
| 353 | + public static function downloadFile(string $url, string $path, int $chunk_size = 512): bool { |
|
| 354 | 354 | $file = fopen($url, 'rb'); |
| 355 | 355 | if (!$file) return false; |
| 356 | 356 | $path = fopen($path, 'wb'); |
| 357 | 357 | if (!$path) return false; |
| 358 | 358 | |
| 359 | 359 | $length = $chunk_size * 1024; |
| 360 | - while (!feof($file)){ |
|
| 360 | + while (!feof($file)) { |
|
| 361 | 361 | fwrite($path, fread($file, $length), $length); |
| 362 | 362 | } |
| 363 | 363 | fclose($path); |
@@ -380,10 +380,10 @@ discard block |
||
| 380 | 380 | * |
| 381 | 381 | * @return string |
| 382 | 382 | */ |
| 383 | - public static function byteFormat (int $byte, int $precision = 2, bool $space_between = true): string { |
|
| 383 | + public static function byteFormat(int $byte, int $precision = 2, bool $space_between = true): string { |
|
| 384 | 384 | $rate_counter = 0; |
| 385 | 385 | |
| 386 | - while ($byte > 1024){ |
|
| 386 | + while ($byte > 1024) { |
|
| 387 | 387 | $byte /= 1024; |
| 388 | 388 | $rate_counter++; |
| 389 | 389 | } |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | $byte = round($byte, $precision); |
| 393 | 393 | } |
| 394 | 394 | |
| 395 | - return $byte . ($space_between ? ' ' : '') . ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'][$rate_counter]; |
|
| 395 | + return $byte.($space_between ? ' ' : '').['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'][$rate_counter]; |
|
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | /** |
@@ -409,10 +409,10 @@ discard block |
||
| 409 | 409 | * |
| 410 | 410 | * @return string|false return false when mode is incorrect |
| 411 | 411 | */ |
| 412 | - public static function modeEscape (string $text, string $mode = parseMode::HTML): string|false { |
|
| 412 | + public static function modeEscape(string $text, string $mode = parseMode::HTML): string | false { |
|
| 413 | 413 | return match ($mode) { |
| 414 | - parseMode::HTML => str_replace(['&', '<', '>',], ["&", "<", ">",], $text), |
|
| 415 | - parseMode::MARKDOWN => str_replace(['\\', '_', '*', '`', '['], ['\\\\', '\_', '\*', '\`', '\[',], $text), |
|
| 414 | + parseMode::HTML => str_replace(['&', '<', '>', ], ["&", "<", ">", ], $text), |
|
| 415 | + parseMode::MARKDOWN => str_replace(['\\', '_', '*', '`', '['], ['\\\\', '\_', '\*', '\`', '\[', ], $text), |
|
| 416 | 416 | parseMode::MARKDOWNV2 => str_replace( |
| 417 | 417 | ['_', '*', '[', ']', '(', ')', '~', '`', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!', '\\'], |
| 418 | 418 | ['\_', '\*', '\[', '\]', '\(', '\)', '\~', '\`', '\>', '\#', '\+', '\-', '\=', '\|', '\{', '\}', '\.', '\!', '\\\\'], |
@@ -451,9 +451,9 @@ discard block |
||
| 451 | 451 | * @return array{status: string,year: string,month: string,day: string,hour: string,minute: string,second: string} |
| 452 | 452 | * @throws Exception |
| 453 | 453 | */ |
| 454 | - public static function timeDiff (int|string $target_time, int|string|null $base_time = null): array { |
|
| 454 | + public static function timeDiff(int | string $target_time, int | string | null $base_time = null): array { |
|
| 455 | 455 | $base_time = new DateTime($base_time ?? '@'.time()); |
| 456 | - $target_time = new DateTime(is_numeric($target_time) ? '@' . $target_time : $target_time . ' +00:00'); |
|
| 456 | + $target_time = new DateTime(is_numeric($target_time) ? '@'.$target_time : $target_time.' +00:00'); |
|
| 457 | 457 | |
| 458 | 458 | $diff = $base_time->diff($target_time); |
| 459 | 459 | |
@@ -480,12 +480,12 @@ discard block |
||
| 480 | 480 | * |
| 481 | 481 | * @return string[]|string |
| 482 | 482 | */ |
| 483 | - public static function realEscapeString(string|array $input): string|array { |
|
| 484 | - if(is_array($input)) { |
|
| 483 | + public static function realEscapeString(string | array $input): string | array { |
|
| 484 | + if (is_array($input)) { |
|
| 485 | 485 | return array_map(__METHOD__, $input); |
| 486 | 486 | } |
| 487 | 487 | |
| 488 | - if(!empty($input) && is_string($input)) { |
|
| 488 | + if (!empty($input) && is_string($input)) { |
|
| 489 | 489 | return str_replace(['\\', "\0", "\n", "\r", "'", '"', "\x1a"], ['\\\\', '\\0', '\\n', '\\r', "\\'", '\\"', '\\Z'], $input); |
| 490 | 490 | } |
| 491 | 491 | |
@@ -503,7 +503,7 @@ discard block |
||
| 503 | 503 | * |
| 504 | 504 | * @return string[]|string |
| 505 | 505 | */ |
| 506 | - public static function strReplaceFirst(string|array $search, string|array $replace, string|array $subject): string|array { |
|
| 506 | + public static function strReplaceFirst(string | array $search, string | array $replace, string | array $subject): string | array { |
|
| 507 | 507 | $pos = strpos($subject, $search); |
| 508 | 508 | if ($pos !== false) { |
| 509 | 509 | return substr_replace($subject, $replace, $pos, strlen($search)); |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | * |
| 521 | 521 | * @return string see possible values in fileType class |
| 522 | 522 | */ |
| 523 | - public static function fileType (string $file_id): string { |
|
| 523 | + public static function fileType(string $file_id): string { |
|
| 524 | 524 | $data = base64_decode(str_pad(strtr($file_id, '-_', '+/'), strlen($file_id) % 4, '=')); |
| 525 | 525 | $new = ''; |
| 526 | 526 | $last = ''; |
@@ -534,7 +534,7 @@ discard block |
||
| 534 | 534 | $last = $char; |
| 535 | 535 | } |
| 536 | 536 | } |
| 537 | - $data = unpack('VtypeId/Vdc_id', $new . $last); |
|
| 537 | + $data = unpack('VtypeId/Vdc_id', $new.$last); |
|
| 538 | 538 | $data['typeId'] = $data['typeId'] & ~33554432 & ~16777216; |
| 539 | 539 | return [ |
| 540 | 540 | fileTypes::THUMBNAIL, |
@@ -572,10 +572,10 @@ discard block |
||
| 572 | 572 | * |
| 573 | 573 | * @return string |
| 574 | 574 | */ |
| 575 | - public static function randomString (int $length = 16, string $characters = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'): string { |
|
| 575 | + public static function randomString(int $length = 16, string $characters = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'): string { |
|
| 576 | 576 | $rand_string = ''; |
| 577 | 577 | $char_len = strlen($characters) - 1; |
| 578 | - for ($i = 0; $i < $length; $i ++) { |
|
| 578 | + for ($i = 0; $i < $length; $i++) { |
|
| 579 | 579 | $rand_string .= $characters[rand(0, $char_len)]; |
| 580 | 580 | } |
| 581 | 581 | return $rand_string; |
@@ -604,7 +604,7 @@ discard block |
||
| 604 | 604 | * @return inlineKeyboardMarkup|replyKeyboardMarkup replyKeyboardMarkup for keyboard and inlineKeyboardMarkup for inline |
| 605 | 605 | * @throws bptException |
| 606 | 606 | */ |
| 607 | - public static function easyKey(array $keyboard = [], array $inline = []): inlineKeyboardMarkup|replyKeyboardMarkup { |
|
| 607 | + public static function easyKey(array $keyboard = [], array $inline = []): inlineKeyboardMarkup | replyKeyboardMarkup { |
|
| 608 | 608 | if (!empty($keyboard)) { |
| 609 | 609 | $keyboard_object = new replyKeyboardMarkup(); |
| 610 | 610 | $keyboard_object->setResize_keyboard($keyboard['resize'] ?? true); |
@@ -667,7 +667,7 @@ discard block |
||
| 667 | 667 | $keyboard_object->setInline_keyboard($rows); |
| 668 | 668 | return $keyboard_object; |
| 669 | 669 | } |
| 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 | |
@@ -683,10 +683,10 @@ discard block |
||
| 683 | 683 | * |
| 684 | 684 | * @return string |
| 685 | 685 | */ |
| 686 | - public static function inviteLink (int $user_id = null, string $bot_username = null): string { |
|
| 686 | + public static function inviteLink(int $user_id = null, string $bot_username = null): string { |
|
| 687 | 687 | if (empty($user_id)) $user_id = telegram::catchFields(fields::USER_ID); |
| 688 | 688 | if (empty($bot_username)) $bot_username = telegram::getMe()->username; |
| 689 | - return 'https://t.me/' . str_replace('@', '', $bot_username) . '?start=ref_' . tools::shortEncode($user_id); |
|
| 689 | + return 'https://t.me/'.str_replace('@', '', $bot_username).'?start=ref_'.tools::shortEncode($user_id); |
|
| 690 | 690 | } |
| 691 | 691 | |
| 692 | 692 | /** |
@@ -710,9 +710,9 @@ discard block |
||
| 710 | 710 | * @return string|bool|array{hash:string, key:string, iv:string} |
| 711 | 711 | * @throws bptException |
| 712 | 712 | */ |
| 713 | - public static function codec (string $action, string $text, string $key = null, string $iv = null): bool|array|string { |
|
| 713 | + public static function codec(string $action, string $text, string $key = null, string $iv = null): bool | array | string { |
|
| 714 | 714 | if (!extension_loaded('openssl')) { |
| 715 | - logger::write("tools::codec function used\nopenssl extension is not found , It may not be installed or enabled",loggerTypes::ERROR); |
|
| 715 | + logger::write("tools::codec function used\nopenssl extension is not found , It may not be installed or enabled", loggerTypes::ERROR); |
|
| 716 | 716 | throw new bptException('OPENSSL_EXTENSION_MISSING'); |
| 717 | 717 | } |
| 718 | 718 | if ($action === codecAction::ENCRYPT) { |
@@ -723,16 +723,16 @@ discard block |
||
| 723 | 723 | } |
| 724 | 724 | if ($action === codecAction::DECRYPT) { |
| 725 | 725 | if (empty($key)) { |
| 726 | - logger::write("tools::codec function used\nkey parameter is not set",loggerTypes::ERROR); |
|
| 726 | + logger::write("tools::codec function used\nkey parameter is not set", loggerTypes::ERROR); |
|
| 727 | 727 | throw new bptException('ARGUMENT_NOT_FOUND_KEY'); |
| 728 | 728 | } |
| 729 | 729 | if (empty($iv)) { |
| 730 | - logger::write("tools::codec function used\niv parameter is not set",loggerTypes::ERROR); |
|
| 730 | + logger::write("tools::codec function used\niv parameter is not set", loggerTypes::ERROR); |
|
| 731 | 731 | throw new bptException('ARGUMENT_NOT_FOUND_IV'); |
| 732 | 732 | } |
| 733 | 733 | return openssl_decrypt(base64_decode($text), 'AES-256-CBC', $key, 1, $iv); |
| 734 | 734 | } |
| 735 | - logger::write("tools::codec function used\naction is not right, its must be `encode` or `decode`",loggerTypes::WARNING); |
|
| 735 | + logger::write("tools::codec function used\naction is not right, its must be `encode` or `decode`", loggerTypes::WARNING); |
|
| 736 | 736 | return false; |
| 737 | 737 | } |
| 738 | 738 | |
@@ -748,7 +748,7 @@ discard block |
||
| 748 | 748 | public static function shortEncode(int $num): string { |
| 749 | 749 | $codes = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; |
| 750 | 750 | $array = []; |
| 751 | - while ($num > 0){ |
|
| 751 | + while ($num > 0) { |
|
| 752 | 752 | $array[] = $num % 62; |
| 753 | 753 | $num = floor($num / 62); |
| 754 | 754 | } |
@@ -756,7 +756,7 @@ discard block |
||
| 756 | 756 | foreach ($array as &$value) { |
| 757 | 757 | $value = $codes[$value]; |
| 758 | 758 | } |
| 759 | - return strrev(implode('',$array)); |
|
| 759 | + return strrev(implode('', $array)); |
|
| 760 | 760 | } |
| 761 | 761 | |
| 762 | 762 | /** |
@@ -773,7 +773,7 @@ discard block |
||
| 773 | 773 | $num = 0; |
| 774 | 774 | $text = str_split(strrev($text)); |
| 775 | 775 | foreach ($text as $key=>$value) { |
| 776 | - $num += strpos($codes,$value) * pow(62,$key); |
|
| 776 | + $num += strpos($codes, $value) * pow(62, $key); |
|
| 777 | 777 | } |
| 778 | 778 | return $num; |
| 779 | 779 | } |
@@ -217,8 +217,9 @@ discard block |
||
| 217 | 217 | if (telegram::$status) { |
| 218 | 218 | $check = $check->status; |
| 219 | 219 | $result[$id] = $check !== chatMemberStatus::LEFT && $check !== chatMemberStatus::KICKED; |
| 220 | + } else { |
|
| 221 | + $result[$id] = null; |
|
| 220 | 222 | } |
| 221 | - else $result[$id] = null; |
|
| 222 | 223 | } |
| 223 | 224 | return $result; |
| 224 | 225 | } |
@@ -260,8 +261,7 @@ discard block |
||
| 260 | 261 | curl_exec($ch); |
| 261 | 262 | $size = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD); |
| 262 | 263 | curl_close($ch); |
| 263 | - } |
|
| 264 | - else { |
|
| 264 | + } else { |
|
| 265 | 265 | $path = realpath($path); |
| 266 | 266 | $size = file_exists($path) ? filesize($path) : false; |
| 267 | 267 | } |
@@ -332,8 +332,7 @@ discard block |
||
| 332 | 332 | $zip->addFile($filePath, substr($filePath, $root_len)); |
| 333 | 333 | } |
| 334 | 334 | } |
| 335 | - } |
|
| 336 | - else { |
|
| 335 | + } else { |
|
| 337 | 336 | $zip->addFile($path, basename($path)); |
| 338 | 337 | } |
| 339 | 338 | return $zip->close(); |
@@ -352,9 +351,13 @@ discard block |
||
| 352 | 351 | */ |
| 353 | 352 | public static function downloadFile (string $url, string $path, int $chunk_size = 512): bool { |
| 354 | 353 | $file = fopen($url, 'rb'); |
| 355 | - if (!$file) return false; |
|
| 354 | + if (!$file) { |
|
| 355 | + return false; |
|
| 356 | + } |
|
| 356 | 357 | $path = fopen($path, 'wb'); |
| 357 | - if (!$path) return false; |
|
| 358 | + if (!$path) { |
|
| 359 | + return false; |
|
| 360 | + } |
|
| 358 | 361 | |
| 359 | 362 | $length = $chunk_size * 1024; |
| 360 | 363 | while (!feof($file)){ |
@@ -461,8 +464,9 @@ discard block |
||
| 461 | 464 | foreach ($string as $k => &$v) { |
| 462 | 465 | if ($diff->$v) { |
| 463 | 466 | $v = $diff->$v; |
| 467 | + } else { |
|
| 468 | + unset($string[$k]); |
|
| 464 | 469 | } |
| 465 | - else unset($string[$k]); |
|
| 466 | 470 | } |
| 467 | 471 | $string['status'] = $base_time < $target_time ? 'later' : 'ago'; |
| 468 | 472 | |
@@ -528,8 +532,7 @@ discard block |
||
| 528 | 532 | if ($last === "\0") { |
| 529 | 533 | $new .= str_repeat($last, ord($char)); |
| 530 | 534 | $last = ''; |
| 531 | - } |
|
| 532 | - else { |
|
| 535 | + } else { |
|
| 533 | 536 | $new .= $last; |
| 534 | 537 | $last = $char; |
| 535 | 538 | } |
@@ -613,7 +616,9 @@ discard block |
||
| 613 | 616 | } |
| 614 | 617 | $rows = []; |
| 615 | 618 | foreach ($keyboard as $row) { |
| 616 | - if (!is_array($row)) continue; |
|
| 619 | + if (!is_array($row)) { |
|
| 620 | + continue; |
|
| 621 | + } |
|
| 617 | 622 | $buttons = []; |
| 618 | 623 | foreach ($row as $base_button) { |
| 619 | 624 | $button_info = explode('||', $base_button); |
@@ -622,15 +627,12 @@ discard block |
||
| 622 | 627 | if (count($button_info) > 1) { |
| 623 | 628 | if ($button_info[1] === 'con') { |
| 624 | 629 | $button->setRequest_contact(true); |
| 625 | - } |
|
| 626 | - elseif ($button_info[1] === 'loc') { |
|
| 630 | + } elseif ($button_info[1] === 'loc') { |
|
| 627 | 631 | $button->setRequest_location(true); |
| 628 | - } |
|
| 629 | - elseif ($button_info[1] === 'poll') { |
|
| 632 | + } elseif ($button_info[1] === 'poll') { |
|
| 630 | 633 | $type = $button_info[2] === pollType::QUIZ ? pollType::QUIZ : pollType::REGULAR; |
| 631 | 634 | $button->setRequest_poll((new keyboardButtonPollType())->setType($type)); |
| 632 | - } |
|
| 633 | - elseif ($button_info[1] === 'web' && isset($button_info[2])) { |
|
| 635 | + } elseif ($button_info[1] === 'web' && isset($button_info[2])) { |
|
| 634 | 636 | $url = $button_info[2]; |
| 635 | 637 | $button->setWeb_app((new webAppInfo())->setUrl($url)); |
| 636 | 638 | } |
@@ -652,12 +654,10 @@ discard block |
||
| 652 | 654 | if (isset($button_info[1])) { |
| 653 | 655 | if (filter_var($button_info[1], FILTER_VALIDATE_URL) && str_starts_with($button_info[1], 'http')) { |
| 654 | 656 | $button->setText($button_info[0])->setUrl($button_info[1]); |
| 655 | - } |
|
| 656 | - else { |
|
| 657 | + } else { |
|
| 657 | 658 | $button->setText($button_info[0])->setCallback_data($button_info[1]); |
| 658 | 659 | } |
| 659 | - } |
|
| 660 | - else { |
|
| 660 | + } else { |
|
| 661 | 661 | $button->setText($button_info[0])->setUrl('https://t.me/BPT_CH'); |
| 662 | 662 | } |
| 663 | 663 | $buttons[] = $button; |
@@ -684,8 +684,12 @@ discard block |
||
| 684 | 684 | * @return string |
| 685 | 685 | */ |
| 686 | 686 | public static function inviteLink (int $user_id = null, string $bot_username = null): string { |
| 687 | - if (empty($user_id)) $user_id = telegram::catchFields(fields::USER_ID); |
|
| 688 | - if (empty($bot_username)) $bot_username = telegram::getMe()->username; |
|
| 687 | + if (empty($user_id)) { |
|
| 688 | + $user_id = telegram::catchFields(fields::USER_ID); |
|
| 689 | + } |
|
| 690 | + if (empty($bot_username)) { |
|
| 691 | + $bot_username = telegram::getMe()->username; |
|
| 692 | + } |
|
| 689 | 693 | return 'https://t.me/' . str_replace('@', '', $bot_username) . '?start=ref_' . tools::shortEncode($user_id); |
| 690 | 694 | } |
| 691 | 695 | |
@@ -752,7 +756,9 @@ discard block |
||
| 752 | 756 | $array[] = $num % 62; |
| 753 | 757 | $num = floor($num / 62); |
| 754 | 758 | } |
| 755 | - if (count($array) < 1) $array = [0]; |
|
| 759 | + if (count($array) < 1) { |
|
| 760 | + $array = [0]; |
|
| 761 | + } |
|
| 756 | 762 | foreach ($array as &$value) { |
| 757 | 763 | $value = $codes[$value]; |
| 758 | 764 | } |
@@ -22,30 +22,30 @@ discard block |
||
| 22 | 22 | * |
| 23 | 23 | * @return void |
| 24 | 24 | */ |
| 25 | - public static function init (string $cpanelUser, string $cpanelPassword, string $cpanelUrl = '127.0.0.1', int $cpanelPort = 2083): void { |
|
| 25 | + public static function init(string $cpanelUser, string $cpanelPassword, string $cpanelUrl = '127.0.0.1', int $cpanelPort = 2083): void { |
|
| 26 | 26 | self::$cpanelUser = $cpanelUser; |
| 27 | 27 | self::$cpanelPassword = $cpanelPassword; |
| 28 | 28 | self::$cpanelUrl = $cpanelUrl; |
| 29 | 29 | self::$cpanelPort = $cpanelPort; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - private static function createCurl () { |
|
| 32 | + private static function createCurl() { |
|
| 33 | 33 | $curl = curl_init(); |
| 34 | 34 | curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); |
| 35 | 35 | curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); |
| 36 | 36 | curl_setopt($curl, CURLOPT_HEADER, 0); |
| 37 | 37 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); |
| 38 | - $header[0] = 'Authorization: Basic ' . base64_encode(self::$cpanelUser . ':' . self::$cpanelPassword) . "\n\r"; |
|
| 38 | + $header[0] = 'Authorization: Basic '.base64_encode(self::$cpanelUser.':'.self::$cpanelPassword)."\n\r"; |
|
| 39 | 39 | curl_setopt($curl, CURLOPT_HTTPHEADER, $header); |
| 40 | 40 | return $curl; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - private static function execute (string $query = ''): bool|stdClass|array { |
|
| 43 | + private static function execute(string $query = ''): bool | stdClass | array { |
|
| 44 | 44 | $curl = self::createCurl(); |
| 45 | - curl_setopt($curl, CURLOPT_URL, 'https://' . self::$cpanelUrl . ':' . self::$cpanelPort . '/execute/' . $query); |
|
| 45 | + curl_setopt($curl, CURLOPT_URL, 'https://'.self::$cpanelUrl.':'.self::$cpanelPort.'/execute/'.$query); |
|
| 46 | 46 | $result = curl_exec($curl); |
| 47 | 47 | if (!$result) { |
| 48 | - error_log('curl_exec threw error `' . curl_error($curl) . "` for $query"); |
|
| 48 | + error_log('curl_exec threw error `'.curl_error($curl)."` for $query"); |
|
| 49 | 49 | } |
| 50 | 50 | curl_close($curl); |
| 51 | 51 | $result = json_decode($result); |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | return $result->data ?? true; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - private static function executev2 (string $module, string $function, array $vars = []) { |
|
| 58 | + private static function executev2(string $module, string $function, array $vars = []) { |
|
| 59 | 59 | $curl = self::createCurl(); |
| 60 | 60 | $vars = array_merge([ |
| 61 | 61 | 'cpanel_jsonapi_user' => 'user', |
@@ -63,10 +63,10 @@ discard block |
||
| 63 | 63 | 'cpanel_jsonapi_module' => $module, |
| 64 | 64 | 'cpanel_jsonapi_func' => $function, |
| 65 | 65 | ], $vars); |
| 66 | - curl_setopt($curl, CURLOPT_URL, 'https://' . self::$cpanelUrl . ':' . self::$cpanelPort . '/json-api/cpanel?' . http_build_query($vars)); |
|
| 66 | + curl_setopt($curl, CURLOPT_URL, 'https://'.self::$cpanelUrl.':'.self::$cpanelPort.'/json-api/cpanel?'.http_build_query($vars)); |
|
| 67 | 67 | $result = curl_exec($curl); |
| 68 | 68 | if (!$result) { |
| 69 | - error_log('curl_exec threw error `' . curl_error($curl) . '` for ' . json_encode($vars)); |
|
| 69 | + error_log('curl_exec threw error `'.curl_error($curl).'` for '.json_encode($vars)); |
|
| 70 | 70 | } |
| 71 | 71 | curl_close($curl); |
| 72 | 72 | return $result; |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * |
| 81 | 81 | * @return array |
| 82 | 82 | */ |
| 83 | - public static function mysqlWizard (string $database, string $user, string $password, array $privileges = []): array { |
|
| 83 | + public static function mysqlWizard(string $database, string $user, string $password, array $privileges = []): array { |
|
| 84 | 84 | $create_database = self::createMysqlDatabase($database); |
| 85 | 85 | $create_user = self::createMysqlUser($user, $password); |
| 86 | 86 | if (empty($privileges)) { |
@@ -101,9 +101,9 @@ discard block |
||
| 101 | 101 | * |
| 102 | 102 | * @return bool|array|stdClass |
| 103 | 103 | */ |
| 104 | - public static function createMysqlDatabase (string $database): bool|array|stdClass { |
|
| 104 | + public static function createMysqlDatabase(string $database): bool | array | stdClass { |
|
| 105 | 105 | if (!str_starts_with($database, self::$cpanelUser)) { |
| 106 | - $database = self::$cpanelUser . '_' . $database; |
|
| 106 | + $database = self::$cpanelUser.'_'.$database; |
|
| 107 | 107 | } |
| 108 | 108 | return self::execute("Mysql/create_database?name=$database"); |
| 109 | 109 | } |
@@ -113,9 +113,9 @@ discard block |
||
| 113 | 113 | * |
| 114 | 114 | * @return bool|array|stdClass |
| 115 | 115 | */ |
| 116 | - public static function deleteMysqlDatabase (string $database): bool|array|stdClass { |
|
| 116 | + public static function deleteMysqlDatabase(string $database): bool | array | stdClass { |
|
| 117 | 117 | if (!str_starts_with($database, self::$cpanelUser)) { |
| 118 | - $database = self::$cpanelUser . '_' . $database; |
|
| 118 | + $database = self::$cpanelUser.'_'.$database; |
|
| 119 | 119 | } |
| 120 | 120 | return self::execute("Mysql/delete_database?name=$database"); |
| 121 | 121 | } |
@@ -126,9 +126,9 @@ discard block |
||
| 126 | 126 | * |
| 127 | 127 | * @return bool|array|stdClass |
| 128 | 128 | */ |
| 129 | - public static function createMysqlUser (string $user, string $password): bool|array|stdClass { |
|
| 129 | + public static function createMysqlUser(string $user, string $password): bool | array | stdClass { |
|
| 130 | 130 | if (!str_starts_with($user, self::$cpanelUser)) { |
| 131 | - $user = self::$cpanelUser . '_' . $user; |
|
| 131 | + $user = self::$cpanelUser.'_'.$user; |
|
| 132 | 132 | } |
| 133 | 133 | return self::execute("Mysql/create_user?name=$user&password=$password"); |
| 134 | 134 | } |
@@ -138,9 +138,9 @@ discard block |
||
| 138 | 138 | * |
| 139 | 139 | * @return bool|array|stdClass |
| 140 | 140 | */ |
| 141 | - public static function deleteMysqlUser (string $user): bool|array|stdClass { |
|
| 141 | + public static function deleteMysqlUser(string $user): bool | array | stdClass { |
|
| 142 | 142 | if (!str_starts_with($user, self::$cpanelUser)) { |
| 143 | - $user = self::$cpanelUser . '_' . $user; |
|
| 143 | + $user = self::$cpanelUser.'_'.$user; |
|
| 144 | 144 | } |
| 145 | 145 | return self::execute("Mysql/delete_user?name=$user"); |
| 146 | 146 | } |
@@ -152,12 +152,12 @@ discard block |
||
| 152 | 152 | * |
| 153 | 153 | * @return bool|array|stdClass |
| 154 | 154 | */ |
| 155 | - public static function setMysqlPrivileges (string $database, string $user, array $privileges): bool|array|stdClass { |
|
| 155 | + public static function setMysqlPrivileges(string $database, string $user, array $privileges): bool | array | stdClass { |
|
| 156 | 156 | if (!str_starts_with($database, self::$cpanelUser)) { |
| 157 | - $database = self::$cpanelUser . '_' . $database; |
|
| 157 | + $database = self::$cpanelUser.'_'.$database; |
|
| 158 | 158 | } |
| 159 | 159 | if (!str_starts_with($user, self::$cpanelUser)) { |
| 160 | - $user = self::$cpanelUser . '_' . $user; |
|
| 160 | + $user = self::$cpanelUser.'_'.$user; |
|
| 161 | 161 | } |
| 162 | 162 | $all_privileges = [ |
| 163 | 163 | 'ALTER', |
@@ -193,12 +193,12 @@ discard block |
||
| 193 | 193 | * |
| 194 | 194 | * @return bool|array|stdClass |
| 195 | 195 | */ |
| 196 | - public static function setMysqlPrivilegesAll (string $database, string $user): bool|array|stdClass { |
|
| 196 | + public static function setMysqlPrivilegesAll(string $database, string $user): bool | array | stdClass { |
|
| 197 | 197 | if (!str_starts_with($database, self::$cpanelUser)) { |
| 198 | - $database = self::$cpanelUser . '_' . $database; |
|
| 198 | + $database = self::$cpanelUser.'_'.$database; |
|
| 199 | 199 | } |
| 200 | 200 | if (!str_starts_with($user, self::$cpanelUser)) { |
| 201 | - $user = self::$cpanelUser . '_' . $user; |
|
| 201 | + $user = self::$cpanelUser.'_'.$user; |
|
| 202 | 202 | } |
| 203 | 203 | return self::execute("Mysql/set_privileges_on_database?user=$user&database=$database&privileges=ALL"); |
| 204 | 204 | } |
@@ -209,12 +209,12 @@ discard block |
||
| 209 | 209 | * |
| 210 | 210 | * @return bool|array|stdClass |
| 211 | 211 | */ |
| 212 | - public static function changeMysqlDatabaseName (string $old_name, string $new_name): bool|array|stdClass { |
|
| 212 | + public static function changeMysqlDatabaseName(string $old_name, string $new_name): bool | array | stdClass { |
|
| 213 | 213 | if (!str_starts_with($old_name, self::$cpanelUser)) { |
| 214 | - $old_name = self::$cpanelUser . '_' . $old_name; |
|
| 214 | + $old_name = self::$cpanelUser.'_'.$old_name; |
|
| 215 | 215 | } |
| 216 | 216 | if (!str_starts_with($new_name, self::$cpanelUser)) { |
| 217 | - $new_name = self::$cpanelUser . '_' . $new_name; |
|
| 217 | + $new_name = self::$cpanelUser.'_'.$new_name; |
|
| 218 | 218 | } |
| 219 | 219 | return self::execute("Mysql/rename_database?oldname=$old_name&newname=$new_name"); |
| 220 | 220 | } |
@@ -225,12 +225,12 @@ discard block |
||
| 225 | 225 | * |
| 226 | 226 | * @return bool|array|stdClass |
| 227 | 227 | */ |
| 228 | - public static function changeMysqlUserName (string $old_name, string $new_name): bool|array|stdClass { |
|
| 228 | + public static function changeMysqlUserName(string $old_name, string $new_name): bool | array | stdClass { |
|
| 229 | 229 | if (!str_starts_with($old_name, self::$cpanelUser)) { |
| 230 | - $old_name = self::$cpanelUser . '_' . $old_name; |
|
| 230 | + $old_name = self::$cpanelUser.'_'.$old_name; |
|
| 231 | 231 | } |
| 232 | 232 | if (!str_starts_with($new_name, self::$cpanelUser)) { |
| 233 | - $new_name = self::$cpanelUser . '_' . $new_name; |
|
| 233 | + $new_name = self::$cpanelUser.'_'.$new_name; |
|
| 234 | 234 | } |
| 235 | 235 | return self::execute("Mysql/rename_user?oldname=$old_name&newname=$new_name"); |
| 236 | 236 | } |
@@ -240,9 +240,9 @@ discard block |
||
| 240 | 240 | * |
| 241 | 241 | * @return bool|array|stdClass |
| 242 | 242 | */ |
| 243 | - public static function dumpMysqlDatabaseSchema (string $database): bool|array|stdClass { |
|
| 243 | + public static function dumpMysqlDatabaseSchema(string $database): bool | array | stdClass { |
|
| 244 | 244 | if (!str_starts_with($database, self::$cpanelUser)) { |
| 245 | - $database = self::$cpanelUser . '_' . $database; |
|
| 245 | + $database = self::$cpanelUser.'_'.$database; |
|
| 246 | 246 | } |
| 247 | 247 | return self::execute("Mysql/dump_database_schema?dbname=$database"); |
| 248 | 248 | } |
@@ -250,14 +250,14 @@ discard block |
||
| 250 | 250 | /** |
| 251 | 251 | * @return bool|array|stdClass |
| 252 | 252 | */ |
| 253 | - public static function mysqlDatabases (): bool|array|stdClass { |
|
| 253 | + public static function mysqlDatabases(): bool | array | stdClass { |
|
| 254 | 254 | return self::execute('Mysql/list_databases'); |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | /** |
| 258 | 258 | * @return bool|array|stdClass |
| 259 | 259 | */ |
| 260 | - public static function mysqlUsers (): bool|array|stdClass { |
|
| 260 | + public static function mysqlUsers(): bool | array | stdClass { |
|
| 261 | 261 | return self::execute('Mysql/list_users'); |
| 262 | 262 | } |
| 263 | 263 | } |
| 264 | 264 | \ No newline at end of file |
@@ -85,8 +85,7 @@ |
||
| 85 | 85 | $create_user = self::createMysqlUser($user, $password); |
| 86 | 86 | if (empty($privileges)) { |
| 87 | 87 | $set_privileges = self::setMysqlPrivilegesAll($database, $user); |
| 88 | - } |
|
| 89 | - else { |
|
| 88 | + } else { |
|
| 90 | 89 | $set_privileges = self::setMysqlPrivileges($database, $user, $privileges); |
| 91 | 90 | } |
| 92 | 91 | return [ |
@@ -35,27 +35,27 @@ |
||
| 35 | 35 | public int $date; |
| 36 | 36 | |
| 37 | 37 | /** Optional. Bio of the user. */ |
| 38 | - public null|string $bio = null; |
|
| 38 | + public null | string $bio = null; |
|
| 39 | 39 | |
| 40 | 40 | /** Optional. Chat invite link that was used by the user to send the join request */ |
| 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 | } |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - public function accept(): responseError|bool { |
|
| 51 | - return telegram::approveChatJoinRequest($this->chat->id,$this->from->id); |
|
| 50 | + public function accept(): responseError | bool { |
|
| 51 | + return telegram::approveChatJoinRequest($this->chat->id, $this->from->id); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - public function deny(): responseError|bool { |
|
| 55 | - return telegram::declineChatJoinRequest($this->chat->id,$this->from->id); |
|
| 54 | + public function deny(): responseError | bool { |
|
| 55 | + return telegram::declineChatJoinRequest($this->chat->id, $this->from->id); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - public function revokeLink(): responseError|bool { |
|
| 58 | + public function revokeLink(): responseError | bool { |
|
| 59 | 59 | return telegram::revokeChatInviteLink($this->invite_link->invite_link, $this->chat->id); |
| 60 | 60 | } |
| 61 | 61 | } |
@@ -68,13 +68,13 @@ discard block |
||
| 68 | 68 | public int $message_id; |
| 69 | 69 | |
| 70 | 70 | /** Optional. Unique identifier of a message thread to which the message belongs; for supergroups only */ |
| 71 | - public null|int $message_thread_id = null; |
|
| 71 | + public null | int $message_thread_id = null; |
|
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | 74 | * Optional. Sender of the message; empty for messages sent to channels. For backward compatibility, the field |
| 75 | 75 | * contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat. |
| 76 | 76 | */ |
| 77 | - public null|user $from = null; |
|
| 77 | + public null | user $from = null; |
|
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | 80 | * Optional. Sender of the message, sent on behalf of a chat. For example, the channel itself for channel posts, |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | * automatically forwarded to the discussion group. For backward compatibility, the field from contains a fake |
| 83 | 83 | * sender user in non-channel chats, if the message was sent on behalf of a chat. |
| 84 | 84 | */ |
| 85 | - public null|chat $sender_chat = null; |
|
| 85 | + public null | chat $sender_chat = null; |
|
| 86 | 86 | |
| 87 | 87 | /** Date the message was sent in Unix time */ |
| 88 | 88 | public int $date; |
@@ -91,188 +91,188 @@ discard block |
||
| 91 | 91 | public chat $chat; |
| 92 | 92 | |
| 93 | 93 | /** Optional. For forwarded messages, sender of the original message */ |
| 94 | - public null|user $forward_from = null; |
|
| 94 | + public null | user $forward_from = null; |
|
| 95 | 95 | |
| 96 | 96 | /** |
| 97 | 97 | * Optional. For messages forwarded from channels or from anonymous administrators, information about the |
| 98 | 98 | * original sender chat |
| 99 | 99 | */ |
| 100 | - public null|chat $forward_from_chat = null; |
|
| 100 | + public null | chat $forward_from_chat = null; |
|
| 101 | 101 | |
| 102 | 102 | /** Optional. For messages forwarded from channels, identifier of the original message in the channel */ |
| 103 | - public null|int $forward_from_message_id = null; |
|
| 103 | + public null | int $forward_from_message_id = null; |
|
| 104 | 104 | |
| 105 | 105 | /** |
| 106 | 106 | * Optional. For forwarded messages that were originally sent in channels or by an anonymous chat administrator, |
| 107 | 107 | * signature of the message sender if present |
| 108 | 108 | */ |
| 109 | - public null|string $forward_signature = null; |
|
| 109 | + public null | string $forward_signature = null; |
|
| 110 | 110 | |
| 111 | 111 | /** |
| 112 | 112 | * Optional. Sender's name for messages forwarded from users who disallow adding a link to their account in |
| 113 | 113 | * forwarded messages |
| 114 | 114 | */ |
| 115 | - public null|string $forward_sender_name = null; |
|
| 115 | + public null | string $forward_sender_name = null; |
|
| 116 | 116 | |
| 117 | 117 | /** Optional. For forwarded messages, date the original message was sent in Unix time */ |
| 118 | - public null|int $forward_date = null; |
|
| 118 | + public null | int $forward_date = null; |
|
| 119 | 119 | |
| 120 | 120 | /** Optional. True, if the message is sent to a forum topic */ |
| 121 | - public null|bool $is_topic_message = null; |
|
| 121 | + public null | bool $is_topic_message = null; |
|
| 122 | 122 | |
| 123 | 123 | /** |
| 124 | 124 | * Optional. True, if the message is a channel post that was automatically forwarded to the connected discussion |
| 125 | 125 | * group |
| 126 | 126 | */ |
| 127 | - public null|bool $is_automatic_forward = null; |
|
| 127 | + public null | bool $is_automatic_forward = null; |
|
| 128 | 128 | |
| 129 | 129 | /** |
| 130 | 130 | * Optional. For replies, the original message. Note that the Message object in this field will not contain |
| 131 | 131 | * further reply_to_message fields even if it itself is a reply. |
| 132 | 132 | */ |
| 133 | - public null|message $reply_to_message = null; |
|
| 133 | + public null | message $reply_to_message = null; |
|
| 134 | 134 | |
| 135 | 135 | /** Optional. Bot through which the message was sent */ |
| 136 | - public null|user $via_bot = null; |
|
| 136 | + public null | user $via_bot = null; |
|
| 137 | 137 | |
| 138 | 138 | /** Optional. Date the message was last edited in Unix time */ |
| 139 | - public null|int $edit_date = null; |
|
| 139 | + public null | int $edit_date = null; |
|
| 140 | 140 | |
| 141 | 141 | /** Optional. True, if the message can't be forwarded */ |
| 142 | - public null|bool $has_protected_content = null; |
|
| 142 | + public null | bool $has_protected_content = null; |
|
| 143 | 143 | |
| 144 | 144 | /** Optional. The unique identifier of a media message group this message belongs to */ |
| 145 | - public null|string $media_group_id = null; |
|
| 145 | + public null | string $media_group_id = null; |
|
| 146 | 146 | |
| 147 | 147 | /** |
| 148 | 148 | * Optional. Signature of the post author for messages in channels, or the custom title of an anonymous group |
| 149 | 149 | * administrator |
| 150 | 150 | */ |
| 151 | - public null|string $author_signature = null; |
|
| 151 | + public null | string $author_signature = null; |
|
| 152 | 152 | |
| 153 | 153 | /** Optional. For text messages, the actual UTF-8 text of the message */ |
| 154 | - public null|string $text = null; |
|
| 154 | + public null | string $text = null; |
|
| 155 | 155 | |
| 156 | 156 | /** Optional. If user message was a command , this parameter will be the command */ |
| 157 | - public string|null $command = null; |
|
| 157 | + public string | null $command = null; |
|
| 158 | 158 | |
| 159 | 159 | /** Optional. If user message was a command , this parameter will be the command username(if exist) */ |
| 160 | - public string|null $command_username = null; |
|
| 160 | + public string | null $command_username = null; |
|
| 161 | 161 | |
| 162 | 162 | /** Optional. If user message was a command , this parameter will be the command payload(if exist) */ |
| 163 | - public string|null $command_payload = null; |
|
| 163 | + public string | null $command_payload = null; |
|
| 164 | 164 | |
| 165 | 165 | /** |
| 166 | 166 | * Optional. For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text |
| 167 | 167 | * @var messageEntity[] |
| 168 | 168 | */ |
| 169 | - public null|array $entities = null; |
|
| 169 | + public null | array $entities = null; |
|
| 170 | 170 | |
| 171 | 171 | /** |
| 172 | 172 | * Optional. Message is an animation, information about the animation. For backward compatibility, when this |
| 173 | 173 | * field is set, the document field will also be set |
| 174 | 174 | */ |
| 175 | - public null|animation $animation = null; |
|
| 175 | + public null | animation $animation = null; |
|
| 176 | 176 | |
| 177 | 177 | /** Optional. Message is an audio file, information about the file */ |
| 178 | - public null|audio $audio = null; |
|
| 178 | + public null | audio $audio = null; |
|
| 179 | 179 | |
| 180 | 180 | /** Optional. Message is a general file, information about the file */ |
| 181 | - public null|document $document = null; |
|
| 181 | + public null | document $document = null; |
|
| 182 | 182 | |
| 183 | 183 | /** |
| 184 | 184 | * Optional. Message is a photo, available sizes of the photo |
| 185 | 185 | * @var photoSize[] |
| 186 | 186 | */ |
| 187 | - public null|array $photo = null; |
|
| 187 | + public null | array $photo = null; |
|
| 188 | 188 | |
| 189 | 189 | /** Optional. Message is a sticker, information about the sticker */ |
| 190 | - public null|sticker $sticker = null; |
|
| 190 | + public null | sticker $sticker = null; |
|
| 191 | 191 | |
| 192 | 192 | /** Optional. Message is a video, information about the video */ |
| 193 | - public null|video $video = null; |
|
| 193 | + public null | video $video = null; |
|
| 194 | 194 | |
| 195 | 195 | /** Optional. Message is a video note, information about the video message */ |
| 196 | - public null|videoNote $video_note = null; |
|
| 196 | + public null | videoNote $video_note = null; |
|
| 197 | 197 | |
| 198 | 198 | /** Optional. Message is a voice message, information about the file */ |
| 199 | - public null|voice $voice = null; |
|
| 199 | + public null | voice $voice = null; |
|
| 200 | 200 | |
| 201 | 201 | /** Optional. Caption for the animation, audio, document, photo, video or voice */ |
| 202 | - public null|string $caption = null; |
|
| 202 | + public null | string $caption = null; |
|
| 203 | 203 | |
| 204 | 204 | /** |
| 205 | 205 | * Optional. For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear |
| 206 | 206 | * in the caption |
| 207 | 207 | * @var messageEntity[] |
| 208 | 208 | */ |
| 209 | - public null|array $caption_entities = null; |
|
| 209 | + public null | array $caption_entities = null; |
|
| 210 | 210 | |
| 211 | 211 | /** Optional. True, if the message media is covered by a spoiler animation */ |
| 212 | - public null|bool $has_media_spoiler = null; |
|
| 212 | + public null | bool $has_media_spoiler = null; |
|
| 213 | 213 | |
| 214 | 214 | /** Optional. Message is a shared contact, information about the contact */ |
| 215 | - public null|contact $contact = null; |
|
| 215 | + public null | contact $contact = null; |
|
| 216 | 216 | |
| 217 | 217 | /** Optional. Message is a dice with random value */ |
| 218 | - public null|dice $dice = null; |
|
| 218 | + public null | dice $dice = null; |
|
| 219 | 219 | |
| 220 | 220 | /** Optional. Message is a game, information about the game. More about games » */ |
| 221 | - public null|game $game = null; |
|
| 221 | + public null | game $game = null; |
|
| 222 | 222 | |
| 223 | 223 | /** Optional. Message is a native poll, information about the poll */ |
| 224 | - public null|poll $poll = null; |
|
| 224 | + public null | poll $poll = null; |
|
| 225 | 225 | |
| 226 | 226 | /** |
| 227 | 227 | * Optional. Message is a venue, information about the venue. For backward compatibility, when this field is set, |
| 228 | 228 | * the location field will also be set |
| 229 | 229 | */ |
| 230 | - public null|venue $venue = null; |
|
| 230 | + public null | venue $venue = null; |
|
| 231 | 231 | |
| 232 | 232 | /** Optional. Message is a shared location, information about the location */ |
| 233 | - public null|location $location = null; |
|
| 233 | + public null | location $location = null; |
|
| 234 | 234 | |
| 235 | 235 | /** |
| 236 | 236 | * Optional. New members that were added to the group or supergroup and information about them (the bot itself |
| 237 | 237 | * may be one of these members) |
| 238 | 238 | * @var user[] |
| 239 | 239 | */ |
| 240 | - public null|array $new_chat_members = null; |
|
| 240 | + public null | array $new_chat_members = null; |
|
| 241 | 241 | |
| 242 | 242 | /** Optional. A member was removed from the group, information about them (this member may be the bot itself) */ |
| 243 | - public null|user $left_chat_member = null; |
|
| 243 | + public null | user $left_chat_member = null; |
|
| 244 | 244 | |
| 245 | 245 | /** Optional. A chat title was changed to this value */ |
| 246 | - public null|string $new_chat_title = null; |
|
| 246 | + public null | string $new_chat_title = null; |
|
| 247 | 247 | |
| 248 | 248 | /** |
| 249 | 249 | * Optional. A chat photo was change to this value |
| 250 | 250 | * @var photoSize[] |
| 251 | 251 | */ |
| 252 | - public null|array $new_chat_photo = null; |
|
| 252 | + public null | array $new_chat_photo = null; |
|
| 253 | 253 | |
| 254 | 254 | /** Optional. Service message: the chat photo was deleted */ |
| 255 | - public null|bool $delete_chat_photo = null; |
|
| 255 | + public null | bool $delete_chat_photo = null; |
|
| 256 | 256 | |
| 257 | 257 | /** Optional. Service message: the group has been created */ |
| 258 | - public null|bool $group_chat_created = null; |
|
| 258 | + public null | bool $group_chat_created = null; |
|
| 259 | 259 | |
| 260 | 260 | /** |
| 261 | 261 | * Optional. Service message: the supergroup has been created. This field can't be received in a message coming |
| 262 | 262 | * through updates, because bot can't be a member of a supergroup when it is created. It can only be found in |
| 263 | 263 | * reply_to_message if someone replies to a very first message in a directly created supergroup. |
| 264 | 264 | */ |
| 265 | - public null|bool $supergroup_chat_created = null; |
|
| 265 | + public null | bool $supergroup_chat_created = null; |
|
| 266 | 266 | |
| 267 | 267 | /** |
| 268 | 268 | * Optional. Service message: the channel has been created. This field can't be received in a message coming |
| 269 | 269 | * through updates, because bot can't be a member of a channel when it is created. It can only be found in |
| 270 | 270 | * reply_to_message if someone replies to a very first message in a channel. |
| 271 | 271 | */ |
| 272 | - public null|bool $channel_chat_created = null; |
|
| 272 | + public null | bool $channel_chat_created = null; |
|
| 273 | 273 | |
| 274 | 274 | /** Optional. Service message: auto-delete timer settings changed in the chat */ |
| 275 | - public null|messageAutoDeleteTimerChanged $message_auto_delete_timer_changed = null; |
|
| 275 | + public null | messageAutoDeleteTimerChanged $message_auto_delete_timer_changed = null; |
|
| 276 | 276 | |
| 277 | 277 | /** |
| 278 | 278 | * Optional. The group has been migrated to a supergroup with the specified identifier. This number may have more |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | * But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for |
| 281 | 281 | * storing this identifier. |
| 282 | 282 | */ |
| 283 | - public null|int $migrate_to_chat_id = null; |
|
| 283 | + public null | int $migrate_to_chat_id = null; |
|
| 284 | 284 | |
| 285 | 285 | /** |
| 286 | 286 | * Optional. The supergroup has been migrated from a group with the specified identifier. This number may have |
@@ -288,134 +288,134 @@ discard block |
||
| 288 | 288 | * interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float |
| 289 | 289 | * type are safe for storing this identifier. |
| 290 | 290 | */ |
| 291 | - public null|int $migrate_from_chat_id = null; |
|
| 291 | + public null | int $migrate_from_chat_id = null; |
|
| 292 | 292 | |
| 293 | 293 | /** |
| 294 | 294 | * Optional. Specified message was pinned. Note that the Message object in this field will not contain further |
| 295 | 295 | * reply_to_message fields even if it is itself a reply. |
| 296 | 296 | */ |
| 297 | - public null|message $pinned_message = null; |
|
| 297 | + public null | message $pinned_message = null; |
|
| 298 | 298 | |
| 299 | 299 | /** Optional. Message is an invoice for a payment, information about the invoice. More about payments » */ |
| 300 | - public null|invoice $invoice = null; |
|
| 300 | + public null | invoice $invoice = null; |
|
| 301 | 301 | |
| 302 | 302 | /** |
| 303 | 303 | * Optional. Message is a service message about a successful payment, information about the payment. More about |
| 304 | 304 | * payments » |
| 305 | 305 | */ |
| 306 | - public null|successfulPayment $successful_payment = null; |
|
| 306 | + public null | successfulPayment $successful_payment = null; |
|
| 307 | 307 | |
| 308 | 308 | /** Optional. Service message: a user was shared with the bot */ |
| 309 | - public null|userShared $user_shared = null; |
|
| 309 | + public null | userShared $user_shared = null; |
|
| 310 | 310 | |
| 311 | 311 | /** Optional. Service message: a chat was shared with the bot */ |
| 312 | - public null|chatShared $chat_shared = null; |
|
| 312 | + public null | chatShared $chat_shared = null; |
|
| 313 | 313 | |
| 314 | 314 | /** Optional. The domain name of the website on which the user has logged in. More about Telegram Login » */ |
| 315 | - public null|string $connected_website = null; |
|
| 315 | + public null | string $connected_website = null; |
|
| 316 | 316 | |
| 317 | 317 | /** Optional. Service message: the user allowed the bot added to the attachment menu to write messages */ |
| 318 | - public null|writeAccessAllowed $write_access_allowed = null; |
|
| 318 | + public null | writeAccessAllowed $write_access_allowed = null; |
|
| 319 | 319 | |
| 320 | 320 | /** Optional. Telegram Passport data */ |
| 321 | - public null|passportData $passport_data = null; |
|
| 321 | + public null | passportData $passport_data = null; |
|
| 322 | 322 | |
| 323 | 323 | /** |
| 324 | 324 | * Optional. Service message. A user in the chat triggered another user's proximity alert while sharing Live |
| 325 | 325 | * Location. |
| 326 | 326 | */ |
| 327 | - public null|proximityAlertTriggered $proximity_alert_triggered = null; |
|
| 327 | + public null | proximityAlertTriggered $proximity_alert_triggered = null; |
|
| 328 | 328 | |
| 329 | 329 | /** Optional. Service message: forum topic created */ |
| 330 | - public null|forumTopicCreated $forum_topic_created = null; |
|
| 330 | + public null | forumTopicCreated $forum_topic_created = null; |
|
| 331 | 331 | |
| 332 | 332 | /** Optional. Service message: forum topic edited */ |
| 333 | - public null|forumTopicEdited $forum_topic_edited = null; |
|
| 333 | + public null | forumTopicEdited $forum_topic_edited = null; |
|
| 334 | 334 | |
| 335 | 335 | /** Optional. Service message: forum topic closed */ |
| 336 | - public null|forumTopicClosed $forum_topic_closed = null; |
|
| 336 | + public null | forumTopicClosed $forum_topic_closed = null; |
|
| 337 | 337 | |
| 338 | 338 | /** Optional. Service message: forum topic reopened */ |
| 339 | - public null|forumTopicReopened $forum_topic_reopened = null; |
|
| 339 | + public null | forumTopicReopened $forum_topic_reopened = null; |
|
| 340 | 340 | |
| 341 | 341 | /** Optional. Service message: the 'General' forum topic hidden */ |
| 342 | - public null|generalForumTopicHidden $general_forum_topic_hidden = null; |
|
| 342 | + public null | generalForumTopicHidden $general_forum_topic_hidden = null; |
|
| 343 | 343 | |
| 344 | 344 | /** Optional. Service message: the 'General' forum topic unhidden */ |
| 345 | - public null|generalForumTopicUnhidden $general_forum_topic_unhidden = null; |
|
| 345 | + public null | generalForumTopicUnhidden $general_forum_topic_unhidden = null; |
|
| 346 | 346 | |
| 347 | 347 | /** Optional. Service message: video chat scheduled */ |
| 348 | - public null|videoChatScheduled $video_chat_scheduled = null; |
|
| 348 | + public null | videoChatScheduled $video_chat_scheduled = null; |
|
| 349 | 349 | |
| 350 | 350 | /** Optional. Service message: video chat started */ |
| 351 | - public null|videoChatStarted $video_chat_started = null; |
|
| 351 | + public null | videoChatStarted $video_chat_started = null; |
|
| 352 | 352 | |
| 353 | 353 | /** Optional. Service message: video chat ended */ |
| 354 | - public null|videoChatEnded $video_chat_ended = null; |
|
| 354 | + public null | videoChatEnded $video_chat_ended = null; |
|
| 355 | 355 | |
| 356 | 356 | /** Optional. Service message: new participants invited to a video chat */ |
| 357 | - public null|videoChatParticipantsInvited $video_chat_participants_invited = null; |
|
| 357 | + public null | videoChatParticipantsInvited $video_chat_participants_invited = null; |
|
| 358 | 358 | |
| 359 | 359 | /** Optional. Service message: data sent by a Web App */ |
| 360 | - public null|webAppData $web_app_data = null; |
|
| 360 | + public null | webAppData $web_app_data = null; |
|
| 361 | 361 | |
| 362 | 362 | /** Optional. Inline keyboard attached to the message. login_url buttons are represented as ordinary url buttons. */ |
| 363 | - public null|inlineKeyboardMarkup $reply_markup = null; |
|
| 363 | + public null | inlineKeyboardMarkup $reply_markup = null; |
|
| 364 | 364 | |
| 365 | 365 | |
| 366 | - public function __construct(stdClass|null $object = null) { |
|
| 366 | + public function __construct(stdClass | null $object = null) { |
|
| 367 | 367 | if ($object != null) { |
| 368 | 368 | parent::__construct($object, self::subs); |
| 369 | 369 | } |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | - public function isCommand (): bool { |
|
| 372 | + public function isCommand(): bool { |
|
| 373 | 373 | return !empty($this->command); |
| 374 | 374 | } |
| 375 | 375 | |
| 376 | - public function isForwarded (): bool { |
|
| 376 | + public function isForwarded(): bool { |
|
| 377 | 377 | return $this->forward_from !== null || $this->forward_from_chat !== null; |
| 378 | 378 | } |
| 379 | 379 | |
| 380 | - public function isAdmin (): bool { |
|
| 380 | + public function isAdmin(): bool { |
|
| 381 | 381 | return $this->chat->getMember($this->from->id)->status === chatMemberStatus::ADMINISTRATOR; |
| 382 | 382 | } |
| 383 | 383 | |
| 384 | - public function isOwner (): bool { |
|
| 384 | + public function isOwner(): bool { |
|
| 385 | 385 | return $this->chat->getMember($this->from->id)->status === chatMemberStatus::CREATOR; |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | - public function banMember(): responseError|bool { |
|
| 388 | + public function banMember(): responseError | bool { |
|
| 389 | 389 | if ($this->chat->isPrivate()) { |
| 390 | 390 | return false; |
| 391 | 391 | } |
| 392 | 392 | return telegram::banChatMember($this->chat->id, $this->from->id); |
| 393 | 393 | } |
| 394 | 394 | |
| 395 | - public function kickMember(): responseError|bool { |
|
| 395 | + public function kickMember(): responseError | bool { |
|
| 396 | 396 | if ($this->chat->isPrivate()) { |
| 397 | 397 | return false; |
| 398 | 398 | } |
| 399 | 399 | return telegram::unbanChatMember($this->chat->id, $this->from->id); |
| 400 | 400 | } |
| 401 | 401 | |
| 402 | - public function delete (): responseError|bool { |
|
| 403 | - return telegram::deleteMessage($this->chat->id,$this->id); |
|
| 402 | + public function delete(): responseError | bool { |
|
| 403 | + return telegram::deleteMessage($this->chat->id, $this->id); |
|
| 404 | 404 | } |
| 405 | 405 | |
| 406 | - public function pinChatMessage (): responseError|bool { |
|
| 407 | - return telegram::deleteMessage($this->chat->id,$this->id); |
|
| 406 | + public function pinChatMessage(): responseError | bool { |
|
| 407 | + return telegram::deleteMessage($this->chat->id, $this->id); |
|
| 408 | 408 | } |
| 409 | 409 | |
| 410 | - public function editText (string $text): message|responseError|bool { |
|
| 411 | - return telegram::editMessageText($text,$this->chat->id,$this->message_id); |
|
| 410 | + public function editText(string $text): message | responseError | bool { |
|
| 411 | + return telegram::editMessageText($text, $this->chat->id, $this->message_id); |
|
| 412 | 412 | } |
| 413 | 413 | |
| 414 | - public function copy (int|string $chat_id): messageId|responseError { |
|
| 414 | + public function copy(int | string $chat_id): messageId | responseError { |
|
| 415 | 415 | return telegram::copyMessage($chat_id); |
| 416 | 416 | } |
| 417 | 417 | |
| 418 | - public function forward (int|string $chat_id): message|responseError { |
|
| 418 | + public function forward(int | string $chat_id): message | responseError { |
|
| 419 | 419 | return telegram::forwardMessage($chat_id); |
| 420 | 420 | } |
| 421 | 421 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | public bool $via_chat_folder_invite_link; |
| 45 | 45 | |
| 46 | 46 | |
| 47 | - public function __construct(stdClass|null $object = null) { |
|
| 47 | + public function __construct(stdClass | null $object = null) { |
|
| 48 | 48 | if ($object != null) { |
| 49 | 49 | parent::__construct($object, self::subs); |
| 50 | 50 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | return $this->chat->isPrivate() && $this->isMe() && $this->isKicked(); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - public function isMe (): bool { |
|
| 61 | + public function isMe(): bool { |
|
| 62 | 62 | return $this->new_chat_member->user->id == settings::$bot_id; |
| 63 | 63 | } |
| 64 | 64 | |
@@ -74,19 +74,19 @@ discard block |
||
| 74 | 74 | return $this->isJoined() && !empty($this->invite_link); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - public function isLeaved (): bool { |
|
| 77 | + public function isLeaved(): bool { |
|
| 78 | 78 | return $this->new_chat_member->status === chatMemberStatus::LEFT; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - public function isKicked (): bool { |
|
| 81 | + public function isKicked(): bool { |
|
| 82 | 82 | return $this->new_chat_member->status === chatMemberStatus::KICKED; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - public function isOldAdmin (): bool { |
|
| 85 | + public function isOldAdmin(): bool { |
|
| 86 | 86 | return $this->old_chat_member->status === chatMemberStatus::ADMINISTRATOR; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - public function isNewAdmin (): bool { |
|
| 89 | + public function isNewAdmin(): bool { |
|
| 90 | 90 | return $this->new_chat_member->status === chatMemberStatus::ADMINISTRATOR; |
| 91 | 91 | } |
| 92 | 92 | } |