Passed
Push — main ( 7834cc...51b09b )
by Miaad
01:43
created
src/telegram/request/curl.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -16,17 +16,17 @@  discard block
 block discarded – undo
16 16
     /**
17 17
      * @internal Only for BPT self usage , Don't use it in your source!
18 18
      */
19
-    public static function init(string $method,array $data) {
19
+    public static function init(string $method, array $data) {
20 20
         $info = self::getInfo($data);
21 21
         $data = $info['data'];
22 22
         $handler = $info['handler'];
23
-        self::setTimeout($data,$handler,$method);
23
+        self::setTimeout($data, $handler, $method);
24 24
         self::setData($data);
25 25
         $data['method'] = $method;
26 26
         curl_setopt($handler, CURLOPT_POSTFIELDS, $data);
27 27
         $result = curl_exec($handler);
28 28
         if (curl_errno($handler)) {
29
-            logger::write(curl_error($handler),loggerTypes::WARNING);
29
+            logger::write(curl_error($handler), loggerTypes::WARNING);
30 30
         }
31 31
         if ($info['token'] != settings::$token) {
32 32
             curl_close($handler);
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
             curl_setopt($curl_handler, CURLOPT_RETURNTRANSFER, true);
43 43
             curl_setopt($curl_handler, CURLOPT_SSL_VERIFYPEER, false);
44 44
         }
45
-        else{
45
+        else {
46 46
             $token = settings::$token;
47
-            if (!isset(self::$curl_handler)){
47
+            if (!isset(self::$curl_handler)) {
48 48
                 self::$curl_handler = curl_init(settings::$base_url."/bot$token/");
49 49
                 curl_setopt(self::$curl_handler, CURLOPT_RETURNTRANSFER, true);
50 50
                 curl_setopt(self::$curl_handler, CURLOPT_SSL_VERIFYPEER, false);
@@ -60,22 +60,22 @@  discard block
 block discarded – undo
60 60
         ];
61 61
     }
62 62
 
63
-    private static function setTimeout(array &$data , CurlHandle $curl_handler,string $method): void {
63
+    private static function setTimeout(array &$data, CurlHandle $curl_handler, string $method): void {
64 64
         if (isset($data['forgot'])) {
65 65
             curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, settings::$forgot_time);
66 66
             unset($data['forgot']);
67 67
         }
68
-        elseif ($method === 'getUpdates' || $method === 'setWebhook'){
68
+        elseif ($method === 'getUpdates' || $method === 'setWebhook') {
69 69
             curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, 5000);
70 70
         }
71
-        else{
71
+        else {
72 72
             curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, settings::$base_timeout);
73 73
         }
74 74
     }
75 75
 
76 76
     private static function setData(array &$data): void {
77
-        foreach ($data as &$value){
78
-            if (is_array($value) || (is_object($value) && !is_a($value,'CURLFile'))){
77
+        foreach ($data as &$value) {
78
+            if (is_array($value) || (is_object($value) && !is_a($value, 'CURLFile'))) {
79 79
                 $value = json_encode($value);
80 80
             }
81 81
         }
Please login to merge, or discard this patch.
src/settings.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
     public static int $log_size = 10;
27 27
 
28
-    public static string|CURLFile|null $certificate = null;
28
+    public static string | CURLFile | null $certificate = null;
29 29
 
30 30
     public static bool $handler = true;
31 31
 
@@ -59,12 +59,12 @@  discard block
 block discarded – undo
59 59
 
60 60
     public static array $allowed_updates = ['message', 'edited_channel_post', 'callback_query', 'inline_query'];
61 61
 
62
-    public static array|null $db = ['type' => 'json'];
62
+    public static array | null $db = ['type' => 'json'];
63 63
 
64 64
     /**
65 65
      * @internal Only for BPT self usage , Don't use it in your source!
66 66
      */
67
-    public static function init (array|stdClass $settings): void {
67
+    public static function init(array | stdClass $settings): void {
68 68
         $settings = (array) $settings;
69 69
         foreach ($settings as $setting => $value) {
70 70
             try {
@@ -72,10 +72,10 @@  discard block
 block discarded – undo
72 72
                     if (!is_dir('bots_files')) {
73 73
                         mkdir('bots_files');
74 74
                     }
75
-                    if (!is_dir('bots_files/' . $value)) {
76
-                        mkdir('bots_files/' . $value);
75
+                    if (!is_dir('bots_files/'.$value)) {
76
+                        mkdir('bots_files/'.$value);
77 77
                     }
78
-                    $value = 'bots_files/' . $value . '/';
78
+                    $value = 'bots_files/'.$value.'/';
79 79
                 }
80 80
                 self::$$setting = $value;
81 81
             }
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
     /**
109 109
      * @internal Only for BPT self usage , Don't use it in your source!
110 110
      */
111
-    public static function done (): void {
111
+    public static function done(): void {
112 112
         if (self::$logger) {
113 113
             $estimated = round((microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']) * 1000, 2);
114 114
             $status_message = match (true) {
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
         }
124 124
     }
125 125
 
126
-    private static function security (): void {
126
+    private static function security(): void {
127 127
         if (self::$security) {
128 128
             ini_set('magic_quotes_gpc', 'off');
129 129
             ini_set('sql.safe_mode', 'on');
@@ -138,11 +138,11 @@  discard block
 block discarded – undo
138 138
         }
139 139
     }
140 140
 
141
-    private static function secureFolder (): void {
141
+    private static function secureFolder(): void {
142 142
         if (self::$secure_folder) {
143 143
             $address = explode('/', $_SERVER['REQUEST_URI']);
144 144
             unset($address[count($address) - 1]);
145
-            $address = implode('/', $address) . '/BPT.php';
145
+            $address = implode('/', $address).'/BPT.php';
146 146
             $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>";
147 147
             if (!file_exists('.htaccess') || filesize('.htaccess') != strlen($text)) {
148 148
                 file_put_contents('.htaccess', $text);
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
         }
151 151
     }
152 152
 
153
-    private static function getUpdates (): void {
153
+    private static function getUpdates(): void {
154 154
         if (!self::$handler) {
155 155
             logger::write('You can\'t use getUpdates receiver when handler is off , use webhook or use handler', loggerTypes::ERROR);
156 156
             throw new bptException('GETUPDATE_NEED_HANDLER');
Please login to merge, or discard this patch.
src/telegram/request.php 1 patch
Spacing   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -480,95 +480,95 @@  discard block
 block discarded – undo
480 480
     ];
481 481
 
482 482
     private const METHODS_KEYS = [
483
-        'getUpdates'                      => ['offset','limit','timeout','allowed_updates','token','forgot','answer'],
484
-        'setWebhook'                      => ['url','certificate','ip_address','max_connections','allowed_updates','drop_pending_updates','secret_token','token','forgot','answer'],
485
-        'deleteWebhook'                   => ['drop_pending_updates','token','forgot','answer'],
486
-        'getWebhookInfo'                  => ['token','forgot','answer'],
487
-        'getMe'                           => ['token','forgot','answer'],
488
-        'logOut'                          => ['token','forgot','answer'],
489
-        'close'                           => ['token','forgot','answer'],
490
-        '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'],
491
-        'forwardMessage'                  => ['chat_id','from_chat_id','disable_notification','protect_content','message_id','token','forgot','answer'],
492
-        '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'],
493
-        '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'],
494
-        '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'],
495
-        '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'],
496
-        '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'],
497
-        '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'],
498
-        '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'],
499
-        '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'],
500
-        'sendMediaGroup'                  => ['media','chat_id','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','token','forgot','answer'],
501
-        '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'],
502
-        'editMessageLiveLocation'         => ['latitude','longitude','chat_id','message_id','inline_message_id','horizontal_accuracy','heading','proximity_alert_radius','reply_markup','token','forgot','answer'],
503
-        'stopMessageLiveLocation'         => ['chat_id','message_id','inline_message_id','reply_markup','token','forgot','answer'],
504
-        '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'],
505
-        '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'],
506
-        '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'],
507
-        'sendDice'                        => ['chat_id','emoji','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer'],
508
-        'sendChatAction'                  => ['chat_id','action','token','forgot','answer'],
509
-        'getUserProfilePhotos'            => ['user_id','offset','limit','token','forgot','answer'],
510
-        'getFile'                         => ['file_id','token','forgot','answer'],
511
-        'banChatMember'                   => ['chat_id','user_id','until_date','revoke_messages','token','forgot','answer'],
512
-        'unbanChatMember'                 => ['chat_id','user_id','only_if_banned','token','forgot','answer'],
513
-        'restrictChatMember'              => ['permissions','chat_id','user_id','until_date','token','forgot','answer'],
514
-        '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','forgot','answer'],
515
-        'setChatAdministratorCustomTitle' => ['custom_title','chat_id','user_id','token','forgot','answer'],
516
-        'banChatSenderChat'               => ['sender_chat_id','chat_id','token','forgot','answer'],
517
-        'unbanChatSenderChat'             => ['sender_chat_id','chat_id','token','forgot','answer'],
518
-        'setChatPermissions'              => ['permissions','chat_id','token','forgot','answer'],
519
-        'exportChatInviteLink'            => ['chat_id','token','forgot','answer'],
520
-        'createChatInviteLink'            => ['chat_id','name','expire_date','member_limit','creates_join_request','token','forgot','answer'],
521
-        'editChatInviteLink'              => ['invite_link','chat_id','name','expire_date','member_limit','creates_join_request','token','forgot','answer'],
522
-        'revokeChatInviteLink'            => ['invite_link','chat_id','token','forgot','answer'],
523
-        'approveChatJoinRequest'          => ['chat_id','user_id','token','forgot','answer'],
524
-        'declineChatJoinRequest'          => ['chat_id','user_id','token','forgot','answer'],
525
-        'setChatPhoto'                    => ['photo','chat_id','token','forgot','answer'],
526
-        'deleteChatPhoto'                 => ['chat_id','token','forgot','answer'],
527
-        'setChatTitle'                    => ['title','chat_id','token','forgot','answer'],
528
-        'setChatDescription'              => ['chat_id','description','token','forgot','answer'],
529
-        'pinChatMessage'                  => ['message_id','chat_id','disable_notification','token','forgot','answer'],
530
-        'unpinChatMessage'                => ['chat_id','message_id','token','forgot','answer'],
531
-        'unpinAllChatMessages'            => ['chat_id','token','forgot','answer'],
532
-        'leaveChat'                       => ['chat_id','token','forgot','answer'],
533
-        'getChat'                         => ['chat_id','token','forgot','answer'],
534
-        'getChatAdministrators'           => ['chat_id','token','forgot','answer'],
535
-        'getChatMemberCount'              => ['chat_id','token','forgot','answer'],
536
-        'getChatMember'                   => ['chat_id','user_id','token','forgot','answer'],
537
-        'setChatStickerSet'               => ['sticker_set_name','chat_id','token','forgot','answer'],
538
-        'deleteChatStickerSet'            => ['chat_id','token','forgot','answer'],
539
-        'answerCallbackQuery'             => ['callback_query_id','text','show_alert','url','cache_time','token','forgot','answer'],
540
-        'setMyCommands'                   => ['commands','scope','language_code','token','forgot','answer'],
541
-        'deleteMyCommands'                => ['scope','language_code','token','forgot','answer'],
542
-        'getMyCommands'                   => ['scope','language_code','token','forgot','answer'],
543
-        'setChatMenuButton'               => ['chat_id','menu_button','token','forgot','answer'],
544
-        'getChatMenuButton'               => ['chat_id','token','forgot','answer'],
545
-        'setMyDefaultAdministratorRights' => ['rights','for_channels','token','forgot','answer'],
546
-        'getMyDefaultAdministratorRights' => ['for_channels','token','forgot','answer'],
547
-        'editMessageText'                 => ['text','chat_id','message_id','inline_message_id','parse_mode','entities','disable_web_page_preview','reply_markup','token','forgot','answer'],
548
-        'editMessageCaption'              => ['chat_id','message_id','inline_message_id','caption','parse_mode','caption_entities','reply_markup','token','forgot','answer'],
549
-        'editMessageMedia'                => ['media','chat_id','message_id','inline_message_id','reply_markup','token','forgot','answer'],
550
-        'editMessageReplyMarkup'          => ['chat_id','message_id','inline_message_id','reply_markup','token','forgot','answer'],
551
-        'stopPoll'                        => ['chat_id','message_id','reply_markup','token','forgot','answer'],
552
-        'deleteMessage'                   => ['chat_id','message_id','token','forgot','answer'],
553
-        'sendSticker'                     => ['sticker','chat_id','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer'],
554
-        'getStickerSet'                   => ['name','token','forgot','answer'],
483
+        'getUpdates'                      => ['offset', 'limit', 'timeout', 'allowed_updates', 'token', 'forgot', 'answer'],
484
+        'setWebhook'                      => ['url', 'certificate', 'ip_address', 'max_connections', 'allowed_updates', 'drop_pending_updates', 'secret_token', 'token', 'forgot', 'answer'],
485
+        'deleteWebhook'                   => ['drop_pending_updates', 'token', 'forgot', 'answer'],
486
+        'getWebhookInfo'                  => ['token', 'forgot', 'answer'],
487
+        'getMe'                           => ['token', 'forgot', 'answer'],
488
+        'logOut'                          => ['token', 'forgot', 'answer'],
489
+        'close'                           => ['token', 'forgot', 'answer'],
490
+        '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'],
491
+        'forwardMessage'                  => ['chat_id', 'from_chat_id', 'disable_notification', 'protect_content', 'message_id', 'token', 'forgot', 'answer'],
492
+        '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'],
493
+        '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'],
494
+        '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'],
495
+        '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'],
496
+        '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'],
497
+        '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'],
498
+        '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'],
499
+        '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'],
500
+        'sendMediaGroup'                  => ['media', 'chat_id', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'token', 'forgot', 'answer'],
501
+        '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'],
502
+        'editMessageLiveLocation'         => ['latitude', 'longitude', 'chat_id', 'message_id', 'inline_message_id', 'horizontal_accuracy', 'heading', 'proximity_alert_radius', 'reply_markup', 'token', 'forgot', 'answer'],
503
+        'stopMessageLiveLocation'         => ['chat_id', 'message_id', 'inline_message_id', 'reply_markup', 'token', 'forgot', 'answer'],
504
+        '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'],
505
+        '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'],
506
+        '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'],
507
+        'sendDice'                        => ['chat_id', 'emoji', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer'],
508
+        'sendChatAction'                  => ['chat_id', 'action', 'token', 'forgot', 'answer'],
509
+        'getUserProfilePhotos'            => ['user_id', 'offset', 'limit', 'token', 'forgot', 'answer'],
510
+        'getFile'                         => ['file_id', 'token', 'forgot', 'answer'],
511
+        'banChatMember'                   => ['chat_id', 'user_id', 'until_date', 'revoke_messages', 'token', 'forgot', 'answer'],
512
+        'unbanChatMember'                 => ['chat_id', 'user_id', 'only_if_banned', 'token', 'forgot', 'answer'],
513
+        'restrictChatMember'              => ['permissions', 'chat_id', 'user_id', 'until_date', 'token', 'forgot', 'answer'],
514
+        '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', 'forgot', 'answer'],
515
+        'setChatAdministratorCustomTitle' => ['custom_title', 'chat_id', 'user_id', 'token', 'forgot', 'answer'],
516
+        'banChatSenderChat'               => ['sender_chat_id', 'chat_id', 'token', 'forgot', 'answer'],
517
+        'unbanChatSenderChat'             => ['sender_chat_id', 'chat_id', 'token', 'forgot', 'answer'],
518
+        'setChatPermissions'              => ['permissions', 'chat_id', 'token', 'forgot', 'answer'],
519
+        'exportChatInviteLink'            => ['chat_id', 'token', 'forgot', 'answer'],
520
+        'createChatInviteLink'            => ['chat_id', 'name', 'expire_date', 'member_limit', 'creates_join_request', 'token', 'forgot', 'answer'],
521
+        'editChatInviteLink'              => ['invite_link', 'chat_id', 'name', 'expire_date', 'member_limit', 'creates_join_request', 'token', 'forgot', 'answer'],
522
+        'revokeChatInviteLink'            => ['invite_link', 'chat_id', 'token', 'forgot', 'answer'],
523
+        'approveChatJoinRequest'          => ['chat_id', 'user_id', 'token', 'forgot', 'answer'],
524
+        'declineChatJoinRequest'          => ['chat_id', 'user_id', 'token', 'forgot', 'answer'],
525
+        'setChatPhoto'                    => ['photo', 'chat_id', 'token', 'forgot', 'answer'],
526
+        'deleteChatPhoto'                 => ['chat_id', 'token', 'forgot', 'answer'],
527
+        'setChatTitle'                    => ['title', 'chat_id', 'token', 'forgot', 'answer'],
528
+        'setChatDescription'              => ['chat_id', 'description', 'token', 'forgot', 'answer'],
529
+        'pinChatMessage'                  => ['message_id', 'chat_id', 'disable_notification', 'token', 'forgot', 'answer'],
530
+        'unpinChatMessage'                => ['chat_id', 'message_id', 'token', 'forgot', 'answer'],
531
+        'unpinAllChatMessages'            => ['chat_id', 'token', 'forgot', 'answer'],
532
+        'leaveChat'                       => ['chat_id', 'token', 'forgot', 'answer'],
533
+        'getChat'                         => ['chat_id', 'token', 'forgot', 'answer'],
534
+        'getChatAdministrators'           => ['chat_id', 'token', 'forgot', 'answer'],
535
+        'getChatMemberCount'              => ['chat_id', 'token', 'forgot', 'answer'],
536
+        'getChatMember'                   => ['chat_id', 'user_id', 'token', 'forgot', 'answer'],
537
+        'setChatStickerSet'               => ['sticker_set_name', 'chat_id', 'token', 'forgot', 'answer'],
538
+        'deleteChatStickerSet'            => ['chat_id', 'token', 'forgot', 'answer'],
539
+        'answerCallbackQuery'             => ['callback_query_id', 'text', 'show_alert', 'url', 'cache_time', 'token', 'forgot', 'answer'],
540
+        'setMyCommands'                   => ['commands', 'scope', 'language_code', 'token', 'forgot', 'answer'],
541
+        'deleteMyCommands'                => ['scope', 'language_code', 'token', 'forgot', 'answer'],
542
+        'getMyCommands'                   => ['scope', 'language_code', 'token', 'forgot', 'answer'],
543
+        'setChatMenuButton'               => ['chat_id', 'menu_button', 'token', 'forgot', 'answer'],
544
+        'getChatMenuButton'               => ['chat_id', 'token', 'forgot', 'answer'],
545
+        'setMyDefaultAdministratorRights' => ['rights', 'for_channels', 'token', 'forgot', 'answer'],
546
+        'getMyDefaultAdministratorRights' => ['for_channels', 'token', 'forgot', 'answer'],
547
+        'editMessageText'                 => ['text', 'chat_id', 'message_id', 'inline_message_id', 'parse_mode', 'entities', 'disable_web_page_preview', 'reply_markup', 'token', 'forgot', 'answer'],
548
+        'editMessageCaption'              => ['chat_id', 'message_id', 'inline_message_id', 'caption', 'parse_mode', 'caption_entities', 'reply_markup', 'token', 'forgot', 'answer'],
549
+        'editMessageMedia'                => ['media', 'chat_id', 'message_id', 'inline_message_id', 'reply_markup', 'token', 'forgot', 'answer'],
550
+        'editMessageReplyMarkup'          => ['chat_id', 'message_id', 'inline_message_id', 'reply_markup', 'token', 'forgot', 'answer'],
551
+        'stopPoll'                        => ['chat_id', 'message_id', 'reply_markup', 'token', 'forgot', 'answer'],
552
+        'deleteMessage'                   => ['chat_id', 'message_id', 'token', 'forgot', 'answer'],
553
+        'sendSticker'                     => ['sticker', 'chat_id', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer'],
554
+        'getStickerSet'                   => ['name', 'token', 'forgot', 'answer'],
555 555
         'getCustomEmojiStickers'          => ['custom_emoji_ids', 'token', 'return_array', 'forgot', 'answer'],
556
-        'uploadStickerFile'               => ['png_sticker','user_id','token','forgot','answer'],
557
-        'createNewStickerSet'             => ['name','title','emojis','user_id','png_sticker','tgs_sticker','webm_sticker','sticker_type','contains_masks','mask_position','token','forgot','answer'],
558
-        'addStickerToSet'                 => ['name','emojis','user_id','png_sticker','tgs_sticker','webm_sticker','mask_position','token','forgot','answer'],
559
-        'setStickerPositionInSet'         => ['sticker','position','token','forgot','answer'],
560
-        'deleteStickerFromSet'            => ['sticker','token','forgot','answer'],
561
-        'setStickerSetThumb'              => ['name','user_id','thumb','token','forgot','answer'],
562
-        'answerInlineQuery'               => ['results','inline_query_id','cache_time','is_personal','next_offset','switch_pm_text','switch_pm_parameter','token','forgot','answer'],
563
-        'answerWebAppQuery'               => ['web_app_query_id','result','token','forgot','answer'],
564
-        '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'],
565
-        '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'],
566
-        'answerShippingQuery'             => ['ok','shipping_query_id','shipping_options','error_message','token','forgot','answer'],
567
-        'answerPreCheckoutQuery'          => ['ok','pre_checkout_query_id','error_message','token','forgot','answer'],
568
-        'setPassportDataErrors'           => ['errors','user_id','token','forgot','answer'],
569
-        'sendGame'                        => ['game_short_name','chat_id','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer'],
570
-        'setGameScore'                    => ['score','user_id','force','disable_edit_message','chat_id','message_id','inline_message_id','token','forgot','answer'],
571
-        'getGameHighScores'               => ['user_id','chat_id','message_id','inline_message_id','token','forgot','answer'],
556
+        'uploadStickerFile'               => ['png_sticker', 'user_id', 'token', 'forgot', 'answer'],
557
+        'createNewStickerSet'             => ['name', 'title', 'emojis', 'user_id', 'png_sticker', 'tgs_sticker', 'webm_sticker', 'sticker_type', 'contains_masks', 'mask_position', 'token', 'forgot', 'answer'],
558
+        'addStickerToSet'                 => ['name', 'emojis', 'user_id', 'png_sticker', 'tgs_sticker', 'webm_sticker', 'mask_position', 'token', 'forgot', 'answer'],
559
+        'setStickerPositionInSet'         => ['sticker', 'position', 'token', 'forgot', 'answer'],
560
+        'deleteStickerFromSet'            => ['sticker', 'token', 'forgot', 'answer'],
561
+        'setStickerSetThumb'              => ['name', 'user_id', 'thumb', 'token', 'forgot', 'answer'],
562
+        'answerInlineQuery'               => ['results', 'inline_query_id', 'cache_time', 'is_personal', 'next_offset', 'switch_pm_text', 'switch_pm_parameter', 'token', 'forgot', 'answer'],
563
+        'answerWebAppQuery'               => ['web_app_query_id', 'result', 'token', 'forgot', 'answer'],
564
+        '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'],
565
+        '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'],
566
+        'answerShippingQuery'             => ['ok', 'shipping_query_id', 'shipping_options', 'error_message', 'token', 'forgot', 'answer'],
567
+        'answerPreCheckoutQuery'          => ['ok', 'pre_checkout_query_id', 'error_message', 'token', 'forgot', 'answer'],
568
+        'setPassportDataErrors'           => ['errors', 'user_id', 'token', 'forgot', 'answer'],
569
+        'sendGame'                        => ['game_short_name', 'chat_id', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer'],
570
+        'setGameScore'                    => ['score', 'user_id', 'force', 'disable_edit_message', 'chat_id', 'message_id', 'inline_message_id', 'token', 'forgot', 'answer'],
571
+        'getGameHighScores'               => ['user_id', 'chat_id', 'message_id', 'inline_message_id', 'token', 'forgot', 'answer'],
572 572
         'getForumTopicIconStickers'       => ['token', 'return_array', 'forgot', 'answer'],
573 573
         'createForumTopic'                => ['chat_id', 'name', 'icon_color', 'icon_custom_emoji_id', 'token', 'return_array', 'forgot', 'answer'],
574 574
         'editForumTopic'                  => ['chat_id', 'message_thread_id', 'name', 'icon_custom_emoji_id', 'token', 'return_array', 'forgot', 'answer'],
@@ -604,8 +604,8 @@  discard block
 block discarded – undo
604 604
         'logOut'                          => [],
605 605
         'close'                           => [],
606 606
         'sendMessage'                     => ['chat_id'],
607
-        'forwardMessage'                  => ['from_chat_id','message_id'],
608
-        'copyMessage'                     => ['from_chat_id','message_id'],
607
+        'forwardMessage'                  => ['from_chat_id', 'message_id'],
608
+        'copyMessage'                     => ['from_chat_id', 'message_id'],
609 609
         'sendPhoto'                       => ['chat_id'],
610 610
         'sendAudio'                       => ['chat_id'],
611 611
         'sendDocument'                    => ['chat_id'],
@@ -621,15 +621,15 @@  discard block
 block discarded – undo
621 621
         'sendContact'                     => ['chat_id'],
622 622
         'sendPoll'                        => ['chat_id'],
623 623
         'sendDice'                        => ['chat_id'],
624
-        'sendChatAction'                  => ['chat_id','action'],
624
+        'sendChatAction'                  => ['chat_id', 'action'],
625 625
         'getUserProfilePhotos'            => ['user_id'],
626 626
         'getFile'                         => ['file_id'],
627
-        'banChatMember'                   => ['chat_id','user_id'],
628
-        'kickChatMember'                  => ['chat_id','user_id'],
629
-        'unbanChatMember'                 => ['chat_id','user_id'],
630
-        'restrictChatMember'              => ['chat_id','user_id'],
631
-        'promoteChatMember'               => ['chat_id','user_id'],
632
-        'setChatAdministratorCustomTitle' => ['chat_id','user_id'],
627
+        'banChatMember'                   => ['chat_id', 'user_id'],
628
+        'kickChatMember'                  => ['chat_id', 'user_id'],
629
+        'unbanChatMember'                 => ['chat_id', 'user_id'],
630
+        'restrictChatMember'              => ['chat_id', 'user_id'],
631
+        'promoteChatMember'               => ['chat_id', 'user_id'],
632
+        'setChatAdministratorCustomTitle' => ['chat_id', 'user_id'],
633 633
         'banChatSenderChat'               => ['chat_id'],
634 634
         'unbanChatSenderChat'             => ['chat_id'],
635 635
         'setChatPermissions'              => ['chat_id'],
@@ -637,8 +637,8 @@  discard block
 block discarded – undo
637 637
         'createChatInviteLink'            => ['chat_id'],
638 638
         'editChatInviteLink'              => ['chat_id'],
639 639
         'revokeChatInviteLink'            => ['chat_id'],
640
-        'approveChatJoinRequest'          => ['chat_id','user_id'],
641
-        'declineChatJoinRequest'          => ['chat_id','user_id'],
640
+        'approveChatJoinRequest'          => ['chat_id', 'user_id'],
641
+        'declineChatJoinRequest'          => ['chat_id', 'user_id'],
642 642
         'setChatPhoto'                    => ['chat_id'],
643 643
         'deleteChatPhoto'                 => ['chat_id'],
644 644
         'setChatTitle'                    => ['chat_id'],
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
         'getChat'                         => ['chat_id'],
651 651
         'getChatAdministrators'           => ['chat_id'],
652 652
         'getChatMembersCount'             => ['chat_id'],
653
-        'getChatMember'                   => ['chat_id','user_id'],
653
+        'getChatMember'                   => ['chat_id', 'user_id'],
654 654
         'setChatStickerSet'               => ['chat_id'],
655 655
         'deleteChatStickerSet'            => ['chat_id'],
656 656
         'answerCallbackQuery'             => ['callback_query_id'],
@@ -661,12 +661,12 @@  discard block
 block discarded – undo
661 661
         'getChatMenuButton'               => [],
662 662
         'setMyDefaultAdministratorRights' => [],
663 663
         'getMyDefaultAdministratorRights' => [],
664
-        'editMessageText'                 => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']],
665
-        'editMessageCaption'              => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']],
666
-        'editMessageMedia'                => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']],
667
-        'editMessageReplyMarkup'          => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']],
668
-        'stopPoll'                        => ['chat_id','message_id'],
669
-        'deleteMessage'                   => ['chat_id','message_id'],
664
+        'editMessageText'                 => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']],
665
+        'editMessageCaption'              => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']],
666
+        'editMessageMedia'                => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']],
667
+        'editMessageReplyMarkup'          => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']],
668
+        'stopPoll'                        => ['chat_id', 'message_id'],
669
+        'deleteMessage'                   => ['chat_id', 'message_id'],
670 670
         'sendSticker'                     => ['chat_id'],
671 671
         'getStickerSet'                   => [],
672 672
         'uploadStickerFile'               => ['user_id'],
@@ -682,8 +682,8 @@  discard block
 block discarded – undo
682 682
         'answerPreCheckoutQuery'          => ['pre_checkout_query_id'],
683 683
         'setPassportDataErrors'           => ['user_id'],
684 684
         'sendGame'                        => ['chat_id'],
685
-        'setGameScore'                    => ['user_id','inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']],
686
-        'getGameHighScores'               => ['user_id','inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']]
685
+        'setGameScore'                    => ['user_id', 'inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']],
686
+        'getGameHighScores'               => ['user_id', 'inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']]
687 687
     ];
688 688
 
689 689
     private const METHODS_RETURN = [
@@ -737,24 +737,24 @@  discard block
 block discarded – undo
737 737
         'getGameHighScores' => ['BPT\types\gameHighScore']
738 738
     ];
739 739
 
740
-    public static function __callStatic (string $name, array $arguments) {
740
+    public static function __callStatic(string $name, array $arguments) {
741 741
         if (!$action = self::methodAction($name)) {
742
-            logger::write("$name method is not supported",loggerTypes::ERROR);
742
+            logger::write("$name method is not supported", loggerTypes::ERROR);
743 743
             throw new bptException('METHOD_NOT_FOUND');
744 744
         }
745 745
         self::checkArguments($arguments);
746
-        self::keysName($action,$arguments);
747
-        self::readyFile($action,$arguments);
748
-        self::setDefaults($action,$arguments);
746
+        self::keysName($action, $arguments);
747
+        self::readyFile($action, $arguments);
748
+        self::setDefaults($action, $arguments);
749 749
         if (isset($arguments['answer'])) {
750
-            return answer::init($action,$arguments);
750
+            return answer::init($action, $arguments);
751 751
         }
752 752
         else {
753
-            $result = curl::init($action,$arguments);
753
+            $result = curl::init($action, $arguments);
754 754
             if (!is_object($result)) {
755 755
                 return false;
756 756
             }
757
-            return self::processResponse($action,$result);
757
+            return self::processResponse($action, $result);
758 758
         }
759 759
     }
760 760
 
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
         }
765 765
     }
766 766
 
767
-    private static function keysName (string $name, array &$arguments): void {
767
+    private static function keysName(string $name, array &$arguments): void {
768 768
         foreach ($arguments as $key => $argument) {
769 769
             if (is_numeric($key) && isset(self::METHODS_KEYS[$name][$key])) {
770 770
                 $arguments[self::METHODS_KEYS[$name][$key]] = $argument;
@@ -773,7 +773,7 @@  discard block
 block discarded – undo
773 773
         }
774 774
     }
775 775
 
776
-    private static function methodAction(string $name): string|false {
776
+    private static function methodAction(string $name): string | false {
777 777
         return self::METHODS_ACTION[str_replace('_', '', strtolower($name))] ?? false;
778 778
     }
779 779
 
@@ -794,11 +794,11 @@  discard block
 block discarded – undo
794 794
         }
795 795
     }
796 796
 
797
-    private static function methodFile(string $name): array|false {
797
+    private static function methodFile(string $name): array | false {
798 798
         return self::METHODS_WITH_FILE[$name] ?? false;
799 799
     }
800 800
 
801
-    private static function methodReturn(string $name,stdClass $response) {
801
+    private static function methodReturn(string $name, stdClass $response) {
802 802
         if (isset(self::METHODS_RETURN[$name])) {
803 803
             $return = self::METHODS_RETURN[$name];
804 804
             if (is_array($return)) {
@@ -821,13 +821,13 @@  discard block
 block discarded – undo
821 821
         $defaults = self::METHODS_EXTRA_DEFAULTS[$name];
822 822
         foreach ($defaults as $key => $default) {
823 823
             if (is_numeric($key)) {
824
-                if (!isset($arguments[$default])){
824
+                if (!isset($arguments[$default])) {
825 825
                     $arguments[$default] = self::catchFields($default);
826 826
                 }
827 827
             }
828 828
             elseif (isset(BPT::$update->$key) || $key === 'other') {
829 829
                 foreach ($default as $def) {
830
-                    if (!isset($arguments[$def])){
830
+                    if (!isset($arguments[$def])) {
831 831
                         $arguments[$def] = self::catchFields($def);
832 832
                     }
833 833
                 }
@@ -840,7 +840,7 @@  discard block
 block discarded – undo
840 840
         if ($response->ok) {
841 841
             self::$status = true;
842 842
             self::$pure_response = $response;
843
-            return self::methodReturn($name,$response);
843
+            return self::methodReturn($name, $response);
844 844
         }
845 845
         else {
846 846
             self::$status = false;
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
      *
857 857
      * @return int|string|bool
858 858
      */
859
-    public static function catchFields (string $field): int|string|bool {
859
+    public static function catchFields(string $field): int | string | bool {
860 860
         switch ($field) {
861 861
             case fields::CHAT_ID :
862 862
             case fields::FROM_CHAT_ID :
@@ -992,7 +992,7 @@  discard block
 block discarded – undo
992 992
                     default => false
993 993
                 };
994 994
             case fields::URL :
995
-                return 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
995
+                return 'https://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
996 996
             default:
997 997
                 return false;
998 998
         }
Please login to merge, or discard this patch.
src/telegram/telegram.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * telegram class , Adding normal method call to request class and a simple name for being easy to call
17 17
  */
18 18
 class telegram extends request {
19
-    public function __call (string $name, array $arguments) {
19
+    public function __call(string $name, array $arguments) {
20 20
         return request::$name(...$arguments);
21 21
     }
22 22
 
@@ -34,12 +34,12 @@  discard block
 block discarded – undo
34 34
      *
35 35
      * @return bool
36 36
      */
37
-    public static function downloadFile (string|null $destination = null, string|null $file_id = null): bool {
37
+    public static function downloadFile(string | null $destination = null, string | null $file_id = null): bool {
38 38
         $file = telegram::getFile($file_id);
39 39
         if (!isset($file->file_path)) {
40 40
             return false;
41 41
         }
42
-        $file_path = settings::$down_url . 'bot' . settings::$token . '/' . $file->file_path;
42
+        $file_path = settings::$down_url.'bot'.settings::$token.'/'.$file->file_path;
43 43
         return tools::downloadFile($file_path, $destination);
44 44
     }
45 45
 
@@ -57,31 +57,31 @@  discard block
 block discarded – undo
57 57
      *
58 58
      * @return message|bool|responseError
59 59
      */
60
-    public static function sendFile (string $file_id, int|string $chat_id = null, int $message_thread_id = null, string $caption = null, string $parse_mode = null, array $caption_entities = null, bool $disable_notification = null, bool $protect_content = null, int $reply_to_message_id = null, bool $allow_sending_without_reply = null, inlineKeyboardMarkup|replyKeyboardMarkup|replyKeyboardRemove|forceReply|stdClass|array $reply_markup = null, string $token = null, bool $forgot = null, bool $answer = null): message|bool|responseError {
60
+    public static function sendFile(string $file_id, int | string $chat_id = null, int $message_thread_id = null, string $caption = null, string $parse_mode = null, array $caption_entities = null, bool $disable_notification = null, bool $protect_content = null, int $reply_to_message_id = null, bool $allow_sending_without_reply = null, inlineKeyboardMarkup | replyKeyboardMarkup | replyKeyboardRemove | forceReply | stdClass | array $reply_markup = null, string $token = null, bool $forgot = null, bool $answer = null): message | bool | responseError {
61 61
         $type = tools::fileType($file_id);
62 62
         if ($type === fileTypes::VIDEO) {
63
-            return self::sendVideo($file_id,$chat_id,$message_thread_id,null,null,null,null,$caption,$parse_mode,$caption_entities,null,$disable_notification,$protect_content,$reply_to_message_id,$allow_sending_without_reply,$reply_markup,$token,$forgot,$answer);
63
+            return self::sendVideo($file_id, $chat_id, $message_thread_id, null, null, null, null, $caption, $parse_mode, $caption_entities, null, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer);
64 64
         }
65 65
         elseif ($type === fileTypes::VIDEO_NOTE) {
66
-            return self::sendVideoNote($file_id,$chat_id,$message_thread_id,null,null,null,$disable_notification,$protect_content,$reply_to_message_id,$allow_sending_without_reply,$reply_markup,$token,$forgot,$answer);
66
+            return self::sendVideoNote($file_id, $chat_id, $message_thread_id, null, null, null, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer);
67 67
         }
68 68
         elseif ($type === fileTypes::ANIMATION) {
69
-            return self::sendAnimation($file_id,$chat_id,$message_thread_id,null,null,null,null,$caption,$parse_mode,$caption_entities,$disable_notification,$protect_content,$reply_to_message_id,$allow_sending_without_reply,$reply_markup,$token,$forgot,$answer);
69
+            return self::sendAnimation($file_id, $chat_id, $message_thread_id, null, null, null, null, $caption, $parse_mode, $caption_entities, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer);
70 70
         }
71 71
         elseif ($type === fileTypes::AUDIO) {
72
-            return self::sendAudio($file_id,$chat_id,$message_thread_id,$caption,$parse_mode,$caption_entities,null,null,null,null,$disable_notification,$protect_content,$reply_to_message_id,$allow_sending_without_reply,$reply_markup,$token,$forgot,$answer);
72
+            return self::sendAudio($file_id, $chat_id, $message_thread_id, $caption, $parse_mode, $caption_entities, null, null, null, null, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer);
73 73
         }
74 74
         elseif ($type === fileTypes::PHOTO || $type === fileTypes::PROFILE_PHOTO) {
75
-            return self::sendPhoto($file_id,$chat_id,$message_thread_id,$caption,$parse_mode,$caption_entities,$disable_notification,$protect_content,$reply_to_message_id,$allow_sending_without_reply,$reply_markup,$token,$forgot,$answer);
75
+            return self::sendPhoto($file_id, $chat_id, $message_thread_id, $caption, $parse_mode, $caption_entities, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer);
76 76
         }
77 77
         elseif ($type === fileTypes::VOICE) {
78
-            return self::sendVoice($file_id,$chat_id,$message_thread_id,$caption,$parse_mode,$caption_entities,null,$disable_notification,$protect_content,$reply_to_message_id,$allow_sending_without_reply,$reply_markup,$token,$forgot,$answer);
78
+            return self::sendVoice($file_id, $chat_id, $message_thread_id, $caption, $parse_mode, $caption_entities, null, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer);
79 79
         }
80 80
         elseif ($type === fileTypes::STICKER) {
81
-            return self::sendSticker($file_id,$chat_id,$message_thread_id,$disable_notification,$protect_content,$reply_to_message_id,$allow_sending_without_reply,$reply_markup,$token,$forgot,$answer);
81
+            return self::sendSticker($file_id, $chat_id, $message_thread_id, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer);
82 82
         }
83 83
         elseif ($type === fileTypes::DOCUMENT) {
84
-            return self::sendDocument($file_id,$chat_id,$message_thread_id,null,$caption,$parse_mode,$caption_entities,null,$disable_notification,$protect_content,$reply_to_message_id,$allow_sending_without_reply,$reply_markup,$token,$forgot,$answer);
84
+            return self::sendDocument($file_id, $chat_id, $message_thread_id, null, $caption, $parse_mode, $caption_entities, null, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer);
85 85
         }
86 86
         else return false;
87 87
     }
Please login to merge, or discard this patch.
src/receiver/multi/exec.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -17,14 +17,14 @@  discard block
 block discarded – undo
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|null {
20
+    public static function init(): string | null {
21 21
         return self::getUpdate();
22 22
     }
23 23
 
24
-    private static function getUpdate (): string|null {
24
+    private static function getUpdate(): string | null {
25 25
         $up = glob('*.update');
26 26
         if (!isset($up[0])) {
27
-            logger::write('not authorized access denied. IP : '. $_SERVER['REMOTE_ADDR'] ?? 'unknown',loggerTypes::WARNING);
27
+            logger::write('not authorized access denied. IP : '.$_SERVER['REMOTE_ADDR'] ?? 'unknown', loggerTypes::WARNING);
28 28
             BPT::exit();
29 29
         }
30 30
         $up = end($up);
@@ -56,12 +56,12 @@  discard block
 block discarded – undo
56 56
     }
57 57
 
58 58
     private static function create($file) {
59
-        file_put_contents('receiver.php', '<?php $BPT = file_get_contents("php://input");$id = json_decode($BPT, true)[\'update_id\'];file_put_contents("{$_SERVER[\'REMOTE_ADDR\']}-$id.update",$BPT);exec("php ' . $file . ' > /dev/null &");');
59
+        file_put_contents('receiver.php', '<?php $BPT = file_get_contents("php://input");$id = json_decode($BPT, true)[\'update_id\'];file_put_contents("{$_SERVER[\'REMOTE_ADDR\']}-$id.update",$BPT);exec("php '.$file.' > /dev/null &");');
60 60
     }
61 61
 
62 62
     #[ArrayShape(['url' => "array|string|string[]", 'file' => "string"])]
63 63
     private static function setURLS(): array {
64
-        $base_url = (isset(settings::$certificate) ? 'http://' : 'https://') . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
64
+        $base_url = (isset(settings::$certificate) ? 'http://' : 'https://').$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
65 65
         return [
66 66
             'url'=>str_replace(basename($_SERVER['REQUEST_URI']), 'receiver.php', $base_url),
67 67
             'file'=>basename($_SERVER['SCRIPT_NAME'])
Please login to merge, or discard this patch.
src/receiver/multi/curl.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -14,9 +14,9 @@  discard block
 block discarded – undo
14 14
  * curl class , for multiprocessing with curl tricks
15 15
  */
16 16
 class curl extends webhook {
17
-    public static function init (): string|null {
17
+    public static function init(): string | null {
18 18
         if (!self::checkIP()) {
19
-            logger::write('not authorized access denied. IP : '. $_SERVER['REMOTE_ADDR'] ?? 'unknown',loggerTypes::WARNING);
19
+            logger::write('not authorized access denied. IP : '.$_SERVER['REMOTE_ADDR'] ?? 'unknown', loggerTypes::WARNING);
20 20
             BPT::exit();
21 21
         }
22 22
         return self::getUpdate();
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
         return $_SERVER['REMOTE_ADDR'] === $_SERVER['SERVER_ADDR'];
27 27
     }
28 28
 
29
-    private static function getUpdate (): string {
29
+    private static function getUpdate(): string {
30 30
         $input = json_decode(file_get_contents("php://input"), true);
31 31
         webhook::telegramVerify($input['ip']);
32 32
         return $input['update'];
@@ -39,14 +39,14 @@  discard block
 block discarded – undo
39 39
         $urls = self::setURLS();
40 40
         $file = $urls['file'];
41 41
         $timeout = self::getTimeout($file);
42
-        self::create($file,$timeout);
42
+        self::create($file, $timeout);
43 43
         self::setWebhook($urls['url']);
44 44
         lock::set('BPT-MULTI-CURL');
45 45
     }
46 46
 
47
-    private static function getTimeout($url): float|int {
47
+    private static function getTimeout($url): float | int {
48 48
         $times = [];
49
-        for ($i = 0; $i < 10; $i ++) {
49
+        for ($i = 0; $i < 10; $i++) {
50 50
             $ch = curl_init($url);
51 51
             curl_setopt_array($ch, [CURLOPT_POSTFIELDS => json_encode([]), CURLOPT_TIMEOUT_MS => 100, CURLOPT_NOBODY => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_CONNECTTIMEOUT_MS => 100, CURLOPT_HTTPHEADER => ['accept: application/json', 'content-type: application/json']]);
52 52
             $start = microtime(true);
@@ -57,13 +57,13 @@  discard block
 block discarded – undo
57 57
         return $timeout > 50 ? $timeout + 10 : 50;
58 58
     }
59 59
 
60
-    private static function create($file,$timeout) {
61
-        file_put_contents('receiver.php', '<?php http_response_code(200);ignore_user_abort();$ch = curl_init(\'' . $file . '\');curl_setopt_array($ch, [CURLOPT_POSTFIELDS => json_encode([\'update\'=>file_get_contents(\'php://input\'),\'ip\'=>$_SERVER[\'REMOTE_ADDR\']]), CURLOPT_TIMEOUT_MS => ' . $timeout . ', CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_CONNECTTIMEOUT_MS => ' . $timeout . ', CURLOPT_HTTPHEADER => [\'accept: application/json\', \'content-type: application/json\']]);curl_exec($ch);curl_close($ch);?>');
60
+    private static function create($file, $timeout) {
61
+        file_put_contents('receiver.php', '<?php http_response_code(200);ignore_user_abort();$ch = curl_init(\''.$file.'\');curl_setopt_array($ch, [CURLOPT_POSTFIELDS => json_encode([\'update\'=>file_get_contents(\'php://input\'),\'ip\'=>$_SERVER[\'REMOTE_ADDR\']]), CURLOPT_TIMEOUT_MS => '.$timeout.', CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_CONNECTTIMEOUT_MS => '.$timeout.', CURLOPT_HTTPHEADER => [\'accept: application/json\', \'content-type: application/json\']]);curl_exec($ch);curl_close($ch);?>');
62 62
     }
63 63
 
64 64
     #[ArrayShape(['url' => "array|string|string[]", 'file' => "array|string|string[]"])]
65 65
     private static function setURLS(): array {
66
-        $base_url = (isset(settings::$certificate) ? 'http://' : 'https://') . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
66
+        $base_url = (isset(settings::$certificate) ? 'http://' : 'https://').$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
67 67
         $file = basename($_SERVER['REQUEST_URI']);
68 68
         return [
69 69
             'url'=>str_replace($file, 'receiver.php', $base_url),
Please login to merge, or discard this patch.
src/receiver/getUpdates.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -16,23 +16,23 @@  discard block
 block discarded – undo
16 16
  */
17 17
 class getUpdates extends receiver {
18 18
     #[NoReturn]
19
-    public static function init () {
19
+    public static function init() {
20 20
         $last_update_id = self::loadData();
21
-        while(true) {
21
+        while (true) {
22 22
             if (!lock::exist('getUpdate')) {
23
-                $updates = telegram::getUpdates($last_update_id,allowed_updates: settings::$allowed_updates);
23
+                $updates = telegram::getUpdates($last_update_id, allowed_updates: settings::$allowed_updates);
24 24
                 if (!telegram::$status) {
25
-                    logger::write("There is some problem happened , telegram response : \n".json_encode($updates),loggerTypes::ERROR);
26
-                    BPT::exit(print_r($updates,true));
25
+                    logger::write("There is some problem happened , telegram response : \n".json_encode($updates), loggerTypes::ERROR);
26
+                    BPT::exit(print_r($updates, true));
27 27
                 }
28 28
                 self::handleUpdates($updates);
29
-                lock::save('getUpdate',BPT::$update->update_id+1);
30
-                $last_update_id = BPT::$update->update_id+1;
29
+                lock::save('getUpdate', BPT::$update->update_id + 1);
30
+                $last_update_id = BPT::$update->update_id + 1;
31 31
             }
32 32
         }
33 33
     }
34 34
 
35
-    private static function loadData(): bool|int|string {
35
+    private static function loadData(): bool | int | string {
36 36
         if (lock::exist('getUpdate')) {
37 37
             $last_update_id = lock::read('getUpdate');
38 38
         }
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
             self::deleteOldLocks();
41 41
             telegram::deleteWebhook();
42 42
             $last_update_id = 0;
43
-            lock::save('getUpdate',0);
43
+            lock::save('getUpdate', 0);
44 44
         }
45 45
         return $last_update_id;
46 46
     }
Please login to merge, or discard this patch.
src/receiver/webhook.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
     /**
21 21
      * @internal Only for BPT self usage , Don't use it in your source!
22 22
      */
23
-    public static function init () {
23
+    public static function init() {
24 24
         if (settings::$multi) {
25 25
             multi::init();
26 26
         }
@@ -49,24 +49,24 @@  discard block
 block discarded – undo
49 49
         }
50 50
     }
51 51
 
52
-    protected static function setWebhook(string $url,string $secret = '') {
52
+    protected static function setWebhook(string $url, string $secret = '') {
53 53
         $res = telegram::setWebhook($url, settings::$certificate, max_connections: settings::$max_connection, allowed_updates: settings::$allowed_updates, drop_pending_updates: settings::$skip_old_updates, secret_token: $secret);
54 54
         if (!telegram::$status) {
55
-            logger::write("There is some problem happened , telegram response : \n".json_encode($res),loggerTypes::ERROR);
56
-            BPT::exit(print_r($res,true));
55
+            logger::write("There is some problem happened , telegram response : \n".json_encode($res), loggerTypes::ERROR);
56
+            BPT::exit(print_r($res, true));
57 57
         }
58
-        logger::write('Webhook was set successfully',loggerTypes::INFO);
58
+        logger::write('Webhook was set successfully', loggerTypes::INFO);
59 59
     }
60 60
 
61 61
     protected static function checkURL() {
62 62
         if (!(isset($_SERVER['SERVER_NAME']) && isset($_SERVER['REQUEST_URI']))) {
63
-            logger::write('For using webhook receiver , you should open this file in your webserver(by domain)',loggerTypes::ERROR);
63
+            logger::write('For using webhook receiver , you should open this file in your webserver(by domain)', loggerTypes::ERROR);
64 64
             throw new bptException('WEBHOOK_NEED_URL');
65 65
         }
66 66
     }
67 67
 
68 68
     private static function setURL(): string {
69
-        return (isset(settings::$certificate) ? 'http://' : 'https://') . $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME'];
69
+        return (isset(settings::$certificate) ? 'http://' : 'https://').$_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME'];
70 70
     }
71 71
 
72 72
     protected static function setCertificate() {
@@ -89,15 +89,15 @@  discard block
 block discarded – undo
89 89
         self::setCertificate();
90 90
         $url = self::setURL();
91 91
         $secret = !empty(settings::$secret) ? settings::$secret : tools::randomString(64);
92
-        self::setWebhook($url,$secret);
93
-        lock::save('BPT-HOOK',$secret);
92
+        self::setWebhook($url, $secret);
93
+        lock::save('BPT-HOOK', $secret);
94 94
         BPT::exit('Done');
95 95
     }
96 96
 
97 97
     private static function checkSecret() {
98 98
         $secret = lock::read('BPT-HOOK');
99 99
         if ($secret !== self::getSecret()) {
100
-            logger::write('This is not webhook set by BPT, webhook will reset',loggerTypes::WARNING);
100
+            logger::write('This is not webhook set by BPT, webhook will reset', loggerTypes::WARNING);
101 101
             self::processSetWebhook();
102 102
         }
103 103
     }
Please login to merge, or discard this patch.
src/tools.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 /**
30 30
  * tools class , gather what ever you need
31 31
  */
32
-class tools{
32
+class tools {
33 33
     /**
34 34
      * Check the given username format
35 35
      *
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
      *
42 42
      * @return bool
43 43
      */
44
-    public static function isUsername (string $username): bool {
44
+    public static function isUsername(string $username): bool {
45 45
         $length = strlen($username);
46 46
         return !str_contains($username, '__') && $length >= 5 && $length <= 33 && preg_match('/^@?([a-zA-Z])(\w{4,31})$/', $username);
47 47
     }
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
      *
59 59
      * @return bool
60 60
      */
61
-    public static function ipInRange (string $ip, string $range): bool {
61
+    public static function ipInRange(string $ip, string $range): bool {
62 62
         if (!str_contains($range, '/')) {
63 63
             $range .= '/32';
64 64
         }
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
      *
79 79
      * @return bool
80 80
      */
81
-    public static function isTelegram (string $ip): bool {
81
+    public static function isTelegram(string $ip): bool {
82 82
         return tools::ipInRange($ip, '149.154.160.0/20') || tools::ipInRange($ip, '91.108.4.0/22');
83 83
     }
84 84
 
@@ -93,10 +93,10 @@  discard block
 block discarded – undo
93 93
      *
94 94
      * @return bool
95 95
      */
96
-    public static function isCloudFlare (string $ip): bool {
96
+    public static function isCloudFlare(string $ip): bool {
97 97
         $cf_ips = ['173.245.48.0/20', '103.21.244.0/22', '103.22.200.0/22', '103.31.4.0/22', '141.101.64.0/18', '108.162.192.0/18', '190.93.240.0/20', '188.114.96.0/20', '197.234.240.0/22', '198.41.128.0/17', '162.158.0.0/15', '104.16.0.0/12', '104.24.0.0/14', '172.64.0.0/13', '131.0.72.0/22'];
98 98
         foreach ($cf_ips as $cf_ip) {
99
-            if (self::ipInRange($ip,$cf_ip)) {
99
+            if (self::ipInRange($ip, $cf_ip)) {
100 100
                 return true;
101 101
             }
102 102
         }
@@ -114,10 +114,10 @@  discard block
 block discarded – undo
114 114
      *
115 115
      * @return bool
116 116
      */
117
-    public static function isArvanCloud (string $ip): bool {
117
+    public static function isArvanCloud(string $ip): bool {
118 118
         $ar_ips = ['185.143.232.0/22', '92.114.16.80/28', '2.146.0.0/28', '46.224.2.32/29', '89.187.178.96/29', '195.181.173.128/29', '89.187.169.88/29', '188.229.116.16/29', '83.123.255.56/31', '164.138.128.28/31', '94.182.182.28/30', '185.17.115.176/30', '5.213.255.36/31', '138.128.139.144/29', '5.200.14.8/29', '188.122.68.224/29', '188.122.83.176/29', '213.179.217.16/29', '185.179.201.192/29', '43.239.139.192/29', '213.179.197.16/29', '213.179.201.192/29', '109.200.214.248/29', '138.128.141.16/29', '188.122.78.136/29', '213.179.211.32/29', '103.194.164.24/29', '185.50.105.136/29', '213.179.213.16/29', '162.244.52.120/29', '188.122.80.240/29', '109.200.195.64/29', '109.200.199.224/29', '185.228.238.0/28', '94.182.153.24/29', '94.101.182.0/27', '37.152.184.208/28', '78.39.156.192/28', '158.255.77.238/31', '81.12.28.16/29', '176.65.192.202/31', '2.144.3.128/28', '89.45.48.64/28', '37.32.16.0/27', '37.32.17.0/27', '37.32.18.0/27'];
119 119
         foreach ($ar_ips as $ar_ip) {
120
-            if (self::ipInRange($ip,$ar_ip)) {
120
+            if (self::ipInRange($ip, $ar_ip)) {
121 121
                 return true;
122 122
             }
123 123
         }
@@ -137,11 +137,11 @@  discard block
 block discarded – undo
137 137
      *
138 138
      * @return bool|user return array when verify is active and token is true array of telegram getMe result
139 139
      */
140
-    public static function isToken (string $token, bool $verify = false): bool|user {
140
+    public static function isToken(string $token, bool $verify = false): bool | user {
141 141
         if (!preg_match('/^(\d{8,10}):[\w\-]{35}$/', $token)) {
142 142
             return false;
143 143
         }
144
-        if (!$verify){
144
+        if (!$verify) {
145 145
             return true;
146 146
         }
147 147
         $res = telegram::me($token);
@@ -171,14 +171,14 @@  discard block
 block discarded – undo
171 171
      *
172 172
      * @return bool
173 173
      */
174
-    public static function isJoined (array|string|int $ids , int|null $user_id = null): bool {
174
+    public static function isJoined(array | string | int $ids, int | null $user_id = null): bool {
175 175
         if (!is_array($ids)) {
176 176
             $ids = [$ids];
177 177
         }
178 178
         $user_id = $user_id ?? request::catchFields('user_id');
179 179
 
180 180
         foreach ($ids as $id) {
181
-            $check = telegram::getChatMember($id,$user_id);
181
+            $check = telegram::getChatMember($id, $user_id);
182 182
             if (telegram::$status) {
183 183
                 $check = $check->status;
184 184
                 if ($check === chatMemberStatus::LEFT || $check === chatMemberStatus::KICKED) {
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
      *
206 206
      * @return array keys will be id and values will be bool(null for not founded ids)
207 207
      */
208
-    public static function joinChecker (array|string|int $ids , int|null $user_id = null): array {
208
+    public static function joinChecker(array | string | int $ids, int | null $user_id = null): array {
209 209
         if (!is_array($ids)) {
210 210
             $ids = [$ids];
211 211
         }
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 
214 214
         $result = [];
215 215
         foreach ($ids as $id) {
216
-            $check = telegram::getChatMember($id,$user_id);
216
+            $check = telegram::getChatMember($id, $user_id);
217 217
             if (telegram::$status) {
218 218
                 $check = $check->status;
219 219
                 $result[$id] = $check !== chatMemberStatus::LEFT && $check !== chatMemberStatus::KICKED;
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
      * @return bool
234 234
      */
235 235
     public static function isShorted(string $text): bool{
236
-        return preg_match('/^[a-zA-Z0-9]+$/',$text);
236
+        return preg_match('/^[a-zA-Z0-9]+$/', $text);
237 237
     }
238 238
 
239 239
     /**
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
      *
251 251
      * @return string|int|false string for formatted data , int for normal data , false when size can not be found(file not found or ...)
252 252
      */
253
-    public static function size (string $path, bool $format = true): string|int|false {
253
+    public static function size(string $path, bool $format = true): string | int | false {
254 254
         if (filter_var($path, FILTER_VALIDATE_URL)) {
255 255
             $ch = curl_init($path);
256 256
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
      * @return bool
283 283
      * @throws bptException
284 284
      */
285
-    public static function delete (string $path, bool $sub = true): bool {
285
+    public static function delete(string $path, bool $sub = true): bool {
286 286
         if (!is_dir($path)) {
287 287
             return unlink($path);
288 288
         }
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
             return rmdir($path);
291 291
         }
292 292
         if (!$sub) {
293
-            logger::write("tools::delete function used\ndelete function cannot delete folder because its have subFiles and sub parameter haven't true value",loggerTypes::ERROR);
293
+            logger::write("tools::delete function used\ndelete function cannot delete folder because its have subFiles and sub parameter haven't true value", loggerTypes::ERROR);
294 294
             throw new bptException('DELETE_FOLDER_HAS_SUB');
295 295
         }
296 296
         $it = new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS);
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
      * @return bool
313 313
      * @throws bptException when zip extension not found
314 314
      */
315
-    public static function zip (string $path, string $destination): bool {
315
+    public static function zip(string $path, string $destination): bool {
316 316
         if (!extension_loaded('zip')) {
317 317
             logger::write("tools::zip function used\nzip extension is not found , It may not be installed or enabled", loggerTypes::ERROR);
318 318
             throw new bptException('ZIP_EXTENSION_MISSING');
@@ -347,14 +347,14 @@  discard block
 block discarded – undo
347 347
      *
348 348
      * @return bool true on success and false in failure
349 349
      */
350
-    public static function downloadFile (string $url, string $path,int $chunk_size = 512): bool {
350
+    public static function downloadFile(string $url, string $path, int $chunk_size = 512): bool {
351 351
         $file = fopen($url, 'rb');
352 352
         if (!$file) return false;
353 353
         $path = fopen($path, 'wb');
354 354
         if (!$path) return false;
355 355
 
356 356
         $length = $chunk_size * 1024;
357
-        while (!feof($file)){
357
+        while (!feof($file)) {
358 358
             fwrite($path, fread($file, $length), $length);
359 359
         }
360 360
         fclose($path);
@@ -376,10 +376,10 @@  discard block
 block discarded – undo
376 376
      *
377 377
      * @return string
378 378
      */
379
-    public static function byteFormat (int $byte, int $precision = 2): string {
379
+    public static function byteFormat(int $byte, int $precision = 2): string {
380 380
         $rate_counter = 0;
381 381
 
382
-        while ($byte > 1024){
382
+        while ($byte > 1024) {
383 383
             $byte /= 1024;
384 384
             $rate_counter++;
385 385
         }
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
             $byte = round($byte, $precision);
389 389
         }
390 390
 
391
-        return $byte . ' ' . ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'][$rate_counter];
391
+        return $byte.' '.['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'][$rate_counter];
392 392
     }
393 393
 
394 394
     /**
@@ -405,10 +405,10 @@  discard block
 block discarded – undo
405 405
      *
406 406
      * @return string|false return false when mode is incorrect
407 407
      */
408
-    public static function modeEscape (string $text, string $mode = parseMode::HTML): string|false {
408
+    public static function modeEscape(string $text, string $mode = parseMode::HTML): string | false {
409 409
         return match ($mode) {
410
-            parseMode::HTML => str_replace(['&', '<', '>',], ["&amp;", "&lt;", "&gt;",], $text),
411
-            parseMode::MARKDOWN => str_replace(['\\', '_', '*', '`', '['], ['\\\\', '\_', '\*', '\`', '\[',], $text),
410
+            parseMode::HTML => str_replace(['&', '<', '>', ], ["&amp;", "&lt;", "&gt;", ], $text),
411
+            parseMode::MARKDOWN => str_replace(['\\', '_', '*', '`', '['], ['\\\\', '\_', '\*', '\`', '\[', ], $text),
412 412
             parseMode::MARKDOWNV2 => str_replace(
413 413
                 ['_', '*', '[', ']', '(', ')', '~', '`', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!', '\\'],
414 414
                 ['\_', '\*', '\[', '\]', '\(', '\)', '\~', '\`', '\>', '\#', '\+', '\-', '\=', '\|', '\{', '\}', '\.', '\!', '\\\\'],
@@ -447,12 +447,12 @@  discard block
 block discarded – undo
447 447
      * @return array{status: string,year: string,month: string,day: string,hour: string,minute: string,second: string}
448 448
      * @throws Exception
449 449
      */
450
-    public static function timeDiff (int|string $target_time, int|string|null $base_time = null): array {
450
+    public static function timeDiff(int | string $target_time, int | string | null $base_time = null): array {
451 451
         if (!isset($base_time)) {
452 452
             $base_time = '@'.time();
453 453
         }
454 454
         $base_time = new DateTime($base_time);
455
-        $target_time = new DateTime(is_numeric($target_time) ? '@' . $target_time : $target_time . ' +00:00');
455
+        $target_time = new DateTime(is_numeric($target_time) ? '@'.$target_time : $target_time.' +00:00');
456 456
 
457 457
         $diff = $base_time->diff($target_time);
458 458
 
@@ -479,12 +479,12 @@  discard block
 block discarded – undo
479 479
      *
480 480
      * @return string[]|string
481 481
      */
482
-    public static function realEscapeString(string|array $input): string|array {
483
-        if(is_array($input)) {
482
+    public static function realEscapeString(string | array $input): string | array {
483
+        if (is_array($input)) {
484 484
             return array_map(__METHOD__, $input);
485 485
         }
486 486
 
487
-        if(!empty($input) && is_string($input)) {
487
+        if (!empty($input) && is_string($input)) {
488 488
             return str_replace(['\\', "\0", "\n", "\r", "'", '"', "\x1a"], ['\\\\', '\\0', '\\n', '\\r', "\\'", '\\"', '\\Z'], $input);
489 489
         }
490 490
 
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
      *
503 503
      * @return string[]|string
504 504
      */
505
-    public static function strReplaceFirst(string|array $search, string|array $replace, string|array $subject): string|array {
505
+    public static function strReplaceFirst(string | array $search, string | array $replace, string | array $subject): string | array {
506 506
         $pos = strpos($subject, $search);
507 507
         if ($pos !== false) {
508 508
             return substr_replace($subject, $replace, $pos, strlen($search));
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
      *
520 520
      * @return string see possible values in fileType class
521 521
      */
522
-    public static function fileType (string $file_id): string {
522
+    public static function fileType(string $file_id): string {
523 523
         $data = base64_decode(str_pad(strtr($file_id, '-_', '+/'), strlen($file_id) % 4, '='));
524 524
         $new = '';
525 525
         $last = '';
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
                 $last = $char;
534 534
             }
535 535
         }
536
-        $data = unpack('VtypeId/Vdc_id', $new . $last);
536
+        $data = unpack('VtypeId/Vdc_id', $new.$last);
537 537
         $data['typeId'] = $data['typeId'] & ~33554432 & ~16777216;
538 538
         return [
539 539
             fileTypes::THUMBNAIL,
@@ -571,10 +571,10 @@  discard block
 block discarded – undo
571 571
      *
572 572
      * @return string
573 573
      */
574
-    public static function randomString (int $length = 16, string $characters = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'): string {
574
+    public static function randomString(int $length = 16, string $characters = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'): string {
575 575
         $rand_string = '';
576 576
         $char_len = strlen($characters) - 1;
577
-        for ($i = 0; $i < $length; $i ++) {
577
+        for ($i = 0; $i < $length; $i++) {
578 578
             $rand_string .= $characters[rand(0, $char_len)];
579 579
         }
580 580
         return $rand_string;
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
      * @return inlineKeyboardMarkup|replyKeyboardMarkup replyKeyboardMarkup for keyboard and inlineKeyboardMarkup for inline
604 604
      * @throws bptException
605 605
      */
606
-    public static function easyKey(array $keyboard = [], array $inline = []): inlineKeyboardMarkup|replyKeyboardMarkup {
606
+    public static function easyKey(array $keyboard = [], array $inline = []): inlineKeyboardMarkup | replyKeyboardMarkup {
607 607
         if (!empty($keyboard)) {
608 608
             $keyboard_object = new replyKeyboardMarkup();
609 609
             $keyboard_object->setResize_keyboard($keyboard['resize'] ?? true);
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
             return $keyboard_object;
668 668
         }
669 669
         else {
670
-            logger::write("tools::eKey function used\nkeyboard or inline parameter must be set",loggerTypes::ERROR);
670
+            logger::write("tools::eKey function used\nkeyboard or inline parameter must be set", loggerTypes::ERROR);
671 671
             throw new bptException('ARGUMENT_NOT_FOUND_KEYBOARD_INLINE');
672 672
         }
673 673
     }
@@ -684,10 +684,10 @@  discard block
 block discarded – undo
684 684
      *
685 685
      * @return string
686 686
      */
687
-    public static function inviteLink (int $user_id = null, string $bot_username = null): string {
687
+    public static function inviteLink(int $user_id = null, string $bot_username = null): string {
688 688
         if (empty($user_id)) $user_id = telegram::catchFields(fields::USER_ID);
689 689
         if (empty($bot_username)) $bot_username = telegram::getMe()->username;
690
-        return 'https://t.me/' . str_replace('@', '', $bot_username) . '?start=ref_' . tools::shortEncode($user_id);
690
+        return 'https://t.me/'.str_replace('@', '', $bot_username).'?start=ref_'.tools::shortEncode($user_id);
691 691
     }
692 692
 
693 693
     /**
@@ -711,9 +711,9 @@  discard block
 block discarded – undo
711 711
      * @return string|bool|array{hash:string, key:string, iv:string}
712 712
      * @throws bptException
713 713
      */
714
-    public static function crypto (string $action, string $text, string $key = null, string $iv = null): bool|array|string {
714
+    public static function crypto(string $action, string $text, string $key = null, string $iv = null): bool | array | string {
715 715
         if (!extension_loaded('openssl')) {
716
-            logger::write("tools::crypto function used\nopenssl extension is not found , It may not be installed or enabled",loggerTypes::ERROR);
716
+            logger::write("tools::crypto function used\nopenssl extension is not found , It may not be installed or enabled", loggerTypes::ERROR);
717 717
             throw new bptException('OPENSSL_EXTENSION_MISSING');
718 718
         }
719 719
         if ($action === cryptoAction::ENCRYPT) {
@@ -724,17 +724,17 @@  discard block
 block discarded – undo
724 724
         }
725 725
         elseif ($action === cryptoAction::DECRYPT) {
726 726
             if (empty($key)) {
727
-                logger::write("tools::crypto function used\nkey parameter is not set",loggerTypes::ERROR);
727
+                logger::write("tools::crypto function used\nkey parameter is not set", loggerTypes::ERROR);
728 728
                 throw new bptException('ARGUMENT_NOT_FOUND_KEY');
729 729
             }
730 730
             if (empty($iv)) {
731
-                logger::write("tools::crypto function used\niv parameter is not set",loggerTypes::ERROR);
731
+                logger::write("tools::crypto function used\niv parameter is not set", loggerTypes::ERROR);
732 732
                 throw new bptException('ARGUMENT_NOT_FOUND_IV');
733 733
             }
734 734
             return openssl_decrypt(base64_decode($text), 'AES-256-CBC', $key, 1, $iv);
735 735
         }
736 736
         else {
737
-            logger::write("tools::crypto function used\naction is not right, its must be `encode` or `decode`",loggerTypes::WARNING);
737
+            logger::write("tools::crypto function used\naction is not right, its must be `encode` or `decode`", loggerTypes::WARNING);
738 738
             return false;
739 739
         }
740 740
     }
@@ -751,7 +751,7 @@  discard block
 block discarded – undo
751 751
     public static function shortEncode(int $num): string {
752 752
         $codes = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
753 753
         $array = [];
754
-        while ($num > 0){
754
+        while ($num > 0) {
755 755
             $array[] = $num % 62;
756 756
             $num = floor($num / 62);
757 757
         }
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
         foreach ($array as &$value) {
760 760
             $value = $codes[$value];
761 761
         }
762
-        return strrev(implode('',$array));
762
+        return strrev(implode('', $array));
763 763
     }
764 764
 
765 765
     /**
@@ -776,7 +776,7 @@  discard block
 block discarded – undo
776 776
         $num = 0;
777 777
         $text = str_split(strrev($text));
778 778
         foreach ($text as $key=>$value) {
779
-            $num += strpos($codes,$value) * pow(62,$key);
779
+            $num += strpos($codes, $value) * pow(62, $key);
780 780
         }
781 781
         return $num;
782 782
     }
Please login to merge, or discard this patch.