@@ -217,8 +217,9 @@ discard block |
||
217 | 217 | if (telegram::$status) { |
218 | 218 | $check = $check->status; |
219 | 219 | $result[$id] = $check !== chatMemberStatus::LEFT && $check !== chatMemberStatus::KICKED; |
220 | + } else { |
|
221 | + $result[$id] = null; |
|
220 | 222 | } |
221 | - else $result[$id] = null; |
|
222 | 223 | } |
223 | 224 | return $result; |
224 | 225 | } |
@@ -259,8 +260,7 @@ discard block |
||
259 | 260 | curl_exec($ch); |
260 | 261 | $size = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD); |
261 | 262 | curl_close($ch); |
262 | - } |
|
263 | - else { |
|
263 | + } else { |
|
264 | 264 | $path = realpath($path); |
265 | 265 | $size = file_exists($path) ? filesize($path) : false; |
266 | 266 | } |
@@ -331,8 +331,7 @@ discard block |
||
331 | 331 | $zip->addFile($filePath, substr($filePath, $root_len)); |
332 | 332 | } |
333 | 333 | } |
334 | - } |
|
335 | - else { |
|
334 | + } else { |
|
336 | 335 | $zip->addFile($path, basename($path)); |
337 | 336 | } |
338 | 337 | return $zip->close(); |
@@ -351,9 +350,13 @@ discard block |
||
351 | 350 | */ |
352 | 351 | public static function downloadFile (string $url, string $path,int $chunk_size = 512): bool { |
353 | 352 | $file = fopen($url, 'rb'); |
354 | - if (!$file) return false; |
|
353 | + if (!$file) { |
|
354 | + return false; |
|
355 | + } |
|
355 | 356 | $path = fopen($path, 'wb'); |
356 | - if (!$path) return false; |
|
357 | + if (!$path) { |
|
358 | + return false; |
|
359 | + } |
|
357 | 360 | |
358 | 361 | $length = $chunk_size * 1024; |
359 | 362 | while (!feof($file)){ |
@@ -462,8 +465,9 @@ discard block |
||
462 | 465 | foreach ($string as $k => &$v) { |
463 | 466 | if ($diff->$v) { |
464 | 467 | $v = $diff->$v; |
468 | + } else { |
|
469 | + unset($string[$k]); |
|
465 | 470 | } |
466 | - else unset($string[$k]); |
|
467 | 471 | } |
468 | 472 | $string['status'] = $base_time < $target_time ? 'later' : 'ago'; |
469 | 473 | |
@@ -529,8 +533,7 @@ discard block |
||
529 | 533 | if ($last === "\0") { |
530 | 534 | $new .= str_repeat($last, ord($char)); |
531 | 535 | $last = ''; |
532 | - } |
|
533 | - else { |
|
536 | + } else { |
|
534 | 537 | $new .= $last; |
535 | 538 | $last = $char; |
536 | 539 | } |
@@ -614,7 +617,9 @@ discard block |
||
614 | 617 | } |
615 | 618 | $rows = []; |
616 | 619 | foreach ($keyboard as $row) { |
617 | - if (!is_array($row)) continue; |
|
620 | + if (!is_array($row)) { |
|
621 | + continue; |
|
622 | + } |
|
618 | 623 | $buttons = []; |
619 | 624 | foreach ($row as $base_button) { |
620 | 625 | $button_info = explode('||', $base_button); |
@@ -623,15 +628,12 @@ discard block |
||
623 | 628 | if (count($button_info) > 1) { |
624 | 629 | if ($button_info[1] === 'con') { |
625 | 630 | $button->setRequest_contact(true); |
626 | - } |
|
627 | - elseif ($button_info[1] === 'loc') { |
|
631 | + } elseif ($button_info[1] === 'loc') { |
|
628 | 632 | $button->setRequest_location(true); |
629 | - } |
|
630 | - elseif ($button_info[1] === 'poll') { |
|
633 | + } elseif ($button_info[1] === 'poll') { |
|
631 | 634 | $type = $button_info[2] === pollType::QUIZ ? pollType::QUIZ : pollType::REGULAR; |
632 | 635 | $button->setRequest_poll((new keyboardButtonPollType())->setType($type)); |
633 | - } |
|
634 | - elseif ($button_info[1] === 'web' && isset($button_info[2])) { |
|
636 | + } elseif ($button_info[1] === 'web' && isset($button_info[2])) { |
|
635 | 637 | $url = $button_info[2]; |
636 | 638 | $button->setWeb_app((new webAppInfo())->setUrl($url)); |
637 | 639 | } |
@@ -642,8 +644,7 @@ discard block |
||
642 | 644 | } |
643 | 645 | $keyboard_object->setKeyboard($rows); |
644 | 646 | return $keyboard_object; |
645 | - } |
|
646 | - elseif (!empty($inline)) { |
|
647 | + } elseif (!empty($inline)) { |
|
647 | 648 | $keyboard_object = new inlineKeyboardMarkup(); |
648 | 649 | $rows = []; |
649 | 650 | foreach ($inline as $row) { |
@@ -653,12 +654,10 @@ discard block |
||
653 | 654 | if (isset($button_info[1])) { |
654 | 655 | if (filter_var($button_info[1], FILTER_VALIDATE_URL) && str_starts_with($button_info[1], 'http')) { |
655 | 656 | $button->setText($button_info[0])->setUrl($button_info[1]); |
656 | - } |
|
657 | - else { |
|
657 | + } else { |
|
658 | 658 | $button->setText($button_info[0])->setCallback_data($button_info[1]); |
659 | 659 | } |
660 | - } |
|
661 | - else { |
|
660 | + } else { |
|
662 | 661 | $button->setText($button_info[0])->setUrl('https://t.me/BPT_CH'); |
663 | 662 | } |
664 | 663 | $buttons[] = $button; |
@@ -667,8 +666,7 @@ discard block |
||
667 | 666 | } |
668 | 667 | $keyboard_object->setInline_keyboard($rows); |
669 | 668 | return $keyboard_object; |
670 | - } |
|
671 | - else { |
|
669 | + } else { |
|
672 | 670 | logger::write("tools::eKey function used\nkeyboard or inline parameter must be set",loggerTypes::ERROR); |
673 | 671 | throw new bptException('ARGUMENT_NOT_FOUND_KEYBOARD_INLINE'); |
674 | 672 | } |
@@ -687,8 +685,12 @@ discard block |
||
687 | 685 | * @return string |
688 | 686 | */ |
689 | 687 | public static function inviteLink (int $user_id = null, string $bot_username = null): string { |
690 | - if (empty($user_id)) $user_id = telegram::catchFields(fields::USER_ID); |
|
691 | - if (empty($bot_username)) $bot_username = telegram::getMe()->username; |
|
688 | + if (empty($user_id)) { |
|
689 | + $user_id = telegram::catchFields(fields::USER_ID); |
|
690 | + } |
|
691 | + if (empty($bot_username)) { |
|
692 | + $bot_username = telegram::getMe()->username; |
|
693 | + } |
|
692 | 694 | return 'https://t.me/' . str_replace('@', '', $bot_username) . '?start=ref_' . tools::shortEncode($user_id); |
693 | 695 | } |
694 | 696 | |
@@ -723,8 +725,7 @@ discard block |
||
723 | 725 | $iv = self::randomString(); |
724 | 726 | $output = base64_encode(openssl_encrypt($text, 'AES-256-CBC', $key, 1, $iv)); |
725 | 727 | return ['hash' => $output, 'key' => $key, 'iv' => $iv]; |
726 | - } |
|
727 | - elseif ($action === cryptoAction::DECRYPT) { |
|
728 | + } elseif ($action === cryptoAction::DECRYPT) { |
|
728 | 729 | if (empty($key)) { |
729 | 730 | logger::write("tools::crypto function used\nkey parameter is not set",loggerTypes::ERROR); |
730 | 731 | throw new bptException('ARGUMENT_NOT_FOUND_KEY'); |
@@ -734,8 +735,7 @@ discard block |
||
734 | 735 | throw new bptException('ARGUMENT_NOT_FOUND_IV'); |
735 | 736 | } |
736 | 737 | return openssl_decrypt(base64_decode($text), 'AES-256-CBC', $key, 1, $iv); |
737 | - } |
|
738 | - else { |
|
738 | + } else { |
|
739 | 739 | logger::write("tools::crypto function used\naction is not right, its must be `encode` or `decode`",loggerTypes::WARNING); |
740 | 740 | return false; |
741 | 741 | } |
@@ -757,7 +757,9 @@ discard block |
||
757 | 757 | $array[] = $num % 62; |
758 | 758 | $num = floor($num / 62); |
759 | 759 | } |
760 | - if (count($array) < 1) $array = [0]; |
|
760 | + if (count($array) < 1) { |
|
761 | + $array = [0]; |
|
762 | + } |
|
761 | 763 | foreach ($array as &$value) { |
762 | 764 | $value = $codes[$value]; |
763 | 765 | } |
@@ -69,17 +69,13 @@ discard block |
||
69 | 69 | if (self::$auto_process) { |
70 | 70 | if (isset(BPT::$update->message)) { |
71 | 71 | self::processMessage(BPT::$update->message); |
72 | - } |
|
73 | - elseif (isset(BPT::$update->edited_message)) { |
|
72 | + } elseif (isset(BPT::$update->edited_message)) { |
|
74 | 73 | self::processMessage(BPT::$update->edited_message); |
75 | - } |
|
76 | - elseif (isset(BPT::$update->callback_query)) { |
|
74 | + } elseif (isset(BPT::$update->callback_query)) { |
|
77 | 75 | self::processCallbackQuery(BPT::$update->callback_query); |
78 | - } |
|
79 | - elseif (isset(BPT::$update->inline_query)) { |
|
76 | + } elseif (isset(BPT::$update->inline_query)) { |
|
80 | 77 | self::processInlineQuery(BPT::$update->inline_query); |
81 | - } |
|
82 | - elseif (isset(BPT::$update->my_chat_member)) { |
|
78 | + } elseif (isset(BPT::$update->my_chat_member)) { |
|
83 | 79 | self::processMyChatMember(BPT::$update->my_chat_member); |
84 | 80 | } |
85 | 81 | } |
@@ -136,8 +132,7 @@ discard block |
||
136 | 132 | if ($type === chatType::PRIVATE) { |
137 | 133 | if ($update->new_chat_member->status === chatMemberStatus::MEMBER) { |
138 | 134 | self::update('users', ['blocked' => false], ['id' => $update->from->id], 1); |
139 | - } |
|
140 | - else { |
|
135 | + } else { |
|
141 | 136 | self::update('users', ['blocked' => true], ['id' => $update->from->id], 1); |
142 | 137 | } |
143 | 138 | } |
@@ -226,8 +221,7 @@ discard block |
||
226 | 221 | foreach ($array as $name => $value) { |
227 | 222 | if ($first) { |
228 | 223 | $first = false; |
229 | - } |
|
230 | - else { |
|
224 | + } else { |
|
231 | 225 | $query .= $operator; |
232 | 226 | } |
233 | 227 | $query .= " `$name` = ?"; |
@@ -244,8 +238,7 @@ discard block |
||
244 | 238 | } |
245 | 239 | if (!empty($count)) { |
246 | 240 | $query .= !empty($offset) ? " LIMIT $offset,$count" : " LIMIT $count"; |
247 | - } |
|
248 | - elseif (!empty($offset)) { |
|
241 | + } elseif (!empty($offset)) { |
|
249 | 242 | $query .= " OFFSET $offset"; |
250 | 243 | } |
251 | 244 | return $values; |
@@ -303,7 +296,9 @@ discard block |
||
303 | 296 | public static function insert (string $table, string|array $columns, array|string $values): mysqli_result|bool { |
304 | 297 | $query = "INSERT INTO `$table`("; |
305 | 298 | $query .= '`' . (is_string($columns) ? $columns : implode('`,`', $columns)) . '`) VALUES ('; |
306 | - if (is_string($values)) $values = [$values]; |
|
299 | + if (is_string($values)) { |
|
300 | + $values = [$values]; |
|
301 | + } |
|
307 | 302 | $query .= '?' . str_repeat(',?', count($values) - 1) . ')'; |
308 | 303 | return self::query($query, $values, false); |
309 | 304 | } |
@@ -327,8 +322,7 @@ discard block |
||
327 | 322 | $query = "SELECT "; |
328 | 323 | if ($columns == '*') { |
329 | 324 | $query .= "* "; |
330 | - } |
|
331 | - else { |
|
325 | + } else { |
|
332 | 326 | $query .= '`' . (is_string($columns) ? $columns : implode('`,`', $columns)) . '` '; |
333 | 327 | } |
334 | 328 | $query .= "FROM `$table`"; |
@@ -389,8 +383,11 @@ discard block |
||
389 | 383 | public static function selectEach (string $table, array|string $columns = '*', array $where = null, int $count = null, int $offset = null): bool|Generator { |
390 | 384 | $res = self::select($table, $columns, $where, $count, $offset); |
391 | 385 | if ($res) { |
392 | - while ($row = $res->fetch_assoc()) yield $row; |
|
386 | + while ($row = $res->fetch_assoc()) { |
|
387 | + yield $row; |
|
388 | + } |
|
389 | + } else { |
|
390 | + return $res; |
|
393 | 391 | } |
394 | - else return $res; |
|
395 | 392 | } |
396 | 393 | } |
397 | 394 | \ No newline at end of file |
@@ -195,17 +195,13 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -23,8 +23,7 @@ discard block |
||
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 |
||
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 | } |