Passed
Push — main ( 41e5bc...ca9ae3 )
by Miaad
01:45
created
src/types/poll.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -29,43 +29,43 @@
 block discarded – undo
29 29
     public int $total_voter_count;
30 30
 
31 31
     /** True, if the poll is closed */
32
-    public null|bool $is_closed = null;
32
+    public null | bool $is_closed = null;
33 33
 
34 34
     /** True, if the poll is anonymous */
35
-    public null|bool $is_anonymous = null;
35
+    public null | bool $is_anonymous = null;
36 36
 
37 37
     /** Poll type, currently can be “regular” or “quiz” */
38 38
     public string $type;
39 39
 
40 40
     /** True, if the poll allows multiple answers */
41
-    public null|bool $allows_multiple_answers = null;
41
+    public null | bool $allows_multiple_answers = null;
42 42
 
43 43
     /**
44 44
      * Optional. 0-based identifier of the correct answer option. Available only for polls in the quiz mode, which
45 45
      * are closed, or was sent (not forwarded) by the bot or to the private chat with the bot.
46 46
      */
47
-    public null|int $correct_option_id = null;
47
+    public null | int $correct_option_id = null;
48 48
 
49 49
     /**
50 50
      * Optional. Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style
51 51
      * poll, 0-200 characters
52 52
      */
53
-    public null|string $explanation = null;
53
+    public null | string $explanation = null;
54 54
 
55 55
     /**
56 56
      * Optional. Special entities like usernames, URLs, bot commands, etc. that appear in the explanation
57 57
      * @var messageEntity[]
58 58
      */
59
-    public null|array $explanation_entities = null;
59
+    public null | array $explanation_entities = null;
60 60
 
61 61
     /** Optional. Amount of time in seconds the poll will be active after creation */
62
-    public null|int $open_period = null;
62
+    public null | int $open_period = null;
63 63
 
64 64
     /** Optional. Point in time (Unix timestamp) when the poll will be automatically closed */
65
-    public null|int $close_date = null;
65
+    public null | int $close_date = null;
66 66
 
67 67
 
68
-    public function __construct(stdClass|null $object = null) {
68
+    public function __construct(stdClass | null $object = null) {
69 69
         if ($object != null) {
70 70
             parent::__construct($object, self::subs);
71 71
         }
Please login to merge, or discard this patch.
src/telegram/request/curl.php 2 patches
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.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -41,8 +41,7 @@  discard block
 block discarded – undo
41 41
             $curl_handler = curl_init(settings::$base_url."/bot$token/");
42 42
             curl_setopt($curl_handler, CURLOPT_RETURNTRANSFER, true);
43 43
             curl_setopt($curl_handler, CURLOPT_SSL_VERIFYPEER, false);
44
-        }
45
-        else{
44
+        } else{
46 45
             $token = settings::$token;
47 46
             if (!isset(self::$curl_handler)){
48 47
                 self::$curl_handler = curl_init(settings::$base_url."/bot$token/");
@@ -64,11 +63,9 @@  discard block
 block discarded – undo
64 63
         if (isset($data['forgot'])) {
65 64
             curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, settings::$forgot_time);
66 65
             unset($data['forgot']);
67
-        }
68
-        elseif ($method === 'getUpdates' || $method === 'setWebhook'){
66
+        } elseif ($method === 'getUpdates' || $method === 'setWebhook'){
69 67
             curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, 5000);
70
-        }
71
-        else{
68
+        } else{
72 69
             curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, settings::$base_timeout);
73 70
         }
74 71
     }
Please login to merge, or discard this patch.
src/settings.php 2 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -78,11 +78,9 @@
 block discarded – undo
78 78
                     $value = 'bots_files/' . $value . '/';
79 79
                 }
80 80
                 self::$$setting = $value;
81
-            }
82
-            catch (TypeError) {
81
+            } catch (TypeError) {
83 82
                 logger::write("$setting setting has wrong type , its set to default value", loggerTypes::WARNING);
84
-            }
85
-            catch (Error) {
83
+            } catch (Error) {
86 84
                 logger::write("$setting setting is not one of library settings", loggerTypes::WARNING);
87 85
             }
88 86
         }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 
29 29
     public static int $log_size = 10;
30 30
 
31
-    public static string|CURLFile|null $certificate = null;
31
+    public static string | CURLFile | null $certificate = null;
32 32
 
33 33
     public static bool $handler = true;
34 34
 
@@ -62,14 +62,14 @@  discard block
 block discarded – undo
62 62
 
63 63
     public static array $allowed_updates = ['message', 'edited_channel_post', 'callback_query', 'inline_query'];
64 64
 
65
-    public static array|null $db = null;
65
+    public static array | null $db = null;
66 66
 
67
-    public static array|null $pay = null;
67
+    public static array | null $pay = null;
68 68
 
69 69
     /**
70 70
      * @internal Only for BPT self usage , Don't use it in your source!
71 71
      */
72
-    public static function init (array|stdClass $settings): void {
72
+    public static function init(array | stdClass $settings): void {
73 73
         $settings = (array) $settings;
74 74
         foreach ($settings as $setting => $value) {
75 75
             try {
@@ -77,10 +77,10 @@  discard block
 block discarded – undo
77 77
                     if (!is_dir(realpath('bots_files'))) {
78 78
                         mkdir('bots_files');
79 79
                     }
80
-                    if (!is_dir(realpath('bots_files/' . $value))) {
81
-                        mkdir('bots_files/' . $value);
80
+                    if (!is_dir(realpath('bots_files/'.$value))) {
81
+                        mkdir('bots_files/'.$value);
82 82
                     }
83
-                    $value = 'bots_files/' . $value . '/';
83
+                    $value = 'bots_files/'.$value.'/';
84 84
                 }
85 85
                 self::$$setting = $value;
86 86
             }
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
     /**
120 120
      * @internal Only for BPT self usage , Don't use it in your source!
121 121
      */
122
-    public static function done (): void {
122
+    public static function done(): void {
123 123
         if (self::$logger) {
124 124
             $estimated = round((microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']) * 1000, 2);
125 125
             $status_message = match (true) {
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
         }
135 135
     }
136 136
 
137
-    private static function security (): void {
137
+    private static function security(): void {
138 138
         if (self::$security) {
139 139
             ini_set('magic_quotes_gpc', 'off');
140 140
             ini_set('sql.safe_mode', 'on');
@@ -149,11 +149,11 @@  discard block
 block discarded – undo
149 149
         }
150 150
     }
151 151
 
152
-    private static function secureFolder (): void {
152
+    private static function secureFolder(): void {
153 153
         if (self::$secure_folder) {
154 154
             $address = explode('/', $_SERVER['REQUEST_URI']);
155 155
             unset($address[count($address) - 1]);
156
-            $address = implode('/', $address) . '/BPT.php';
156
+            $address = implode('/', $address).'/BPT.php';
157 157
             $text = "ErrorDocument 404 $address\nErrorDocument 403 $address\n Options -Indexes\n  Order Deny,Allow\nDeny from all\nAllow from 127.0.0.1\n<Files *.php>\n    Order Allow,Deny\n    Allow from all\n</Files>";
158 158
             $htaccess = realpath('.htaccess');
159 159
             if (!file_exists($htaccess) || filesize($htaccess) != strlen($text)) {
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
         }
163 163
     }
164 164
 
165
-    private static function getUpdates (): void {
165
+    private static function getUpdates(): void {
166 166
         if (!self::$handler) {
167 167
             logger::write('You can\'t use getUpdates receiver when handler is off , use webhook or use handler', loggerTypes::ERROR);
168 168
             throw new bptException('GETUPDATE_NEED_HANDLER');
Please login to merge, or discard this patch.
src/types/forumTopic.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,10 +18,10 @@
 block discarded – undo
18 18
     public int $icon_color;
19 19
 
20 20
     /** Optional. Unique identifier of the custom emoji shown as the topic icon */
21
-    public null|string $icon_custom_emoji_id = null;
21
+    public null | string $icon_custom_emoji_id = null;
22 22
 
23 23
 
24
-    public function __construct(stdClass|null $object = null) {
24
+    public function __construct(stdClass | null $object = null) {
25 25
         if ($object != null) {
26 26
             parent::__construct($object, self::subs);
27 27
         }
Please login to merge, or discard this patch.
src/database/json.php 2 patches
Braces   +43 added lines, -56 removed lines patch added patch discarded remove patch
@@ -195,17 +195,13 @@  discard block
 block discarded – undo
195 195
     public static function process (): void {
196 196
         if (isset(BPT::$update->message)) {
197 197
             self::processMessage(BPT::$update->message);
198
-        }
199
-        elseif (isset(BPT::$update->edited_message)) {
198
+        } elseif (isset(BPT::$update->edited_message)) {
200 199
             self::processMessage(BPT::$update->edited_message);
201
-        }
202
-        elseif (isset(BPT::$update->callback_query)) {
200
+        } elseif (isset(BPT::$update->callback_query)) {
203 201
             self::processCallbackQuery(BPT::$update->callback_query);
204
-        }
205
-        elseif (isset(BPT::$update->inline_query)) {
202
+        } elseif (isset(BPT::$update->inline_query)) {
206 203
             self::processInlineQuery(BPT::$update->inline_query);
207
-        }
208
-        elseif (isset(BPT::$update->chat_member)) {
204
+        } elseif (isset(BPT::$update->chat_member)) {
209 205
             self::processChatMember(BPT::$update->chat_member);
210 206
         }
211 207
     }
@@ -230,8 +226,7 @@  discard block
 block discarded – undo
230 226
             if (empty(self::$group)) {
231 227
                 $category = 'supergroups';
232 228
                 $group_id = self::$supergroup_id;
233
-            }
234
-            else {
229
+            } else {
235 230
                 $category = 'groups';
236 231
                 $group_id = self::$group_id;
237 232
             }
@@ -247,8 +242,7 @@  discard block
 block discarded – undo
247 242
             if (empty(self::$group)) {
248 243
                 $category = 'supergroups';
249 244
                 $group_id = self::$supergroup_id;
250
-            }
251
-            else {
245
+            } else {
252 246
                 $category = 'groups';
253 247
                 $group_id = self::$group_id;
254 248
             }
@@ -265,8 +259,7 @@  discard block
 block discarded – undo
265 259
                 self::$user = self::read($category . '/' . self::$user_id);
266 260
                 self::$old_user = clone self::$user;
267 261
                 self::$user->last_active = time();
268
-            }
269
-            else {
262
+            } else {
270 263
                 self::$ids[$category][] = self::$user_id;
271 264
                 self::$user = (object) self::$user_default_data;
272 265
                 self::$user->first_active = self::$user->last_active = time();
@@ -279,19 +272,16 @@  discard block
 block discarded – undo
279 272
                     }
280 273
                 }
281 274
             }
282
-        }
283
-        elseif ($type === chatType::CHANNEL) {
275
+        } elseif ($type === chatType::CHANNEL) {
284 276
             self::$channel_id = $update->chat->id;
285 277
             if (in_array(self::$channel_id,self::$ids[$category])) {
286 278
                 self::$channel = self::read($category . '/' . self::$channel_id);
287 279
                 self::$old_channel = clone self::$channel;
288
-            }
289
-            else {
280
+            } else {
290 281
                 self::$ids[$category][] = self::$channel_id;
291 282
                 self::$channel = (object) self::$channel_default_data;
292 283
             }
293
-        }
294
-        else {
284
+        } else {
295 285
             self::$user_id = $update->from->id;
296 286
             self::$group_user_id = self::$user_id;
297 287
             $chat_id = $update->chat->id;
@@ -302,22 +292,19 @@  discard block
 block discarded – undo
302 292
                     self::$old_supergroup = clone self::$supergroup;
303 293
                     self::$group_ids = self::read($category . '/' . $chat_id . '/users');
304 294
                     self::$old_group_ids = clone self::$group_ids;
305
-                }
306
-                else {
295
+                } else {
307 296
                     self::$ids[$category][] = $chat_id;
308 297
                     self::$supergroup = (object) self::$supergroup_default_data;
309 298
                     self::$group_ids = [];
310 299
                 }
311
-            }
312
-            else {
300
+            } else {
313 301
                 self::$group_id = $update->chat->id;
314 302
                 if (in_array($chat_id,self::$ids[$category])) {
315 303
                     self::$group = self::read($category . '/' . $chat_id);
316 304
                     self::$old_group = clone self::$group;
317 305
                     self::$group_ids = self::read($category . '/' . $chat_id . '/users');
318 306
                     self::$old_group_ids = clone self::$group_ids;
319
-                }
320
-                else {
307
+                } else {
321 308
                     self::$ids[$category][] = $chat_id;
322 309
                     self::$group = (object) self::$group_default_data;
323 310
                     self::$group_ids = [];
@@ -327,15 +314,16 @@  discard block
 block discarded – undo
327 314
             if (in_array(self::$user_id,self::$group_ids)) {
328 315
                 self::$group_user = self::read($category . '/' . $chat_id . '/' . self::$user_id);
329 316
                 self::$old_group_user = clone self::$group_user;
330
-            }
331
-            else {
317
+            } else {
332 318
                 self::$group_ids[] = self::$user_id;
333 319
                 self::$group_user = (object) self::$group_user_default_data;
334 320
             }
335 321
 
336 322
             self::$user = self::read($category.'/'.self::$user_id);
337 323
             self::$old_user = clone self::$user;
338
-            if (!empty(self::$user)) self::$user->last_active = time();
324
+            if (!empty(self::$user)) {
325
+                self::$user->last_active = time();
326
+            }
339 327
         }
340 328
     }
341 329
 
@@ -349,15 +337,13 @@  discard block
 block discarded – undo
349 337
                 self::$old_user = clone self::$user;
350 338
                 self::$user->last_active = time();
351 339
             }
352
-        }
353
-        elseif ($type === chatType::CHANNEL) {
340
+        } elseif ($type === chatType::CHANNEL) {
354 341
             self::$channel_id = $update->message->chat->id;
355 342
             if (in_array(self::$channel_id,self::$ids[$category])) {
356 343
                 self::$channel = self::read($category . '/' . self::$channel_id);
357 344
                 self::$old_channel = clone self::$channel;
358 345
             }
359
-        }
360
-        else {
346
+        } else {
361 347
             self::$user_id = $update->from->id;
362 348
             $chat_id = $update->message->chat->id;
363 349
             if (in_array($chat_id,self::$ids[$category])) {
@@ -365,8 +351,7 @@  discard block
 block discarded – undo
365 351
                     self::$supergroup_id = $update->message->chat->id;
366 352
                     self::$supergroup = self::read($category . '/' . $chat_id);
367 353
                     self::$old_supergroup = clone self::$supergroup;
368
-                }
369
-                else {
354
+                } else {
370 355
                     self::$group_id = $update->message->chat->id;
371 356
                     self::$group = self::read($category . '/' . $chat_id);
372 357
                     self::$old_group = clone self::$group;
@@ -383,7 +368,9 @@  discard block
 block discarded – undo
383 368
 
384 369
             self::$user = self::read($category.'/'.self::$user_id);
385 370
             self::$old_user = clone self::$user;
386
-            if (!empty(self::$user)) self::$user->last_active = time();
371
+            if (!empty(self::$user)) {
372
+                self::$user->last_active = time();
373
+            }
387 374
         }
388 375
     }
389 376
 
@@ -409,13 +396,11 @@  discard block
 block discarded – undo
409 396
             if (in_array(self::$channel_id,self::$ids[$category])) {
410 397
                 self::$channel = self::read($category . '/' . self::$channel_id);
411 398
                 self::$old_channel = clone self::$channel;
412
-            }
413
-            else {
399
+            } else {
414 400
                 self::$ids[$category][] = self::$channel_id;
415 401
                 self::$channel = (object) self::$channel_default_data;
416 402
             }
417
-        }
418
-        else {
403
+        } else {
419 404
             $chat_id = $update->chat->id;
420 405
             $by_id = $update->from->id;
421 406
             $old_user = $update->old_chat_member;
@@ -431,22 +416,19 @@  discard block
 block discarded – undo
431 416
                     self::$old_supergroup = clone self::$supergroup;
432 417
                     self::$group_ids = self::read($category . '/' . $chat_id . '/users');
433 418
                     self::$old_group_ids = clone self::$group_ids;
434
-                }
435
-                else {
419
+                } else {
436 420
                     self::$ids[$category][] = $chat_id;
437 421
                     self::$supergroup = (object) self::$supergroup_default_data;
438 422
                     self::$group_ids = [];
439 423
                 }
440
-            }
441
-            elseif ($type === chatType::GROUP) {
424
+            } elseif ($type === chatType::GROUP) {
442 425
                 self::$group_id = $chat_id;
443 426
                 if (in_array($chat_id,self::$ids[$category])) {
444 427
                     self::$group = self::read($category . '/' . $chat_id);
445 428
                     self::$old_group = clone self::$group;
446 429
                     self::$group_ids = self::read($category . '/' . $chat_id . '/users');
447 430
                     self::$old_group_ids = clone self::$group_ids;
448
-                }
449
-                else {
431
+                } else {
450 432
                     self::$ids[$category][] = $chat_id;
451 433
                     self::$group = (object) self::$group_default_data;
452 434
                     self::$group_ids = [];
@@ -456,8 +438,7 @@  discard block
 block discarded – undo
456 438
             if (!in_array($user_id,self::$group_ids)) {
457 439
                 self::$group_ids[] = $user_id;
458 440
                 self::$group_user = (object) self::$group_user_default_data;
459
-            }
460
-            else {
441
+            } else {
461 442
                 self::$group_user_id = $by_id == $user_id ? $user_id : $by_id;
462 443
                 self::$group_user = self::read($category . '/' . $chat_id . '/' . self::$group_user_id);
463 444
             }
@@ -470,8 +451,7 @@  discard block
 block discarded – undo
470 451
                         self::$group_user->removed_by = $by_id;
471 452
                     }
472 453
                 }
473
-            }
474
-            else {
454
+            } else {
475 455
                 if ($old_user->status === chatMemberStatus::LEFT || $old_user->status === chatMemberStatus::KICKED) {
476 456
                     self::$group_user->presence = true;
477 457
                     self::$group_user->removed = false;
@@ -481,8 +461,7 @@  discard block
 block discarded – undo
481 461
                         if (!empty($invite_link)) {
482 462
                             self::$group_user->accepted_by = $by_id;
483 463
                             self::$group_user->invited_by = null;
484
-                        }
485
-                        else {
464
+                        } else {
486 465
                             self::$group_user->invited_by = $by_id;
487 466
                             self::$group_user->accepted_by = null;
488 467
                         }
@@ -501,7 +480,9 @@  discard block
 block discarded – undo
501 480
      * @throws bptException
502 481
      */
503 482
     public static function deleteUser (int $user_id = null): bool {
504
-        if (empty($user_id)) $user_id = telegram::catchFields(fields::USER_ID);
483
+        if (empty($user_id)) {
484
+            $user_id = telegram::catchFields(fields::USER_ID);
485
+        }
505 486
         if (!file_exists(realpath(self::$folder . '/privates/' . $user_id . '.json'))) {
506 487
             return false;
507 488
         }
@@ -522,7 +503,9 @@  discard block
 block discarded – undo
522 503
      * @throws bptException
523 504
      */
524 505
     public static function deleteGroup (int $group_id = null): bool {
525
-        if (empty($group_id)) $group_id = telegram::catchFields(fields::CHAT_ID);
506
+        if (empty($group_id)) {
507
+            $group_id = telegram::catchFields(fields::CHAT_ID);
508
+        }
526 509
         if (!file_exists(realpath(self::$folder . '/groups/' . $group_id . '.json'))) {
527 510
             return false;
528 511
         }
@@ -544,7 +527,9 @@  discard block
 block discarded – undo
544 527
      * @throws bptException
545 528
      */
546 529
     public static function deleteSuperGroup (int $group_id = null): bool {
547
-        if (empty($group_id)) $group_id = telegram::catchFields(fields::CHAT_ID);
530
+        if (empty($group_id)) {
531
+            $group_id = telegram::catchFields(fields::CHAT_ID);
532
+        }
548 533
         if (!file_exists(realpath(self::$folder . '/supergroups/' . $group_id . '.json'))) {
549 534
             return false;
550 535
         }
@@ -566,7 +551,9 @@  discard block
 block discarded – undo
566 551
      * @throws bptException
567 552
      */
568 553
     public static function deleteChannel (int $channel_id = null): bool {
569
-        if (empty($channel_id)) $channel_id = telegram::catchFields(fields::CHAT_ID);
554
+        if (empty($channel_id)) {
555
+            $channel_id = telegram::catchFields(fields::CHAT_ID);
556
+        }
570 557
         if (!file_exists(realpath(self::$folder . '/channels/' . $channel_id . '.json'))) {
571 558
             return false;
572 559
         }
Please login to merge, or discard this patch.
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
     /**
104 104
      * @internal Only for BPT self usage , Don't use it in your source!
105 105
      */
106
-    public static function init (): void {
106
+    public static function init(): void {
107 107
         self::$folder = settings::$name.'database';
108 108
         self::$global_default_data = settings::$db['global'] ?? self::$global_default_data;
109 109
         self::setUserDefaultData();
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
         self::load();
116 116
     }
117 117
 
118
-    private static function setUserDefaultData (): void {
118
+    private static function setUserDefaultData(): void {
119 119
         self::$user_default_data = settings::$db['user'] ?? self::$user_default_data;
120 120
         if (!isset(self::$user_default_data['step'])) {
121 121
             self::$user_default_data['step'] = 'none';
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
         }
135 135
     }
136 136
 
137
-    private static function setGroupUserDefaultData (): void {
137
+    private static function setGroupUserDefaultData(): void {
138 138
         self::$group_user_default_data = settings::$db['group_user'] ?? self::$group_user_default_data;
139 139
         if (!isset(self::$group_user_default_data['step'])) {
140 140
             self::$group_user_default_data['step'] = 'none';
@@ -162,10 +162,10 @@  discard block
 block discarded – undo
162 162
         }
163 163
 
164 164
         if (!file_exists(realpath(self::$folder.'/global.json'))) {
165
-            file_put_contents(self::$folder.'/global.json',self::$global_default_data);
165
+            file_put_contents(self::$folder.'/global.json', self::$global_default_data);
166 166
         }
167 167
         if (!file_exists(realpath(self::$folder.'/ids.json'))) {
168
-            file_put_contents(self::$folder.'/ids.json',json_encode([
168
+            file_put_contents(self::$folder.'/ids.json', json_encode([
169 169
                 'privates' => [],
170 170
                 'groups' => [],
171 171
                 'supergroups' => [],
@@ -174,25 +174,25 @@  discard block
 block discarded – undo
174 174
         }
175 175
     }
176 176
 
177
-    private static function load (): void {
177
+    private static function load(): void {
178 178
         self::$global = json_decode(file_get_contents(self::$folder.'/global.json'));
179 179
         self::$old_global = clone self::$global;
180
-        self::$ids = json_decode(file_get_contents(self::$folder.'/ids.json'),true);
180
+        self::$ids = json_decode(file_get_contents(self::$folder.'/ids.json'), true);
181 181
         self::$old_ids = clone self::$ids;
182 182
     }
183 183
 
184
-    private static function read (string $address) {
184
+    private static function read(string $address) {
185 185
         return file_exists(realpath(self::$folder.'/'.$address.'.json')) ? json_decode(file_get_contents(self::$folder.'/'.$address.'.json'), false) : null;
186 186
     }
187 187
 
188
-    private static function write (string $address,string $data): void {
189
-        file_put_contents(self::$folder.'/'.$address.'.json',$data);
188
+    private static function write(string $address, string $data): void {
189
+        file_put_contents(self::$folder.'/'.$address.'.json', $data);
190 190
     }
191 191
 
192 192
     /**
193 193
      * @internal Only for BPT self usage , Don't use it in your source!
194 194
      */
195
-    public static function process (): void {
195
+    public static function process(): void {
196 196
         if (isset(BPT::$update->message)) {
197 197
             self::processMessage(BPT::$update->message);
198 198
         }
@@ -215,16 +215,16 @@  discard block
 block discarded – undo
215 215
      */
216 216
     public static function save(): void {
217 217
         if (self::$user !== self::$old_user && !empty(self::$user_id)) {
218
-            self::write('privates/' . self::$user_id,json_encode(self::$user));
218
+            self::write('privates/'.self::$user_id, json_encode(self::$user));
219 219
         }
220 220
         if (self::$group !== self::$old_group && !empty(self::$group_id)) {
221
-            self::write('groups/' . self::$group_id,json_encode(self::$group));
221
+            self::write('groups/'.self::$group_id, json_encode(self::$group));
222 222
         }
223 223
         if (self::$supergroup !== self::$old_supergroup && !empty(self::$supergroup_id)) {
224
-            self::write('supergroups/' . self::$supergroup_id,json_encode(self::$supergroup));
224
+            self::write('supergroups/'.self::$supergroup_id, json_encode(self::$supergroup));
225 225
         }
226 226
         if (self::$channel !== self::$old_channel && !empty(self::$channel_id)) {
227
-            self::write('channels/' . self::$channel_id,json_encode(self::$channel));
227
+            self::write('channels/'.self::$channel_id, json_encode(self::$channel));
228 228
         }
229 229
         if (self::$group_user !== self::$old_group_user && !empty(self::$group_user_id)) {
230 230
             if (empty(self::$group)) {
@@ -235,13 +235,13 @@  discard block
 block discarded – undo
235 235
                 $category = 'groups';
236 236
                 $group_id = self::$group_id;
237 237
             }
238
-            self::write($category . '/' . $group_id . '/' . self::$group_user_id,json_encode(self::$group_user));
238
+            self::write($category.'/'.$group_id.'/'.self::$group_user_id, json_encode(self::$group_user));
239 239
         }
240 240
         if (self::$ids !== self::$old_ids) {
241
-            self::write('ids',json_encode(self::$ids));
241
+            self::write('ids', json_encode(self::$ids));
242 242
         }
243 243
         if (self::$global !== self::$old_global) {
244
-            self::write('global',json_encode(self::$global));
244
+            self::write('global', json_encode(self::$global));
245 245
         }
246 246
         if (self::$group_ids !== self::$old_group_ids) {
247 247
             if (empty(self::$group)) {
@@ -252,17 +252,17 @@  discard block
 block discarded – undo
252 252
                 $category = 'groups';
253 253
                 $group_id = self::$group_id;
254 254
             }
255
-            self::write($category . '/' . $group_id . '/users',json_encode(self::$group_user));
255
+            self::write($category.'/'.$group_id.'/users', json_encode(self::$group_user));
256 256
         }
257 257
     }
258 258
 
259 259
     private static function processMessage(message $update): void {
260 260
         $type = $update->chat->type;
261
-        $category = $type . 's';
261
+        $category = $type.'s';
262 262
         if ($type === chatType::PRIVATE) {
263 263
             self::$user_id = $update->from->id;
264
-            if (in_array(self::$user_id,self::$ids[$category])) {
265
-                self::$user = self::read($category . '/' . self::$user_id);
264
+            if (in_array(self::$user_id, self::$ids[$category])) {
265
+                self::$user = self::read($category.'/'.self::$user_id);
266 266
                 self::$old_user = clone self::$user;
267 267
                 self::$user->last_active = time();
268 268
             }
@@ -270,10 +270,10 @@  discard block
 block discarded – undo
270 270
                 self::$ids[$category][] = self::$user_id;
271 271
                 self::$user = (object) self::$user_default_data;
272 272
                 self::$user->first_active = self::$user->last_active = time();
273
-                if (isset($update->command) && isset($update->command_payload) && $update->command === 'start' && str_starts_with($update->command_payload,'ref_')) {
274
-                    if (tools::isShorted(substr($update->command_payload,4))) {
275
-                        $referral = tools::shortDecode(substr($update->command_payload,4));
276
-                        if (in_array($referral,self::$ids[$category])) {
273
+                if (isset($update->command) && isset($update->command_payload) && $update->command === 'start' && str_starts_with($update->command_payload, 'ref_')) {
274
+                    if (tools::isShorted(substr($update->command_payload, 4))) {
275
+                        $referral = tools::shortDecode(substr($update->command_payload, 4));
276
+                        if (in_array($referral, self::$ids[$category])) {
277 277
                             self::$user->referral = $referral;
278 278
                         }
279 279
                     }
@@ -282,8 +282,8 @@  discard block
 block discarded – undo
282 282
         }
283 283
         elseif ($type === chatType::CHANNEL) {
284 284
             self::$channel_id = $update->chat->id;
285
-            if (in_array(self::$channel_id,self::$ids[$category])) {
286
-                self::$channel = self::read($category . '/' . self::$channel_id);
285
+            if (in_array(self::$channel_id, self::$ids[$category])) {
286
+                self::$channel = self::read($category.'/'.self::$channel_id);
287 287
                 self::$old_channel = clone self::$channel;
288 288
             }
289 289
             else {
@@ -297,10 +297,10 @@  discard block
 block discarded – undo
297 297
             $chat_id = $update->chat->id;
298 298
             if ($type === chatType::SUPERGROUP) {
299 299
                 self::$supergroup_id = $update->chat->id;
300
-                if (in_array($chat_id,self::$ids[$category])) {
301
-                    self::$supergroup = self::read($category . '/' . $chat_id);
300
+                if (in_array($chat_id, self::$ids[$category])) {
301
+                    self::$supergroup = self::read($category.'/'.$chat_id);
302 302
                     self::$old_supergroup = clone self::$supergroup;
303
-                    self::$group_ids = self::read($category . '/' . $chat_id . '/users');
303
+                    self::$group_ids = self::read($category.'/'.$chat_id.'/users');
304 304
                     self::$old_group_ids = clone self::$group_ids;
305 305
                 }
306 306
                 else {
@@ -311,10 +311,10 @@  discard block
 block discarded – undo
311 311
             }
312 312
             else {
313 313
                 self::$group_id = $update->chat->id;
314
-                if (in_array($chat_id,self::$ids[$category])) {
315
-                    self::$group = self::read($category . '/' . $chat_id);
314
+                if (in_array($chat_id, self::$ids[$category])) {
315
+                    self::$group = self::read($category.'/'.$chat_id);
316 316
                     self::$old_group = clone self::$group;
317
-                    self::$group_ids = self::read($category . '/' . $chat_id . '/users');
317
+                    self::$group_ids = self::read($category.'/'.$chat_id.'/users');
318 318
                     self::$old_group_ids = clone self::$group_ids;
319 319
                 }
320 320
                 else {
@@ -324,8 +324,8 @@  discard block
 block discarded – undo
324 324
                 }
325 325
             }
326 326
 
327
-            if (in_array(self::$user_id,self::$group_ids)) {
328
-                self::$group_user = self::read($category . '/' . $chat_id . '/' . self::$user_id);
327
+            if (in_array(self::$user_id, self::$group_ids)) {
328
+                self::$group_user = self::read($category.'/'.$chat_id.'/'.self::$user_id);
329 329
                 self::$old_group_user = clone self::$group_user;
330 330
             }
331 331
             else {
@@ -341,42 +341,42 @@  discard block
 block discarded – undo
341 341
 
342 342
     private static function processCallbackQuery(callbackQuery $update): void {
343 343
         $type = $update->message->chat->type;
344
-        $category = $type . 's';
344
+        $category = $type.'s';
345 345
         if ($type === chatType::PRIVATE) {
346 346
             self::$user_id = $update->from->id;
347
-            if (in_array(self::$user_id,self::$ids[$category])) {
348
-                self::$user = self::read($category . '/' . self::$user_id);
347
+            if (in_array(self::$user_id, self::$ids[$category])) {
348
+                self::$user = self::read($category.'/'.self::$user_id);
349 349
                 self::$old_user = clone self::$user;
350 350
                 self::$user->last_active = time();
351 351
             }
352 352
         }
353 353
         elseif ($type === chatType::CHANNEL) {
354 354
             self::$channel_id = $update->message->chat->id;
355
-            if (in_array(self::$channel_id,self::$ids[$category])) {
356
-                self::$channel = self::read($category . '/' . self::$channel_id);
355
+            if (in_array(self::$channel_id, self::$ids[$category])) {
356
+                self::$channel = self::read($category.'/'.self::$channel_id);
357 357
                 self::$old_channel = clone self::$channel;
358 358
             }
359 359
         }
360 360
         else {
361 361
             self::$user_id = $update->from->id;
362 362
             $chat_id = $update->message->chat->id;
363
-            if (in_array($chat_id,self::$ids[$category])) {
363
+            if (in_array($chat_id, self::$ids[$category])) {
364 364
                 if ($type === chatType::SUPERGROUP) {
365 365
                     self::$supergroup_id = $update->message->chat->id;
366
-                    self::$supergroup = self::read($category . '/' . $chat_id);
366
+                    self::$supergroup = self::read($category.'/'.$chat_id);
367 367
                     self::$old_supergroup = clone self::$supergroup;
368 368
                 }
369 369
                 else {
370 370
                     self::$group_id = $update->message->chat->id;
371
-                    self::$group = self::read($category . '/' . $chat_id);
371
+                    self::$group = self::read($category.'/'.$chat_id);
372 372
                     self::$old_group = clone self::$group;
373 373
                 }
374
-                self::$group_ids = self::read($category . '/' . $chat_id . '/users');
374
+                self::$group_ids = self::read($category.'/'.$chat_id.'/users');
375 375
                 self::$old_group_ids = clone self::$group_ids;
376 376
             }
377 377
 
378
-            if (in_array(self::$user_id,self::$group_ids)) {
379
-                self::$group_user = self::read($category . '/' . $chat_id . '/' . self::$user_id);
378
+            if (in_array(self::$user_id, self::$group_ids)) {
379
+                self::$group_user = self::read($category.'/'.$chat_id.'/'.self::$user_id);
380 380
                 self::$group_user_id = self::$user_id;
381 381
                 self::$old_group_user = clone self::$group_user;
382 382
             }
@@ -390,10 +390,10 @@  discard block
 block discarded – undo
390 390
     private static function processInlineQuery(inlineQuery $update): void {
391 391
         $type = $update->chat_type;
392 392
         if ($type === chatType::PRIVATE || $type === chatType::SENDER) {
393
-            $category = chatType::PRIVATE . 's';
393
+            $category = chatType::PRIVATE.'s';
394 394
             self::$user_id = $update->from->id;
395
-            if (in_array(self::$user_id,self::$ids[$category])) {
396
-                self::$user = self::read($category . '/' . self::$user_id);
395
+            if (in_array(self::$user_id, self::$ids[$category])) {
396
+                self::$user = self::read($category.'/'.self::$user_id);
397 397
                 self::$old_user = clone self::$user;
398 398
                 self::$user->last_active = time();
399 399
             }
@@ -403,11 +403,11 @@  discard block
 block discarded – undo
403 403
     private static function processChatMember(chatMemberUpdated $update): void {
404 404
         $type = $update->chat->type;
405 405
 
406
-        $category = $type . 's';
406
+        $category = $type.'s';
407 407
         if ($type === chatType::CHANNEL) {
408 408
             self::$channel_id = $update->chat->id;
409
-            if (in_array(self::$channel_id,self::$ids[$category])) {
410
-                self::$channel = self::read($category . '/' . self::$channel_id);
409
+            if (in_array(self::$channel_id, self::$ids[$category])) {
410
+                self::$channel = self::read($category.'/'.self::$channel_id);
411 411
                 self::$old_channel = clone self::$channel;
412 412
             }
413 413
             else {
@@ -426,10 +426,10 @@  discard block
 block discarded – undo
426 426
 
427 427
             if ($type === chatType::SUPERGROUP) {
428 428
                 self::$supergroup_id = $chat_id;
429
-                if (in_array($chat_id,self::$ids[$category])) {
430
-                    self::$supergroup = self::read($category . '/' . $chat_id);
429
+                if (in_array($chat_id, self::$ids[$category])) {
430
+                    self::$supergroup = self::read($category.'/'.$chat_id);
431 431
                     self::$old_supergroup = clone self::$supergroup;
432
-                    self::$group_ids = self::read($category . '/' . $chat_id . '/users');
432
+                    self::$group_ids = self::read($category.'/'.$chat_id.'/users');
433 433
                     self::$old_group_ids = clone self::$group_ids;
434 434
                 }
435 435
                 else {
@@ -440,10 +440,10 @@  discard block
 block discarded – undo
440 440
             }
441 441
             elseif ($type === chatType::GROUP) {
442 442
                 self::$group_id = $chat_id;
443
-                if (in_array($chat_id,self::$ids[$category])) {
444
-                    self::$group = self::read($category . '/' . $chat_id);
443
+                if (in_array($chat_id, self::$ids[$category])) {
444
+                    self::$group = self::read($category.'/'.$chat_id);
445 445
                     self::$old_group = clone self::$group;
446
-                    self::$group_ids = self::read($category . '/' . $chat_id . '/users');
446
+                    self::$group_ids = self::read($category.'/'.$chat_id.'/users');
447 447
                     self::$old_group_ids = clone self::$group_ids;
448 448
                 }
449 449
                 else {
@@ -453,13 +453,13 @@  discard block
 block discarded – undo
453 453
                 }
454 454
             }
455 455
 
456
-            if (!in_array($user_id,self::$group_ids)) {
456
+            if (!in_array($user_id, self::$group_ids)) {
457 457
                 self::$group_ids[] = $user_id;
458 458
                 self::$group_user = (object) self::$group_user_default_data;
459 459
             }
460 460
             else {
461 461
                 self::$group_user_id = $by_id == $user_id ? $user_id : $by_id;
462
-                self::$group_user = self::read($category . '/' . $chat_id . '/' . self::$group_user_id);
462
+                self::$group_user = self::read($category.'/'.$chat_id.'/'.self::$group_user_id);
463 463
             }
464 464
 
465 465
             if ($new_user->status === chatMemberStatus::LEFT || $new_user->status === chatMemberStatus::KICKED) {
@@ -500,9 +500,9 @@  discard block
 block discarded – undo
500 500
      * @return bool
501 501
      * @throws bptException
502 502
      */
503
-    public static function deleteUser (int $user_id = null): bool {
503
+    public static function deleteUser(int $user_id = null): bool {
504 504
         if (empty($user_id)) $user_id = telegram::catchFields(fields::USER_ID);
505
-        if (!file_exists(realpath(self::$folder . '/privates/' . $user_id . '.json'))) {
505
+        if (!file_exists(realpath(self::$folder.'/privates/'.$user_id.'.json'))) {
506 506
             return false;
507 507
         }
508 508
         unset(self::$ids['privates'][array_search($user_id, self::$ids['privates'])]);
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
         if ($user_id === self::$user_id) {
511 511
             self::$user = self::$old_user = null;
512 512
         }
513
-        return tools::delete(self::$folder . '/privates/' . $user_id . '.json');
513
+        return tools::delete(self::$folder.'/privates/'.$user_id.'.json');
514 514
     }
515 515
 
516 516
     /**
@@ -521,18 +521,18 @@  discard block
 block discarded – undo
521 521
      * @return bool
522 522
      * @throws bptException
523 523
      */
524
-    public static function deleteGroup (int $group_id = null): bool {
524
+    public static function deleteGroup(int $group_id = null): bool {
525 525
         if (empty($group_id)) $group_id = telegram::catchFields(fields::CHAT_ID);
526
-        if (!file_exists(realpath(self::$folder . '/groups/' . $group_id . '.json'))) {
526
+        if (!file_exists(realpath(self::$folder.'/groups/'.$group_id.'.json'))) {
527 527
             return false;
528 528
         }
529 529
         unset(self::$ids['groups'][array_search($group_id, self::$ids['groups'])]);
530 530
         sort(self::$ids['groups']);
531
-        tools::delete(self::$folder . '/groups/' . $group_id);
531
+        tools::delete(self::$folder.'/groups/'.$group_id);
532 532
         if ($group_id === self::$group_id) {
533 533
             self::$group = self::$old_group = null;
534 534
         }
535
-        return tools::delete(self::$folder . '/groups/' . $group_id . '.json');
535
+        return tools::delete(self::$folder.'/groups/'.$group_id.'.json');
536 536
     }
537 537
 
538 538
     /**
@@ -543,18 +543,18 @@  discard block
 block discarded – undo
543 543
      * @return bool
544 544
      * @throws bptException
545 545
      */
546
-    public static function deleteSuperGroup (int $group_id = null): bool {
546
+    public static function deleteSuperGroup(int $group_id = null): bool {
547 547
         if (empty($group_id)) $group_id = telegram::catchFields(fields::CHAT_ID);
548
-        if (!file_exists(realpath(self::$folder . '/supergroups/' . $group_id . '.json'))) {
548
+        if (!file_exists(realpath(self::$folder.'/supergroups/'.$group_id.'.json'))) {
549 549
             return false;
550 550
         }
551 551
         unset(self::$ids['supergroups'][array_search($group_id, self::$ids['supergroups'])]);
552 552
         sort(self::$ids['supergroups']);
553
-        tools::delete(self::$folder . '/supergroups/' . $group_id);
553
+        tools::delete(self::$folder.'/supergroups/'.$group_id);
554 554
         if ($group_id === self::$supergroup_id) {
555 555
             self::$supergroup = self::$old_supergroup = null;
556 556
         }
557
-        return tools::delete(self::$folder . '/supergroups/' . $group_id . '.json');
557
+        return tools::delete(self::$folder.'/supergroups/'.$group_id.'.json');
558 558
     }
559 559
 
560 560
     /**
@@ -565,9 +565,9 @@  discard block
 block discarded – undo
565 565
      * @return bool
566 566
      * @throws bptException
567 567
      */
568
-    public static function deleteChannel (int $channel_id = null): bool {
568
+    public static function deleteChannel(int $channel_id = null): bool {
569 569
         if (empty($channel_id)) $channel_id = telegram::catchFields(fields::CHAT_ID);
570
-        if (!file_exists(realpath(self::$folder . '/channels/' . $channel_id . '.json'))) {
570
+        if (!file_exists(realpath(self::$folder.'/channels/'.$channel_id.'.json'))) {
571 571
             return false;
572 572
         }
573 573
         unset(self::$ids['channels'][array_search($channel_id, self::$ids['channels'])]);
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
         if ($channel_id === self::$channel_id) {
576 576
             self::$channel = self::$old_channel = null;
577 577
         }
578
-        return tools::delete(self::$folder . '/channels/' . $channel_id . '.json');
578
+        return tools::delete(self::$folder.'/channels/'.$channel_id.'.json');
579 579
     }
580 580
 
581 581
     /**
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
      *
584 584
      * @return int[]
585 585
      */
586
-    public static function getUsers (): array {
586
+    public static function getUsers(): array {
587 587
         return self::$ids['privates'] ?? [];
588 588
     }
589 589
 
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
      *
593 593
      * @return int[]
594 594
      */
595
-    public static function getGroups (): array {
595
+    public static function getGroups(): array {
596 596
         return self::$ids['groups'] ?? [];
597 597
     }
598 598
 
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
      *
602 602
      * @return int[]
603 603
      */
604
-    public static function getSuperGroups (): array {
604
+    public static function getSuperGroups(): array {
605 605
         return self::$ids['supergroups'] ?? [];
606 606
     }
607 607
 
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
      *
611 611
      * @return int[]
612 612
      */
613
-    public static function getChannels (): array {
613
+    public static function getChannels(): array {
614 614
         return self::$ids['channels'] ?? [];
615 615
     }
616 616
 }
Please login to merge, or discard this patch.
src/logger.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  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 (int $log_size = 10): void {
20
+    public static function init(int $log_size = 10): void {
21 21
         self::$log_size = $log_size;
22 22
         $log_file = realpath(settings::$name.'BPT.log');
23 23
         if (file_exists($log_file) && !(filesize($log_file) > self::$log_size * 1024 * 1024)) {
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
         self::$handler = fopen(settings::$name.'BPT.log', $mode);
32 32
 
33 33
         if ($write) {
34
-            fwrite(self::$handler,"♥♥♥♥♥♥♥♥♥♥♥♥♥♥ BPT Library  ♥♥♥♥♥♥♥♥♥♥♥♥♥♥\nTnx for using our library\nSome information about us :\nAuthor : @Im_Miaad\nHelper : @A_LiReza_ME\nChannel : @BPT_CH\nOur Website : https://bptlib.ir\n\nIf you have any problem with our library\nContact to our supports\n♥♥♥♥♥♥♥♥♥♥♥♥♥♥ BPT Library  ♥♥♥♥♥♥♥♥♥♥♥♥♥♥\nINFO : BPT Library LOG STARTED ...\nwarning : this file automatically deleted when its size reached log_size setting, do not delete it manually\n\n");
34
+            fwrite(self::$handler, "♥♥♥♥♥♥♥♥♥♥♥♥♥♥ BPT Library  ♥♥♥♥♥♥♥♥♥♥♥♥♥♥\nTnx for using our library\nSome information about us :\nAuthor : @Im_Miaad\nHelper : @A_LiReza_ME\nChannel : @BPT_CH\nOur Website : https://bptlib.ir\n\nIf you have any problem with our library\nContact to our supports\n♥♥♥♥♥♥♥♥♥♥♥♥♥♥ BPT Library  ♥♥♥♥♥♥♥♥♥♥♥♥♥♥\nINFO : BPT Library LOG STARTED ...\nwarning : this file automatically deleted when its size reached log_size setting, do not delete it manually\n\n");
35 35
         }
36 36
 
37 37
         if (self::$waited_logs != []) {
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
      * @return void
53 53
      */
54 54
     public static function write(string $data, string $type = loggerTypes::NONE): void {
55
-        $text = date('Y/m/d H:i:s') . ( $type === loggerTypes::NONE ? " : $data\n\n" : " : ⤵\n$type : $data\n\n" );
55
+        $text = date('Y/m/d H:i:s').($type === loggerTypes::NONE ? " : $data\n\n" : " : ⤵\n$type : $data\n\n");
56 56
         if (!is_null(self::$handler)) {
57 57
             fwrite(self::$handler, $text);
58 58
         }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -23,8 +23,7 @@  discard block
 block discarded – undo
23 23
         if (file_exists($log_file) && !(filesize($log_file) > self::$log_size * 1024 * 1024)) {
24 24
             $mode = 'a';
25 25
             $write = false;
26
-        }
27
-        else {
26
+        } else {
28 27
             $mode = 'w';
29 28
             $write = true;
30 29
         }
@@ -55,8 +54,7 @@  discard block
 block discarded – undo
55 54
         $text = date('Y/m/d H:i:s') . ( $type === loggerTypes::NONE ? " : $data\n\n" : " : ⤵\n$type : $data\n\n" );
56 55
         if (!is_null(self::$handler)) {
57 56
             fwrite(self::$handler, $text);
58
-        }
59
-        else {
57
+        } else {
60 58
             self::$waited_logs[] = $text;
61 59
         }
62 60
     }
Please login to merge, or discard this patch.
examples/messenger/bot.php 2 patches
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -5,11 +5,11 @@  discard block
 block discarded – undo
5 5
 use BPT\database\mysql;
6 6
 use BPT\types\message;
7 7
 
8
-if (file_exists('vendor/autoload.php')){
8
+if (file_exists('vendor/autoload.php')) {
9 9
     require 'vendor/autoload.php';
10 10
 }
11
-else{
12
-    if(!file_exists('BPT.phar')) {
11
+else {
12
+    if (!file_exists('BPT.phar')) {
13 13
         copy('https://dl.bptlib.ir/BPT.phar', 'BPT.phar');
14 14
     }
15 15
     require 'BPT.phar';
@@ -35,16 +35,16 @@  discard block
 block discarded – undo
35 35
     const SEND_FAILED = 'Failed!';
36 36
     const SEND_SUCCESSFUL = 'Done!';
37 37
 
38
-    public function __construct(array $settings){
38
+    public function __construct(array $settings) {
39 39
         parent::__construct($settings);
40 40
     }
41 41
 
42
-    public function message(message $update){
42
+    public function message(message $update) {
43 43
         $text = $update->text ?? '';
44 44
         $user_id = $update->from->id;
45 45
 
46 46
         if ($text === '/start') {
47
-            $this->sendMessage(self::START_TEXT,answer: true);
47
+            $this->sendMessage(self::START_TEXT, answer: true);
48 48
         }
49 49
         else {
50 50
             /** You could use both style */
@@ -56,21 +56,21 @@  discard block
 block discarded – undo
56 56
                     $this->sendMessage(self::HELP, answer: true);
57 57
                 }
58 58
                 elseif ($text === '/reply_on') {
59
-                    mysql::update('users',['value'=>'reply_on'],['id'=>$user_id],1);
59
+                    mysql::update('users', ['value'=>'reply_on'], ['id'=>$user_id], 1);
60 60
                     $this->sendMessage(self::REPLY_ON, answer: true);
61 61
                 }
62 62
                 elseif ($text === '/reply_off') {
63
-                    mysql::update('users',['value'=>'reply_off'],['id'=>$user_id],1);
63
+                    mysql::update('users', ['value'=>'reply_off'], ['id'=>$user_id], 1);
64 64
                     $this->sendMessage(self::REPLY_OFF, answer: true);
65 65
                 }
66 66
                 elseif (isset($update->reply_to_message)) {
67 67
                     $reply_message_id = $update->reply_to_message->message_id;
68 68
 
69 69
                     if ($update->reply_to_message->from->id === $user_id) {
70
-                        $check_message = mysql::select('messages', ['receiver_message_id','receiver_id'], [
70
+                        $check_message = mysql::select('messages', ['receiver_message_id', 'receiver_id'], [
71 71
                             'sender_message_id' => $reply_message_id,
72 72
                             'sender_id'         => $user_id
73
-                        ],1);
73
+                        ], 1);
74 74
 
75 75
                         if ($check_message->num_rows > 0) {
76 76
                             $data = $check_message->fetch_object();
@@ -83,15 +83,15 @@  discard block
 block discarded – undo
83 83
                         }
84 84
                     }
85 85
                     else {
86
-                        $data = mysql::select('messages', ['sender_message_id','sender_id'], [
86
+                        $data = mysql::select('messages', ['sender_message_id', 'sender_id'], [
87 87
                             'receiver_message_id' => $reply_message_id,
88 88
                             'receiver_id'         => $user_id
89
-                        ],1)->fetch_object();
89
+                        ], 1)->fetch_object();
90 90
 
91
-                        $value = mysql::select('users','value',['id'=>$user_id])->fetch_object()->value;
91
+                        $value = mysql::select('users', 'value', ['id'=>$user_id])->fetch_object()->value;
92 92
                         $receiver_id = $data->sender_id;
93 93
                         if ($value === 'reply_on') {
94
-                            mysql::update('users',['value'=>''],['id'=>$user_id]);
94
+                            mysql::update('users', ['value'=>''], ['id'=>$user_id]);
95 95
                             $result = $this->copyMessage($receiver_id, reply_to_message_id: $data->sender_message_id);
96 96
                         }
97 97
                         else {
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 
102 102
                     if (self::$status) {
103 103
                         mysql::insert('messages',
104
-                            ['sender_message_id','sender_id','receiver_message_id','receiver_id'],
105
-                            [$message_id,$user_id,$result->message_id,$receiver_id]
104
+                            ['sender_message_id', 'sender_id', 'receiver_message_id', 'receiver_id'],
105
+                            [$message_id, $user_id, $result->message_id, $receiver_id]
106 106
                         );
107 107
                         if (self::SHOW_STATUS) {
108 108
                             $this->sendMessage(self::SEND_SUCCESSFUL, answer: true);
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
             else {
117 117
                 $username = $update->from->username;
118 118
                 if (empty($username)) {
119
-                    $name = $update->from->first_name . (!empty($update->from->last_name) ? (' ' . $update->from->last_name) : '');
119
+                    $name = $update->from->first_name.(!empty($update->from->last_name) ? (' '.$update->from->last_name) : '');
120 120
                     $keyboard = [
121 121
                         'inline_keyboard' => [
122 122
                             [
@@ -154,33 +154,33 @@  discard block
 block discarded – undo
154 154
                 }
155 155
                 if (isset($update->reply_to_message)) {
156 156
                     $reply_message_id = $update->reply_to_message->message_id;
157
-                    if ($update->reply_to_message->from->id === $user_id){
157
+                    if ($update->reply_to_message->from->id === $user_id) {
158 158
                         $check_message = mysql::select('messages', 'receiver_message_id', [
159 159
                             'sender_message_id' => $reply_message_id,
160 160
                             'sender_id'         => $user_id
161
-                        ],1);
161
+                        ], 1);
162 162
                         if ($check_message->num_rows > 0) {
163
-                            $result = $this->copyMessage(self::ADMIN, reply_to_message_id: $check_message->fetch_object()->receiver_message_id,reply_markup: $keyboard);
163
+                            $result = $this->copyMessage(self::ADMIN, reply_to_message_id: $check_message->fetch_object()->receiver_message_id, reply_markup: $keyboard);
164 164
                         }
165 165
                         else {
166
-                            $result = $this->copyMessage(self::ADMIN,reply_markup: $keyboard);
166
+                            $result = $this->copyMessage(self::ADMIN, reply_markup: $keyboard);
167 167
                         }
168 168
                     }
169 169
                     else {
170 170
                         $check_message = mysql::select('messages', 'sender_message_id', [
171 171
                             'receiver_message_id' => $reply_message_id,
172 172
                             'receiver_id'         => $user_id
173
-                        ],1);
173
+                        ], 1);
174 174
                         if ($check_message->num_rows > 0) {
175
-                            $result = $this->copyMessage(self::ADMIN, reply_to_message_id: $check_message->fetch_object()->sender_message_id,reply_markup: $keyboard);
175
+                            $result = $this->copyMessage(self::ADMIN, reply_to_message_id: $check_message->fetch_object()->sender_message_id, reply_markup: $keyboard);
176 176
                         }
177 177
                         else {
178
-                            $result = $this->copyMessage(self::ADMIN,reply_markup: $keyboard);
178
+                            $result = $this->copyMessage(self::ADMIN, reply_markup: $keyboard);
179 179
                         }
180 180
                     }
181 181
                 }
182 182
                 else {
183
-                    $result = $this->copyMessage(self::ADMIN,reply_markup: $keyboard);
183
+                    $result = $this->copyMessage(self::ADMIN, reply_markup: $keyboard);
184 184
                 }
185 185
 
186 186
                 /**
@@ -189,8 +189,8 @@  discard block
 block discarded – undo
189 189
                  */
190 190
                 if (self::$status) {
191 191
                     mysql::insert('messages',
192
-                        ['sender_message_id','sender_id','receiver_message_id','receiver_id'],
193
-                        [$message_id,$user_id,$result->message_id,self::ADMIN]
192
+                        ['sender_message_id', 'sender_id', 'receiver_message_id', 'receiver_id'],
193
+                        [$message_id, $user_id, $result->message_id, self::ADMIN]
194 194
                     );
195 195
                     if (self::SHOW_STATUS) {
196 196
                         $this->sendMessage(self::SEND_SUCCESSFUL, answer: true);
Please login to merge, or discard this patch.
Braces   +16 added lines, -32 removed lines patch added patch discarded remove patch
@@ -7,8 +7,7 @@  discard block
 block discarded – undo
7 7
 
8 8
 if (file_exists('vendor/autoload.php')){
9 9
     require 'vendor/autoload.php';
10
-}
11
-else{
10
+} else{
12 11
     if(!file_exists('BPT.phar')) {
13 12
         copy('https://dl.bptlib.ir/BPT.phar', 'BPT.phar');
14 13
     }
@@ -45,8 +44,7 @@  discard block
 block discarded – undo
45 44
 
46 45
         if ($text === '/start') {
47 46
             $this->sendMessage(self::START_TEXT,answer: true);
48
-        }
49
-        else {
47
+        } else {
50 48
             /** You could use both style */
51 49
             $message_id = $update->message_id;
52 50
             #$message_id = $update->id;
@@ -54,16 +52,13 @@  discard block
 block discarded – undo
54 52
             if (self::ADMIN === $user_id) {
55 53
                 if ($text === '/help') {
56 54
                     $this->sendMessage(self::HELP, answer: true);
57
-                }
58
-                elseif ($text === '/reply_on') {
55
+                } elseif ($text === '/reply_on') {
59 56
                     mysql::update('users',['value'=>'reply_on'],['id'=>$user_id],1);
60 57
                     $this->sendMessage(self::REPLY_ON, answer: true);
61
-                }
62
-                elseif ($text === '/reply_off') {
58
+                } elseif ($text === '/reply_off') {
63 59
                     mysql::update('users',['value'=>'reply_off'],['id'=>$user_id],1);
64 60
                     $this->sendMessage(self::REPLY_OFF, answer: true);
65
-                }
66
-                elseif (isset($update->reply_to_message)) {
61
+                } elseif (isset($update->reply_to_message)) {
67 62
                     $reply_message_id = $update->reply_to_message->message_id;
68 63
 
69 64
                     if ($update->reply_to_message->from->id === $user_id) {
@@ -76,13 +71,11 @@  discard block
 block discarded – undo
76 71
                             $data = $check_message->fetch_object();
77 72
                             $receiver_id = $data->receiver_id;
78 73
                             $result = $this->copyMessage($receiver_id, reply_to_message_id: $data->receiver_message_id);
79
-                        }
80
-                        else {
74
+                        } else {
81 75
                             $this->sendMessage(self::NOT_FOUND, answer: true);
82 76
                             return;
83 77
                         }
84
-                    }
85
-                    else {
78
+                    } else {
86 79
                         $data = mysql::select('messages', ['sender_message_id','sender_id'], [
87 80
                             'receiver_message_id' => $reply_message_id,
88 81
                             'receiver_id'         => $user_id
@@ -93,8 +86,7 @@  discard block
 block discarded – undo
93 86
                         if ($value === 'reply_on') {
94 87
                             mysql::update('users',['value'=>''],['id'=>$user_id]);
95 88
                             $result = $this->copyMessage($receiver_id, reply_to_message_id: $data->sender_message_id);
96
-                        }
97
-                        else {
89
+                        } else {
98 90
                             $result = $this->copyMessage($receiver_id);
99 91
                         }
100 92
                     }
@@ -107,13 +99,11 @@  discard block
 block discarded – undo
107 99
                         if (self::SHOW_STATUS) {
108 100
                             $this->sendMessage(self::SEND_SUCCESSFUL, answer: true);
109 101
                         }
110
-                    }
111
-                    else {
102
+                    } else {
112 103
                         $this->sendMessage(self::SEND_FAILED, answer: true);
113 104
                     }
114 105
                 }
115
-            }
116
-            else {
106
+            } else {
117 107
                 $username = $update->from->username;
118 108
                 if (empty($username)) {
119 109
                     $name = $update->from->first_name . (!empty($update->from->last_name) ? (' ' . $update->from->last_name) : '');
@@ -137,8 +127,7 @@  discard block
 block discarded – undo
137 127
                             ]
138 128
                         ]
139 129
                     ];
140
-                }
141
-                else {
130
+                } else {
142 131
                     $keyboard = [
143 132
                         'inline_keyboard' => [
144 133
                             [
@@ -161,25 +150,21 @@  discard block
 block discarded – undo
161 150
                         ],1);
162 151
                         if ($check_message->num_rows > 0) {
163 152
                             $result = $this->copyMessage(self::ADMIN, reply_to_message_id: $check_message->fetch_object()->receiver_message_id,reply_markup: $keyboard);
164
-                        }
165
-                        else {
153
+                        } else {
166 154
                             $result = $this->copyMessage(self::ADMIN,reply_markup: $keyboard);
167 155
                         }
168
-                    }
169
-                    else {
156
+                    } else {
170 157
                         $check_message = mysql::select('messages', 'sender_message_id', [
171 158
                             'receiver_message_id' => $reply_message_id,
172 159
                             'receiver_id'         => $user_id
173 160
                         ],1);
174 161
                         if ($check_message->num_rows > 0) {
175 162
                             $result = $this->copyMessage(self::ADMIN, reply_to_message_id: $check_message->fetch_object()->sender_message_id,reply_markup: $keyboard);
176
-                        }
177
-                        else {
163
+                        } else {
178 164
                             $result = $this->copyMessage(self::ADMIN,reply_markup: $keyboard);
179 165
                         }
180 166
                     }
181
-                }
182
-                else {
167
+                } else {
183 168
                     $result = $this->copyMessage(self::ADMIN,reply_markup: $keyboard);
184 169
                 }
185 170
 
@@ -195,8 +180,7 @@  discard block
 block discarded – undo
195 180
                     if (self::SHOW_STATUS) {
196 181
                         $this->sendMessage(self::SEND_SUCCESSFUL, answer: true);
197 182
                     }
198
-                }
199
-                else {
183
+                } else {
200 184
                     $this->sendMessage(self::SEND_FAILED, answer: true);
201 185
                 }
202 186
             }
Please login to merge, or discard this patch.
src/types/user.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -21,37 +21,37 @@  discard block
 block discarded – undo
21 21
     public int $id;
22 22
 
23 23
     /** True, if this user is a bot */
24
-    public null|bool $is_bot = null;
24
+    public null | bool $is_bot = null;
25 25
 
26 26
     /** User's or bot's first name */
27
-    public null|string $first_name = null;
27
+    public null | string $first_name = null;
28 28
 
29 29
     /** Optional. User's or bot's last name */
30
-    public null|string $last_name = null;
30
+    public null | string $last_name = null;
31 31
 
32 32
     /** Optional. User's or bot's username */
33
-    public null|string $username = null;
33
+    public null | string $username = null;
34 34
 
35 35
     /** Optional. IETF language tag of the user's language */
36
-    public null|string $language_code = null;
36
+    public null | string $language_code = null;
37 37
 
38 38
     /** Optional. True, if this user is a Telegram Premium user */
39
-    public null|bool $is_premium = null;
39
+    public null | bool $is_premium = null;
40 40
 
41 41
     /** Optional. True, if this user added the bot to the attachment menu */
42
-    public null|bool $added_to_attachment_menu = null;
42
+    public null | bool $added_to_attachment_menu = null;
43 43
 
44 44
     /** Optional. True, if the bot can be invited to groups. Returned only in getMe. */
45
-    public null|bool $can_join_groups = null;
45
+    public null | bool $can_join_groups = null;
46 46
 
47 47
     /** Optional. True, if privacy mode is disabled for the bot. Returned only in getMe. */
48
-    public null|bool $can_read_all_group_messages = null;
48
+    public null | bool $can_read_all_group_messages = null;
49 49
 
50 50
     /** Optional. True, if the bot supports inline queries. Returned only in getMe. */
51
-    public null|bool $supports_inline_queries = null;
51
+    public null | bool $supports_inline_queries = null;
52 52
 
53 53
 
54
-    public function __construct(stdClass|null $object = null) {
54
+    public function __construct(stdClass | null $object = null) {
55 55
         if ($object != null) {
56 56
             parent::__construct($object, self::subs);
57 57
         }
@@ -62,10 +62,10 @@  discard block
 block discarded – undo
62 62
     }
63 63
 
64 64
     public function fullName(bool $nameFirst = true): string {
65
-        return trim($nameFirst ? $this->first_name . ' ' . $this->last_name : $this->last_name . ' ' . $this->first_name);
65
+        return trim($nameFirst ? $this->first_name.' '.$this->last_name : $this->last_name.' '.$this->first_name);
66 66
     }
67 67
 
68
-    public function getProfiles(int|null $offset = null, int|null $limit = null): userProfilePhotos|responseError {
69
-        return telegram::getUserProfilePhotos($this->id,$offset,$limit);
68
+    public function getProfiles(int | null $offset = null, int | null $limit = null): userProfilePhotos | responseError {
69
+        return telegram::getUserProfilePhotos($this->id, $offset, $limit);
70 70
     }
71 71
 }
Please login to merge, or discard this patch.
src/types/photoSize.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,10 +28,10 @@  discard block
 block discarded – undo
28 28
     public int $height;
29 29
 
30 30
     /** Optional. File size in bytes */
31
-    public null|int $file_size = null;
31
+    public null | int $file_size = null;
32 32
 
33 33
 
34
-    public function __construct(stdClass|null $object = null) {
34
+    public function __construct(stdClass | null $object = null) {
35 35
         if ($object != null) {
36 36
             parent::__construct($object, self::subs);
37 37
         }
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
      *
53 53
      * @return bool|string string will be returned when destination doesn't set
54 54
      */
55
-    public function download(string|null $destination = null): bool|string {
56
-        return telegram::downloadFile($destination ?? 'unknown.jpg',$this->file_id);
55
+    public function download(string | null $destination = null): bool | string {
56
+        return telegram::downloadFile($destination ?? 'unknown.jpg', $this->file_id);
57 57
     }
58 58
 
59 59
     public function link(): string {
Please login to merge, or discard this patch.