Passed
Push — main ( b61dc0...006c6c )
by Miaad
01:56
created
src/api/request/answer.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -11,32 +11,32 @@  discard block
 block discarded – undo
11 11
 class answer {
12 12
     private static bool $is_answered = false;
13 13
 
14
-    public static function init(string $method,array $data) {
14
+    public static function init(string $method, array $data) {
15 15
         self::checkAnswered();
16 16
         self::checkWebhook();
17 17
         self::sieveData($data);
18 18
         self::$is_answered = true;
19 19
         $data['method'] = $method;
20 20
         $payload = json_encode($data);
21
-        header('Content-Type: application/json;Content-Length: ' . strlen($payload));
21
+        header('Content-Type: application/json;Content-Length: '.strlen($payload));
22 22
         echo $payload;
23 23
         return true;
24 24
     }
25 25
 
26 26
     private static function checkAnswered() {
27 27
         if (self::$is_answered) {
28
-            logger::write('You can use answer mode only once for each webhook update , You already did it!',loggerTypes::ERROR);
28
+            logger::write('You can use answer mode only once for each webhook update , You already did it!', loggerTypes::ERROR);
29 29
             throw new bptException('ANSWER_MODE_USED');
30 30
         }
31 31
     }
32 32
 
33 33
     private static function checkWebhook() {
34
-        if(settings::$receiver === receiver::GETUPDATES) {
35
-            logger::write('Answer mode only work when receiver is webhook',loggerTypes::ERROR);
34
+        if (settings::$receiver === receiver::GETUPDATES) {
35
+            logger::write('Answer mode only work when receiver is webhook', loggerTypes::ERROR);
36 36
             throw new bptException('ANSWER_MODE_GETUPDATES');
37 37
         }
38
-        elseif(settings::$multi) {
39
-            logger::write('You can not use answer mode when multi setting is on',loggerTypes::ERROR);
38
+        elseif (settings::$multi) {
39
+            logger::write('You can not use answer mode when multi setting is on', loggerTypes::ERROR);
40 40
             throw new bptException('ANSWER_MODE_MULTI');
41 41
         }
42 42
     }
@@ -46,11 +46,11 @@  discard block
 block discarded – undo
46 46
         unset($data['forgot']);
47 47
         unset($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
         }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -34,8 +34,7 @@  discard block
 block discarded – undo
34 34
         if(settings::$receiver === receiver::GETUPDATES) {
35 35
             logger::write('Answer mode only work when receiver is webhook',loggerTypes::ERROR);
36 36
             throw new bptException('ANSWER_MODE_GETUPDATES');
37
-        }
38
-        elseif(settings::$multi) {
37
+        } elseif(settings::$multi) {
39 38
             logger::write('You can not use answer mode when multi setting is on',loggerTypes::ERROR);
40 39
             throw new bptException('ANSWER_MODE_MULTI');
41 40
         }
@@ -49,8 +48,7 @@  discard block
 block discarded – undo
49 48
         foreach ($data as $key=>&$value){
50 49
             if (!isset($value)){
51 50
                 unset($data[$key]);
52
-            }
53
-            elseif (is_array($value) || is_object($value)){
51
+            } elseif (is_array($value) || is_object($value)){
54 52
                 $value = json_encode($value);
55 53
             }
56 54
         }
Please login to merge, or discard this patch.
src/api/request.php 2 patches
Spacing   +124 added lines, -124 removed lines patch added patch discarded remove patch
@@ -448,94 +448,94 @@  discard block
 block discarded – undo
448 448
     ];
449 449
 
450 450
     private const METHODS_KEYS = [
451
-        'getUpdates'                      => ['offset','limit','timeout','allowed_updates','token','return_array','forgot','answer'],
452
-        'setWebhook'                      => ['url','certificate','ip_address','max_connections','allowed_updates','drop_pending_updates','secret_token','token','return_array','forgot','answer'],
453
-        'deleteWebhook'                   => ['drop_pending_updates','token','return_array','forgot','answer'],
454
-        'getWebhookInfo'                  => ['token','return_array','forgot','answer'],
455
-        'getMe'                           => ['token','return_array','forgot','answer'],
456
-        'logOut'                          => ['token','return_array','forgot','answer'],
457
-        'close'                           => ['token','return_array','forgot','answer'],
458
-        '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','return_array','forgot','answer'],
459
-        'forwardMessage'                  => ['chat_id','from_chat_id','disable_notification','protect_content','message_id','token','return_array','forgot','answer'],
460
-        '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','return_array','forgot','answer'],
461
-        'sendPhoto'                       => ['photo','chat_id','caption','parse_mode','caption_entities','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'],
462
-        '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','return_array','forgot','answer'],
463
-        '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','return_array','forgot','answer'],
464
-        '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','return_array','forgot','answer'],
465
-        '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','return_array','forgot','answer'],
466
-        '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','return_array','forgot','answer'],
467
-        'sendVideoNote'                   => ['video_note','chat_id','duration','length','thumb','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'],
468
-        'sendMediaGroup'                  => ['media','chat_id','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','token','return_array','forgot','answer'],
469
-        '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','return_array','forgot','answer'],
470
-        'editMessageLiveLocation'         => ['latitude','longitude','chat_id','message_id','inline_message_id','horizontal_accuracy','heading','proximity_alert_radius','reply_markup','token','return_array','forgot','answer'],
471
-        'stopMessageLiveLocation'         => ['chat_id','message_id','inline_message_id','reply_markup','token','return_array','forgot','answer'],
472
-        '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','return_array','forgot','answer'],
473
-        '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','return_array','forgot','answer'],
474
-        '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','return_array','forgot','answer'],
475
-        'sendDice'                        => ['chat_id','emoji','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'],
476
-        'sendChatAction'                  => ['chat_id','action','token','return_array','forgot','answer'],
477
-        'getUserProfilePhotos'            => ['user_id','offset','limit','token','return_array','forgot','answer'],
478
-        'getFile'                         => ['file_id','token','return_array','forgot','answer'],
479
-        'banChatMember'                   => ['chat_id','user_id','until_date','revoke_messages','token','return_array','forgot','answer'],
480
-        'unbanChatMember'                 => ['chat_id','user_id','only_if_banned','token','return_array','forgot','answer'],
481
-        'restrictChatMember'              => ['permissions','chat_id','user_id','until_date','token','return_array','forgot','answer'],
482
-        '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','token','return_array','forgot','answer'],
483
-        'setChatAdministratorCustomTitle' => ['custom_title','chat_id','user_id','token','return_array','forgot','answer'],
484
-        'banChatSenderChat'               => ['sender_chat_id','chat_id','token','return_array','forgot','answer'],
485
-        'unbanChatSenderChat'             => ['sender_chat_id','chat_id','token','return_array','forgot','answer'],
486
-        'setChatPermissions'              => ['permissions','chat_id','token','return_array','forgot','answer'],
487
-        'exportChatInviteLink'            => ['chat_id','token','return_array','forgot','answer'],
488
-        'createChatInviteLink'            => ['chat_id','name','expire_date','member_limit','creates_join_request','token','return_array','forgot','answer'],
489
-        'editChatInviteLink'              => ['invite_link','chat_id','name','expire_date','member_limit','creates_join_request','token','return_array','forgot','answer'],
490
-        'revokeChatInviteLink'            => ['invite_link','chat_id','token','return_array','forgot','answer'],
491
-        'approveChatJoinRequest'          => ['chat_id','user_id','token','return_array','forgot','answer'],
492
-        'declineChatJoinRequest'          => ['chat_id','user_id','token','return_array','forgot','answer'],
493
-        'setChatPhoto'                    => ['photo','chat_id','token','return_array','forgot','answer'],
494
-        'deleteChatPhoto'                 => ['chat_id','token','return_array','forgot','answer'],
495
-        'setChatTitle'                    => ['title','chat_id','token','return_array','forgot','answer'],
496
-        'setChatDescription'              => ['chat_id','description','token','return_array','forgot','answer'],
497
-        'pinChatMessage'                  => ['message_id','chat_id','disable_notification','token','return_array','forgot','answer'],
498
-        'unpinChatMessage'                => ['chat_id','message_id','token','return_array','forgot','answer'],
499
-        'unpinAllChatMessages'            => ['chat_id','token','return_array','forgot','answer'],
500
-        'leaveChat'                       => ['chat_id','token','return_array','forgot','answer'],
501
-        'getChat'                         => ['chat_id','token','return_array','forgot','answer'],
502
-        'getChatAdministrators'           => ['chat_id','token','return_array','forgot','answer'],
503
-        'getChatMemberCount'              => ['chat_id','token','return_array','forgot','answer'],
504
-        'getChatMember'                   => ['chat_id','user_id','token','return_array','forgot','answer'],
505
-        'setChatStickerSet'               => ['sticker_set_name','chat_id','token','return_array','forgot','answer'],
506
-        'deleteChatStickerSet'            => ['chat_id','token','return_array','forgot','answer'],
507
-        'answerCallbackQuery'             => ['callback_query_id','text','show_alert','url','cache_time','token','return_array','forgot','answer'],
508
-        'setMyCommands'                   => ['commands','scope','language_code','token','return_array','forgot','answer'],
509
-        'deleteMyCommands'                => ['scope','language_code','token','return_array','forgot','answer'],
510
-        'getMyCommands'                   => ['scope','language_code','token','return_array','forgot','answer'],
511
-        'setChatMenuButton'               => ['chat_id','menu_button','token','return_array','forgot','answer'],
512
-        'getChatMenuButton'               => ['chat_id','token','return_array','forgot','answer'],
513
-        'setMyDefaultAdministratorRights' => ['rights','for_channels','token','return_array','forgot','answer'],
514
-        'getMyDefaultAdministratorRights' => ['for_channels','token','return_array','forgot','answer'],
515
-        'editMessageText'                 => ['text','chat_id','message_id','inline_message_id','parse_mode','entities','disable_web_page_preview','reply_markup','token','return_array','forgot','answer'],
516
-        'editMessageCaption'              => ['chat_id','message_id','inline_message_id','caption','parse_mode','caption_entities','reply_markup','token','return_array','forgot','answer'],
517
-        'editMessageMedia'                => ['media','chat_id','message_id','inline_message_id','reply_markup','token','return_array','forgot','answer'],
518
-        'editMessageReplyMarkup'          => ['chat_id','message_id','inline_message_id','reply_markup','token','return_array','forgot','answer'],
519
-        'stopPoll'                        => ['chat_id','message_id','reply_markup','token','return_array','forgot','answer'],
520
-        'deleteMessage'                   => ['chat_id','message_id','token','return_array','forgot','answer'],
521
-        'sendSticker'                     => ['sticker','chat_id','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'],
522
-        'getStickerSet'                   => ['name','token','return_array','forgot','answer'],
523
-        'uploadStickerFile'               => ['png_sticker','user_id','token','return_array','forgot','answer'],
524
-        'createNewStickerSet'             => ['name','title','emojis','user_id','png_sticker','tgs_sticker','webm_sticker','contains_masks','mask_position','token','return_array','forgot','answer'],
525
-        'addStickerToSet'                 => ['name','emojis','user_id','png_sticker','tgs_sticker','webm_sticker','mask_position','token','return_array','forgot','answer'],
526
-        'setStickerPositionInSet'         => ['sticker','position','token','return_array','forgot','answer'],
527
-        'deleteStickerFromSet'            => ['sticker','token','return_array','forgot','answer'],
528
-        'setStickerSetThumb'              => ['name','user_id','thumb','token','return_array','forgot','answer'],
529
-        'answerInlineQuery'               => ['results','inline_query_id','cache_time','is_personal','next_offset','switch_pm_text','switch_pm_parameter','token','return_array','forgot','answer'],
530
-        'answerWebAppQuery'               => ['web_app_query_id','result','token','return_array','forgot','answer'],
531
-        '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','return_array','forgot','answer'],
532
-        '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','return_array','forgot','answer'],
533
-        'answerShippingQuery'             => ['ok','shipping_query_id','shipping_options','error_message','token','return_array','forgot','answer'],
534
-        'answerPreCheckoutQuery'          => ['ok','pre_checkout_query_id','error_message','token','return_array','forgot','answer'],
535
-        'setPassportDataErrors'           => ['errors','user_id','token','return_array','forgot','answer'],
536
-        'sendGame'                        => ['game_short_name','chat_id','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'],
537
-        'setGameScore'                    => ['score','user_id','force','disable_edit_message','chat_id','message_id','inline_message_id','token','return_array','forgot','answer'],
538
-        'getGameHighScores'               => ['user_id','chat_id','message_id','inline_message_id','token','return_array','forgot','answer'],
451
+        'getUpdates'                      => ['offset', 'limit', 'timeout', 'allowed_updates', 'token', 'return_array', 'forgot', 'answer'],
452
+        'setWebhook'                      => ['url', 'certificate', 'ip_address', 'max_connections', 'allowed_updates', 'drop_pending_updates', 'secret_token', 'token', 'return_array', 'forgot', 'answer'],
453
+        'deleteWebhook'                   => ['drop_pending_updates', 'token', 'return_array', 'forgot', 'answer'],
454
+        'getWebhookInfo'                  => ['token', 'return_array', 'forgot', 'answer'],
455
+        'getMe'                           => ['token', 'return_array', 'forgot', 'answer'],
456
+        'logOut'                          => ['token', 'return_array', 'forgot', 'answer'],
457
+        'close'                           => ['token', 'return_array', 'forgot', 'answer'],
458
+        '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', 'return_array', 'forgot', 'answer'],
459
+        'forwardMessage'                  => ['chat_id', 'from_chat_id', 'disable_notification', 'protect_content', 'message_id', 'token', 'return_array', 'forgot', 'answer'],
460
+        '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', 'return_array', 'forgot', 'answer'],
461
+        'sendPhoto'                       => ['photo', 'chat_id', 'caption', 'parse_mode', 'caption_entities', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'],
462
+        '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', 'return_array', 'forgot', 'answer'],
463
+        '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', 'return_array', 'forgot', 'answer'],
464
+        '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', 'return_array', 'forgot', 'answer'],
465
+        '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', 'return_array', 'forgot', 'answer'],
466
+        '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', 'return_array', 'forgot', 'answer'],
467
+        'sendVideoNote'                   => ['video_note', 'chat_id', 'duration', 'length', 'thumb', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'],
468
+        'sendMediaGroup'                  => ['media', 'chat_id', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'token', 'return_array', 'forgot', 'answer'],
469
+        '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', 'return_array', 'forgot', 'answer'],
470
+        'editMessageLiveLocation'         => ['latitude', 'longitude', 'chat_id', 'message_id', 'inline_message_id', 'horizontal_accuracy', 'heading', 'proximity_alert_radius', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'],
471
+        'stopMessageLiveLocation'         => ['chat_id', 'message_id', 'inline_message_id', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'],
472
+        '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', 'return_array', 'forgot', 'answer'],
473
+        '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', 'return_array', 'forgot', 'answer'],
474
+        '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', 'return_array', 'forgot', 'answer'],
475
+        'sendDice'                        => ['chat_id', 'emoji', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'],
476
+        'sendChatAction'                  => ['chat_id', 'action', 'token', 'return_array', 'forgot', 'answer'],
477
+        'getUserProfilePhotos'            => ['user_id', 'offset', 'limit', 'token', 'return_array', 'forgot', 'answer'],
478
+        'getFile'                         => ['file_id', 'token', 'return_array', 'forgot', 'answer'],
479
+        'banChatMember'                   => ['chat_id', 'user_id', 'until_date', 'revoke_messages', 'token', 'return_array', 'forgot', 'answer'],
480
+        'unbanChatMember'                 => ['chat_id', 'user_id', 'only_if_banned', 'token', 'return_array', 'forgot', 'answer'],
481
+        'restrictChatMember'              => ['permissions', 'chat_id', 'user_id', 'until_date', 'token', 'return_array', 'forgot', 'answer'],
482
+        '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', 'token', 'return_array', 'forgot', 'answer'],
483
+        'setChatAdministratorCustomTitle' => ['custom_title', 'chat_id', 'user_id', 'token', 'return_array', 'forgot', 'answer'],
484
+        'banChatSenderChat'               => ['sender_chat_id', 'chat_id', 'token', 'return_array', 'forgot', 'answer'],
485
+        'unbanChatSenderChat'             => ['sender_chat_id', 'chat_id', 'token', 'return_array', 'forgot', 'answer'],
486
+        'setChatPermissions'              => ['permissions', 'chat_id', 'token', 'return_array', 'forgot', 'answer'],
487
+        'exportChatInviteLink'            => ['chat_id', 'token', 'return_array', 'forgot', 'answer'],
488
+        'createChatInviteLink'            => ['chat_id', 'name', 'expire_date', 'member_limit', 'creates_join_request', 'token', 'return_array', 'forgot', 'answer'],
489
+        'editChatInviteLink'              => ['invite_link', 'chat_id', 'name', 'expire_date', 'member_limit', 'creates_join_request', 'token', 'return_array', 'forgot', 'answer'],
490
+        'revokeChatInviteLink'            => ['invite_link', 'chat_id', 'token', 'return_array', 'forgot', 'answer'],
491
+        'approveChatJoinRequest'          => ['chat_id', 'user_id', 'token', 'return_array', 'forgot', 'answer'],
492
+        'declineChatJoinRequest'          => ['chat_id', 'user_id', 'token', 'return_array', 'forgot', 'answer'],
493
+        'setChatPhoto'                    => ['photo', 'chat_id', 'token', 'return_array', 'forgot', 'answer'],
494
+        'deleteChatPhoto'                 => ['chat_id', 'token', 'return_array', 'forgot', 'answer'],
495
+        'setChatTitle'                    => ['title', 'chat_id', 'token', 'return_array', 'forgot', 'answer'],
496
+        'setChatDescription'              => ['chat_id', 'description', 'token', 'return_array', 'forgot', 'answer'],
497
+        'pinChatMessage'                  => ['message_id', 'chat_id', 'disable_notification', 'token', 'return_array', 'forgot', 'answer'],
498
+        'unpinChatMessage'                => ['chat_id', 'message_id', 'token', 'return_array', 'forgot', 'answer'],
499
+        'unpinAllChatMessages'            => ['chat_id', 'token', 'return_array', 'forgot', 'answer'],
500
+        'leaveChat'                       => ['chat_id', 'token', 'return_array', 'forgot', 'answer'],
501
+        'getChat'                         => ['chat_id', 'token', 'return_array', 'forgot', 'answer'],
502
+        'getChatAdministrators'           => ['chat_id', 'token', 'return_array', 'forgot', 'answer'],
503
+        'getChatMemberCount'              => ['chat_id', 'token', 'return_array', 'forgot', 'answer'],
504
+        'getChatMember'                   => ['chat_id', 'user_id', 'token', 'return_array', 'forgot', 'answer'],
505
+        'setChatStickerSet'               => ['sticker_set_name', 'chat_id', 'token', 'return_array', 'forgot', 'answer'],
506
+        'deleteChatStickerSet'            => ['chat_id', 'token', 'return_array', 'forgot', 'answer'],
507
+        'answerCallbackQuery'             => ['callback_query_id', 'text', 'show_alert', 'url', 'cache_time', 'token', 'return_array', 'forgot', 'answer'],
508
+        'setMyCommands'                   => ['commands', 'scope', 'language_code', 'token', 'return_array', 'forgot', 'answer'],
509
+        'deleteMyCommands'                => ['scope', 'language_code', 'token', 'return_array', 'forgot', 'answer'],
510
+        'getMyCommands'                   => ['scope', 'language_code', 'token', 'return_array', 'forgot', 'answer'],
511
+        'setChatMenuButton'               => ['chat_id', 'menu_button', 'token', 'return_array', 'forgot', 'answer'],
512
+        'getChatMenuButton'               => ['chat_id', 'token', 'return_array', 'forgot', 'answer'],
513
+        'setMyDefaultAdministratorRights' => ['rights', 'for_channels', 'token', 'return_array', 'forgot', 'answer'],
514
+        'getMyDefaultAdministratorRights' => ['for_channels', 'token', 'return_array', 'forgot', 'answer'],
515
+        'editMessageText'                 => ['text', 'chat_id', 'message_id', 'inline_message_id', 'parse_mode', 'entities', 'disable_web_page_preview', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'],
516
+        'editMessageCaption'              => ['chat_id', 'message_id', 'inline_message_id', 'caption', 'parse_mode', 'caption_entities', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'],
517
+        'editMessageMedia'                => ['media', 'chat_id', 'message_id', 'inline_message_id', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'],
518
+        'editMessageReplyMarkup'          => ['chat_id', 'message_id', 'inline_message_id', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'],
519
+        'stopPoll'                        => ['chat_id', 'message_id', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'],
520
+        'deleteMessage'                   => ['chat_id', 'message_id', 'token', 'return_array', 'forgot', 'answer'],
521
+        'sendSticker'                     => ['sticker', 'chat_id', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'],
522
+        'getStickerSet'                   => ['name', 'token', 'return_array', 'forgot', 'answer'],
523
+        'uploadStickerFile'               => ['png_sticker', 'user_id', 'token', 'return_array', 'forgot', 'answer'],
524
+        'createNewStickerSet'             => ['name', 'title', 'emojis', 'user_id', 'png_sticker', 'tgs_sticker', 'webm_sticker', 'contains_masks', 'mask_position', 'token', 'return_array', 'forgot', 'answer'],
525
+        'addStickerToSet'                 => ['name', 'emojis', 'user_id', 'png_sticker', 'tgs_sticker', 'webm_sticker', 'mask_position', 'token', 'return_array', 'forgot', 'answer'],
526
+        'setStickerPositionInSet'         => ['sticker', 'position', 'token', 'return_array', 'forgot', 'answer'],
527
+        'deleteStickerFromSet'            => ['sticker', 'token', 'return_array', 'forgot', 'answer'],
528
+        'setStickerSetThumb'              => ['name', 'user_id', 'thumb', 'token', 'return_array', 'forgot', 'answer'],
529
+        'answerInlineQuery'               => ['results', 'inline_query_id', 'cache_time', 'is_personal', 'next_offset', 'switch_pm_text', 'switch_pm_parameter', 'token', 'return_array', 'forgot', 'answer'],
530
+        'answerWebAppQuery'               => ['web_app_query_id', 'result', 'token', 'return_array', 'forgot', 'answer'],
531
+        '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', 'return_array', 'forgot', 'answer'],
532
+        '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', 'return_array', 'forgot', 'answer'],
533
+        'answerShippingQuery'             => ['ok', 'shipping_query_id', 'shipping_options', 'error_message', 'token', 'return_array', 'forgot', 'answer'],
534
+        'answerPreCheckoutQuery'          => ['ok', 'pre_checkout_query_id', 'error_message', 'token', 'return_array', 'forgot', 'answer'],
535
+        'setPassportDataErrors'           => ['errors', 'user_id', 'token', 'return_array', 'forgot', 'answer'],
536
+        'sendGame'                        => ['game_short_name', 'chat_id', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'],
537
+        'setGameScore'                    => ['score', 'user_id', 'force', 'disable_edit_message', 'chat_id', 'message_id', 'inline_message_id', 'token', 'return_array', 'forgot', 'answer'],
538
+        'getGameHighScores'               => ['user_id', 'chat_id', 'message_id', 'inline_message_id', 'token', 'return_array', 'forgot', 'answer'],
539 539
     ];
540 540
 
541 541
     private const METHODS_WITH_FILE = [
@@ -564,8 +564,8 @@  discard block
 block discarded – undo
564 564
         'logOut'                          => [],
565 565
         'close'                           => [],
566 566
         'sendMessage'                     => ['chat_id'],
567
-        'forwardMessage'                  => ['from_chat_id','message_id'],
568
-        'copyMessage'                     => ['from_chat_id','message_id'],
567
+        'forwardMessage'                  => ['from_chat_id', 'message_id'],
568
+        'copyMessage'                     => ['from_chat_id', 'message_id'],
569 569
         'sendPhoto'                       => ['chat_id'],
570 570
         'sendAudio'                       => ['chat_id'],
571 571
         'sendDocument'                    => ['chat_id'],
@@ -581,15 +581,15 @@  discard block
 block discarded – undo
581 581
         'sendContact'                     => ['chat_id'],
582 582
         'sendPoll'                        => ['chat_id'],
583 583
         'sendDice'                        => ['chat_id'],
584
-        'sendChatAction'                  => ['chat_id','action'],
584
+        'sendChatAction'                  => ['chat_id', 'action'],
585 585
         'getUserProfilePhotos'            => ['user_id'],
586 586
         'getFile'                         => ['file_id'],
587
-        'banChatMember'                   => ['chat_id','user_id'],
588
-        'kickChatMember'                  => ['chat_id','user_id'],
589
-        'unbanChatMember'                 => ['chat_id','user_id'],
590
-        'restrictChatMember'              => ['chat_id','user_id'],
591
-        'promoteChatMember'               => ['chat_id','user_id'],
592
-        'setChatAdministratorCustomTitle' => ['chat_id','user_id'],
587
+        'banChatMember'                   => ['chat_id', 'user_id'],
588
+        'kickChatMember'                  => ['chat_id', 'user_id'],
589
+        'unbanChatMember'                 => ['chat_id', 'user_id'],
590
+        'restrictChatMember'              => ['chat_id', 'user_id'],
591
+        'promoteChatMember'               => ['chat_id', 'user_id'],
592
+        'setChatAdministratorCustomTitle' => ['chat_id', 'user_id'],
593 593
         'banChatSenderChat'               => ['chat_id'],
594 594
         'unbanChatSenderChat'             => ['chat_id'],
595 595
         'setChatPermissions'              => ['chat_id'],
@@ -597,8 +597,8 @@  discard block
 block discarded – undo
597 597
         'createChatInviteLink'            => ['chat_id'],
598 598
         'editChatInviteLink'              => ['chat_id'],
599 599
         'revokeChatInviteLink'            => ['chat_id'],
600
-        'approveChatJoinRequest'          => ['chat_id','user_id'],
601
-        'declineChatJoinRequest'          => ['chat_id','user_id'],
600
+        'approveChatJoinRequest'          => ['chat_id', 'user_id'],
601
+        'declineChatJoinRequest'          => ['chat_id', 'user_id'],
602 602
         'setChatPhoto'                    => ['chat_id'],
603 603
         'deleteChatPhoto'                 => ['chat_id'],
604 604
         'setChatTitle'                    => ['chat_id'],
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
         'getChat'                         => ['chat_id'],
611 611
         'getChatAdministrators'           => ['chat_id'],
612 612
         'getChatMembersCount'             => ['chat_id'],
613
-        'getChatMember'                   => ['chat_id','user_id'],
613
+        'getChatMember'                   => ['chat_id', 'user_id'],
614 614
         'setChatStickerSet'               => ['chat_id'],
615 615
         'deleteChatStickerSet'            => ['chat_id'],
616 616
         'answerCallbackQuery'             => ['callback_query_id'],
@@ -621,12 +621,12 @@  discard block
 block discarded – undo
621 621
         'getChatMenuButton'               => [],
622 622
         'setMyDefaultAdministratorRights' => [],
623 623
         'getMyDefaultAdministratorRights' => [],
624
-        'editMessageText'                 => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']],
625
-        'editMessageCaption'              => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']],
626
-        'editMessageMedia'                => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']],
627
-        'editMessageReplyMarkup'          => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']],
628
-        'stopPoll'                        => ['chat_id','message_id'],
629
-        'deleteMessage'                   => ['chat_id','message_id'],
624
+        'editMessageText'                 => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']],
625
+        'editMessageCaption'              => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']],
626
+        'editMessageMedia'                => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']],
627
+        'editMessageReplyMarkup'          => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']],
628
+        'stopPoll'                        => ['chat_id', 'message_id'],
629
+        'deleteMessage'                   => ['chat_id', 'message_id'],
630 630
         'sendSticker'                     => ['chat_id'],
631 631
         'getStickerSet'                   => [],
632 632
         'uploadStickerFile'               => ['user_id'],
@@ -642,8 +642,8 @@  discard block
 block discarded – undo
642 642
         'answerPreCheckoutQuery'          => ['pre_checkout_query_id'],
643 643
         'setPassportDataErrors'           => ['user_id'],
644 644
         'sendGame'                        => ['chat_id'],
645
-        'setGameScore'                    => ['user_id','inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']],
646
-        'getGameHighScores'               => ['user_id','inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']]
645
+        'setGameScore'                    => ['user_id', 'inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']],
646
+        'getGameHighScores'               => ['user_id', 'inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']]
647 647
     ];
648 648
     
649 649
     private const METHODS_RETURN = [
@@ -695,25 +695,25 @@  discard block
 block discarded – undo
695 695
     ];
696 696
 
697 697
 
698
-    public static function __callStatic (string $name, array $arguments) {
698
+    public static function __callStatic(string $name, array $arguments) {
699 699
         if ($action = self::methodAction($name)) {
700
-            self::keysName($action,$arguments);
701
-            self::readyFile($action,$arguments);
702
-            self::setDefaults($action,$arguments);
700
+            self::keysName($action, $arguments);
701
+            self::readyFile($action, $arguments);
702
+            self::setDefaults($action, $arguments);
703 703
             if (isset($arguments['answer'])) {
704
-                return answer::init($action,$arguments);
704
+                return answer::init($action, $arguments);
705 705
             }
706 706
             else {
707
-                return self::processResponse($action,curl::init($action,$arguments));
707
+                return self::processResponse($action, curl::init($action, $arguments));
708 708
             }
709 709
         }
710 710
         else {
711
-            logger::write("$name method is not supported",loggerTypes::ERROR);
711
+            logger::write("$name method is not supported", loggerTypes::ERROR);
712 712
             throw new bptException('METHOD_NOT_FOUND');
713 713
         }
714 714
     }
715 715
 
716
-    private static function keysName (string $name, array &$arguments) {
716
+    private static function keysName(string $name, array &$arguments) {
717 717
         foreach ($arguments as $key => $argument) {
718 718
             if (is_numeric($key) && isset(self::METHODS_KEYS[$name][$key])) {
719 719
                 $arguments[self::METHODS_KEYS[$name][$key]] = $argument;
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
         }
723 723
     }
724 724
 
725
-    private static function methodAction(string $name): string|false {
725
+    private static function methodAction(string $name): string | false {
726 726
         return self::METHODS_ACTION[str_replace('_', '', strtolower($name))] ?? false;
727 727
     }
728 728
 
@@ -743,11 +743,11 @@  discard block
 block discarded – undo
743 743
         }
744 744
     }
745 745
 
746
-    private static function methodFile(string $name): array|false {
746
+    private static function methodFile(string $name): array | false {
747 747
         return self::METHODS_WITH_FILE[$name] ?? false;
748 748
     }
749 749
 
750
-    private static function methodReturn(string $name,stdClass $response) {
750
+    private static function methodReturn(string $name, stdClass $response) {
751 751
         if (isset(self::METHODS_RETURN[$name])) {
752 752
             $return = self::METHODS_RETURN[$name];
753 753
             if (is_array($return)) {
@@ -770,13 +770,13 @@  discard block
 block discarded – undo
770 770
         $defaults = self::METHODS_EXTRA_DEFAULTS[$name];
771 771
         foreach ($defaults as $key => $default) {
772 772
             if (is_numeric($key)) {
773
-                if (!isset($arguments[$default])){
773
+                if (!isset($arguments[$default])) {
774 774
                     $arguments[$default] = self::catchFields($default);
775 775
                 }
776 776
             }
777 777
             elseif (isset(BPT::$update->$key) || $key === 'other') {
778 778
                 foreach ($default as $def) {
779
-                    if (!isset($arguments[$def])){
779
+                    if (!isset($arguments[$def])) {
780 780
                         $arguments[$def] = self::catchFields($def);
781 781
                     }
782 782
                 }
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
         if ($response->ok) {
790 790
             self::$status = true;
791 791
             self::$pure_response = $response;
792
-            return self::methodReturn($name,$response);
792
+            return self::methodReturn($name, $response);
793 793
         }
794 794
         else {
795 795
             self::$status = false;
@@ -798,7 +798,7 @@  discard block
 block discarded – undo
798 798
         }
799 799
     }
800 800
 
801
-    public static function catchFields (string $field): int|string|bool {
801
+    public static function catchFields(string $field): int | string | bool {
802 802
         switch ($field) {
803 803
             case 'chat_id' :
804 804
             case 'from_chat_id' :
@@ -934,7 +934,7 @@  discard block
 block discarded – undo
934 934
                     default => false
935 935
                 };
936 936
             case 'url' :
937
-                return 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
937
+                return 'https://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
938 938
             default:
939 939
                 return false;
940 940
         }
Please login to merge, or discard this patch.
Braces   +14 added lines, -17 removed lines patch added patch discarded remove patch
@@ -702,12 +702,10 @@  discard block
 block discarded – undo
702 702
             self::setDefaults($action,$arguments);
703 703
             if (isset($arguments['answer'])) {
704 704
                 return answer::init($action,$arguments);
705
-            }
706
-            else {
705
+            } else {
707 706
                 return self::processResponse($action,curl::init($action,$arguments));
708 707
             }
709
-        }
710
-        else {
708
+        } else {
711 709
             logger::write("$name method is not supported",loggerTypes::ERROR);
712 710
             throw new bptException('METHOD_NOT_FOUND');
713 711
         }
@@ -733,8 +731,7 @@  discard block
 block discarded – undo
733 731
                     $arguments['media'][$key]['media'] = new CURLFile($media['media']);
734 732
                 }
735 733
             }
736
-        }
737
-        elseif ($file_params = self::methodFile($name)) {
734
+        } elseif ($file_params = self::methodFile($name)) {
738 735
             foreach ($file_params as $param) {
739 736
                 if (isset($arguments[$param]) && file_exists($arguments[$param])) {
740 737
                     $arguments[$param] = new CURLFile($arguments[$param]);
@@ -756,12 +753,10 @@  discard block
 block discarded – undo
756 753
                     $value = new ($return[0]) ($value);
757 754
                 }
758 755
                 return $response;
759
-            }
760
-            else {
756
+            } else {
761 757
                 return new ($return) ($response->result);
762 758
             }
763
-        }
764
-        else {
759
+        } else {
765 760
             return $response->result;
766 761
         }
767 762
     }
@@ -773,8 +768,7 @@  discard block
 block discarded – undo
773 768
                 if (!isset($arguments[$default])){
774 769
                     $arguments[$default] = self::catchFields($default);
775 770
                 }
776
-            }
777
-            elseif (isset(BPT::$update->$key) || $key === 'other') {
771
+            } elseif (isset(BPT::$update->$key) || $key === 'other') {
778 772
                 foreach ($default as $def) {
779 773
                     if (!isset($arguments[$def])){
780 774
                         $arguments[$def] = self::catchFields($def);
@@ -790,8 +784,7 @@  discard block
 block discarded – undo
790 784
             self::$status = true;
791 785
             self::$pure_response = $response;
792 786
             return self::methodReturn($name,$response);
793
-        }
794
-        else {
787
+        } else {
795 788
             self::$status = false;
796 789
             self::$pure_response = $response;
797 790
             return new responseError($response);
@@ -827,9 +820,13 @@  discard block
 block discarded – undo
827 820
                     default => false
828 821
                 };
829 822
             case 'file_id' :
830
-                if (isset(BPT::$update->message)) $type = 'message';
831
-                elseif (isset(BPT::$update->edited_message)) $type = 'edited_message';
832
-                else return false;
823
+                if (isset(BPT::$update->message)) {
824
+                    $type = 'message';
825
+                } elseif (isset(BPT::$update->edited_message)) {
826
+                    $type = 'edited_message';
827
+                } else {
828
+                    return false;
829
+                }
833 830
 
834 831
                 return match(true) {
835 832
                     isset(BPT::$update->$type->animation) => BPT::$update->$type->animation->file_id,
Please login to merge, or discard this patch.
src/api/telegram.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@
 block discarded – undo
3 3
 namespace BPT\api;
4 4
 
5 5
 class telegram extends request {
6
-    public function __call (string $name, array $arguments) {
6
+    public function __call(string $name, array $arguments) {
7 7
         if (!isset($arguments[1]) && isset($arguments[0]) && is_array($arguments[0])) {
8 8
             return request::$name(...$arguments[0]);
9 9
         }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,8 +6,7 @@
 block discarded – undo
6 6
     public function __call (string $name, array $arguments) {
7 7
         if (!isset($arguments[1]) && isset($arguments[0]) && is_array($arguments[0])) {
8 8
             return request::$name(...$arguments[0]);
9
-        }
10
-        else {
9
+        } else {
11 10
             return request::$name(...$arguments);
12 11
         }
13 12
     }
Please login to merge, or discard this patch.
src/tools/is.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
      *
21 21
      * @return bool
22 22
      */
23
-    public static function isUsername (string $username): bool {
23
+    public static function isUsername(string $username): bool {
24 24
         $length = strlen($username);
25 25
         return !str_contains($username, '__') && $length >= 5 && $length <= 33 && preg_match('/^@?([a-zA-Z])(\w{4,31})$/', $username);
26 26
     }
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
      *
38 38
      * @return bool
39 39
      */
40
-    public static function ipInRange (string $ip, string $range): bool {
40
+    public static function ipInRange(string $ip, string $range): bool {
41 41
         if (!str_contains($range, '/')) {
42 42
             $range .= '/32';
43 43
         }
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      *
58 58
      * @return bool
59 59
      */
60
-    public static function isTelegram (string $ip): bool {
60
+    public static function isTelegram(string $ip): bool {
61 61
         return tools::ipInRange($ip, '149.154.160.0/20') || tools::ipInRange($ip, '91.108.4.0/22');
62 62
     }
63 63
 
@@ -72,10 +72,10 @@  discard block
 block discarded – undo
72 72
      *
73 73
      * @return bool
74 74
      */
75
-    public static function isCloudFlare (string $ip): bool {
75
+    public static function isCloudFlare(string $ip): bool {
76 76
         $cf_ips = ['173.245.48.0/20', '103.21.244.0/22', '103.22.200.0/22', '103.31.4.0/22', '141.101.64.0/18', '108.162.192.0/18', '190.93.240.0/20', '188.114.96.0/20', '197.234.240.0/22', '198.41.128.0/17', '162.158.0.0/15', '104.16.0.0/12', '172.64.0.0/13', '131.0.72.0/22'];
77 77
         foreach ($cf_ips as $cf_ip) {
78
-            if (self::ipInRange($ip,$cf_ip)) {
78
+            if (self::ipInRange($ip, $cf_ip)) {
79 79
                 return true;
80 80
             }
81 81
         }
@@ -95,9 +95,9 @@  discard block
 block discarded – undo
95 95
      *
96 96
      * @return bool|user return array when verify is active and token is true array of telegram getMe result
97 97
      */
98
-    public static function isToken (string $token, bool $verify = false): bool|user {
98
+    public static function isToken(string $token, bool $verify = false): bool | user {
99 99
         if (preg_match('/^(\d{8,10}):[\w\-]{35}$/', $token)) {
100
-            if ($verify){
100
+            if ($verify) {
101 101
                 $res = telegram::me($token);
102 102
                 if (telegram::$status) {
103 103
                     return $res;
@@ -129,14 +129,14 @@  discard block
 block discarded – undo
129 129
      *
130 130
      * @return bool
131 131
      */
132
-    public static function isJoined (array|string|int $ids , int|null $user_id = null): bool {
132
+    public static function isJoined(array | string | int $ids, int | null $user_id = null): bool {
133 133
         if (!is_array($ids)) {
134 134
             $ids = [$ids];
135 135
         }
136 136
         $user_id = $user_id ?? request::catchFields('user_id');
137 137
 
138 138
         foreach ($ids as $id) {
139
-            $check = telegram::getChatMember($id,$user_id);
139
+            $check = telegram::getChatMember($id, $user_id);
140 140
             if (telegram::$status) {
141 141
                 $check = $check->status;
142 142
                 if ($check === chatMemberStatus::LEFT || $check === chatMemberStatus::KICKED) {
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
      *
164 164
      * @return array keys will be id and values will be bool(null for not founded ids)
165 165
      */
166
-    public static function joinChecker (array|string|int $ids , int|null $user_id = null): array {
166
+    public static function joinChecker(array | string | int $ids, int | null $user_id = null): array {
167 167
         if (!is_array($ids)) {
168 168
             $ids = [$ids];
169 169
         }
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 
172 172
         $result = [];
173 173
         foreach ($ids as $id) {
174
-            $check = telegram::getChatMember($id,$user_id);
174
+            $check = telegram::getChatMember($id, $user_id);
175 175
             if (telegram::$status) {
176 176
                 $check = $check->status;
177 177
                 $result[$id] = $check !== chatMemberStatus::LEFT && $check !== chatMemberStatus::KICKED;
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -175,8 +175,9 @@
 block discarded – undo
175 175
             if (telegram::$status) {
176 176
                 $check = $check->status;
177 177
                 $result[$id] = $check !== chatMemberStatus::LEFT && $check !== chatMemberStatus::KICKED;
178
+            } else {
179
+                $result[$id] = null;
178 180
             }
179
-            else $result[$id] = null;
180 181
         }
181 182
         return $result;
182 183
     }
Please login to merge, or discard this patch.
src/tools/file.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
      *
27 27
      * @return string|int|false string for formatted data , int for normal data , false when size can not be found(file not found or ...)
28 28
      */
29
-    public static function size (string $path, bool $format = true): string|int|false {
29
+    public static function size(string $path, bool $format = true): string | int | false {
30 30
         if (filter_var($path, FILTER_VALIDATE_URL)) {
31 31
             $ch = curl_init($path);
32 32
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
      * @return bool
59 59
      * @throws bptException
60 60
      */
61
-    public static function delete (string $path, bool $sub = true): bool {
61
+    public static function delete(string $path, bool $sub = true): bool {
62 62
         if (is_dir($path)) {
63 63
             if (count(scandir($path)) > 2) {
64 64
                 if ($sub) {
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
                     return rmdir($path);
71 71
                 }
72 72
                 else {
73
-                    logger::write("tools::delete function used\ndelete function cannot delete folder because its have subFiles and sub parameter haven't true value",loggerTypes::ERROR);
73
+                    logger::write("tools::delete function used\ndelete function cannot delete folder because its have subFiles and sub parameter haven't true value", loggerTypes::ERROR);
74 74
                     throw new bptException('DELETE_FOLDER_HAS_SUB');
75 75
                 }
76 76
             }
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
      * @return bool
91 91
      * @throws bptException when zip extension not found
92 92
      */
93
-    public static function zip (string $path, string $destination): bool {
93
+    public static function zip(string $path, string $destination): bool {
94 94
         if (extension_loaded('zip')) {
95 95
             $rootPath = realpath($path);
96 96
             $zip = new ZipArchive();
Please login to merge, or discard this patch.
Braces   +10 added lines, -11 removed lines patch added patch discarded remove patch
@@ -35,14 +35,14 @@  discard block
 block discarded – undo
35 35
             curl_exec($ch);
36 36
             $size = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD);
37 37
             curl_close($ch);
38
-        }
39
-        else {
38
+        } else {
40 39
             $size = file_exists($path) ? filesize($path) : false;
41 40
         }
42 41
         if (isset($size) && is_numeric($size)) {
43 42
             return $format ? tools::byteFormat($size) : $size;
43
+        } else {
44
+            return false;
44 45
         }
45
-        else return false;
46 46
     }
47 47
 
48 48
     /**
@@ -68,15 +68,16 @@  discard block
 block discarded – undo
68 68
                         $file->isDir() ? rmdir($file->getRealPath()) : unlink($file->getRealPath());
69 69
                     }
70 70
                     return rmdir($path);
71
-                }
72
-                else {
71
+                } else {
73 72
                     logger::write("tools::delete function used\ndelete function cannot delete folder because its have subFiles and sub parameter haven't true value",loggerTypes::ERROR);
74 73
                     throw new bptException('DELETE_FOLDER_HAS_SUB');
75 74
                 }
75
+            } else {
76
+                return rmdir($path);
76 77
             }
77
-            else return rmdir($path);
78
+        } else {
79
+            return unlink($path);
78 80
         }
79
-        else return unlink($path);
80 81
     }
81 82
 
82 83
     /**
@@ -104,13 +105,11 @@  discard block
 block discarded – undo
104 105
                         $zip->addFile($filePath, substr($filePath, $root_len));
105 106
                     }
106 107
                 }
107
-            }
108
-            else {
108
+            } else {
109 109
                 $zip->addFile($path, basename($path));
110 110
             }
111 111
             return $zip->close();
112
-        }
113
-        else {
112
+        } else {
114 113
             logger::write("tools::zip function used\nzip extension is not found , It may not be installed or enabled", loggerTypes::ERROR);
115 114
             throw new bptException('ZIP_EXTENSION_MISSING');
116 115
         }
Please login to merge, or discard this patch.
src/tools/generator.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,10 +28,10 @@  discard block
 block discarded – undo
28 28
      *
29 29
      * @return string
30 30
      */
31
-    public static function randomString (int $length = 16, string $characters = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'): string {
31
+    public static function randomString(int $length = 16, string $characters = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'): string {
32 32
         $rand_string = '';
33 33
         $char_len = strlen($characters) - 1;
34
-        for ($i = 0; $i < $length; $i ++) {
34
+        for ($i = 0; $i < $length; $i++) {
35 35
             $rand_string .= $characters[rand(0, $char_len)];
36 36
         }
37 37
         return $rand_string;
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
      * @return inlineKeyboardMarkup|replyKeyboardMarkup replyKeyboardMarkup for keyboard and inlineKeyboardMarkup for inline
61 61
      * @throws bptException
62 62
      */
63
-    public static function easyKey(array $keyboard = [], array $inline = []): inlineKeyboardMarkup|replyKeyboardMarkup {
63
+    public static function easyKey(array $keyboard = [], array $inline = []): inlineKeyboardMarkup | replyKeyboardMarkup {
64 64
         if (!empty($keyboard)) {
65 65
             $keyboard_object = new replyKeyboardMarkup();
66 66
             $keyboard_object->setResize_keyboard($keyboard['resize'] ?? true);
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
             return $keyboard_object;
120 120
         }
121 121
         else {
122
-            logger::write("tools::eKey function used\nkeyboard or inline parameter must be set",loggerTypes::ERROR);
122
+            logger::write("tools::eKey function used\nkeyboard or inline parameter must be set", loggerTypes::ERROR);
123 123
             throw new bptException('ARGUMENT_NOT_FOUND_KEYBOARD_INLINE');
124 124
         }
125 125
     }
Please login to merge, or discard this patch.
Braces   +10 added lines, -15 removed lines patch added patch discarded remove patch
@@ -68,7 +68,9 @@  discard block
 block discarded – undo
68 68
                 $keyboard_object->setOne_time_keyboard($keyboard['one_time']);
69 69
             }
70 70
             foreach ($keyboard as $row) {
71
-                if (!is_array($row)) continue;
71
+                if (!is_array($row)) {
72
+                    continue;
73
+                }
72 74
                 $buttons = [];
73 75
                 foreach ($row as $base_button) {
74 76
                     $button_info = explode('||', $base_button);
@@ -77,15 +79,12 @@  discard block
 block discarded – undo
77 79
                     if (count($button_info) > 1) {
78 80
                         if ($button_info[1] === 'con') {
79 81
                             $button->setRequest_contact(true);
80
-                        }
81
-                        elseif ($button_info[1] === 'loc') {
82
+                        } elseif ($button_info[1] === 'loc') {
82 83
                             $button->setRequest_location(true);
83
-                        }
84
-                        elseif ($button_info[1] === 'poll') {
84
+                        } elseif ($button_info[1] === 'poll') {
85 85
                             $type = $button_info[2] === pollType::QUIZ ? pollType::QUIZ : pollType::REGULAR;
86 86
                             $button->setRequest_poll((new keyboardButtonPollType())->setType($type));
87
-                        }
88
-                        elseif ($button_info[1] === 'web' && isset($button_info[2])) {
87
+                        } elseif ($button_info[1] === 'web' && isset($button_info[2])) {
89 88
                             $url = $button_info[2];
90 89
                             $button->setWeb_app((new webAppInfo())->setUrl($url));
91 90
                         }
@@ -95,8 +94,7 @@  discard block
 block discarded – undo
95 94
                 $keyboard_object->setKeyboard([$buttons]);
96 95
             }
97 96
             return $keyboard_object;
98
-        }
99
-        elseif (!empty($inline)) {
97
+        } elseif (!empty($inline)) {
100 98
             $keyboard_object = new inlineKeyboardMarkup();
101 99
             foreach ($inline as $row) {
102 100
                 $buttons = [];
@@ -105,20 +103,17 @@  discard block
 block discarded – undo
105 103
                     if (isset($button_info[1])) {
106 104
                         if (filter_var($button_info[1], FILTER_VALIDATE_URL) && str_starts_with($button_info[1], 'http')) {
107 105
                             $button->setText($button_info[0])->setUrl($button_info[1]);
108
-                        }
109
-                        else {
106
+                        } else {
110 107
                             $button->setText($button_info[0])->setCallback_data($button_info[1]);
111 108
                         }
112
-                    }
113
-                    else {
109
+                    } else {
114 110
                         $button->setText($button_info[0])->setUrl('https://t.me/BPT_CH');
115 111
                     }
116 112
                 }
117 113
                 $keyboard_object->setInline_keyboard([$buttons]);
118 114
             }
119 115
             return $keyboard_object;
120
-        }
121
-        else {
116
+        } else {
122 117
             logger::write("tools::eKey function used\nkeyboard or inline parameter must be set",loggerTypes::ERROR);
123 118
             throw new bptException('ARGUMENT_NOT_FOUND_KEYBOARD_INLINE');
124 119
         }
Please login to merge, or discard this patch.
src/tools/encrypt.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
      * @return string|bool|array{hash:string, key:string, iv:string}
30 30
      * @throws bptException
31 31
      */
32
-    public static function crypto (string $action, string $text, string $key = null, string $iv = null): bool|array|string {
32
+    public static function crypto(string $action, string $text, string $key = null, string $iv = null): bool | array | string {
33 33
         if (extension_loaded('openssl')) {
34 34
             if ($action === cryptoAction::ENCRYPT) {
35 35
                 $key = self::randomString(64);
@@ -39,22 +39,22 @@  discard block
 block discarded – undo
39 39
             }
40 40
             elseif ($action === cryptoAction::DECRYPT) {
41 41
                 if (empty($key)) {
42
-                    logger::write("tools::crypto function used\nkey parameter is not set",loggerTypes::ERROR);
42
+                    logger::write("tools::crypto function used\nkey parameter is not set", loggerTypes::ERROR);
43 43
                     throw new bptException('ARGUMENT_NOT_FOUND_KEY');
44 44
                 }
45 45
                 elseif (empty($iv)) {
46
-                    logger::write("tools::crypto function used\niv parameter is not set",loggerTypes::ERROR);
46
+                    logger::write("tools::crypto function used\niv parameter is not set", loggerTypes::ERROR);
47 47
                     throw new bptException('ARGUMENT_NOT_FOUND_IV');
48 48
                 }
49 49
                 return openssl_decrypt(base64_decode($text), 'AES-256-CBC', $key, 1, $iv);
50 50
             }
51 51
             else {
52
-                logger::write("tools::crypto function used\naction is not right, its must be `encode` or `decode`",loggerTypes::WARNING);
52
+                logger::write("tools::crypto function used\naction is not right, its must be `encode` or `decode`", loggerTypes::WARNING);
53 53
                 return false;
54 54
             }
55 55
         }
56 56
         else {
57
-            logger::write("tools::crypto function used\nopenssl extension is not found , It may not be installed or enabled",loggerTypes::ERROR);
57
+            logger::write("tools::crypto function used\nopenssl extension is not found , It may not be installed or enabled", loggerTypes::ERROR);
58 58
             throw new bptException('OPENSSL_EXTENSION_MISSING');
59 59
         }
60 60
     }
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -36,24 +36,20 @@
 block discarded – undo
36 36
                 $iv = self::randomString();
37 37
                 $output = base64_encode(openssl_encrypt($text, 'AES-256-CBC', $key, 1, $iv));
38 38
                 return ['hash' => $output, 'key' => $key, 'iv' => $iv];
39
-            }
40
-            elseif ($action === cryptoAction::DECRYPT) {
39
+            } elseif ($action === cryptoAction::DECRYPT) {
41 40
                 if (empty($key)) {
42 41
                     logger::write("tools::crypto function used\nkey parameter is not set",loggerTypes::ERROR);
43 42
                     throw new bptException('ARGUMENT_NOT_FOUND_KEY');
44
-                }
45
-                elseif (empty($iv)) {
43
+                } elseif (empty($iv)) {
46 44
                     logger::write("tools::crypto function used\niv parameter is not set",loggerTypes::ERROR);
47 45
                     throw new bptException('ARGUMENT_NOT_FOUND_IV');
48 46
                 }
49 47
                 return openssl_decrypt(base64_decode($text), 'AES-256-CBC', $key, 1, $iv);
50
-            }
51
-            else {
48
+            } else {
52 49
                 logger::write("tools::crypto function used\naction is not right, its must be `encode` or `decode`",loggerTypes::WARNING);
53 50
                 return false;
54 51
             }
55
-        }
56
-        else {
52
+        } else {
57 53
             logger::write("tools::crypto function used\nopenssl extension is not found , It may not be installed or enabled",loggerTypes::ERROR);
58 54
             throw new bptException('OPENSSL_EXTENSION_MISSING');
59 55
         }
Please login to merge, or discard this patch.
src/tools/convert.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -21,10 +21,10 @@  discard block
 block discarded – undo
21 21
      *
22 22
      * @return string
23 23
      */
24
-    public static function byteFormat (int $byte, int $precision = 2): string {
24
+    public static function byteFormat(int $byte, int $precision = 2): string {
25 25
         $rate_counter = 0;
26 26
 
27
-        while ($byte > 1024){
27
+        while ($byte > 1024) {
28 28
             $byte /= 1024;
29 29
             $rate_counter++;
30 30
         }
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
             $byte = round($byte, $precision);
34 34
         }
35 35
 
36
-        return $byte . ' ' . ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'][$rate_counter];
36
+        return $byte.' '.['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'][$rate_counter];
37 37
     }
38 38
 
39 39
     /**
@@ -50,10 +50,10 @@  discard block
 block discarded – undo
50 50
      *
51 51
      * @return string|false return false when mode is incorrect
52 52
      */
53
-    public static function modeEscape (string $text, string $mode = parseMode::HTML): string|false {
53
+    public static function modeEscape(string $text, string $mode = parseMode::HTML): string | false {
54 54
         return match ($mode) {
55
-            parseMode::HTML => str_replace(['&', '<', '>',], ["&amp;", "&lt;", "&gt;",], $text),
56
-            parseMode::MARKDOWN => str_replace(['\\', '_', '*', '`', '['], ['\\\\', '\_', '\*', '\`', '\[',], $text),
55
+            parseMode::HTML => str_replace(['&', '<', '>', ], ["&amp;", "&lt;", "&gt;", ], $text),
56
+            parseMode::MARKDOWN => str_replace(['\\', '_', '*', '`', '['], ['\\\\', '\_', '\*', '\`', '\[', ], $text),
57 57
             parseMode::MARKDOWNV2 => str_replace(
58 58
                 ['_', '*', '[', ']', '(', ')', '~', '`', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!', '\\'],
59 59
                 ['\_', '\*', '\[', '\]', '\(', '\)', '\~', '\`', '\>', '\#', '\+', '\-', '\=', '\|', '\{', '\}', '\.', '\!', '\\\\'],
@@ -92,12 +92,12 @@  discard block
 block discarded – undo
92 92
      * @return array{status: string,year: string,month: string,day: string,hour: string,minute: string,second: string}
93 93
      * @throws Exception
94 94
      */
95
-    public static function timeDiff (int|string $target_time, int|string|null $base_time = null): array {
95
+    public static function timeDiff(int | string $target_time, int | string | null $base_time = null): array {
96 96
         if (!isset($base_time)) {
97 97
             $base_time = '@'.time();
98 98
         }
99 99
         $base_time = new DateTime($base_time);
100
-        $target_time = new DateTime(is_numeric($target_time) ? '@' . $target_time : $target_time . ' +00:00');
100
+        $target_time = new DateTime(is_numeric($target_time) ? '@'.$target_time : $target_time.' +00:00');
101 101
 
102 102
         $diff = $base_time->diff($target_time);
103 103
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -105,8 +105,9 @@
 block discarded – undo
105 105
         foreach ($string as $k => &$v) {
106 106
             if ($diff->$v) {
107 107
                 $v = $diff->$v;
108
+            } else {
109
+                unset($string[$k]);
108 110
             }
109
-            else unset($string[$k]);
110 111
         }
111 112
         $string['status'] = $base_time < $target_time ? 'later' : 'ago';
112 113
 
Please login to merge, or discard this patch.
src/database/database.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
     /**
12 12
      * @method Json_init
13 13
      */
14
-    public function json_init () {
14
+    public function json_init() {
15 15
         (new jsondb())->init(handler::$dbname);
16 16
     }
17 17
 }
18 18
\ No newline at end of file
Please login to merge, or discard this patch.