@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | public static int $log_size = 10; |
| 30 | 30 | |
| 31 | - public static string|CURLFile|null $certificate = null; |
|
| 31 | + public static string | CURLFile | null $certificate = null; |
|
| 32 | 32 | |
| 33 | 33 | public static bool $handler = true; |
| 34 | 34 | |
@@ -62,14 +62,14 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | public static array $allowed_updates = ['message', 'edited_channel_post', 'callback_query', 'inline_query']; |
| 64 | 64 | |
| 65 | - public static array|null $db = null; |
|
| 65 | + public static array | null $db = null; |
|
| 66 | 66 | |
| 67 | - public static array|null $pay = null; |
|
| 67 | + public static array | null $pay = null; |
|
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | 70 | * @internal Only for BPT self usage , Don't use it in your source! |
| 71 | 71 | */ |
| 72 | - public static function init (array|stdClass $settings): void { |
|
| 72 | + public static function init(array | stdClass $settings): void { |
|
| 73 | 73 | $settings = (array) $settings; |
| 74 | 74 | foreach ($settings as $setting => $value) { |
| 75 | 75 | try { |
@@ -77,10 +77,10 @@ discard block |
||
| 77 | 77 | if (!is_dir(realpath('bots_files'))) { |
| 78 | 78 | mkdir('bots_files'); |
| 79 | 79 | } |
| 80 | - if (!is_dir(realpath('bots_files/' . $value))) { |
|
| 81 | - mkdir('bots_files/' . $value); |
|
| 80 | + if (!is_dir(realpath('bots_files/'.$value))) { |
|
| 81 | + mkdir('bots_files/'.$value); |
|
| 82 | 82 | } |
| 83 | - $value = 'bots_files/' . $value . '/'; |
|
| 83 | + $value = 'bots_files/'.$value.'/'; |
|
| 84 | 84 | } |
| 85 | 85 | self::$$setting = $value; |
| 86 | 86 | } |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | /** |
| 120 | 120 | * @internal Only for BPT self usage , Don't use it in your source! |
| 121 | 121 | */ |
| 122 | - public static function done (): void { |
|
| 122 | + public static function done(): void { |
|
| 123 | 123 | if (self::$logger) { |
| 124 | 124 | $estimated = round((microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']) * 1000, 2); |
| 125 | 125 | $status_message = match (true) { |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - private static function security (): void { |
|
| 137 | + private static function security(): void { |
|
| 138 | 138 | if (self::$security) { |
| 139 | 139 | ini_set('magic_quotes_gpc', 'off'); |
| 140 | 140 | ini_set('sql.safe_mode', 'on'); |
@@ -149,11 +149,11 @@ discard block |
||
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - private static function secureFolder (): void { |
|
| 152 | + private static function secureFolder(): void { |
|
| 153 | 153 | if (self::$secure_folder) { |
| 154 | 154 | $address = explode('/', $_SERVER['REQUEST_URI']); |
| 155 | 155 | unset($address[count($address) - 1]); |
| 156 | - $address = implode('/', $address) . '/BPT.php'; |
|
| 156 | + $address = implode('/', $address).'/BPT.php'; |
|
| 157 | 157 | $text = "ErrorDocument 404 $address\nErrorDocument 403 $address\n Options -Indexes\n Order Deny,Allow\nDeny from all\nAllow from 127.0.0.1\n<Files *.php>\n Order Allow,Deny\n Allow from all\n</Files>"; |
| 158 | 158 | $htaccess = realpath('.htaccess'); |
| 159 | 159 | if (!file_exists($htaccess) || filesize($htaccess) != strlen($text)) { |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - private static function getUpdates (): void { |
|
| 165 | + private static function getUpdates(): void { |
|
| 166 | 166 | if (!self::$handler) { |
| 167 | 167 | logger::write('You can\'t use getUpdates receiver when handler is off , use webhook or use handler', loggerTypes::ERROR); |
| 168 | 168 | throw new bptException('GETUPDATE_NEED_HANDLER'); |
@@ -17,40 +17,40 @@ |
||
| 17 | 17 | /** |
| 18 | 18 | * @internal Only for BPT self usage , Don't use it in your source! |
| 19 | 19 | */ |
| 20 | - public static function init(string $method,array $data): bool { |
|
| 20 | + public static function init(string $method, array $data): bool { |
|
| 21 | 21 | self::checkWebhook(); |
| 22 | 22 | self::sieveData($data); |
| 23 | 23 | self::$is_answered = true; |
| 24 | 24 | $data['method'] = $method; |
| 25 | 25 | $payload = json_encode($data); |
| 26 | - header('Content-Type: application/json;Content-Length: ' . strlen($payload)); |
|
| 26 | + header('Content-Type: application/json;Content-Length: '.strlen($payload)); |
|
| 27 | 27 | echo $payload; |
| 28 | 28 | return true; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - public static function isAnswered (): bool { |
|
| 31 | + public static function isAnswered(): bool { |
|
| 32 | 32 | return self::$is_answered; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | private static function checkWebhook(): void { |
| 36 | - if(settings::$receiver === receiver::GETUPDATES) { |
|
| 37 | - logger::write('Answer mode only work when receiver is webhook',loggerTypes::ERROR); |
|
| 36 | + if (settings::$receiver === receiver::GETUPDATES) { |
|
| 37 | + logger::write('Answer mode only work when receiver is webhook', loggerTypes::ERROR); |
|
| 38 | 38 | throw new bptException('ANSWER_MODE_GETUPDATES'); |
| 39 | 39 | } |
| 40 | - if(settings::$multi) { |
|
| 41 | - logger::write('You can not use answer mode when multi setting is on',loggerTypes::ERROR); |
|
| 40 | + if (settings::$multi) { |
|
| 41 | + logger::write('You can not use answer mode when multi setting is on', loggerTypes::ERROR); |
|
| 42 | 42 | throw new bptException('ANSWER_MODE_MULTI'); |
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | private static function sieveData(array &$data): void { |
| 47 | - unset($data['token'],$data['forgot'],$data['return_array']); |
|
| 47 | + unset($data['token'], $data['forgot'], $data['return_array']); |
|
| 48 | 48 | |
| 49 | - foreach ($data as $key=>&$value){ |
|
| 50 | - if (!isset($value)){ |
|
| 49 | + foreach ($data as $key=>&$value) { |
|
| 50 | + if (!isset($value)) { |
|
| 51 | 51 | unset($data[$key]); |
| 52 | 52 | } |
| 53 | - elseif (is_array($value) || is_object($value)){ |
|
| 53 | + elseif (is_array($value) || is_object($value)) { |
|
| 54 | 54 | $value = json_encode($value); |
| 55 | 55 | } |
| 56 | 56 | } |
@@ -49,8 +49,7 @@ |
||
| 49 | 49 | foreach ($data as $key=>&$value){ |
| 50 | 50 | if (!isset($value)){ |
| 51 | 51 | unset($data[$key]); |
| 52 | - } |
|
| 53 | - elseif (is_array($value) || is_object($value)){ |
|
| 52 | + } elseif (is_array($value) || is_object($value)){ |
|
| 54 | 53 | $value = json_encode($value); |
| 55 | 54 | } |
| 56 | 55 | } |
@@ -502,95 +502,95 @@ discard block |
||
| 502 | 502 | ]; |
| 503 | 503 | |
| 504 | 504 | private const METHODS_KEYS = [ |
| 505 | - 'getUpdates' => ['offset','limit','timeout','allowed_updates','token','forgot','answer'], |
|
| 506 | - 'setWebhook' => ['url','certificate','ip_address','max_connections','allowed_updates','drop_pending_updates','secret_token','token','forgot','answer'], |
|
| 507 | - 'deleteWebhook' => ['drop_pending_updates','token','forgot','answer'], |
|
| 508 | - 'getWebhookInfo' => ['token','forgot','answer'], |
|
| 509 | - 'getMe' => ['token','forgot','answer'], |
|
| 510 | - 'logOut' => ['token','forgot','answer'], |
|
| 511 | - 'close' => ['token','forgot','answer'], |
|
| 512 | - 'sendMessage' => ['text','chat_id','parse_mode','entities','disable_web_page_preview','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
| 513 | - 'forwardMessage' => ['chat_id','from_chat_id','disable_notification','protect_content','message_id','token','forgot','answer','message_thread_id'], |
|
| 514 | - 'copyMessage' => ['chat_id','from_chat_id','message_id','caption','parse_mode','caption_entities','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
| 515 | - 'sendPhoto' => ['photo','chat_id','caption','parse_mode','caption_entities','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','has_spoiler','message_thread_id'], |
|
| 516 | - 'sendAudio' => ['audio','chat_id','caption','parse_mode','caption_entities','duration','performer','title','thumb','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
| 517 | - 'sendDocument' => ['document','chat_id','thumb','caption','parse_mode','caption_entities','disable_content_type_detection','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
| 518 | - 'sendVideo' => ['video','chat_id','duration','width','height','thumb','caption','parse_mode','caption_entities','supports_streaming','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','has_spoiler','message_thread_id'], |
|
| 519 | - 'sendAnimation' => ['animation','chat_id','duration','width','height','thumb','caption','parse_mode','caption_entities','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','has_spoiler','message_thread_id'], |
|
| 520 | - 'sendVoice' => ['voice','chat_id','caption','parse_mode','caption_entities','duration','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
| 521 | - 'sendVideoNote' => ['video_note','chat_id','duration','length','thumb','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
| 522 | - 'sendMediaGroup' => ['media','chat_id','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','token','forgot','answer','message_thread_id'], |
|
| 523 | - 'sendLocation' => ['latitude','longitude','chat_id','horizontal_accuracy','live_period','heading','proximity_alert_radius','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
| 524 | - 'editMessageLiveLocation' => ['latitude','longitude','chat_id','message_id','inline_message_id','horizontal_accuracy','heading','proximity_alert_radius','reply_markup','token','forgot','answer'], |
|
| 525 | - 'stopMessageLiveLocation' => ['chat_id','message_id','inline_message_id','reply_markup','token','forgot','answer'], |
|
| 526 | - 'sendVenue' => ['chat_id','latitude','longitude','title','address','foursquare_id','foursquare_type','google_place_id','google_place_type','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
| 527 | - 'sendContact' => ['phone_number','first_name','chat_id','last_name','vcard','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
| 528 | - 'sendPoll' => ['question','options','chat_id','is_anonymous','type','allows_multiple_answers','correct_option_id','explanation','explanation_parse_mode','explanation_entities','open_period','close_date','is_closed','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
| 529 | - 'sendDice' => ['chat_id','emoji','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
| 530 | - 'sendChatAction' => ['chat_id','action','token','forgot','answer','message_thread_id'], |
|
| 531 | - 'getUserProfilePhotos' => ['user_id','offset','limit','token','forgot','answer'], |
|
| 532 | - 'getFile' => ['file_id','token','forgot','answer'], |
|
| 533 | - 'banChatMember' => ['chat_id','user_id','until_date','revoke_messages','token','forgot','answer'], |
|
| 534 | - 'unbanChatMember' => ['chat_id','user_id','only_if_banned','token','forgot','answer'], |
|
| 535 | - 'restrictChatMember' => ['permissions','chat_id','user_id','until_date','token','forgot','answer'], |
|
| 536 | - 'promoteChatMember' => ['chat_id','user_id','is_anonymous','can_manage_chat','can_post_messages','can_edit_messages','can_delete_messages','can_manage_video_chats','can_restrict_members','can_promote_members','can_change_info','can_invite_users','can_pin_messages','can_manage_topics','token','forgot','answer'], |
|
| 537 | - 'setChatAdministratorCustomTitle' => ['custom_title','chat_id','user_id','token','forgot','answer'], |
|
| 538 | - 'banChatSenderChat' => ['sender_chat_id','chat_id','token','forgot','answer'], |
|
| 539 | - 'unbanChatSenderChat' => ['sender_chat_id','chat_id','token','forgot','answer'], |
|
| 540 | - 'setChatPermissions' => ['permissions','chat_id','token','forgot','answer'], |
|
| 541 | - 'exportChatInviteLink' => ['chat_id','token','forgot','answer'], |
|
| 542 | - 'createChatInviteLink' => ['chat_id','name','expire_date','member_limit','creates_join_request','token','forgot','answer'], |
|
| 543 | - 'editChatInviteLink' => ['invite_link','chat_id','name','expire_date','member_limit','creates_join_request','token','forgot','answer'], |
|
| 544 | - 'revokeChatInviteLink' => ['invite_link','chat_id','token','forgot','answer'], |
|
| 545 | - 'approveChatJoinRequest' => ['chat_id','user_id','token','forgot','answer'], |
|
| 546 | - 'declineChatJoinRequest' => ['chat_id','user_id','token','forgot','answer'], |
|
| 547 | - 'setChatPhoto' => ['photo','chat_id','token','forgot','answer'], |
|
| 548 | - 'deleteChatPhoto' => ['chat_id','token','forgot','answer'], |
|
| 549 | - 'setChatTitle' => ['title','chat_id','token','forgot','answer'], |
|
| 550 | - 'setChatDescription' => ['chat_id','description','token','forgot','answer'], |
|
| 551 | - 'pinChatMessage' => ['message_id','chat_id','disable_notification','token','forgot','answer'], |
|
| 552 | - 'unpinChatMessage' => ['chat_id','message_id','token','forgot','answer'], |
|
| 553 | - 'unpinAllChatMessages' => ['chat_id','token','forgot','answer'], |
|
| 554 | - 'leaveChat' => ['chat_id','token','forgot','answer'], |
|
| 555 | - 'getChat' => ['chat_id','token','forgot','answer'], |
|
| 556 | - 'getChatAdministrators' => ['chat_id','token','forgot','answer'], |
|
| 557 | - 'getChatMemberCount' => ['chat_id','token','forgot','answer'], |
|
| 558 | - 'getChatMember' => ['chat_id','user_id','token','forgot','answer'], |
|
| 559 | - 'setChatStickerSet' => ['sticker_set_name','chat_id','token','forgot','answer'], |
|
| 560 | - 'deleteChatStickerSet' => ['chat_id','token','forgot','answer'], |
|
| 561 | - 'answerCallbackQuery' => ['callback_query_id','text','show_alert','url','cache_time','token','forgot','answer'], |
|
| 562 | - 'setMyCommands' => ['commands','scope','language_code','token','forgot','answer'], |
|
| 563 | - 'deleteMyCommands' => ['scope','language_code','token','forgot','answer'], |
|
| 564 | - 'getMyCommands' => ['scope','language_code','token','forgot','answer'], |
|
| 565 | - 'setChatMenuButton' => ['chat_id','menu_button','token','forgot','answer'], |
|
| 566 | - 'getChatMenuButton' => ['chat_id','token','forgot','answer'], |
|
| 567 | - 'setMyDefaultAdministratorRights' => ['rights','for_channels','token','forgot','answer'], |
|
| 568 | - 'getMyDefaultAdministratorRights' => ['for_channels','token','forgot','answer'], |
|
| 569 | - 'editMessageText' => ['text','chat_id','message_id','inline_message_id','parse_mode','entities','disable_web_page_preview','reply_markup','token','forgot','answer'], |
|
| 570 | - 'editMessageCaption' => ['chat_id','message_id','inline_message_id','caption','parse_mode','caption_entities','reply_markup','token','forgot','answer'], |
|
| 571 | - 'editMessageMedia' => ['media','chat_id','message_id','inline_message_id','reply_markup','token','forgot','answer'], |
|
| 572 | - 'editMessageReplyMarkup' => ['chat_id','message_id','inline_message_id','reply_markup','token','forgot','answer'], |
|
| 573 | - 'stopPoll' => ['chat_id','message_id','reply_markup','token','forgot','answer'], |
|
| 574 | - 'deleteMessage' => ['chat_id','message_id','token','forgot','answer'], |
|
| 575 | - 'sendSticker' => ['sticker','chat_id','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
| 576 | - 'getStickerSet' => ['name','token','forgot','answer'], |
|
| 505 | + 'getUpdates' => ['offset', 'limit', 'timeout', 'allowed_updates', 'token', 'forgot', 'answer'], |
|
| 506 | + 'setWebhook' => ['url', 'certificate', 'ip_address', 'max_connections', 'allowed_updates', 'drop_pending_updates', 'secret_token', 'token', 'forgot', 'answer'], |
|
| 507 | + 'deleteWebhook' => ['drop_pending_updates', 'token', 'forgot', 'answer'], |
|
| 508 | + 'getWebhookInfo' => ['token', 'forgot', 'answer'], |
|
| 509 | + 'getMe' => ['token', 'forgot', 'answer'], |
|
| 510 | + 'logOut' => ['token', 'forgot', 'answer'], |
|
| 511 | + 'close' => ['token', 'forgot', 'answer'], |
|
| 512 | + 'sendMessage' => ['text', 'chat_id', 'parse_mode', 'entities', 'disable_web_page_preview', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
| 513 | + 'forwardMessage' => ['chat_id', 'from_chat_id', 'disable_notification', 'protect_content', 'message_id', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
| 514 | + 'copyMessage' => ['chat_id', 'from_chat_id', 'message_id', 'caption', 'parse_mode', 'caption_entities', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
| 515 | + 'sendPhoto' => ['photo', 'chat_id', 'caption', 'parse_mode', 'caption_entities', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'has_spoiler', 'message_thread_id'], |
|
| 516 | + 'sendAudio' => ['audio', 'chat_id', 'caption', 'parse_mode', 'caption_entities', 'duration', 'performer', 'title', 'thumb', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
| 517 | + 'sendDocument' => ['document', 'chat_id', 'thumb', 'caption', 'parse_mode', 'caption_entities', 'disable_content_type_detection', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
| 518 | + 'sendVideo' => ['video', 'chat_id', 'duration', 'width', 'height', 'thumb', 'caption', 'parse_mode', 'caption_entities', 'supports_streaming', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'has_spoiler', 'message_thread_id'], |
|
| 519 | + 'sendAnimation' => ['animation', 'chat_id', 'duration', 'width', 'height', 'thumb', 'caption', 'parse_mode', 'caption_entities', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'has_spoiler', 'message_thread_id'], |
|
| 520 | + 'sendVoice' => ['voice', 'chat_id', 'caption', 'parse_mode', 'caption_entities', 'duration', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
| 521 | + 'sendVideoNote' => ['video_note', 'chat_id', 'duration', 'length', 'thumb', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
| 522 | + 'sendMediaGroup' => ['media', 'chat_id', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
| 523 | + 'sendLocation' => ['latitude', 'longitude', 'chat_id', 'horizontal_accuracy', 'live_period', 'heading', 'proximity_alert_radius', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
| 524 | + 'editMessageLiveLocation' => ['latitude', 'longitude', 'chat_id', 'message_id', 'inline_message_id', 'horizontal_accuracy', 'heading', 'proximity_alert_radius', 'reply_markup', 'token', 'forgot', 'answer'], |
|
| 525 | + 'stopMessageLiveLocation' => ['chat_id', 'message_id', 'inline_message_id', 'reply_markup', 'token', 'forgot', 'answer'], |
|
| 526 | + 'sendVenue' => ['chat_id', 'latitude', 'longitude', 'title', 'address', 'foursquare_id', 'foursquare_type', 'google_place_id', 'google_place_type', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
| 527 | + 'sendContact' => ['phone_number', 'first_name', 'chat_id', 'last_name', 'vcard', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
| 528 | + 'sendPoll' => ['question', 'options', 'chat_id', 'is_anonymous', 'type', 'allows_multiple_answers', 'correct_option_id', 'explanation', 'explanation_parse_mode', 'explanation_entities', 'open_period', 'close_date', 'is_closed', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
| 529 | + 'sendDice' => ['chat_id', 'emoji', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
| 530 | + 'sendChatAction' => ['chat_id', 'action', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
| 531 | + 'getUserProfilePhotos' => ['user_id', 'offset', 'limit', 'token', 'forgot', 'answer'], |
|
| 532 | + 'getFile' => ['file_id', 'token', 'forgot', 'answer'], |
|
| 533 | + 'banChatMember' => ['chat_id', 'user_id', 'until_date', 'revoke_messages', 'token', 'forgot', 'answer'], |
|
| 534 | + 'unbanChatMember' => ['chat_id', 'user_id', 'only_if_banned', 'token', 'forgot', 'answer'], |
|
| 535 | + 'restrictChatMember' => ['permissions', 'chat_id', 'user_id', 'until_date', 'token', 'forgot', 'answer'], |
|
| 536 | + 'promoteChatMember' => ['chat_id', 'user_id', 'is_anonymous', 'can_manage_chat', 'can_post_messages', 'can_edit_messages', 'can_delete_messages', 'can_manage_video_chats', 'can_restrict_members', 'can_promote_members', 'can_change_info', 'can_invite_users', 'can_pin_messages', 'can_manage_topics', 'token', 'forgot', 'answer'], |
|
| 537 | + 'setChatAdministratorCustomTitle' => ['custom_title', 'chat_id', 'user_id', 'token', 'forgot', 'answer'], |
|
| 538 | + 'banChatSenderChat' => ['sender_chat_id', 'chat_id', 'token', 'forgot', 'answer'], |
|
| 539 | + 'unbanChatSenderChat' => ['sender_chat_id', 'chat_id', 'token', 'forgot', 'answer'], |
|
| 540 | + 'setChatPermissions' => ['permissions', 'chat_id', 'token', 'forgot', 'answer'], |
|
| 541 | + 'exportChatInviteLink' => ['chat_id', 'token', 'forgot', 'answer'], |
|
| 542 | + 'createChatInviteLink' => ['chat_id', 'name', 'expire_date', 'member_limit', 'creates_join_request', 'token', 'forgot', 'answer'], |
|
| 543 | + 'editChatInviteLink' => ['invite_link', 'chat_id', 'name', 'expire_date', 'member_limit', 'creates_join_request', 'token', 'forgot', 'answer'], |
|
| 544 | + 'revokeChatInviteLink' => ['invite_link', 'chat_id', 'token', 'forgot', 'answer'], |
|
| 545 | + 'approveChatJoinRequest' => ['chat_id', 'user_id', 'token', 'forgot', 'answer'], |
|
| 546 | + 'declineChatJoinRequest' => ['chat_id', 'user_id', 'token', 'forgot', 'answer'], |
|
| 547 | + 'setChatPhoto' => ['photo', 'chat_id', 'token', 'forgot', 'answer'], |
|
| 548 | + 'deleteChatPhoto' => ['chat_id', 'token', 'forgot', 'answer'], |
|
| 549 | + 'setChatTitle' => ['title', 'chat_id', 'token', 'forgot', 'answer'], |
|
| 550 | + 'setChatDescription' => ['chat_id', 'description', 'token', 'forgot', 'answer'], |
|
| 551 | + 'pinChatMessage' => ['message_id', 'chat_id', 'disable_notification', 'token', 'forgot', 'answer'], |
|
| 552 | + 'unpinChatMessage' => ['chat_id', 'message_id', 'token', 'forgot', 'answer'], |
|
| 553 | + 'unpinAllChatMessages' => ['chat_id', 'token', 'forgot', 'answer'], |
|
| 554 | + 'leaveChat' => ['chat_id', 'token', 'forgot', 'answer'], |
|
| 555 | + 'getChat' => ['chat_id', 'token', 'forgot', 'answer'], |
|
| 556 | + 'getChatAdministrators' => ['chat_id', 'token', 'forgot', 'answer'], |
|
| 557 | + 'getChatMemberCount' => ['chat_id', 'token', 'forgot', 'answer'], |
|
| 558 | + 'getChatMember' => ['chat_id', 'user_id', 'token', 'forgot', 'answer'], |
|
| 559 | + 'setChatStickerSet' => ['sticker_set_name', 'chat_id', 'token', 'forgot', 'answer'], |
|
| 560 | + 'deleteChatStickerSet' => ['chat_id', 'token', 'forgot', 'answer'], |
|
| 561 | + 'answerCallbackQuery' => ['callback_query_id', 'text', 'show_alert', 'url', 'cache_time', 'token', 'forgot', 'answer'], |
|
| 562 | + 'setMyCommands' => ['commands', 'scope', 'language_code', 'token', 'forgot', 'answer'], |
|
| 563 | + 'deleteMyCommands' => ['scope', 'language_code', 'token', 'forgot', 'answer'], |
|
| 564 | + 'getMyCommands' => ['scope', 'language_code', 'token', 'forgot', 'answer'], |
|
| 565 | + 'setChatMenuButton' => ['chat_id', 'menu_button', 'token', 'forgot', 'answer'], |
|
| 566 | + 'getChatMenuButton' => ['chat_id', 'token', 'forgot', 'answer'], |
|
| 567 | + 'setMyDefaultAdministratorRights' => ['rights', 'for_channels', 'token', 'forgot', 'answer'], |
|
| 568 | + 'getMyDefaultAdministratorRights' => ['for_channels', 'token', 'forgot', 'answer'], |
|
| 569 | + 'editMessageText' => ['text', 'chat_id', 'message_id', 'inline_message_id', 'parse_mode', 'entities', 'disable_web_page_preview', 'reply_markup', 'token', 'forgot', 'answer'], |
|
| 570 | + 'editMessageCaption' => ['chat_id', 'message_id', 'inline_message_id', 'caption', 'parse_mode', 'caption_entities', 'reply_markup', 'token', 'forgot', 'answer'], |
|
| 571 | + 'editMessageMedia' => ['media', 'chat_id', 'message_id', 'inline_message_id', 'reply_markup', 'token', 'forgot', 'answer'], |
|
| 572 | + 'editMessageReplyMarkup' => ['chat_id', 'message_id', 'inline_message_id', 'reply_markup', 'token', 'forgot', 'answer'], |
|
| 573 | + 'stopPoll' => ['chat_id', 'message_id', 'reply_markup', 'token', 'forgot', 'answer'], |
|
| 574 | + 'deleteMessage' => ['chat_id', 'message_id', 'token', 'forgot', 'answer'], |
|
| 575 | + 'sendSticker' => ['sticker', 'chat_id', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
| 576 | + 'getStickerSet' => ['name', 'token', 'forgot', 'answer'], |
|
| 577 | 577 | 'getCustomEmojiStickers' => ['custom_emoji_ids', 'token', 'return_array', 'forgot', 'answer'], |
| 578 | - 'uploadStickerFile' => ['png_sticker','user_id','token','forgot','answer'], |
|
| 579 | - 'createNewStickerSet' => ['name','title','emojis','user_id','png_sticker','tgs_sticker','webm_sticker','sticker_type','contains_masks','mask_position','token','forgot','answer'], |
|
| 580 | - 'addStickerToSet' => ['name','emojis','user_id','png_sticker','tgs_sticker','webm_sticker','mask_position','token','forgot','answer'], |
|
| 581 | - 'setStickerPositionInSet' => ['sticker','position','token','forgot','answer'], |
|
| 582 | - 'deleteStickerFromSet' => ['sticker','token','forgot','answer'], |
|
| 583 | - 'setStickerSetThumb' => ['name','user_id','thumb','token','forgot','answer'], |
|
| 584 | - 'answerInlineQuery' => ['results','inline_query_id','cache_time','is_personal','next_offset','switch_pm_text','switch_pm_parameter','token','forgot','answer'], |
|
| 585 | - 'answerWebAppQuery' => ['web_app_query_id','result','token','forgot','answer'], |
|
| 586 | - 'sendInvoice' => ['title','description','payload','provider_token','currency','prices','chat_id','max_tip_amount','suggested_tip_amounts','start_parameter','provider_data','photo_url','photo_size','photo_width','photo_height','need_name','need_phone_number','need_email','need_shipping_address','send_phone_number_to_provider','send_email_to_provider','is_flexible','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
| 587 | - 'createInvoiceLink' => ['title','description','payload','provider_token','currency','prices','max_tip_amount','suggested_tip_amounts','provider_data','photo_url','photo_size','photo_width','photo_height','need_name','need_phone_number','need_email','need_shipping_address','send_phone_number_to_provider','send_email_to_provider','is_flexible','token','forgot','answer'], |
|
| 588 | - 'answerShippingQuery' => ['ok','shipping_query_id','shipping_options','error_message','token','forgot','answer'], |
|
| 589 | - 'answerPreCheckoutQuery' => ['ok','pre_checkout_query_id','error_message','token','forgot','answer'], |
|
| 590 | - 'setPassportDataErrors' => ['errors','user_id','token','forgot','answer'], |
|
| 591 | - 'sendGame' => ['game_short_name','chat_id','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer', 'message_thread_id'], |
|
| 592 | - 'setGameScore' => ['score','user_id','force','disable_edit_message','chat_id','message_id','inline_message_id','token','forgot','answer'], |
|
| 593 | - 'getGameHighScores' => ['user_id','chat_id','message_id','inline_message_id','token','forgot','answer'], |
|
| 578 | + 'uploadStickerFile' => ['png_sticker', 'user_id', 'token', 'forgot', 'answer'], |
|
| 579 | + 'createNewStickerSet' => ['name', 'title', 'emojis', 'user_id', 'png_sticker', 'tgs_sticker', 'webm_sticker', 'sticker_type', 'contains_masks', 'mask_position', 'token', 'forgot', 'answer'], |
|
| 580 | + 'addStickerToSet' => ['name', 'emojis', 'user_id', 'png_sticker', 'tgs_sticker', 'webm_sticker', 'mask_position', 'token', 'forgot', 'answer'], |
|
| 581 | + 'setStickerPositionInSet' => ['sticker', 'position', 'token', 'forgot', 'answer'], |
|
| 582 | + 'deleteStickerFromSet' => ['sticker', 'token', 'forgot', 'answer'], |
|
| 583 | + 'setStickerSetThumb' => ['name', 'user_id', 'thumb', 'token', 'forgot', 'answer'], |
|
| 584 | + 'answerInlineQuery' => ['results', 'inline_query_id', 'cache_time', 'is_personal', 'next_offset', 'switch_pm_text', 'switch_pm_parameter', 'token', 'forgot', 'answer'], |
|
| 585 | + 'answerWebAppQuery' => ['web_app_query_id', 'result', 'token', 'forgot', 'answer'], |
|
| 586 | + 'sendInvoice' => ['title', 'description', 'payload', 'provider_token', 'currency', 'prices', 'chat_id', 'max_tip_amount', 'suggested_tip_amounts', 'start_parameter', 'provider_data', 'photo_url', 'photo_size', 'photo_width', 'photo_height', 'need_name', 'need_phone_number', 'need_email', 'need_shipping_address', 'send_phone_number_to_provider', 'send_email_to_provider', 'is_flexible', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
| 587 | + 'createInvoiceLink' => ['title', 'description', 'payload', 'provider_token', 'currency', 'prices', 'max_tip_amount', 'suggested_tip_amounts', 'provider_data', 'photo_url', 'photo_size', 'photo_width', 'photo_height', 'need_name', 'need_phone_number', 'need_email', 'need_shipping_address', 'send_phone_number_to_provider', 'send_email_to_provider', 'is_flexible', 'token', 'forgot', 'answer'], |
|
| 588 | + 'answerShippingQuery' => ['ok', 'shipping_query_id', 'shipping_options', 'error_message', 'token', 'forgot', 'answer'], |
|
| 589 | + 'answerPreCheckoutQuery' => ['ok', 'pre_checkout_query_id', 'error_message', 'token', 'forgot', 'answer'], |
|
| 590 | + 'setPassportDataErrors' => ['errors', 'user_id', 'token', 'forgot', 'answer'], |
|
| 591 | + 'sendGame' => ['game_short_name', 'chat_id', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
| 592 | + 'setGameScore' => ['score', 'user_id', 'force', 'disable_edit_message', 'chat_id', 'message_id', 'inline_message_id', 'token', 'forgot', 'answer'], |
|
| 593 | + 'getGameHighScores' => ['user_id', 'chat_id', 'message_id', 'inline_message_id', 'token', 'forgot', 'answer'], |
|
| 594 | 594 | 'getForumTopicIconStickers' => ['token', 'return_array', 'forgot', 'answer'], |
| 595 | 595 | 'createForumTopic' => ['chat_id', 'name', 'icon_color', 'icon_custom_emoji_id', 'token', 'return_array', 'forgot', 'answer'], |
| 596 | 596 | 'editForumTopic' => ['chat_id', 'name', 'icon_custom_emoji_id', 'token', 'return_array', 'forgot', 'answer', 'message_thread_id'], |
@@ -631,8 +631,8 @@ discard block |
||
| 631 | 631 | 'logOut' => [], |
| 632 | 632 | 'close' => [], |
| 633 | 633 | 'sendMessage' => ['chat_id'], |
| 634 | - 'forwardMessage' => ['from_chat_id','message_id'], |
|
| 635 | - 'copyMessage' => ['from_chat_id','message_id'], |
|
| 634 | + 'forwardMessage' => ['from_chat_id', 'message_id'], |
|
| 635 | + 'copyMessage' => ['from_chat_id', 'message_id'], |
|
| 636 | 636 | 'sendPhoto' => ['chat_id'], |
| 637 | 637 | 'sendAudio' => ['chat_id'], |
| 638 | 638 | 'sendDocument' => ['chat_id'], |
@@ -648,15 +648,15 @@ discard block |
||
| 648 | 648 | 'sendContact' => ['chat_id'], |
| 649 | 649 | 'sendPoll' => ['chat_id'], |
| 650 | 650 | 'sendDice' => ['chat_id'], |
| 651 | - 'sendChatAction' => ['chat_id','action'], |
|
| 651 | + 'sendChatAction' => ['chat_id', 'action'], |
|
| 652 | 652 | 'getUserProfilePhotos' => ['user_id'], |
| 653 | 653 | 'getFile' => ['file_id'], |
| 654 | - 'banChatMember' => ['chat_id','user_id'], |
|
| 655 | - 'kickChatMember' => ['chat_id','user_id'], |
|
| 656 | - 'unbanChatMember' => ['chat_id','user_id'], |
|
| 657 | - 'restrictChatMember' => ['chat_id','user_id'], |
|
| 658 | - 'promoteChatMember' => ['chat_id','user_id'], |
|
| 659 | - 'setChatAdministratorCustomTitle' => ['chat_id','user_id'], |
|
| 654 | + 'banChatMember' => ['chat_id', 'user_id'], |
|
| 655 | + 'kickChatMember' => ['chat_id', 'user_id'], |
|
| 656 | + 'unbanChatMember' => ['chat_id', 'user_id'], |
|
| 657 | + 'restrictChatMember' => ['chat_id', 'user_id'], |
|
| 658 | + 'promoteChatMember' => ['chat_id', 'user_id'], |
|
| 659 | + 'setChatAdministratorCustomTitle' => ['chat_id', 'user_id'], |
|
| 660 | 660 | 'banChatSenderChat' => ['chat_id'], |
| 661 | 661 | 'unbanChatSenderChat' => ['chat_id'], |
| 662 | 662 | 'setChatPermissions' => ['chat_id'], |
@@ -664,8 +664,8 @@ discard block |
||
| 664 | 664 | 'createChatInviteLink' => ['chat_id'], |
| 665 | 665 | 'editChatInviteLink' => ['chat_id'], |
| 666 | 666 | 'revokeChatInviteLink' => ['chat_id'], |
| 667 | - 'approveChatJoinRequest' => ['chat_id','user_id'], |
|
| 668 | - 'declineChatJoinRequest' => ['chat_id','user_id'], |
|
| 667 | + 'approveChatJoinRequest' => ['chat_id', 'user_id'], |
|
| 668 | + 'declineChatJoinRequest' => ['chat_id', 'user_id'], |
|
| 669 | 669 | 'setChatPhoto' => ['chat_id'], |
| 670 | 670 | 'deleteChatPhoto' => ['chat_id'], |
| 671 | 671 | 'setChatTitle' => ['chat_id'], |
@@ -677,7 +677,7 @@ discard block |
||
| 677 | 677 | 'getChat' => ['chat_id'], |
| 678 | 678 | 'getChatAdministrators' => ['chat_id'], |
| 679 | 679 | 'getChatMembersCount' => ['chat_id'], |
| 680 | - 'getChatMember' => ['chat_id','user_id'], |
|
| 680 | + 'getChatMember' => ['chat_id', 'user_id'], |
|
| 681 | 681 | 'setChatStickerSet' => ['chat_id'], |
| 682 | 682 | 'deleteChatStickerSet' => ['chat_id'], |
| 683 | 683 | 'answerCallbackQuery' => ['callback_query_id'], |
@@ -688,12 +688,12 @@ discard block |
||
| 688 | 688 | 'getChatMenuButton' => [], |
| 689 | 689 | 'setMyDefaultAdministratorRights' => [], |
| 690 | 690 | 'getMyDefaultAdministratorRights' => [], |
| 691 | - 'editMessageText' => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
| 692 | - 'editMessageCaption' => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
| 693 | - 'editMessageMedia' => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
| 694 | - 'editMessageReplyMarkup' => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
| 695 | - 'stopPoll' => ['chat_id','message_id'], |
|
| 696 | - 'deleteMessage' => ['chat_id','message_id'], |
|
| 691 | + 'editMessageText' => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
| 692 | + 'editMessageCaption' => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
| 693 | + 'editMessageMedia' => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
| 694 | + 'editMessageReplyMarkup' => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
| 695 | + 'stopPoll' => ['chat_id', 'message_id'], |
|
| 696 | + 'deleteMessage' => ['chat_id', 'message_id'], |
|
| 697 | 697 | 'sendSticker' => ['chat_id'], |
| 698 | 698 | 'getStickerSet' => [], |
| 699 | 699 | 'uploadStickerFile' => ['user_id'], |
@@ -709,8 +709,8 @@ discard block |
||
| 709 | 709 | 'answerPreCheckoutQuery' => ['pre_checkout_query_id'], |
| 710 | 710 | 'setPassportDataErrors' => ['user_id'], |
| 711 | 711 | 'sendGame' => ['chat_id'], |
| 712 | - 'setGameScore' => ['user_id','inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
| 713 | - 'getGameHighScores' => ['user_id','inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']] |
|
| 712 | + 'setGameScore' => ['user_id', 'inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
| 713 | + 'getGameHighScores' => ['user_id', 'inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']] |
|
| 714 | 714 | ]; |
| 715 | 715 | |
| 716 | 716 | private const METHODS_RETURN = [ |
@@ -764,27 +764,27 @@ discard block |
||
| 764 | 764 | 'getGameHighScores' => ['BPT\types\gameHighScore'] |
| 765 | 765 | ]; |
| 766 | 766 | |
| 767 | - public static function __callStatic (string $name, array $arguments) { |
|
| 767 | + public static function __callStatic(string $name, array $arguments) { |
|
| 768 | 768 | if (!$action = self::methodAction($name)) { |
| 769 | - logger::write("$name method is not supported",loggerTypes::ERROR); |
|
| 769 | + logger::write("$name method is not supported", loggerTypes::ERROR); |
|
| 770 | 770 | throw new bptException('METHOD_NOT_FOUND'); |
| 771 | 771 | } |
| 772 | 772 | self::checkArguments($arguments); |
| 773 | - self::keysName($action,$arguments); |
|
| 774 | - self::readyFile($action,$arguments); |
|
| 775 | - self::setDefaults($action,$arguments); |
|
| 773 | + self::keysName($action, $arguments); |
|
| 774 | + self::readyFile($action, $arguments); |
|
| 775 | + self::setDefaults($action, $arguments); |
|
| 776 | 776 | if (isset($arguments['answer'])) { |
| 777 | 777 | if (!answer::isAnswered()) { |
| 778 | - return answer::init($action,$arguments); |
|
| 778 | + return answer::init($action, $arguments); |
|
| 779 | 779 | } |
| 780 | - logger::write('you can use answer mode only once for each webhook update, Others will be called like normal',loggerTypes::WARNING); |
|
| 780 | + logger::write('you can use answer mode only once for each webhook update, Others will be called like normal', loggerTypes::WARNING); |
|
| 781 | 781 | unset($arguments['answer']); |
| 782 | 782 | } |
| 783 | - $result = curl::init($action,$arguments); |
|
| 783 | + $result = curl::init($action, $arguments); |
|
| 784 | 784 | if (!is_object($result)) { |
| 785 | 785 | return false; |
| 786 | 786 | } |
| 787 | - return self::processResponse($action,$result); |
|
| 787 | + return self::processResponse($action, $result); |
|
| 788 | 788 | } |
| 789 | 789 | |
| 790 | 790 | private static function checkArguments(array &$arguments): void { |
@@ -793,7 +793,7 @@ discard block |
||
| 793 | 793 | } |
| 794 | 794 | } |
| 795 | 795 | |
| 796 | - private static function keysName (string $name, array &$arguments): void { |
|
| 796 | + private static function keysName(string $name, array &$arguments): void { |
|
| 797 | 797 | foreach ($arguments as $key => $argument) { |
| 798 | 798 | if (is_numeric($key) && isset(self::METHODS_KEYS[$name][$key])) { |
| 799 | 799 | $arguments[self::METHODS_KEYS[$name][$key]] = $argument; |
@@ -802,7 +802,7 @@ discard block |
||
| 802 | 802 | } |
| 803 | 803 | } |
| 804 | 804 | |
| 805 | - private static function methodAction(string $name): string|false { |
|
| 805 | + private static function methodAction(string $name): string | false { |
|
| 806 | 806 | return self::METHODS_ACTION[str_replace('_', '', strtolower($name))] ?? false; |
| 807 | 807 | } |
| 808 | 808 | |
@@ -835,11 +835,11 @@ discard block |
||
| 835 | 835 | } |
| 836 | 836 | } |
| 837 | 837 | |
| 838 | - private static function methodFile(string $name): array|false { |
|
| 838 | + private static function methodFile(string $name): array | false { |
|
| 839 | 839 | return self::METHODS_WITH_FILE[$name] ?? false; |
| 840 | 840 | } |
| 841 | 841 | |
| 842 | - private static function methodReturn(string $name,stdClass $response) { |
|
| 842 | + private static function methodReturn(string $name, stdClass $response) { |
|
| 843 | 843 | if (!isset(self::METHODS_RETURN[$name])) { |
| 844 | 844 | return $response->result; |
| 845 | 845 | } |
@@ -858,13 +858,13 @@ discard block |
||
| 858 | 858 | $defaults = self::METHODS_EXTRA_DEFAULTS[$name]; |
| 859 | 859 | foreach ($defaults as $key => $default) { |
| 860 | 860 | if (is_numeric($key)) { |
| 861 | - if (!isset($arguments[$default])){ |
|
| 861 | + if (!isset($arguments[$default])) { |
|
| 862 | 862 | $arguments[$default] = self::catchFields($default); |
| 863 | 863 | } |
| 864 | 864 | } |
| 865 | 865 | elseif (isset(BPT::$update->$key) || $key === 'other') { |
| 866 | 866 | foreach ($default as $def) { |
| 867 | - if (!isset($arguments[$def])){ |
|
| 867 | + if (!isset($arguments[$def])) { |
|
| 868 | 868 | $arguments[$def] = self::catchFields($def); |
| 869 | 869 | } |
| 870 | 870 | } |
@@ -877,10 +877,10 @@ discard block |
||
| 877 | 877 | self::$status = $response->ok; |
| 878 | 878 | self::$pure_response = $response; |
| 879 | 879 | if (!$response->ok) { |
| 880 | - logger::write("Telegram $name method failed : " . json_encode($response), loggerTypes::WARNING); |
|
| 880 | + logger::write("Telegram $name method failed : ".json_encode($response), loggerTypes::WARNING); |
|
| 881 | 881 | return new responseError($response); |
| 882 | 882 | } |
| 883 | - return self::methodReturn($name,$response); |
|
| 883 | + return self::methodReturn($name, $response); |
|
| 884 | 884 | } |
| 885 | 885 | |
| 886 | 886 | /** |
@@ -890,7 +890,7 @@ discard block |
||
| 890 | 890 | * |
| 891 | 891 | * @return int|string|bool |
| 892 | 892 | */ |
| 893 | - public static function catchFields (string $field): int|string|bool { |
|
| 893 | + public static function catchFields(string $field): int | string | bool { |
|
| 894 | 894 | switch ($field) { |
| 895 | 895 | case fields::CHAT_ID : |
| 896 | 896 | case fields::FROM_CHAT_ID : |
@@ -1026,7 +1026,7 @@ discard block |
||
| 1026 | 1026 | default => false |
| 1027 | 1027 | }; |
| 1028 | 1028 | case fields::URL : |
| 1029 | - return 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; |
|
| 1029 | + return 'https://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; |
|
| 1030 | 1030 | default: |
| 1031 | 1031 | return false; |
| 1032 | 1032 | } |
@@ -811,19 +811,16 @@ discard block |
||
| 811 | 811 | foreach ($arguments['media'] as $key => $media) { |
| 812 | 812 | if ($media['media'] instanceof CURLFile) { |
| 813 | 813 | $remove_answer = true; |
| 814 | - } |
|
| 815 | - elseif (is_string($media['media']) && file_exists(realpath($media['media']))) { |
|
| 814 | + } elseif (is_string($media['media']) && file_exists(realpath($media['media']))) { |
|
| 816 | 815 | $arguments['media'][$key]['media'] = new CURLFile($media['media']); |
| 817 | 816 | $remove_answer = true; |
| 818 | 817 | } |
| 819 | 818 | } |
| 820 | - } |
|
| 821 | - elseif ($file_params = self::methodFile($name)) { |
|
| 819 | + } elseif ($file_params = self::methodFile($name)) { |
|
| 822 | 820 | foreach ($file_params as $param) { |
| 823 | 821 | if ($arguments[$param] instanceof CURLFile) { |
| 824 | 822 | $remove_answer = true; |
| 825 | - } |
|
| 826 | - elseif (isset($arguments[$param]) && is_string($arguments[$param]) && file_exists(realpath($arguments[$param]))) { |
|
| 823 | + } elseif (isset($arguments[$param]) && is_string($arguments[$param]) && file_exists(realpath($arguments[$param]))) { |
|
| 827 | 824 | $arguments[$param] = new CURLFile($arguments[$param]); |
| 828 | 825 | $remove_answer = true; |
| 829 | 826 | } |
@@ -861,8 +858,7 @@ discard block |
||
| 861 | 858 | if (!isset($arguments[$default])){ |
| 862 | 859 | $arguments[$default] = self::catchFields($default); |
| 863 | 860 | } |
| 864 | - } |
|
| 865 | - elseif (isset(BPT::$update->$key) || $key === 'other') { |
|
| 861 | + } elseif (isset(BPT::$update->$key) || $key === 'other') { |
|
| 866 | 862 | foreach ($default as $def) { |
| 867 | 863 | if (!isset($arguments[$def])){ |
| 868 | 864 | $arguments[$def] = self::catchFields($def); |
@@ -919,9 +915,13 @@ discard block |
||
| 919 | 915 | default => false |
| 920 | 916 | }; |
| 921 | 917 | case fields::FILE_ID : |
| 922 | - if (isset(BPT::$update->message)) $type = 'message'; |
|
| 923 | - elseif (isset(BPT::$update->edited_message)) $type = 'edited_message'; |
|
| 924 | - else return false; |
|
| 918 | + if (isset(BPT::$update->message)) { |
|
| 919 | + $type = 'message'; |
|
| 920 | + } elseif (isset(BPT::$update->edited_message)) { |
|
| 921 | + $type = 'edited_message'; |
|
| 922 | + } else { |
|
| 923 | + return false; |
|
| 924 | + } |
|
| 925 | 925 | |
| 926 | 926 | return match(true) { |
| 927 | 927 | isset(BPT::$update->$type->animation) => BPT::$update->$type->animation->file_id, |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | private static CurlHandle $session; |
| 23 | 23 | |
| 24 | - public static function init (string $api_key = '', string $ipn_secret = ''): void { |
|
| 24 | + public static function init(string $api_key = '', string $ipn_secret = ''): void { |
|
| 25 | 25 | self::$api_key = settings::$pay['crypto']['api_key'] ?? $api_key; |
| 26 | 26 | self::$ipn_secret = settings::$pay['crypto']['ipn_secret'] ?? $ipn_secret; |
| 27 | 27 | self::$session = curl_init(); |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | curl_setopt(self::$session, CURLOPT_SSL_VERIFYHOST, 2); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - private static function execute (string $method, string $endpoint, string|array $data = '') { |
|
| 33 | + private static function execute(string $method, string $endpoint, string | array $data = '') { |
|
| 34 | 34 | if (is_array($data)) { |
| 35 | 35 | foreach ($data as $key => $value) { |
| 36 | 36 | if (empty($value)) { |
@@ -41,17 +41,17 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | $session = self::$session; |
| 43 | 43 | curl_setopt($session, CURLOPT_HTTPHEADER, [ |
| 44 | - 'X-API-KEY: ' . self::$api_key, |
|
| 44 | + 'X-API-KEY: '.self::$api_key, |
|
| 45 | 45 | 'Content-Type: application/json' |
| 46 | 46 | ]); |
| 47 | 47 | switch ($method) { |
| 48 | 48 | case 'GET': |
| 49 | - curl_setopt($session, CURLOPT_URL, self::API_BASE . $endpoint . !empty($data) && is_array($data) ? ('?' . http_build_query($data)) : ''); |
|
| 49 | + curl_setopt($session, CURLOPT_URL, self::API_BASE.$endpoint.!empty($data) && is_array($data) ? ('?'.http_build_query($data)) : ''); |
|
| 50 | 50 | break; |
| 51 | 51 | case 'POST': |
| 52 | 52 | curl_setopt($session, CURLOPT_POST, true); |
| 53 | 53 | curl_setopt($session, CURLOPT_POSTFIELDS, json_encode($data)); |
| 54 | - curl_setopt($session, CURLOPT_URL, self::API_BASE . $endpoint); |
|
| 54 | + curl_setopt($session, CURLOPT_URL, self::API_BASE.$endpoint); |
|
| 55 | 55 | break; |
| 56 | 56 | default: |
| 57 | 57 | return false; |
@@ -59,14 +59,14 @@ discard block |
||
| 59 | 59 | return json_decode(curl_exec($session)); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - public static function status (): bool { |
|
| 62 | + public static function status(): bool { |
|
| 63 | 63 | return self::execute('GET', 'status')->message === 'OK'; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
| 67 | 67 | * @return estimatePriceInterface|mixed |
| 68 | 68 | */ |
| 69 | - public static function getEstimatePrice (int|float $amount, string $currency_from, string $currency_to) { |
|
| 69 | + public static function getEstimatePrice(int | float $amount, string $currency_from, string $currency_to) { |
|
| 70 | 70 | return self::execute('GET', 'estimate', [ |
| 71 | 71 | 'amount' => $amount, |
| 72 | 72 | 'currency_from' => $currency_from, |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | /** |
| 78 | 78 | * @return invoicePaymentInterface|mixed |
| 79 | 79 | */ |
| 80 | - public static function createPayment (int|float $price_amount, string $price_currency, string $pay_currency, int|float $pay_amount = null, string $ipn_callback_url = null, string $order_id = null, string $order_description = null, string $purchase_id = null, string $payout_address = null, string $payout_currency = null, string $payout_extra_id = null, bool $fixed_rate = null) { |
|
| 80 | + public static function createPayment(int | float $price_amount, string $price_currency, string $pay_currency, int | float $pay_amount = null, string $ipn_callback_url = null, string $order_id = null, string $order_description = null, string $purchase_id = null, string $payout_address = null, string $payout_currency = null, string $payout_extra_id = null, bool $fixed_rate = null) { |
|
| 81 | 81 | return self::execute('POST', 'payment', [ |
| 82 | 82 | 'price_amount' => $price_amount, |
| 83 | 83 | 'price_currency' => $price_currency, |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | /** |
| 98 | 98 | * @return invoicePaymentInterface|mixed |
| 99 | 99 | */ |
| 100 | - public static function createInvoicePayment (string $iid, string $pay_currency, string $purchase_id = null, string $order_description = null, string $customer_email = null, string $payout_address = null, string $payout_extra_id = null, string $payout_currency = null) { |
|
| 100 | + public static function createInvoicePayment(string $iid, string $pay_currency, string $purchase_id = null, string $order_description = null, string $customer_email = null, string $payout_address = null, string $payout_extra_id = null, string $payout_currency = null) { |
|
| 101 | 101 | return self::execute('POST', 'invoice', [ |
| 102 | 102 | 'iid' => $iid, |
| 103 | 103 | 'pay_currency' => $pay_currency, |
@@ -113,18 +113,18 @@ discard block |
||
| 113 | 113 | /** |
| 114 | 114 | * @return estimateUpdateInterface|mixed |
| 115 | 115 | */ |
| 116 | - public static function updateEstimatePrice (int $paymentID) { |
|
| 117 | - return self::execute('POST', 'payment/' . $paymentID . '/update-merchant-estimate'); |
|
| 116 | + public static function updateEstimatePrice(int $paymentID) { |
|
| 117 | + return self::execute('POST', 'payment/'.$paymentID.'/update-merchant-estimate'); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | /** |
| 121 | 121 | * @return paymentInterface|mixed |
| 122 | 122 | */ |
| 123 | - public static function getPaymentStatus (int $paymentID) { |
|
| 124 | - return self::execute('GET', 'payment/' . $paymentID); |
|
| 123 | + public static function getPaymentStatus(int $paymentID) { |
|
| 124 | + return self::execute('GET', 'payment/'.$paymentID); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - public static function getMinimumPaymentAmount (string $currency_from, string $currency_to): float { |
|
| 127 | + public static function getMinimumPaymentAmount(string $currency_from, string $currency_to): float { |
|
| 128 | 128 | return self::execute('GET', 'min-amount', [ |
| 129 | 129 | 'currency_from' => $currency_from, |
| 130 | 130 | 'currency_to' => $currency_to |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | /** |
| 135 | 135 | * @return invoiceResponseInterface|mixed |
| 136 | 136 | */ |
| 137 | - public static function createInvoice (int|float $price_amount, string $price_currency, string $pay_currency, int|float $pay_amount = null, string $ipn_callback_url = null, string $order_id = null, string $order_description = null, string $success_url = null, string $cancel_url = null) { |
|
| 137 | + public static function createInvoice(int | float $price_amount, string $price_currency, string $pay_currency, int | float $pay_amount = null, string $ipn_callback_url = null, string $order_id = null, string $order_description = null, string $success_url = null, string $cancel_url = null) { |
|
| 138 | 138 | return self::execute('POST', 'invoice', [ |
| 139 | 139 | 'price_amount' => $price_amount, |
| 140 | 140 | 'price_currency' => $price_currency, |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | ]); |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - public static function getCurrencies (): array { |
|
| 151 | + public static function getCurrencies(): array { |
|
| 152 | 152 | return self::execute('GET', 'currencies')->currencies; |
| 153 | 153 | } |
| 154 | 154 | |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | return tools::remoteIP() === '144.76.201.30'; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - public static function isIPNRequestValid (): bool { |
|
| 159 | + public static function isIPNRequestValid(): bool { |
|
| 160 | 160 | if (empty($_SERVER['HTTP_X_NOWPAYMENTS_SIG'])) { |
| 161 | 161 | return false; |
| 162 | 162 | } |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | /** |
| 177 | 177 | * @return ipnDataInterface|mixed |
| 178 | 178 | */ |
| 179 | - public static function getIPN () { |
|
| 179 | + public static function getIPN() { |
|
| 180 | 180 | if (!self::isIPNRequestValid()) { |
| 181 | 181 | return false; |
| 182 | 182 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | /** |
| 28 | 28 | * If you want to use it in standalone mode , you MUST set `auto_process` to `false` |
| 29 | 29 | */ |
| 30 | - public static function init (string $host = 'localhost', string $username = 'root', string $password = '', string $dbname = '', bool $auto_process = null, int $port = 3306): void { |
|
| 30 | + public static function init(string $host = 'localhost', string $username = 'root', string $password = '', string $dbname = '', bool $auto_process = null, int $port = 3306): void { |
|
| 31 | 31 | $host = settings::$db['host'] ?? $host; |
| 32 | 32 | $port = settings::$db['port'] ?? $port; |
| 33 | 33 | $user = settings::$db['user'] ?? settings::$db['username'] ?? $username; |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | $dbname = settings::$db['dbname'] ?? $dbname; |
| 37 | 37 | self::$connection = new mysqli($host, $user, $pass, $dbname, $port); |
| 38 | 38 | if (self::$connection->connect_errno) { |
| 39 | - logger::write('SQL connection has problem : ' . self::$connection->connect_error, loggerTypes::ERROR); |
|
| 39 | + logger::write('SQL connection has problem : '.self::$connection->connect_error, loggerTypes::ERROR); |
|
| 40 | 40 | throw new bptException('SQL_CONNECTION_PROBLEM'); |
| 41 | 41 | } |
| 42 | 42 | if (self::$auto_process && !lock::exist('BPT-MYSQL')) { |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - private static function install (): void { |
|
| 47 | + private static function install(): void { |
|
| 48 | 48 | self::pureQuery(" |
| 49 | 49 | CREATE TABLE `users` |
| 50 | 50 | ( |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | /** |
| 66 | 66 | * @internal Only for BPT self usage , Don't use it in your source! |
| 67 | 67 | */ |
| 68 | - public static function process (): void { |
|
| 68 | + public static function process(): void { |
|
| 69 | 69 | if (self::$auto_process) { |
| 70 | 70 | if (isset(BPT::$update->message)) { |
| 71 | 71 | self::processMessage(BPT::$update->message); |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - private static function processMessage (message $update): void { |
|
| 88 | + private static function processMessage(message $update): void { |
|
| 89 | 89 | $type = $update->chat->type; |
| 90 | 90 | if ($type === chatType::PRIVATE) { |
| 91 | 91 | $user_id = $update->from->id; |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - private static function processCallbackQuery (callbackQuery $update): void { |
|
| 114 | + private static function processCallbackQuery(callbackQuery $update): void { |
|
| 115 | 115 | $type = $update->message->chat->type; |
| 116 | 116 | if ($type === chatType::PRIVATE) { |
| 117 | 117 | $user_id = $update->from->id; |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - private static function processInlineQuery (inlineQuery $update): void { |
|
| 124 | + private static function processInlineQuery(inlineQuery $update): void { |
|
| 125 | 125 | $type = $update->chat_type; |
| 126 | 126 | if ($type === chatType::PRIVATE || $type === chatType::SENDER) { |
| 127 | 127 | $user_id = $update->from->id; |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - private static function processMyChatMember (chatMemberUpdated $update): void { |
|
| 134 | + private static function processMyChatMember(chatMemberUpdated $update): void { |
|
| 135 | 135 | $type = $update->chat->type; |
| 136 | 136 | if ($type === chatType::PRIVATE) { |
| 137 | 137 | if ($update->new_chat_member->status === chatMemberStatus::MEMBER) { |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | * |
| 149 | 149 | * @return mysqli |
| 150 | 150 | */ |
| 151 | - public static function getMysqli (): mysqli { |
|
| 151 | + public static function getMysqli(): mysqli { |
|
| 152 | 152 | return self::$connection; |
| 153 | 153 | } |
| 154 | 154 | |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * |
| 158 | 158 | * @return int|string |
| 159 | 159 | */ |
| 160 | - public static function affected_rows (): int|string { |
|
| 160 | + public static function affected_rows(): int | string { |
|
| 161 | 161 | return self::$connection->affected_rows; |
| 162 | 162 | } |
| 163 | 163 | |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | * |
| 167 | 167 | * @return int|string |
| 168 | 168 | */ |
| 169 | - public static function insert_id (): int|string { |
|
| 169 | + public static function insert_id(): int | string { |
|
| 170 | 170 | return self::$connection->insert_id; |
| 171 | 171 | } |
| 172 | 172 | |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | * |
| 178 | 178 | * @return string |
| 179 | 179 | */ |
| 180 | - public static function escapeString (string $text): string { |
|
| 180 | + public static function escapeString(string $text): string { |
|
| 181 | 181 | return self::$connection->real_escape_string($text); |
| 182 | 182 | } |
| 183 | 183 | |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | * |
| 193 | 193 | * @return mysqli_result|bool |
| 194 | 194 | */ |
| 195 | - public static function pureQuery (string $query): mysqli_result|bool { |
|
| 195 | + public static function pureQuery(string $query): mysqli_result | bool { |
|
| 196 | 196 | return self::$connection->query($query); |
| 197 | 197 | } |
| 198 | 198 | |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | * |
| 214 | 214 | * @return mysqli_result|bool |
| 215 | 215 | */ |
| 216 | - public static function query (string $query, array $vars = [], bool $need_result = true): mysqli_result|bool { |
|
| 216 | + public static function query(string $query, array $vars = [], bool $need_result = true): mysqli_result | bool { |
|
| 217 | 217 | if (empty($vars)) { |
| 218 | 218 | return self::pureQuery($query); |
| 219 | 219 | } |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | $types .= 's'; |
| 231 | 231 | } |
| 232 | 232 | } |
| 233 | - $prepare->bind_param($types,...$vars); |
|
| 233 | + $prepare->bind_param($types, ...$vars); |
|
| 234 | 234 | if (!$prepare->execute()) { |
| 235 | 235 | logger::write(loggerTypes::WARNING, $prepare->error); |
| 236 | 236 | return false; |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | return $need_result ? $prepare->get_result() : true; |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - private static function makeArrayReady (string &$query, array $array, string $operator = ' AND '): array { |
|
| 241 | + private static function makeArrayReady(string &$query, array $array, string $operator = ' AND '): array { |
|
| 242 | 242 | $first = true; |
| 243 | 243 | $values = []; |
| 244 | 244 | foreach ($array as $name => $value) { |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | return $values; |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | - private static function makeQueryReady (string &$query, array $where = null, int $count = null, int $offset = null): array { |
|
| 257 | + private static function makeQueryReady(string &$query, array $where = null, int $count = null, int $offset = null): array { |
|
| 258 | 258 | $values = []; |
| 259 | 259 | if (!empty($where)) { |
| 260 | 260 | $query .= " WHERE"; |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | * |
| 282 | 282 | * @return mysqli_result|bool |
| 283 | 283 | */ |
| 284 | - public static function delete (string $table, array $where = null, int $count = null, int $offset = null): mysqli_result|bool { |
|
| 284 | + public static function delete(string $table, array $where = null, int $count = null, int $offset = null): mysqli_result | bool { |
|
| 285 | 285 | $query = "DELETE FROM `$table`"; |
| 286 | 286 | $res = self::makeQueryReady($query, $where, $count, $offset); |
| 287 | 287 | return self::query($query, $res, false); |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | * |
| 301 | 301 | * @return mysqli_result|bool |
| 302 | 302 | */ |
| 303 | - public static function update (string $table, array $modify, array $where = null, int $count = null, int $offset = null): mysqli_result|bool { |
|
| 303 | + public static function update(string $table, array $modify, array $where = null, int $count = null, int $offset = null): mysqli_result | bool { |
|
| 304 | 304 | $query = "UPDATE `$table` SET"; |
| 305 | 305 | $values = self::makeArrayReady($query, $modify, ', '); |
| 306 | 306 | $res = self::makeQueryReady($query, $where, $count, $offset); |
@@ -318,11 +318,11 @@ discard block |
||
| 318 | 318 | * |
| 319 | 319 | * @return mysqli_result|bool |
| 320 | 320 | */ |
| 321 | - public static function insert (string $table, string|array $columns, array|string $values): mysqli_result|bool { |
|
| 321 | + public static function insert(string $table, string | array $columns, array | string $values): mysqli_result | bool { |
|
| 322 | 322 | $query = "INSERT INTO `$table`("; |
| 323 | - $query .= '`' . (is_string($columns) ? $columns : implode('`,`', $columns)) . '`) VALUES ('; |
|
| 323 | + $query .= '`'.(is_string($columns) ? $columns : implode('`,`', $columns)).'`) VALUES ('; |
|
| 324 | 324 | if (is_string($values)) $values = [$values]; |
| 325 | - $query .= '?' . str_repeat(',?', count($values) - 1) . ')'; |
|
| 325 | + $query .= '?'.str_repeat(',?', count($values) - 1).')'; |
|
| 326 | 326 | return self::query($query, $values, false); |
| 327 | 327 | } |
| 328 | 328 | |
@@ -341,13 +341,13 @@ discard block |
||
| 341 | 341 | * |
| 342 | 342 | * @return mysqli_result|bool |
| 343 | 343 | */ |
| 344 | - public static function select (string $table, array|string $columns = '*', array $where = null, int $count = null, int $offset = null): mysqli_result|bool { |
|
| 344 | + public static function select(string $table, array | string $columns = '*', array $where = null, int $count = null, int $offset = null): mysqli_result | bool { |
|
| 345 | 345 | $query = "SELECT "; |
| 346 | 346 | if ($columns == '*') { |
| 347 | 347 | $query .= "* "; |
| 348 | 348 | } |
| 349 | 349 | else { |
| 350 | - $query .= '`' . (is_string($columns) ? $columns : implode('`,`', $columns)) . '` '; |
|
| 350 | + $query .= '`'.(is_string($columns) ? $columns : implode('`,`', $columns)).'` '; |
|
| 351 | 351 | } |
| 352 | 352 | $query .= "FROM `$table`"; |
| 353 | 353 | $res = self::makeQueryReady($query, $where, $count, $offset); |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | * |
| 366 | 366 | * @return null|bool|array |
| 367 | 367 | */ |
| 368 | - public static function selectArray (string $table, array|string $columns = '*', array $where = null): bool|array|null { |
|
| 368 | + public static function selectArray(string $table, array | string $columns = '*', array $where = null): bool | array | null { |
|
| 369 | 369 | $res = self::select($table, $columns, $where, 1); |
| 370 | 370 | if ($res) { |
| 371 | 371 | return $res->fetch_assoc(); |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | * @param array|string $columns sets column that you want to retrieve , set '*' to retrieve all , default : '*' |
| 383 | 383 | * @param array|null $where Set your ifs default : null |
| 384 | 384 | */ |
| 385 | - public static function selectObject (string $table, array|string $columns = '*', array $where = null) { |
|
| 385 | + public static function selectObject(string $table, array | string $columns = '*', array $where = null) { |
|
| 386 | 386 | $res = self::select($table, $columns, $where, 1); |
| 387 | 387 | if ($res) { |
| 388 | 388 | return $res->fetch_object(); |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | * |
| 405 | 405 | * @return bool|Generator |
| 406 | 406 | */ |
| 407 | - public static function selectEach (string $table, array|string $columns = '*', array $where = null, int $count = null, int $offset = null): bool|Generator { |
|
| 407 | + public static function selectEach(string $table, array | string $columns = '*', array $where = null, int $count = null, int $offset = null): bool | Generator { |
|
| 408 | 408 | $res = self::select($table, $columns, $where, $count, $offset); |
| 409 | 409 | if ($res) { |
| 410 | 410 | while ($row = $res->fetch_assoc()) yield $row; |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | /** |
| 104 | 104 | * @internal Only for BPT self usage , Don't use it in your source! |
| 105 | 105 | */ |
| 106 | - public static function init (): void { |
|
| 106 | + public static function init(): void { |
|
| 107 | 107 | self::$folder = settings::$name.'database'; |
| 108 | 108 | self::$global_default_data = settings::$db['global'] ?? self::$global_default_data; |
| 109 | 109 | self::setUserDefaultData(); |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | self::load(); |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - private static function setUserDefaultData (): void { |
|
| 118 | + private static function setUserDefaultData(): void { |
|
| 119 | 119 | self::$user_default_data = settings::$db['user'] ?? self::$user_default_data; |
| 120 | 120 | if (!isset(self::$user_default_data['step'])) { |
| 121 | 121 | self::$user_default_data['step'] = 'none'; |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - private static function setGroupUserDefaultData (): void { |
|
| 137 | + private static function setGroupUserDefaultData(): void { |
|
| 138 | 138 | self::$group_user_default_data = settings::$db['group_user'] ?? self::$group_user_default_data; |
| 139 | 139 | if (!isset(self::$group_user_default_data['step'])) { |
| 140 | 140 | self::$group_user_default_data['step'] = 'none'; |
@@ -162,10 +162,10 @@ discard block |
||
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | if (!file_exists(realpath(self::$folder.'/global.json'))) { |
| 165 | - file_put_contents(self::$folder.'/global.json',self::$global_default_data); |
|
| 165 | + file_put_contents(self::$folder.'/global.json', self::$global_default_data); |
|
| 166 | 166 | } |
| 167 | 167 | if (!file_exists(realpath(self::$folder.'/ids.json'))) { |
| 168 | - file_put_contents(self::$folder.'/ids.json',json_encode([ |
|
| 168 | + file_put_contents(self::$folder.'/ids.json', json_encode([ |
|
| 169 | 169 | 'privates' => [], |
| 170 | 170 | 'groups' => [], |
| 171 | 171 | 'supergroups' => [], |
@@ -174,25 +174,25 @@ discard block |
||
| 174 | 174 | } |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - private static function load (): void { |
|
| 177 | + private static function load(): void { |
|
| 178 | 178 | self::$global = json_decode(file_get_contents(self::$folder.'/global.json')); |
| 179 | 179 | self::$old_global = clone self::$global; |
| 180 | - self::$ids = json_decode(file_get_contents(self::$folder.'/ids.json'),true); |
|
| 180 | + self::$ids = json_decode(file_get_contents(self::$folder.'/ids.json'), true); |
|
| 181 | 181 | self::$old_ids = clone self::$ids; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - private static function read (string $address) { |
|
| 184 | + private static function read(string $address) { |
|
| 185 | 185 | return file_exists(realpath(self::$folder.'/'.$address.'.json')) ? json_decode(file_get_contents(self::$folder.'/'.$address.'.json'), false) : null; |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - private static function write (string $address,string $data): void { |
|
| 189 | - file_put_contents(self::$folder.'/'.$address.'.json',$data); |
|
| 188 | + private static function write(string $address, string $data): void { |
|
| 189 | + file_put_contents(self::$folder.'/'.$address.'.json', $data); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | /** |
| 193 | 193 | * @internal Only for BPT self usage , Don't use it in your source! |
| 194 | 194 | */ |
| 195 | - public static function process (): void { |
|
| 195 | + public static function process(): void { |
|
| 196 | 196 | if (isset(BPT::$update->message)) { |
| 197 | 197 | self::processMessage(BPT::$update->message); |
| 198 | 198 | } |
@@ -215,16 +215,16 @@ discard block |
||
| 215 | 215 | */ |
| 216 | 216 | public static function save(): void { |
| 217 | 217 | if (self::$user !== self::$old_user && !empty(self::$user_id)) { |
| 218 | - self::write('privates/' . self::$user_id,json_encode(self::$user)); |
|
| 218 | + self::write('privates/'.self::$user_id, json_encode(self::$user)); |
|
| 219 | 219 | } |
| 220 | 220 | if (self::$group !== self::$old_group && !empty(self::$group_id)) { |
| 221 | - self::write('groups/' . self::$group_id,json_encode(self::$group)); |
|
| 221 | + self::write('groups/'.self::$group_id, json_encode(self::$group)); |
|
| 222 | 222 | } |
| 223 | 223 | if (self::$supergroup !== self::$old_supergroup && !empty(self::$supergroup_id)) { |
| 224 | - self::write('supergroups/' . self::$supergroup_id,json_encode(self::$supergroup)); |
|
| 224 | + self::write('supergroups/'.self::$supergroup_id, json_encode(self::$supergroup)); |
|
| 225 | 225 | } |
| 226 | 226 | if (self::$channel !== self::$old_channel && !empty(self::$channel_id)) { |
| 227 | - self::write('channels/' . self::$channel_id,json_encode(self::$channel)); |
|
| 227 | + self::write('channels/'.self::$channel_id, json_encode(self::$channel)); |
|
| 228 | 228 | } |
| 229 | 229 | if (self::$group_user !== self::$old_group_user && !empty(self::$group_user_id)) { |
| 230 | 230 | if (empty(self::$group)) { |
@@ -235,13 +235,13 @@ discard block |
||
| 235 | 235 | $category = 'groups'; |
| 236 | 236 | $group_id = self::$group_id; |
| 237 | 237 | } |
| 238 | - self::write($category . '/' . $group_id . '/' . self::$group_user_id,json_encode(self::$group_user)); |
|
| 238 | + self::write($category.'/'.$group_id.'/'.self::$group_user_id, json_encode(self::$group_user)); |
|
| 239 | 239 | } |
| 240 | 240 | if (self::$ids !== self::$old_ids) { |
| 241 | - self::write('ids',json_encode(self::$ids)); |
|
| 241 | + self::write('ids', json_encode(self::$ids)); |
|
| 242 | 242 | } |
| 243 | 243 | if (self::$global !== self::$old_global) { |
| 244 | - self::write('global',json_encode(self::$global)); |
|
| 244 | + self::write('global', json_encode(self::$global)); |
|
| 245 | 245 | } |
| 246 | 246 | if (self::$group_ids !== self::$old_group_ids) { |
| 247 | 247 | if (empty(self::$group)) { |
@@ -252,17 +252,17 @@ discard block |
||
| 252 | 252 | $category = 'groups'; |
| 253 | 253 | $group_id = self::$group_id; |
| 254 | 254 | } |
| 255 | - self::write($category . '/' . $group_id . '/users',json_encode(self::$group_user)); |
|
| 255 | + self::write($category.'/'.$group_id.'/users', json_encode(self::$group_user)); |
|
| 256 | 256 | } |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | private static function processMessage(message $update): void { |
| 260 | 260 | $type = $update->chat->type; |
| 261 | - $category = $type . 's'; |
|
| 261 | + $category = $type.'s'; |
|
| 262 | 262 | if ($type === chatType::PRIVATE) { |
| 263 | 263 | self::$user_id = $update->from->id; |
| 264 | - if (in_array(self::$user_id,self::$ids[$category])) { |
|
| 265 | - self::$user = self::read($category . '/' . self::$user_id); |
|
| 264 | + if (in_array(self::$user_id, self::$ids[$category])) { |
|
| 265 | + self::$user = self::read($category.'/'.self::$user_id); |
|
| 266 | 266 | self::$old_user = clone self::$user; |
| 267 | 267 | self::$user->last_active = time(); |
| 268 | 268 | } |
@@ -270,10 +270,10 @@ discard block |
||
| 270 | 270 | self::$ids[$category][] = self::$user_id; |
| 271 | 271 | self::$user = (object) self::$user_default_data; |
| 272 | 272 | self::$user->first_active = self::$user->last_active = time(); |
| 273 | - if (isset($update->command) && isset($update->command_payload) && $update->command === 'start' && str_starts_with($update->command_payload,'ref_')) { |
|
| 274 | - if (tools::isShorted(substr($update->command_payload,4))) { |
|
| 275 | - $referral = tools::shortDecode(substr($update->command_payload,4)); |
|
| 276 | - if (in_array($referral,self::$ids[$category])) { |
|
| 273 | + if (isset($update->command) && isset($update->command_payload) && $update->command === 'start' && str_starts_with($update->command_payload, 'ref_')) { |
|
| 274 | + if (tools::isShorted(substr($update->command_payload, 4))) { |
|
| 275 | + $referral = tools::shortDecode(substr($update->command_payload, 4)); |
|
| 276 | + if (in_array($referral, self::$ids[$category])) { |
|
| 277 | 277 | self::$user->referral = $referral; |
| 278 | 278 | } |
| 279 | 279 | } |
@@ -282,8 +282,8 @@ discard block |
||
| 282 | 282 | } |
| 283 | 283 | elseif ($type === chatType::CHANNEL) { |
| 284 | 284 | self::$channel_id = $update->chat->id; |
| 285 | - if (in_array(self::$channel_id,self::$ids[$category])) { |
|
| 286 | - self::$channel = self::read($category . '/' . self::$channel_id); |
|
| 285 | + if (in_array(self::$channel_id, self::$ids[$category])) { |
|
| 286 | + self::$channel = self::read($category.'/'.self::$channel_id); |
|
| 287 | 287 | self::$old_channel = clone self::$channel; |
| 288 | 288 | } |
| 289 | 289 | else { |
@@ -297,10 +297,10 @@ discard block |
||
| 297 | 297 | $chat_id = $update->chat->id; |
| 298 | 298 | if ($type === chatType::SUPERGROUP) { |
| 299 | 299 | self::$supergroup_id = $update->chat->id; |
| 300 | - if (in_array($chat_id,self::$ids[$category])) { |
|
| 301 | - self::$supergroup = self::read($category . '/' . $chat_id); |
|
| 300 | + if (in_array($chat_id, self::$ids[$category])) { |
|
| 301 | + self::$supergroup = self::read($category.'/'.$chat_id); |
|
| 302 | 302 | self::$old_supergroup = clone self::$supergroup; |
| 303 | - self::$group_ids = self::read($category . '/' . $chat_id . '/users'); |
|
| 303 | + self::$group_ids = self::read($category.'/'.$chat_id.'/users'); |
|
| 304 | 304 | self::$old_group_ids = clone self::$group_ids; |
| 305 | 305 | } |
| 306 | 306 | else { |
@@ -311,10 +311,10 @@ discard block |
||
| 311 | 311 | } |
| 312 | 312 | else { |
| 313 | 313 | self::$group_id = $update->chat->id; |
| 314 | - if (in_array($chat_id,self::$ids[$category])) { |
|
| 315 | - self::$group = self::read($category . '/' . $chat_id); |
|
| 314 | + if (in_array($chat_id, self::$ids[$category])) { |
|
| 315 | + self::$group = self::read($category.'/'.$chat_id); |
|
| 316 | 316 | self::$old_group = clone self::$group; |
| 317 | - self::$group_ids = self::read($category . '/' . $chat_id . '/users'); |
|
| 317 | + self::$group_ids = self::read($category.'/'.$chat_id.'/users'); |
|
| 318 | 318 | self::$old_group_ids = clone self::$group_ids; |
| 319 | 319 | } |
| 320 | 320 | else { |
@@ -324,8 +324,8 @@ discard block |
||
| 324 | 324 | } |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | - if (in_array(self::$user_id,self::$group_ids)) { |
|
| 328 | - self::$group_user = self::read($category . '/' . $chat_id . '/' . self::$user_id); |
|
| 327 | + if (in_array(self::$user_id, self::$group_ids)) { |
|
| 328 | + self::$group_user = self::read($category.'/'.$chat_id.'/'.self::$user_id); |
|
| 329 | 329 | self::$old_group_user = clone self::$group_user; |
| 330 | 330 | } |
| 331 | 331 | else { |
@@ -341,42 +341,42 @@ discard block |
||
| 341 | 341 | |
| 342 | 342 | private static function processCallbackQuery(callbackQuery $update): void { |
| 343 | 343 | $type = $update->message->chat->type; |
| 344 | - $category = $type . 's'; |
|
| 344 | + $category = $type.'s'; |
|
| 345 | 345 | if ($type === chatType::PRIVATE) { |
| 346 | 346 | self::$user_id = $update->from->id; |
| 347 | - if (in_array(self::$user_id,self::$ids[$category])) { |
|
| 348 | - self::$user = self::read($category . '/' . self::$user_id); |
|
| 347 | + if (in_array(self::$user_id, self::$ids[$category])) { |
|
| 348 | + self::$user = self::read($category.'/'.self::$user_id); |
|
| 349 | 349 | self::$old_user = clone self::$user; |
| 350 | 350 | self::$user->last_active = time(); |
| 351 | 351 | } |
| 352 | 352 | } |
| 353 | 353 | elseif ($type === chatType::CHANNEL) { |
| 354 | 354 | self::$channel_id = $update->message->chat->id; |
| 355 | - if (in_array(self::$channel_id,self::$ids[$category])) { |
|
| 356 | - self::$channel = self::read($category . '/' . self::$channel_id); |
|
| 355 | + if (in_array(self::$channel_id, self::$ids[$category])) { |
|
| 356 | + self::$channel = self::read($category.'/'.self::$channel_id); |
|
| 357 | 357 | self::$old_channel = clone self::$channel; |
| 358 | 358 | } |
| 359 | 359 | } |
| 360 | 360 | else { |
| 361 | 361 | self::$user_id = $update->from->id; |
| 362 | 362 | $chat_id = $update->message->chat->id; |
| 363 | - if (in_array($chat_id,self::$ids[$category])) { |
|
| 363 | + if (in_array($chat_id, self::$ids[$category])) { |
|
| 364 | 364 | if ($type === chatType::SUPERGROUP) { |
| 365 | 365 | self::$supergroup_id = $update->message->chat->id; |
| 366 | - self::$supergroup = self::read($category . '/' . $chat_id); |
|
| 366 | + self::$supergroup = self::read($category.'/'.$chat_id); |
|
| 367 | 367 | self::$old_supergroup = clone self::$supergroup; |
| 368 | 368 | } |
| 369 | 369 | else { |
| 370 | 370 | self::$group_id = $update->message->chat->id; |
| 371 | - self::$group = self::read($category . '/' . $chat_id); |
|
| 371 | + self::$group = self::read($category.'/'.$chat_id); |
|
| 372 | 372 | self::$old_group = clone self::$group; |
| 373 | 373 | } |
| 374 | - self::$group_ids = self::read($category . '/' . $chat_id . '/users'); |
|
| 374 | + self::$group_ids = self::read($category.'/'.$chat_id.'/users'); |
|
| 375 | 375 | self::$old_group_ids = clone self::$group_ids; |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | - if (in_array(self::$user_id,self::$group_ids)) { |
|
| 379 | - self::$group_user = self::read($category . '/' . $chat_id . '/' . self::$user_id); |
|
| 378 | + if (in_array(self::$user_id, self::$group_ids)) { |
|
| 379 | + self::$group_user = self::read($category.'/'.$chat_id.'/'.self::$user_id); |
|
| 380 | 380 | self::$group_user_id = self::$user_id; |
| 381 | 381 | self::$old_group_user = clone self::$group_user; |
| 382 | 382 | } |
@@ -390,10 +390,10 @@ discard block |
||
| 390 | 390 | private static function processInlineQuery(inlineQuery $update): void { |
| 391 | 391 | $type = $update->chat_type; |
| 392 | 392 | if ($type === chatType::PRIVATE || $type === chatType::SENDER) { |
| 393 | - $category = chatType::PRIVATE . 's'; |
|
| 393 | + $category = chatType::PRIVATE.'s'; |
|
| 394 | 394 | self::$user_id = $update->from->id; |
| 395 | - if (in_array(self::$user_id,self::$ids[$category])) { |
|
| 396 | - self::$user = self::read($category . '/' . self::$user_id); |
|
| 395 | + if (in_array(self::$user_id, self::$ids[$category])) { |
|
| 396 | + self::$user = self::read($category.'/'.self::$user_id); |
|
| 397 | 397 | self::$old_user = clone self::$user; |
| 398 | 398 | self::$user->last_active = time(); |
| 399 | 399 | } |
@@ -403,11 +403,11 @@ discard block |
||
| 403 | 403 | private static function processChatMember(chatMemberUpdated $update): void { |
| 404 | 404 | $type = $update->chat->type; |
| 405 | 405 | |
| 406 | - $category = $type . 's'; |
|
| 406 | + $category = $type.'s'; |
|
| 407 | 407 | if ($type === chatType::CHANNEL) { |
| 408 | 408 | self::$channel_id = $update->chat->id; |
| 409 | - if (in_array(self::$channel_id,self::$ids[$category])) { |
|
| 410 | - self::$channel = self::read($category . '/' . self::$channel_id); |
|
| 409 | + if (in_array(self::$channel_id, self::$ids[$category])) { |
|
| 410 | + self::$channel = self::read($category.'/'.self::$channel_id); |
|
| 411 | 411 | self::$old_channel = clone self::$channel; |
| 412 | 412 | } |
| 413 | 413 | else { |
@@ -426,10 +426,10 @@ discard block |
||
| 426 | 426 | |
| 427 | 427 | if ($type === chatType::SUPERGROUP) { |
| 428 | 428 | self::$supergroup_id = $chat_id; |
| 429 | - if (in_array($chat_id,self::$ids[$category])) { |
|
| 430 | - self::$supergroup = self::read($category . '/' . $chat_id); |
|
| 429 | + if (in_array($chat_id, self::$ids[$category])) { |
|
| 430 | + self::$supergroup = self::read($category.'/'.$chat_id); |
|
| 431 | 431 | self::$old_supergroup = clone self::$supergroup; |
| 432 | - self::$group_ids = self::read($category . '/' . $chat_id . '/users'); |
|
| 432 | + self::$group_ids = self::read($category.'/'.$chat_id.'/users'); |
|
| 433 | 433 | self::$old_group_ids = clone self::$group_ids; |
| 434 | 434 | } |
| 435 | 435 | else { |
@@ -440,10 +440,10 @@ discard block |
||
| 440 | 440 | } |
| 441 | 441 | elseif ($type === chatType::GROUP) { |
| 442 | 442 | self::$group_id = $chat_id; |
| 443 | - if (in_array($chat_id,self::$ids[$category])) { |
|
| 444 | - self::$group = self::read($category . '/' . $chat_id); |
|
| 443 | + if (in_array($chat_id, self::$ids[$category])) { |
|
| 444 | + self::$group = self::read($category.'/'.$chat_id); |
|
| 445 | 445 | self::$old_group = clone self::$group; |
| 446 | - self::$group_ids = self::read($category . '/' . $chat_id . '/users'); |
|
| 446 | + self::$group_ids = self::read($category.'/'.$chat_id.'/users'); |
|
| 447 | 447 | self::$old_group_ids = clone self::$group_ids; |
| 448 | 448 | } |
| 449 | 449 | else { |
@@ -453,13 +453,13 @@ discard block |
||
| 453 | 453 | } |
| 454 | 454 | } |
| 455 | 455 | |
| 456 | - if (!in_array($user_id,self::$group_ids)) { |
|
| 456 | + if (!in_array($user_id, self::$group_ids)) { |
|
| 457 | 457 | self::$group_ids[] = $user_id; |
| 458 | 458 | self::$group_user = (object) self::$group_user_default_data; |
| 459 | 459 | } |
| 460 | 460 | else { |
| 461 | 461 | self::$group_user_id = $by_id == $user_id ? $user_id : $by_id; |
| 462 | - self::$group_user = self::read($category . '/' . $chat_id . '/' . self::$group_user_id); |
|
| 462 | + self::$group_user = self::read($category.'/'.$chat_id.'/'.self::$group_user_id); |
|
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | if ($new_user->status === chatMemberStatus::LEFT || $new_user->status === chatMemberStatus::KICKED) { |
@@ -500,9 +500,9 @@ discard block |
||
| 500 | 500 | * @return bool |
| 501 | 501 | * @throws bptException |
| 502 | 502 | */ |
| 503 | - public static function deleteUser (int $user_id = null): bool { |
|
| 503 | + public static function deleteUser(int $user_id = null): bool { |
|
| 504 | 504 | if (empty($user_id)) $user_id = telegram::catchFields(fields::USER_ID); |
| 505 | - if (!file_exists(realpath(self::$folder . '/privates/' . $user_id . '.json'))) { |
|
| 505 | + if (!file_exists(realpath(self::$folder.'/privates/'.$user_id.'.json'))) { |
|
| 506 | 506 | return false; |
| 507 | 507 | } |
| 508 | 508 | unset(self::$ids['privates'][array_search($user_id, self::$ids['privates'])]); |
@@ -510,7 +510,7 @@ discard block |
||
| 510 | 510 | if ($user_id === self::$user_id) { |
| 511 | 511 | self::$user = self::$old_user = null; |
| 512 | 512 | } |
| 513 | - return tools::delete(self::$folder . '/privates/' . $user_id . '.json'); |
|
| 513 | + return tools::delete(self::$folder.'/privates/'.$user_id.'.json'); |
|
| 514 | 514 | } |
| 515 | 515 | |
| 516 | 516 | /** |
@@ -521,18 +521,18 @@ discard block |
||
| 521 | 521 | * @return bool |
| 522 | 522 | * @throws bptException |
| 523 | 523 | */ |
| 524 | - public static function deleteGroup (int $group_id = null): bool { |
|
| 524 | + public static function deleteGroup(int $group_id = null): bool { |
|
| 525 | 525 | if (empty($group_id)) $group_id = telegram::catchFields(fields::CHAT_ID); |
| 526 | - if (!file_exists(realpath(self::$folder . '/groups/' . $group_id . '.json'))) { |
|
| 526 | + if (!file_exists(realpath(self::$folder.'/groups/'.$group_id.'.json'))) { |
|
| 527 | 527 | return false; |
| 528 | 528 | } |
| 529 | 529 | unset(self::$ids['groups'][array_search($group_id, self::$ids['groups'])]); |
| 530 | 530 | sort(self::$ids['groups']); |
| 531 | - tools::delete(self::$folder . '/groups/' . $group_id); |
|
| 531 | + tools::delete(self::$folder.'/groups/'.$group_id); |
|
| 532 | 532 | if ($group_id === self::$group_id) { |
| 533 | 533 | self::$group = self::$old_group = null; |
| 534 | 534 | } |
| 535 | - return tools::delete(self::$folder . '/groups/' . $group_id . '.json'); |
|
| 535 | + return tools::delete(self::$folder.'/groups/'.$group_id.'.json'); |
|
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | /** |
@@ -543,18 +543,18 @@ discard block |
||
| 543 | 543 | * @return bool |
| 544 | 544 | * @throws bptException |
| 545 | 545 | */ |
| 546 | - public static function deleteSuperGroup (int $group_id = null): bool { |
|
| 546 | + public static function deleteSuperGroup(int $group_id = null): bool { |
|
| 547 | 547 | if (empty($group_id)) $group_id = telegram::catchFields(fields::CHAT_ID); |
| 548 | - if (!file_exists(realpath(self::$folder . '/supergroups/' . $group_id . '.json'))) { |
|
| 548 | + if (!file_exists(realpath(self::$folder.'/supergroups/'.$group_id.'.json'))) { |
|
| 549 | 549 | return false; |
| 550 | 550 | } |
| 551 | 551 | unset(self::$ids['supergroups'][array_search($group_id, self::$ids['supergroups'])]); |
| 552 | 552 | sort(self::$ids['supergroups']); |
| 553 | - tools::delete(self::$folder . '/supergroups/' . $group_id); |
|
| 553 | + tools::delete(self::$folder.'/supergroups/'.$group_id); |
|
| 554 | 554 | if ($group_id === self::$supergroup_id) { |
| 555 | 555 | self::$supergroup = self::$old_supergroup = null; |
| 556 | 556 | } |
| 557 | - return tools::delete(self::$folder . '/supergroups/' . $group_id . '.json'); |
|
| 557 | + return tools::delete(self::$folder.'/supergroups/'.$group_id.'.json'); |
|
| 558 | 558 | } |
| 559 | 559 | |
| 560 | 560 | /** |
@@ -565,9 +565,9 @@ discard block |
||
| 565 | 565 | * @return bool |
| 566 | 566 | * @throws bptException |
| 567 | 567 | */ |
| 568 | - public static function deleteChannel (int $channel_id = null): bool { |
|
| 568 | + public static function deleteChannel(int $channel_id = null): bool { |
|
| 569 | 569 | if (empty($channel_id)) $channel_id = telegram::catchFields(fields::CHAT_ID); |
| 570 | - if (!file_exists(realpath(self::$folder . '/channels/' . $channel_id . '.json'))) { |
|
| 570 | + if (!file_exists(realpath(self::$folder.'/channels/'.$channel_id.'.json'))) { |
|
| 571 | 571 | return false; |
| 572 | 572 | } |
| 573 | 573 | unset(self::$ids['channels'][array_search($channel_id, self::$ids['channels'])]); |
@@ -575,7 +575,7 @@ discard block |
||
| 575 | 575 | if ($channel_id === self::$channel_id) { |
| 576 | 576 | self::$channel = self::$old_channel = null; |
| 577 | 577 | } |
| 578 | - return tools::delete(self::$folder . '/channels/' . $channel_id . '.json'); |
|
| 578 | + return tools::delete(self::$folder.'/channels/'.$channel_id.'.json'); |
|
| 579 | 579 | } |
| 580 | 580 | |
| 581 | 581 | /** |
@@ -583,7 +583,7 @@ discard block |
||
| 583 | 583 | * |
| 584 | 584 | * @return int[] |
| 585 | 585 | */ |
| 586 | - public static function getUsers (): array { |
|
| 586 | + public static function getUsers(): array { |
|
| 587 | 587 | return self::$ids['privates'] ?? []; |
| 588 | 588 | } |
| 589 | 589 | |
@@ -592,7 +592,7 @@ discard block |
||
| 592 | 592 | * |
| 593 | 593 | * @return int[] |
| 594 | 594 | */ |
| 595 | - public static function getGroups (): array { |
|
| 595 | + public static function getGroups(): array { |
|
| 596 | 596 | return self::$ids['groups'] ?? []; |
| 597 | 597 | } |
| 598 | 598 | |
@@ -601,7 +601,7 @@ discard block |
||
| 601 | 601 | * |
| 602 | 602 | * @return int[] |
| 603 | 603 | */ |
| 604 | - public static function getSuperGroups (): array { |
|
| 604 | + public static function getSuperGroups(): array { |
|
| 605 | 605 | return self::$ids['supergroups'] ?? []; |
| 606 | 606 | } |
| 607 | 607 | |
@@ -610,7 +610,7 @@ discard block |
||
| 610 | 610 | * |
| 611 | 611 | * @return int[] |
| 612 | 612 | */ |
| 613 | - public static function getChannels (): array { |
|
| 613 | + public static function getChannels(): array { |
|
| 614 | 614 | return self::$ids['channels'] ?? []; |
| 615 | 615 | } |
| 616 | 616 | } |
@@ -10,8 +10,8 @@ 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') { |
|
| 14 | - $T_sec = 0;/* <= رفع خطاي زمان سرور ، با اعداد '+' و '-' بر حسب ثانيه */ |
|
| 13 | + public static function jdate($format, $timestamp = '', $none = '', $time_zone = 'Asia/Tehran', $tr_num = 'fa') { |
|
| 14 | + $T_sec = 0; /* <= رفع خطاي زمان سرور ، با اعداد '+' و '-' بر حسب ثانيه */ |
|
| 15 | 15 | if ($time_zone != 'local') date_default_timezone_set(($time_zone === '') ? 'Asia/Tehran' : $time_zone); |
| 16 | 16 | $ts = $T_sec + (($timestamp === '') ? time() : self::tr_num($timestamp)); |
| 17 | 17 | $date = explode('_', date('H_i_j_n_O_P_s_w_Y', $ts)); |
@@ -55,13 +55,13 @@ discard block |
||
| 55 | 55 | $out .= (int) ($j_m / 3.1) + 1; |
| 56 | 56 | break; |
| 57 | 57 | case 'c': |
| 58 | - $out .= $j_y . '/' . $j_m . '/' . $j_d . ' ،' . $date[0] . ':' . $date[1] . ':' . $date[6] . ' ' . $date[5]; |
|
| 58 | + $out .= $j_y.'/'.$j_m.'/'.$j_d.' ،'.$date[0].':'.$date[1].':'.$date[6].' '.$date[5]; |
|
| 59 | 59 | break; |
| 60 | 60 | case 'C': |
| 61 | 61 | $out .= (int) (($j_y + 99) / 100); |
| 62 | 62 | break; |
| 63 | 63 | case 'd': |
| 64 | - $out .= ($j_d < 10) ? '0' . $j_d : $j_d; |
|
| 64 | + $out .= ($j_d < 10) ? '0'.$j_d : $j_d; |
|
| 65 | 65 | break; |
| 66 | 66 | case 'D': |
| 67 | 67 | $out .= self::jdate_words(['kh' => $date[7]], ' '); |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | $out .= $kab; |
| 98 | 98 | break; |
| 99 | 99 | case 'm': |
| 100 | - $out .= ($j_m > 9) ? $j_m : '0' . $j_m; |
|
| 100 | + $out .= ($j_m > 9) ? $j_m : '0'.$j_m; |
|
| 101 | 101 | break; |
| 102 | 102 | case 'M': |
| 103 | 103 | $out .= self::jdate_words(['km' => $j_m], ' '); |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | break; |
| 131 | 131 | case 'r': |
| 132 | 132 | $key = self::jdate_words(['rh' => $date[7], 'mm' => $j_m]); |
| 133 | - $out .= $date[0] . ':' . $date[1] . ':' . $date[6] . ' ' . $date[4] . ' ' . $key['rh'] . '، ' . $j_d . ' ' . $key['mm'] . ' ' . $j_y; |
|
| 133 | + $out .= $date[0].':'.$date[1].':'.$date[6].' '.$date[4].' '.$key['rh'].'، '.$j_d.' '.$key['mm'].' '.$j_y; |
|
| 134 | 134 | break; |
| 135 | 135 | case 's': |
| 136 | 136 | $out .= $date[6]; |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | } |
| 166 | 166 | $aks = $avs + $kab; |
| 167 | 167 | if ($aks == 7) $aks = 0; |
| 168 | - $out .= (($kab + 363 - $doy) < $aks and $aks < 3) ? '01' : (($num < 10) ? '0' . $num : $num); |
|
| 168 | + $out .= (($kab + 363 - $doy) < $aks and $aks < 3) ? '01' : (($num < 10) ? '0'.$num : $num); |
|
| 169 | 169 | break; |
| 170 | 170 | case 'y': |
| 171 | 171 | $out .= substr($j_y, 2, 2); |
@@ -182,8 +182,8 @@ discard block |
||
| 182 | 182 | } |
| 183 | 183 | return ($tr_num != 'en') ? self::tr_num($out, 'fa', '.') : $out; |
| 184 | 184 | } |
| 185 | - public static function jstrftime ($format, $timestamp = '', $none = '', $time_zone = 'Asia/Tehran', $tr_num = 'fa') { |
|
| 186 | - $T_sec = 0;/* <= رفع خطاي زمان سرور ، با اعداد '+' و '-' بر حسب ثانيه */ |
|
| 185 | + public static function jstrftime($format, $timestamp = '', $none = '', $time_zone = 'Asia/Tehran', $tr_num = 'fa') { |
|
| 186 | + $T_sec = 0; /* <= رفع خطاي زمان سرور ، با اعداد '+' و '-' بر حسب ثانيه */ |
|
| 187 | 187 | if ($time_zone != 'local') date_default_timezone_set(($time_zone === '') ? 'Asia/Tehran' : $time_zone); |
| 188 | 188 | $ts = $T_sec + (($timestamp === '') ? time() : self::tr_num($timestamp)); |
| 189 | 189 | $date = explode('_', date('h_H_i_j_n_s_w_Y', $ts)); |
@@ -211,10 +211,10 @@ discard block |
||
| 211 | 211 | $out .= self::jdate_words(['rh' => $date[6]], ' '); |
| 212 | 212 | break; |
| 213 | 213 | case 'd': |
| 214 | - $out .= ($j_d < 10) ? '0' . $j_d : $j_d; |
|
| 214 | + $out .= ($j_d < 10) ? '0'.$j_d : $j_d; |
|
| 215 | 215 | break; |
| 216 | 216 | case 'e': |
| 217 | - $out .= ($j_d < 10) ? ' ' . $j_d : $j_d; |
|
| 217 | + $out .= ($j_d < 10) ? ' '.$j_d : $j_d; |
|
| 218 | 218 | break; |
| 219 | 219 | case 'j': |
| 220 | 220 | $out .= str_pad($doy + 1, 3, 0, STR_PAD_LEFT); |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | if ($avs < 0) $avs += 7; |
| 232 | 232 | $num = (int) (($doy + $avs) / 7) + 1; |
| 233 | 233 | if ($avs > 3 or $avs == 1) $num--; |
| 234 | - $out .= ($num < 10) ? '0' . $num : $num; |
|
| 234 | + $out .= ($num < 10) ? '0'.$num : $num; |
|
| 235 | 235 | break; |
| 236 | 236 | case 'V': |
| 237 | 237 | $avs = (($date[6] == 6) ? 0 : $date[6] + 1) - ($doy % 7); |
@@ -245,14 +245,14 @@ discard block |
||
| 245 | 245 | } |
| 246 | 246 | $aks = $avs + $kab; |
| 247 | 247 | if ($aks == 7) $aks = 0; |
| 248 | - $out .= (($kab + 363 - $doy) < $aks and $aks < 3) ? '01' : (($num < 10) ? '0' . $num : $num); |
|
| 248 | + $out .= (($kab + 363 - $doy) < $aks and $aks < 3) ? '01' : (($num < 10) ? '0'.$num : $num); |
|
| 249 | 249 | break; |
| 250 | 250 | case 'W': |
| 251 | 251 | $avs = (($date[6] == 6) ? 0 : $date[6] + 1) - ($doy % 7); |
| 252 | 252 | if ($avs < 0) $avs += 7; |
| 253 | 253 | $num = (int) (($doy + $avs) / 7) + 1; |
| 254 | 254 | if ($avs > 3) $num--; |
| 255 | - $out .= ($num < 10) ? '0' . $num : $num; |
|
| 255 | + $out .= ($num < 10) ? '0'.$num : $num; |
|
| 256 | 256 | break; |
| 257 | 257 | /* Month */ |
| 258 | 258 | case 'b': |
@@ -263,12 +263,12 @@ discard block |
||
| 263 | 263 | $out .= self::jdate_words(['mm' => $j_m], ' '); |
| 264 | 264 | break; |
| 265 | 265 | case 'm': |
| 266 | - $out .= ($j_m > 9) ? $j_m : '0' . $j_m; |
|
| 266 | + $out .= ($j_m > 9) ? $j_m : '0'.$j_m; |
|
| 267 | 267 | break; |
| 268 | 268 | /* Year */ |
| 269 | 269 | case 'C': |
| 270 | 270 | $tmp = (int) ($j_y / 100); |
| 271 | - $out .= ($tmp > 9) ? $tmp : '0' . $tmp; |
|
| 271 | + $out .= ($tmp > 9) ? $tmp : '0'.$tmp; |
|
| 272 | 272 | break; |
| 273 | 273 | case 'g': |
| 274 | 274 | $jdw = ($date[6] == 6) ? 0 : $date[6] + 1; |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | $out .= $date[0]; |
| 295 | 295 | break; |
| 296 | 296 | case 'l': |
| 297 | - $out .= ($date[0] > 9) ? $date[0] : ' ' . (int) $date[0]; |
|
| 297 | + $out .= ($date[0] > 9) ? $date[0] : ' '.(int) $date[0]; |
|
| 298 | 298 | break; |
| 299 | 299 | case 'M': |
| 300 | 300 | $out .= $date[2]; |
@@ -306,19 +306,19 @@ discard block |
||
| 306 | 306 | $out .= ($date[1] < 12) ? 'ق.ظ' : 'ب.ظ'; |
| 307 | 307 | break; |
| 308 | 308 | case 'r': |
| 309 | - $out .= $date[0] . ':' . $date[2] . ':' . $date[5] . ' ' . (($date[1] < 12) ? 'قبل از ظهر' : 'بعد از ظهر'); |
|
| 309 | + $out .= $date[0].':'.$date[2].':'.$date[5].' '.(($date[1] < 12) ? 'قبل از ظهر' : 'بعد از ظهر'); |
|
| 310 | 310 | break; |
| 311 | 311 | case 'R': |
| 312 | - $out .= $date[1] . ':' . $date[2]; |
|
| 312 | + $out .= $date[1].':'.$date[2]; |
|
| 313 | 313 | break; |
| 314 | 314 | case 'S': |
| 315 | 315 | $out .= $date[5]; |
| 316 | 316 | break; |
| 317 | 317 | case 'T': |
| 318 | - $out .= $date[1] . ':' . $date[2] . ':' . $date[5]; |
|
| 318 | + $out .= $date[1].':'.$date[2].':'.$date[5]; |
|
| 319 | 319 | break; |
| 320 | 320 | case 'X': |
| 321 | - $out .= $date[0] . ':' . $date[2] . ':' . $date[5]; |
|
| 321 | + $out .= $date[0].':'.$date[2].':'.$date[5]; |
|
| 322 | 322 | break; |
| 323 | 323 | case 'z': |
| 324 | 324 | $out .= date('O', $ts); |
@@ -329,19 +329,19 @@ discard block |
||
| 329 | 329 | /* Time and Date Stamps */ |
| 330 | 330 | case 'c': |
| 331 | 331 | $key = self::jdate_words(['rh' => $date[6], 'mm' => $j_m]); |
| 332 | - $out .= $date[1] . ':' . $date[2] . ':' . $date[5] . ' ' . date('P', $ts) . ' ' . $key['rh'] . '، ' . $j_d . ' ' . $key['mm'] . ' ' . $j_y; |
|
| 332 | + $out .= $date[1].':'.$date[2].':'.$date[5].' '.date('P', $ts).' '.$key['rh'].'، '.$j_d.' '.$key['mm'].' '.$j_y; |
|
| 333 | 333 | break; |
| 334 | 334 | case 'D': |
| 335 | - $out .= substr($j_y, 2, 2) . '/' . (($j_m > 9) ? $j_m : '0' . $j_m) . '/' . (($j_d < 10) ? '0' . $j_d : $j_d); |
|
| 335 | + $out .= substr($j_y, 2, 2).'/'.(($j_m > 9) ? $j_m : '0'.$j_m).'/'.(($j_d < 10) ? '0'.$j_d : $j_d); |
|
| 336 | 336 | break; |
| 337 | 337 | case 'F': |
| 338 | - $out .= $j_y . '-' . (($j_m > 9) ? $j_m : '0' . $j_m) . '-' . (($j_d < 10) ? '0' . $j_d : $j_d); |
|
| 338 | + $out .= $j_y.'-'.(($j_m > 9) ? $j_m : '0'.$j_m).'-'.(($j_d < 10) ? '0'.$j_d : $j_d); |
|
| 339 | 339 | break; |
| 340 | 340 | case 's': |
| 341 | 341 | $out .= $ts; |
| 342 | 342 | break; |
| 343 | 343 | case 'x': |
| 344 | - $out .= substr($j_y, 2, 2) . '/' . (($j_m > 9) ? $j_m : '0' . $j_m) . '/' . (($j_d < 10) ? '0' . $j_d : $j_d); |
|
| 344 | + $out .= substr($j_y, 2, 2).'/'.(($j_m > 9) ? $j_m : '0'.$j_m).'/'.(($j_d < 10) ? '0'.$j_d : $j_d); |
|
| 345 | 345 | break; |
| 346 | 346 | /* Miscellaneous */ |
| 347 | 347 | case 'n': |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | } |
| 360 | 360 | return ($tr_num != 'en') ? self::tr_num($out, 'fa', '.') : $out; |
| 361 | 361 | } |
| 362 | - public static function jmktime ($h = '', $m = '', $s = '', $jm = '', $jd = '', $jy = '', $none = '', $timezone = 'Asia/Tehran') { |
|
| 362 | + public static function jmktime($h = '', $m = '', $s = '', $jm = '', $jd = '', $jy = '', $none = '', $timezone = 'Asia/Tehran') { |
|
| 363 | 363 | if ($timezone != 'local') date_default_timezone_set($timezone); |
| 364 | 364 | if ($h === '') { |
| 365 | 365 | return time(); |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | $jm, |
| 373 | 373 | $jd, |
| 374 | 374 | $jy |
| 375 | - ] = explode('_', self::tr_num($h . '_' . $m . '_' . $s . '_' . $jm . '_' . $jd . '_' . $jy)); |
|
| 375 | + ] = explode('_', self::tr_num($h.'_'.$m.'_'.$s.'_'.$jm.'_'.$jd.'_'.$jy)); |
|
| 376 | 376 | if ($m === '') { |
| 377 | 377 | return mktime($h); |
| 378 | 378 | } |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | } |
| 406 | 406 | } |
| 407 | 407 | } |
| 408 | - public static function jgetdate ($timestamp = '', $none = '', $timezone = 'Asia/Tehran', $tn = 'en') { |
|
| 408 | + public static function jgetdate($timestamp = '', $none = '', $timezone = 'Asia/Tehran', $tn = 'en') { |
|
| 409 | 409 | $ts = ($timestamp === '') ? time() : self::tr_num($timestamp); |
| 410 | 410 | $jdate = explode('_', self::jdate('F_G_i_j_l_n_s_w_Y_z', $ts, '', $timezone, $tn)); |
| 411 | 411 | return [ |
@@ -422,17 +422,17 @@ discard block |
||
| 422 | 422 | 0 => self::tr_num($ts, $tn) |
| 423 | 423 | ]; |
| 424 | 424 | } |
| 425 | - public static function jcheckdate ($jm, $jd, $jy) { |
|
| 426 | - [$jm, $jd, $jy] = explode('_', self::tr_num($jm . '_' . $jd . '_' . $jy)); |
|
| 425 | + public static function jcheckdate($jm, $jd, $jy) { |
|
| 426 | + [$jm, $jd, $jy] = explode('_', self::tr_num($jm.'_'.$jd.'_'.$jy)); |
|
| 427 | 427 | $l_d = ($jm == 12 and ((($jy + 12) % 33) % 4) != 1) ? 29 : (31 - (int) ($jm / 6.5)); |
| 428 | 428 | return ($jm > 12 or $jd > $l_d or $jm < 1 or $jd < 1 or $jy < 1) ? false : true; |
| 429 | 429 | } |
| 430 | - public static function tr_num ($str, $mod = 'en', $mf = '٫') { |
|
| 430 | + public static function tr_num($str, $mod = 'en', $mf = '٫') { |
|
| 431 | 431 | $num_a = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.']; |
| 432 | 432 | $key_a = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹', $mf]; |
| 433 | 433 | return ($mod == 'fa') ? str_replace($num_a, $key_a, $str) : str_replace($key_a, $num_a, $str); |
| 434 | 434 | } |
| 435 | - public static function jdate_words ($array, $mod = '') { |
|
| 435 | + public static function jdate_words($array, $mod = '') { |
|
| 436 | 436 | foreach ($array as $type => $num) { |
| 437 | 437 | $num = (int) self::tr_num($num); |
| 438 | 438 | switch ($type) { |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | 'هزار و چهارصد', |
| 461 | 461 | 'هزار و نهصد', |
| 462 | 462 | 'دوهزار' |
| 463 | - ], substr($num, 0, 2)) . ((substr($num, 2, 2) == '00') ? '' : ' و ') : '') . $h3 . $p34 . $h34 . $h4; |
|
| 463 | + ], substr($num, 0, 2)).((substr($num, 2, 2) == '00') ? '' : ' و ') : '').$h3.$p34.$h34.$h4; |
|
| 464 | 464 | break; |
| 465 | 465 | case 'mm': |
| 466 | 466 | $key = [ |
@@ -545,8 +545,8 @@ discard block |
||
| 545 | 545 | } |
| 546 | 546 | return ($mod === '') ? $array : implode($mod, $array); |
| 547 | 547 | } |
| 548 | - public static function gregorian_to_jalali ($gy, $gm, $gd, $mod = '') { |
|
| 549 | - [$gy, $gm, $gd] = explode('_', self::tr_num($gy . '_' . $gm . '_' . $gd));/* <= Extra :اين سطر ، جزء تابع اصلي نيست */ |
|
| 548 | + public static function gregorian_to_jalali($gy, $gm, $gd, $mod = '') { |
|
| 549 | + [$gy, $gm, $gd] = explode('_', self::tr_num($gy.'_'.$gm.'_'.$gd)); /* <= Extra :اين سطر ، جزء تابع اصلي نيست */ |
|
| 550 | 550 | $g_d_m = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334]; |
| 551 | 551 | $gy2 = ($gm > 2) ? ($gy + 1) : $gy; |
| 552 | 552 | $days = 355666 + (365 * $gy) + ((int) (($gy2 + 3) / 4)) - ((int) (($gy2 + 99) / 100)) + ((int) (($gy2 + 399) / 400)) + $gd + $g_d_m[$gm - 1]; |
@@ -566,10 +566,10 @@ discard block |
||
| 566 | 566 | $jm = 7 + (int) (($days - 186) / 30); |
| 567 | 567 | $jd = 1 + (($days - 186) % 30); |
| 568 | 568 | } |
| 569 | - return ($mod == '') ? [$jy, $jm, $jd] : $jy . $mod . $jm . $mod . $jd; |
|
| 569 | + return ($mod == '') ? [$jy, $jm, $jd] : $jy.$mod.$jm.$mod.$jd; |
|
| 570 | 570 | } |
| 571 | - public static function jalali_to_gregorian ($jy, $jm, $jd, $mod = '') { |
|
| 572 | - [$jy, $jm, $jd] = explode('_', self::tr_num($jy . '_' . $jm . '_' . $jd));/* <= Extra :اين سطر ، جزء تابع اصلي نيست */ |
|
| 571 | + public static function jalali_to_gregorian($jy, $jm, $jd, $mod = '') { |
|
| 572 | + [$jy, $jm, $jd] = explode('_', self::tr_num($jy.'_'.$jm.'_'.$jd)); /* <= Extra :اين سطر ، جزء تابع اصلي نيست */ |
|
| 573 | 573 | $jy += 1595; |
| 574 | 574 | $days = -355668 + (365 * $jy) + (((int) ($jy / 33)) * 8) + ((int) ((($jy % 33) + 3) / 4)) + $jd + (($jm < 7) ? ($jm - 1) * 31 : (($jm - 7) * 30) + 186); |
| 575 | 575 | $gy = 400 * ((int) ($days / 146097)); |
@@ -602,6 +602,6 @@ discard block |
||
| 602 | 602 | 31 |
| 603 | 603 | ]; |
| 604 | 604 | for ($gm = 0; $gm < 13 and $gd > $sal_a[$gm]; $gm++) $gd -= $sal_a[$gm]; |
| 605 | - return ($mod == '') ? [$gy, $gm, $gd] : $gy . $mod . $gm . $mod . $gd; |
|
| 605 | + return ($mod == '') ? [$gy, $gm, $gd] : $gy.$mod.$gm.$mod.$gd; |
|
| 606 | 606 | } |
| 607 | 607 | } |
| 608 | 608 | \ No newline at end of file |
@@ -12,7 +12,9 @@ discard block |
||
| 12 | 12 | class jdf { |
| 13 | 13 | public static function jdate ($format, $timestamp = '', $none = '', $time_zone = 'Asia/Tehran', $tr_num = 'fa') { |
| 14 | 14 | $T_sec = 0;/* <= رفع خطاي زمان سرور ، با اعداد '+' و '-' بر حسب ثانيه */ |
| 15 | - if ($time_zone != 'local') date_default_timezone_set(($time_zone === '') ? 'Asia/Tehran' : $time_zone); |
|
| 15 | + if ($time_zone != 'local') { |
|
| 16 | + date_default_timezone_set(($time_zone === '') ? 'Asia/Tehran' : $time_zone); |
|
| 17 | + } |
|
| 16 | 18 | $ts = $T_sec + (($timestamp === '') ? time() : self::tr_num($timestamp)); |
| 17 | 19 | $date = explode('_', date('H_i_j_n_O_P_s_w_Y', $ts)); |
| 18 | 20 | [$j_y, $j_m, $j_d] = self::gregorian_to_jalali($date[8], $date[3], $date[2]); |
@@ -155,16 +157,19 @@ discard block |
||
| 155 | 157 | break; |
| 156 | 158 | case 'W': |
| 157 | 159 | $avs = (($date[7] == 6) ? 0 : $date[7] + 1) - ($doy % 7); |
| 158 | - if ($avs < 0) $avs += 7; |
|
| 160 | + if ($avs < 0) { |
|
| 161 | + $avs += 7; |
|
| 162 | + } |
|
| 159 | 163 | $num = (int) (($doy + $avs) / 7); |
| 160 | 164 | if ($avs < 4) { |
| 161 | 165 | $num++; |
| 162 | - } |
|
| 163 | - elseif ($num < 1) { |
|
| 166 | + } elseif ($num < 1) { |
|
| 164 | 167 | $num = ($avs == 4 or $avs == ((((($j_y % 33) % 4) - 2) == ((int) (($j_y % 33) * 0.05))) ? 5 : 4)) ? 53 : 52; |
| 165 | 168 | } |
| 166 | 169 | $aks = $avs + $kab; |
| 167 | - if ($aks == 7) $aks = 0; |
|
| 170 | + if ($aks == 7) { |
|
| 171 | + $aks = 0; |
|
| 172 | + } |
|
| 168 | 173 | $out .= (($kab + 363 - $doy) < $aks and $aks < 3) ? '01' : (($num < 10) ? '0' . $num : $num); |
| 169 | 174 | break; |
| 170 | 175 | case 'y': |
@@ -184,7 +189,9 @@ discard block |
||
| 184 | 189 | } |
| 185 | 190 | public static function jstrftime ($format, $timestamp = '', $none = '', $time_zone = 'Asia/Tehran', $tr_num = 'fa') { |
| 186 | 191 | $T_sec = 0;/* <= رفع خطاي زمان سرور ، با اعداد '+' و '-' بر حسب ثانيه */ |
| 187 | - if ($time_zone != 'local') date_default_timezone_set(($time_zone === '') ? 'Asia/Tehran' : $time_zone); |
|
| 192 | + if ($time_zone != 'local') { |
|
| 193 | + date_default_timezone_set(($time_zone === '') ? 'Asia/Tehran' : $time_zone); |
|
| 194 | + } |
|
| 188 | 195 | $ts = $T_sec + (($timestamp === '') ? time() : self::tr_num($timestamp)); |
| 189 | 196 | $date = explode('_', date('h_H_i_j_n_s_w_Y', $ts)); |
| 190 | 197 | [$j_y, $j_m, $j_d] = self::gregorian_to_jalali($date[7], $date[4], $date[3]); |
@@ -196,8 +203,7 @@ discard block |
||
| 196 | 203 | $sub = substr($format, $i, 1); |
| 197 | 204 | if ($sub == '%') { |
| 198 | 205 | $sub = substr($format, ++$i, 1); |
| 199 | - } |
|
| 200 | - else { |
|
| 206 | + } else { |
|
| 201 | 207 | $out .= $sub; |
| 202 | 208 | continue; |
| 203 | 209 | } |
@@ -228,30 +234,41 @@ discard block |
||
| 228 | 234 | /* Week */ |
| 229 | 235 | case 'U': |
| 230 | 236 | $avs = (($date[6] < 5) ? $date[6] + 2 : $date[6] - 5) - ($doy % 7); |
| 231 | - if ($avs < 0) $avs += 7; |
|
| 237 | + if ($avs < 0) { |
|
| 238 | + $avs += 7; |
|
| 239 | + } |
|
| 232 | 240 | $num = (int) (($doy + $avs) / 7) + 1; |
| 233 | - if ($avs > 3 or $avs == 1) $num--; |
|
| 241 | + if ($avs > 3 or $avs == 1) { |
|
| 242 | + $num--; |
|
| 243 | + } |
|
| 234 | 244 | $out .= ($num < 10) ? '0' . $num : $num; |
| 235 | 245 | break; |
| 236 | 246 | case 'V': |
| 237 | 247 | $avs = (($date[6] == 6) ? 0 : $date[6] + 1) - ($doy % 7); |
| 238 | - if ($avs < 0) $avs += 7; |
|
| 248 | + if ($avs < 0) { |
|
| 249 | + $avs += 7; |
|
| 250 | + } |
|
| 239 | 251 | $num = (int) (($doy + $avs) / 7); |
| 240 | 252 | if ($avs < 4) { |
| 241 | 253 | $num++; |
| 242 | - } |
|
| 243 | - elseif ($num < 1) { |
|
| 254 | + } elseif ($num < 1) { |
|
| 244 | 255 | $num = ($avs == 4 or $avs == ((((($j_y % 33) % 4) - 2) == ((int) (($j_y % 33) * 0.05))) ? 5 : 4)) ? 53 : 52; |
| 245 | 256 | } |
| 246 | 257 | $aks = $avs + $kab; |
| 247 | - if ($aks == 7) $aks = 0; |
|
| 258 | + if ($aks == 7) { |
|
| 259 | + $aks = 0; |
|
| 260 | + } |
|
| 248 | 261 | $out .= (($kab + 363 - $doy) < $aks and $aks < 3) ? '01' : (($num < 10) ? '0' . $num : $num); |
| 249 | 262 | break; |
| 250 | 263 | case 'W': |
| 251 | 264 | $avs = (($date[6] == 6) ? 0 : $date[6] + 1) - ($doy % 7); |
| 252 | - if ($avs < 0) $avs += 7; |
|
| 265 | + if ($avs < 0) { |
|
| 266 | + $avs += 7; |
|
| 267 | + } |
|
| 253 | 268 | $num = (int) (($doy + $avs) / 7) + 1; |
| 254 | - if ($avs > 3) $num--; |
|
| 269 | + if ($avs > 3) { |
|
| 270 | + $num--; |
|
| 271 | + } |
|
| 255 | 272 | $out .= ($num < 10) ? '0' . $num : $num; |
| 256 | 273 | break; |
| 257 | 274 | /* Month */ |
@@ -360,11 +377,12 @@ discard block |
||
| 360 | 377 | return ($tr_num != 'en') ? self::tr_num($out, 'fa', '.') : $out; |
| 361 | 378 | } |
| 362 | 379 | public static function jmktime ($h = '', $m = '', $s = '', $jm = '', $jd = '', $jy = '', $none = '', $timezone = 'Asia/Tehran') { |
| 363 | - if ($timezone != 'local') date_default_timezone_set($timezone); |
|
| 380 | + if ($timezone != 'local') { |
|
| 381 | + date_default_timezone_set($timezone); |
|
| 382 | + } |
|
| 364 | 383 | if ($h === '') { |
| 365 | 384 | return time(); |
| 366 | - } |
|
| 367 | - else { |
|
| 385 | + } else { |
|
| 368 | 386 | [ |
| 369 | 387 | $h, |
| 370 | 388 | $m, |
@@ -375,27 +393,22 @@ discard block |
||
| 375 | 393 | ] = explode('_', self::tr_num($h . '_' . $m . '_' . $s . '_' . $jm . '_' . $jd . '_' . $jy)); |
| 376 | 394 | if ($m === '') { |
| 377 | 395 | return mktime($h); |
| 378 | - } |
|
| 379 | - else { |
|
| 396 | + } else { |
|
| 380 | 397 | if ($s === '') { |
| 381 | 398 | return mktime($h, $m); |
| 382 | - } |
|
| 383 | - else { |
|
| 399 | + } else { |
|
| 384 | 400 | if ($jm === '') { |
| 385 | 401 | return mktime($h, $m, $s); |
| 386 | - } |
|
| 387 | - else { |
|
| 402 | + } else { |
|
| 388 | 403 | $jdate = explode('_', self::jdate('Y_j', '', '', $timezone, 'en')); |
| 389 | 404 | if ($jd === '') { |
| 390 | 405 | [$gy, $gm, $gd] = self::jalali_to_gregorian($jdate[0], $jm, $jdate[1]); |
| 391 | 406 | return mktime($h, $m, $s, $gm); |
| 392 | - } |
|
| 393 | - else { |
|
| 407 | + } else { |
|
| 394 | 408 | if ($jy === '') { |
| 395 | 409 | [$gy, $gm, $gd] = self::jalali_to_gregorian($jdate[0], $jm, $jd); |
| 396 | 410 | return mktime($h, $m, $s, $gm, $gd); |
| 397 | - } |
|
| 398 | - else { |
|
| 411 | + } else { |
|
| 399 | 412 | [$gy, $gm, $gd] = self::jalali_to_gregorian($jy, $jm, $jd); |
| 400 | 413 | return mktime($h, $m, $s, $gm, $gd, $gy); |
| 401 | 414 | } |
@@ -445,8 +458,7 @@ discard block |
||
| 445 | 458 | $p34 = ''; |
| 446 | 459 | $k34 = ['ده', 'یازده', 'دوازده', 'سیزده', 'چهارده', 'پانزده', 'شانزده', 'هفده', 'هجده', 'نوزده']; |
| 447 | 460 | $h34 = $k34[substr($num, 2 - $sl, 2) - 10]; |
| 448 | - } |
|
| 449 | - else { |
|
| 461 | + } else { |
|
| 450 | 462 | $xy4 = substr($num, 3 - $sl, 1); |
| 451 | 463 | $p34 = ($xy3 == 0 or $xy4 == 0) ? '' : ' و '; |
| 452 | 464 | $k3 = ['', '', 'بیست', 'سی', 'چهل', 'پنجاه', 'شصت', 'هفتاد', 'هشتاد', 'نود']; |
@@ -561,8 +573,7 @@ discard block |
||
| 561 | 573 | if ($days < 186) { |
| 562 | 574 | $jm = 1 + (int) ($days / 31); |
| 563 | 575 | $jd = 1 + ($days % 31); |
| 564 | - } |
|
| 565 | - else { |
|
| 576 | + } else { |
|
| 566 | 577 | $jm = 7 + (int) (($days - 186) / 30); |
| 567 | 578 | $jd = 1 + (($days - 186) % 30); |
| 568 | 579 | } |
@@ -577,7 +588,9 @@ discard block |
||
| 577 | 588 | if ($days > 36524) { |
| 578 | 589 | $gy += 100 * ((int) (--$days / 36524)); |
| 579 | 590 | $days %= 36524; |
| 580 | - if ($days >= 365) $days++; |
|
| 591 | + if ($days >= 365) { |
|
| 592 | + $days++; |
|
| 593 | + } |
|
| 581 | 594 | } |
| 582 | 595 | $gy += 4 * ((int) ($days / 1461)); |
| 583 | 596 | $days %= 1461; |
@@ -601,7 +614,9 @@ discard block |
||
| 601 | 614 | 30, |
| 602 | 615 | 31 |
| 603 | 616 | ]; |
| 604 | - for ($gm = 0; $gm < 13 and $gd > $sal_a[$gm]; $gm++) $gd -= $sal_a[$gm]; |
|
| 617 | + for ($gm = 0; $gm < 13 and $gd > $sal_a[$gm]; $gm++) { |
|
| 618 | + $gd -= $sal_a[$gm]; |
|
| 619 | + } |
|
| 605 | 620 | return ($mod == '') ? [$gy, $gm, $gd] : $gy . $mod . $gm . $mod . $gd; |
| 606 | 621 | } |
| 607 | 622 | } |
| 608 | 623 | \ No newline at end of file |
@@ -64,13 +64,13 @@ discard block |
||
| 64 | 64 | public int $message_id; |
| 65 | 65 | |
| 66 | 66 | /** Optional. Unique identifier of a message thread to which the message belongs; for supergroups only */ |
| 67 | - public null|int $message_thread_id = null; |
|
| 67 | + public null | int $message_thread_id = null; |
|
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | 70 | * Optional. Sender of the message; empty for messages sent to channels. For backward compatibility, the field |
| 71 | 71 | * contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat. |
| 72 | 72 | */ |
| 73 | - public null|user $from = null; |
|
| 73 | + public null | user $from = null; |
|
| 74 | 74 | |
| 75 | 75 | /** |
| 76 | 76 | * Optional. Sender of the message, sent on behalf of a chat. For example, the channel itself for channel posts, |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * automatically forwarded to the discussion group. For backward compatibility, the field from contains a fake |
| 79 | 79 | * sender user in non-channel chats, if the message was sent on behalf of a chat. |
| 80 | 80 | */ |
| 81 | - public null|chat $sender_chat = null; |
|
| 81 | + public null | chat $sender_chat = null; |
|
| 82 | 82 | |
| 83 | 83 | /** Date the message was sent in Unix time */ |
| 84 | 84 | public int $date; |
@@ -87,188 +87,188 @@ discard block |
||
| 87 | 87 | public chat $chat; |
| 88 | 88 | |
| 89 | 89 | /** Optional. For forwarded messages, sender of the original message */ |
| 90 | - public null|user $forward_from = null; |
|
| 90 | + public null | user $forward_from = null; |
|
| 91 | 91 | |
| 92 | 92 | /** |
| 93 | 93 | * Optional. For messages forwarded from channels or from anonymous administrators, information about the |
| 94 | 94 | * original sender chat |
| 95 | 95 | */ |
| 96 | - public null|chat $forward_from_chat = null; |
|
| 96 | + public null | chat $forward_from_chat = null; |
|
| 97 | 97 | |
| 98 | 98 | /** Optional. For messages forwarded from channels, identifier of the original message in the channel */ |
| 99 | - public null|int $forward_from_message_id = null; |
|
| 99 | + public null | int $forward_from_message_id = null; |
|
| 100 | 100 | |
| 101 | 101 | /** |
| 102 | 102 | * Optional. For forwarded messages that were originally sent in channels or by an anonymous chat administrator, |
| 103 | 103 | * signature of the message sender if present |
| 104 | 104 | */ |
| 105 | - public null|string $forward_signature = null; |
|
| 105 | + public null | string $forward_signature = null; |
|
| 106 | 106 | |
| 107 | 107 | /** |
| 108 | 108 | * Optional. Sender's name for messages forwarded from users who disallow adding a link to their account in |
| 109 | 109 | * forwarded messages |
| 110 | 110 | */ |
| 111 | - public null|string $forward_sender_name = null; |
|
| 111 | + public null | string $forward_sender_name = null; |
|
| 112 | 112 | |
| 113 | 113 | /** Optional. For forwarded messages, date the original message was sent in Unix time */ |
| 114 | - public null|int $forward_date = null; |
|
| 114 | + public null | int $forward_date = null; |
|
| 115 | 115 | |
| 116 | 116 | /** Optional. True, if the message is sent to a forum topic */ |
| 117 | - public null|bool $is_topic_message = null; |
|
| 117 | + public null | bool $is_topic_message = null; |
|
| 118 | 118 | |
| 119 | 119 | /** |
| 120 | 120 | * Optional. True, if the message is a channel post that was automatically forwarded to the connected discussion |
| 121 | 121 | * group |
| 122 | 122 | */ |
| 123 | - public null|bool $is_automatic_forward = null; |
|
| 123 | + public null | bool $is_automatic_forward = null; |
|
| 124 | 124 | |
| 125 | 125 | /** |
| 126 | 126 | * Optional. For replies, the original message. Note that the Message object in this field will not contain |
| 127 | 127 | * further reply_to_message fields even if it itself is a reply. |
| 128 | 128 | */ |
| 129 | - public null|message $reply_to_message = null; |
|
| 129 | + public null | message $reply_to_message = null; |
|
| 130 | 130 | |
| 131 | 131 | /** Optional. Bot through which the message was sent */ |
| 132 | - public null|user $via_bot = null; |
|
| 132 | + public null | user $via_bot = null; |
|
| 133 | 133 | |
| 134 | 134 | /** Optional. Date the message was last edited in Unix time */ |
| 135 | - public null|int $edit_date = null; |
|
| 135 | + public null | int $edit_date = null; |
|
| 136 | 136 | |
| 137 | 137 | /** Optional. True, if the message can't be forwarded */ |
| 138 | - public null|bool $has_protected_content = null; |
|
| 138 | + public null | bool $has_protected_content = null; |
|
| 139 | 139 | |
| 140 | 140 | /** Optional. The unique identifier of a media message group this message belongs to */ |
| 141 | - public null|string $media_group_id = null; |
|
| 141 | + public null | string $media_group_id = null; |
|
| 142 | 142 | |
| 143 | 143 | /** |
| 144 | 144 | * Optional. Signature of the post author for messages in channels, or the custom title of an anonymous group |
| 145 | 145 | * administrator |
| 146 | 146 | */ |
| 147 | - public null|string $author_signature = null; |
|
| 147 | + public null | string $author_signature = null; |
|
| 148 | 148 | |
| 149 | 149 | /** Optional. For text messages, the actual UTF-8 text of the message */ |
| 150 | - public null|string $text = null; |
|
| 150 | + public null | string $text = null; |
|
| 151 | 151 | |
| 152 | 152 | /** Optional. If user message was a command , this parameter will be the command */ |
| 153 | - public string|null $command = null; |
|
| 153 | + public string | null $command = null; |
|
| 154 | 154 | |
| 155 | 155 | /** Optional. If user message was a command , this parameter will be the command username(if exist) */ |
| 156 | - public string|null $command_username = null; |
|
| 156 | + public string | null $command_username = null; |
|
| 157 | 157 | |
| 158 | 158 | /** Optional. If user message was a command , this parameter will be the command payload(if exist) */ |
| 159 | - public string|null $command_payload = null; |
|
| 159 | + public string | null $command_payload = null; |
|
| 160 | 160 | |
| 161 | 161 | /** |
| 162 | 162 | * Optional. For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text |
| 163 | 163 | * @var messageEntity[] |
| 164 | 164 | */ |
| 165 | - public null|array $entities = null; |
|
| 165 | + public null | array $entities = null; |
|
| 166 | 166 | |
| 167 | 167 | /** |
| 168 | 168 | * Optional. Message is an animation, information about the animation. For backward compatibility, when this |
| 169 | 169 | * field is set, the document field will also be set |
| 170 | 170 | */ |
| 171 | - public null|animation $animation = null; |
|
| 171 | + public null | animation $animation = null; |
|
| 172 | 172 | |
| 173 | 173 | /** Optional. Message is an audio file, information about the file */ |
| 174 | - public null|audio $audio = null; |
|
| 174 | + public null | audio $audio = null; |
|
| 175 | 175 | |
| 176 | 176 | /** Optional. Message is a general file, information about the file */ |
| 177 | - public null|document $document = null; |
|
| 177 | + public null | document $document = null; |
|
| 178 | 178 | |
| 179 | 179 | /** |
| 180 | 180 | * Optional. Message is a photo, available sizes of the photo |
| 181 | 181 | * @var photoSize[] |
| 182 | 182 | */ |
| 183 | - public null|array $photo = null; |
|
| 183 | + public null | array $photo = null; |
|
| 184 | 184 | |
| 185 | 185 | /** Optional. Message is a sticker, information about the sticker */ |
| 186 | - public null|sticker $sticker = null; |
|
| 186 | + public null | sticker $sticker = null; |
|
| 187 | 187 | |
| 188 | 188 | /** Optional. Message is a video, information about the video */ |
| 189 | - public null|video $video = null; |
|
| 189 | + public null | video $video = null; |
|
| 190 | 190 | |
| 191 | 191 | /** Optional. Message is a video note, information about the video message */ |
| 192 | - public null|videoNote $video_note = null; |
|
| 192 | + public null | videoNote $video_note = null; |
|
| 193 | 193 | |
| 194 | 194 | /** Optional. Message is a voice message, information about the file */ |
| 195 | - public null|voice $voice = null; |
|
| 195 | + public null | voice $voice = null; |
|
| 196 | 196 | |
| 197 | 197 | /** Optional. Caption for the animation, audio, document, photo, video or voice */ |
| 198 | - public null|string $caption = null; |
|
| 198 | + public null | string $caption = null; |
|
| 199 | 199 | |
| 200 | 200 | /** |
| 201 | 201 | * Optional. For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear |
| 202 | 202 | * in the caption |
| 203 | 203 | * @var messageEntity[] |
| 204 | 204 | */ |
| 205 | - public null|array $caption_entities = null; |
|
| 205 | + public null | array $caption_entities = null; |
|
| 206 | 206 | |
| 207 | 207 | /** Optional. True, if the message media is covered by a spoiler animation */ |
| 208 | - public null|bool $has_media_spoiler = null; |
|
| 208 | + public null | bool $has_media_spoiler = null; |
|
| 209 | 209 | |
| 210 | 210 | /** Optional. Message is a shared contact, information about the contact */ |
| 211 | - public null|contact $contact = null; |
|
| 211 | + public null | contact $contact = null; |
|
| 212 | 212 | |
| 213 | 213 | /** Optional. Message is a dice with random value */ |
| 214 | - public null|dice $dice = null; |
|
| 214 | + public null | dice $dice = null; |
|
| 215 | 215 | |
| 216 | 216 | /** Optional. Message is a game, information about the game. More about games » */ |
| 217 | - public null|game $game = null; |
|
| 217 | + public null | game $game = null; |
|
| 218 | 218 | |
| 219 | 219 | /** Optional. Message is a native poll, information about the poll */ |
| 220 | - public null|poll $poll = null; |
|
| 220 | + public null | poll $poll = null; |
|
| 221 | 221 | |
| 222 | 222 | /** |
| 223 | 223 | * Optional. Message is a venue, information about the venue. For backward compatibility, when this field is set, |
| 224 | 224 | * the location field will also be set |
| 225 | 225 | */ |
| 226 | - public null|venue $venue = null; |
|
| 226 | + public null | venue $venue = null; |
|
| 227 | 227 | |
| 228 | 228 | /** Optional. Message is a shared location, information about the location */ |
| 229 | - public null|location $location = null; |
|
| 229 | + public null | location $location = null; |
|
| 230 | 230 | |
| 231 | 231 | /** |
| 232 | 232 | * Optional. New members that were added to the group or supergroup and information about them (the bot itself |
| 233 | 233 | * may be one of these members) |
| 234 | 234 | * @var user[] |
| 235 | 235 | */ |
| 236 | - public null|array $new_chat_members = null; |
|
| 236 | + public null | array $new_chat_members = null; |
|
| 237 | 237 | |
| 238 | 238 | /** Optional. A member was removed from the group, information about them (this member may be the bot itself) */ |
| 239 | - public null|user $left_chat_member = null; |
|
| 239 | + public null | user $left_chat_member = null; |
|
| 240 | 240 | |
| 241 | 241 | /** Optional. A chat title was changed to this value */ |
| 242 | - public null|string $new_chat_title = null; |
|
| 242 | + public null | string $new_chat_title = null; |
|
| 243 | 243 | |
| 244 | 244 | /** |
| 245 | 245 | * Optional. A chat photo was change to this value |
| 246 | 246 | * @var photoSize[] |
| 247 | 247 | */ |
| 248 | - public null|array $new_chat_photo = null; |
|
| 248 | + public null | array $new_chat_photo = null; |
|
| 249 | 249 | |
| 250 | 250 | /** Optional. Service message: the chat photo was deleted */ |
| 251 | - public null|bool $delete_chat_photo = null; |
|
| 251 | + public null | bool $delete_chat_photo = null; |
|
| 252 | 252 | |
| 253 | 253 | /** Optional. Service message: the group has been created */ |
| 254 | - public null|bool $group_chat_created = null; |
|
| 254 | + public null | bool $group_chat_created = null; |
|
| 255 | 255 | |
| 256 | 256 | /** |
| 257 | 257 | * Optional. Service message: the supergroup has been created. This field can't be received in a message coming |
| 258 | 258 | * through updates, because bot can't be a member of a supergroup when it is created. It can only be found in |
| 259 | 259 | * reply_to_message if someone replies to a very first message in a directly created supergroup. |
| 260 | 260 | */ |
| 261 | - public null|bool $supergroup_chat_created = null; |
|
| 261 | + public null | bool $supergroup_chat_created = null; |
|
| 262 | 262 | |
| 263 | 263 | /** |
| 264 | 264 | * Optional. Service message: the channel has been created. This field can't be received in a message coming |
| 265 | 265 | * through updates, because bot can't be a member of a channel when it is created. It can only be found in |
| 266 | 266 | * reply_to_message if someone replies to a very first message in a channel. |
| 267 | 267 | */ |
| 268 | - public null|bool $channel_chat_created = null; |
|
| 268 | + public null | bool $channel_chat_created = null; |
|
| 269 | 269 | |
| 270 | 270 | /** Optional. Service message: auto-delete timer settings changed in the chat */ |
| 271 | - public null|messageAutoDeleteTimerChanged $message_auto_delete_timer_changed = null; |
|
| 271 | + public null | messageAutoDeleteTimerChanged $message_auto_delete_timer_changed = null; |
|
| 272 | 272 | |
| 273 | 273 | /** |
| 274 | 274 | * Optional. The group has been migrated to a supergroup with the specified identifier. This number may have more |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | * But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for |
| 277 | 277 | * storing this identifier. |
| 278 | 278 | */ |
| 279 | - public null|int $migrate_to_chat_id = null; |
|
| 279 | + public null | int $migrate_to_chat_id = null; |
|
| 280 | 280 | |
| 281 | 281 | /** |
| 282 | 282 | * Optional. The supergroup has been migrated from a group with the specified identifier. This number may have |
@@ -284,117 +284,117 @@ discard block |
||
| 284 | 284 | * interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float |
| 285 | 285 | * type are safe for storing this identifier. |
| 286 | 286 | */ |
| 287 | - public null|int $migrate_from_chat_id = null; |
|
| 287 | + public null | int $migrate_from_chat_id = null; |
|
| 288 | 288 | |
| 289 | 289 | /** |
| 290 | 290 | * Optional. Specified message was pinned. Note that the Message object in this field will not contain further |
| 291 | 291 | * reply_to_message fields even if it is itself a reply. |
| 292 | 292 | */ |
| 293 | - public null|message $pinned_message = null; |
|
| 293 | + public null | message $pinned_message = null; |
|
| 294 | 294 | |
| 295 | 295 | /** Optional. Message is an invoice for a payment, information about the invoice. More about payments » */ |
| 296 | - public null|invoice $invoice = null; |
|
| 296 | + public null | invoice $invoice = null; |
|
| 297 | 297 | |
| 298 | 298 | /** |
| 299 | 299 | * Optional. Message is a service message about a successful payment, information about the payment. More about |
| 300 | 300 | * payments » |
| 301 | 301 | */ |
| 302 | - public null|successfulPayment $successful_payment = null; |
|
| 302 | + public null | successfulPayment $successful_payment = null; |
|
| 303 | 303 | |
| 304 | 304 | /** Optional. The domain name of the website on which the user has logged in. More about Telegram Login » */ |
| 305 | - public null|string $connected_website = null; |
|
| 305 | + public null | string $connected_website = null; |
|
| 306 | 306 | |
| 307 | 307 | /** Optional. Service message: the user allowed the bot added to the attachment menu to write messages */ |
| 308 | - public null|writeAccessAllowed $write_access_allowed = null; |
|
| 308 | + public null | writeAccessAllowed $write_access_allowed = null; |
|
| 309 | 309 | |
| 310 | 310 | /** Optional. Telegram Passport data */ |
| 311 | - public null|passportData $passport_data = null; |
|
| 311 | + public null | passportData $passport_data = null; |
|
| 312 | 312 | |
| 313 | 313 | /** |
| 314 | 314 | * Optional. Service message. A user in the chat triggered another user's proximity alert while sharing Live |
| 315 | 315 | * Location. |
| 316 | 316 | */ |
| 317 | - public null|proximityAlertTriggered $proximity_alert_triggered = null; |
|
| 317 | + public null | proximityAlertTriggered $proximity_alert_triggered = null; |
|
| 318 | 318 | |
| 319 | 319 | /** Optional. Service message: forum topic created */ |
| 320 | - public null|forumTopicCreated $forum_topic_created = null; |
|
| 320 | + public null | forumTopicCreated $forum_topic_created = null; |
|
| 321 | 321 | |
| 322 | 322 | /** Optional. Service message: forum topic edited */ |
| 323 | - public null|forumTopicEdited $forum_topic_edited = null; |
|
| 323 | + public null | forumTopicEdited $forum_topic_edited = null; |
|
| 324 | 324 | |
| 325 | 325 | /** Optional. Service message: forum topic closed */ |
| 326 | - public null|forumTopicClosed $forum_topic_closed = null; |
|
| 326 | + public null | forumTopicClosed $forum_topic_closed = null; |
|
| 327 | 327 | |
| 328 | 328 | /** Optional. Service message: forum topic reopened */ |
| 329 | - public null|forumTopicReopened $forum_topic_reopened = null; |
|
| 329 | + public null | forumTopicReopened $forum_topic_reopened = null; |
|
| 330 | 330 | |
| 331 | 331 | /** Optional. Service message: the 'General' forum topic hidden */ |
| 332 | - public null|generalForumTopicHidden $general_forum_topic_hidden = null; |
|
| 332 | + public null | generalForumTopicHidden $general_forum_topic_hidden = null; |
|
| 333 | 333 | |
| 334 | 334 | /** Optional. Service message: the 'General' forum topic unhidden */ |
| 335 | - public null|generalForumTopicUnhidden $general_forum_topic_unhidden = null; |
|
| 335 | + public null | generalForumTopicUnhidden $general_forum_topic_unhidden = null; |
|
| 336 | 336 | |
| 337 | 337 | /** Optional. Service message: video chat scheduled */ |
| 338 | - public null|videoChatScheduled $video_chat_scheduled = null; |
|
| 338 | + public null | videoChatScheduled $video_chat_scheduled = null; |
|
| 339 | 339 | |
| 340 | 340 | /** Optional. Service message: video chat started */ |
| 341 | - public null|videoChatStarted $video_chat_started = null; |
|
| 341 | + public null | videoChatStarted $video_chat_started = null; |
|
| 342 | 342 | |
| 343 | 343 | /** Optional. Service message: video chat ended */ |
| 344 | - public null|videoChatEnded $video_chat_ended = null; |
|
| 344 | + public null | videoChatEnded $video_chat_ended = null; |
|
| 345 | 345 | |
| 346 | 346 | /** Optional. Service message: new participants invited to a video chat */ |
| 347 | - public null|videoChatParticipantsInvited $video_chat_participants_invited = null; |
|
| 347 | + public null | videoChatParticipantsInvited $video_chat_participants_invited = null; |
|
| 348 | 348 | |
| 349 | 349 | /** Optional. Service message: data sent by a Web App */ |
| 350 | - public null|webAppData $web_app_data = null; |
|
| 350 | + public null | webAppData $web_app_data = null; |
|
| 351 | 351 | |
| 352 | 352 | /** Optional. Inline keyboard attached to the message. login_url buttons are represented as ordinary url buttons. */ |
| 353 | - public null|inlineKeyboardMarkup $reply_markup = null; |
|
| 353 | + public null | inlineKeyboardMarkup $reply_markup = null; |
|
| 354 | 354 | |
| 355 | 355 | |
| 356 | - public function __construct(stdClass|null $object = null) { |
|
| 356 | + public function __construct(stdClass | null $object = null) { |
|
| 357 | 357 | if ($object != null) { |
| 358 | 358 | parent::__construct($object, self::subs); |
| 359 | 359 | } |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | - public function isCommand (): bool { |
|
| 362 | + public function isCommand(): bool { |
|
| 363 | 363 | return !empty($this->command); |
| 364 | 364 | } |
| 365 | 365 | |
| 366 | - public function isForwarded (): bool { |
|
| 366 | + public function isForwarded(): bool { |
|
| 367 | 367 | return $this->forward_from !== null || $this->forward_from_chat !== null; |
| 368 | 368 | } |
| 369 | 369 | |
| 370 | - public function isAdmin (): bool { |
|
| 370 | + public function isAdmin(): bool { |
|
| 371 | 371 | return $this->chat->getMember($this->from->id)->status === chatMemberStatus::ADMINISTRATOR; |
| 372 | 372 | } |
| 373 | 373 | |
| 374 | - public function isOwner (): bool { |
|
| 374 | + public function isOwner(): bool { |
|
| 375 | 375 | return $this->chat->getMember($this->from->id)->status === chatMemberStatus::CREATOR; |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | - public function banMember(): responseError|bool { |
|
| 378 | + public function banMember(): responseError | bool { |
|
| 379 | 379 | if ($this->chat->isPrivate()) { |
| 380 | 380 | return false; |
| 381 | 381 | } |
| 382 | 382 | return telegram::banChatMember($this->chat->id, $this->from->id); |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | - public function delete (): responseError|bool { |
|
| 386 | - return telegram::deleteMessage($this->chat->id,$this->id); |
|
| 385 | + public function delete(): responseError | bool { |
|
| 386 | + return telegram::deleteMessage($this->chat->id, $this->id); |
|
| 387 | 387 | } |
| 388 | 388 | |
| 389 | - public function editText (string $text): message|responseError|bool { |
|
| 390 | - return telegram::editMessageText($text,$this->chat->id,$this->message_id); |
|
| 389 | + public function editText(string $text): message | responseError | bool { |
|
| 390 | + return telegram::editMessageText($text, $this->chat->id, $this->message_id); |
|
| 391 | 391 | } |
| 392 | 392 | |
| 393 | - public function copy (int|string $chat_id): messageId|responseError { |
|
| 393 | + public function copy(int | string $chat_id): messageId | responseError { |
|
| 394 | 394 | return telegram::copyMessage($chat_id); |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - public function forward (int|string $chat_id): message|responseError { |
|
| 397 | + public function forward(int | string $chat_id): message | responseError { |
|
| 398 | 398 | return telegram::forwardMessage($chat_id); |
| 399 | 399 | } |
| 400 | 400 | } |
@@ -25,13 +25,13 @@ |
||
| 25 | 25 | public shippingAddress $shipping_address; |
| 26 | 26 | |
| 27 | 27 | |
| 28 | - public function __construct(stdClass|null $object = null) { |
|
| 28 | + public function __construct(stdClass | null $object = null) { |
|
| 29 | 29 | if ($object != null) { |
| 30 | 30 | parent::__construct($object, self::subs); |
| 31 | 31 | } |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - public function answer (bool $ok, null|array $shipping_options = null, string|null $error_message = null): responseError|bool { |
|
| 34 | + public function answer(bool $ok, null | array $shipping_options = null, string | null $error_message = null): responseError | bool { |
|
| 35 | 35 | return telegram::answerShippingQuery($ok, $this->id, $shipping_options, $error_message); |
| 36 | 36 | } |
| 37 | 37 | } |