@@ -22,19 +22,19 @@ |
||
| 22 | 22 | * Optional. Pass True to request bots, pass False to request regular users. If not specified, no additional |
| 23 | 23 | * restrictions are applied. |
| 24 | 24 | */ |
| 25 | - public null|bool $user_is_bot = null; |
|
| 25 | + public null | bool $user_is_bot = null; |
|
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * Optional. Pass True to request premium users, pass False to request non-premium users. If not specified, no |
| 29 | 29 | * additional restrictions are applied. |
| 30 | 30 | */ |
| 31 | - public null|bool $user_is_premium = null; |
|
| 31 | + public null | bool $user_is_premium = null; |
|
| 32 | 32 | |
| 33 | 33 | /** Optional. The maximum number of users to be selected; 1-10. Defaults to 1. */ |
| 34 | - public null|int $max_quantity = null; |
|
| 34 | + public null | int $max_quantity = null; |
|
| 35 | 35 | |
| 36 | 36 | |
| 37 | - public function __construct(stdClass|null $object = null) { |
|
| 37 | + public function __construct(stdClass | null $object = null) { |
|
| 38 | 38 | if ($object != null) { |
| 39 | 39 | parent::__construct($object, self::subs); |
| 40 | 40 | } |
@@ -31,140 +31,140 @@ discard block |
||
| 31 | 31 | public string $type; |
| 32 | 32 | |
| 33 | 33 | /** Optional. Title, for supergroups, channels and group chats */ |
| 34 | - public null|string $title = null; |
|
| 34 | + public null | string $title = null; |
|
| 35 | 35 | |
| 36 | 36 | /** Optional. Username, for private chats, supergroups and channels if available */ |
| 37 | - public null|string $username = null; |
|
| 37 | + public null | string $username = null; |
|
| 38 | 38 | |
| 39 | 39 | /** Optional. First name of the other party in a private chat */ |
| 40 | - public null|string $first_name = null; |
|
| 40 | + public null | string $first_name = null; |
|
| 41 | 41 | |
| 42 | 42 | /** Optional. Last name of the other party in a private chat */ |
| 43 | - public null|string $last_name = null; |
|
| 43 | + public null | string $last_name = null; |
|
| 44 | 44 | |
| 45 | 45 | /** Optional. True, if the supergroup chat is a forum (has topics enabled) */ |
| 46 | - public null|bool $is_forum = null; |
|
| 46 | + public null | bool $is_forum = null; |
|
| 47 | 47 | |
| 48 | 48 | /** Optional. Chat photo. Returned only in getChat. */ |
| 49 | - public null|chatPhoto $photo = null; |
|
| 49 | + public null | chatPhoto $photo = null; |
|
| 50 | 50 | |
| 51 | 51 | /** Optional. If non-empty, the list of all active chat usernames; for private chats, supergroups and channels. Returned only in getChat. */ |
| 52 | - public null|array $active_usernames = null; |
|
| 52 | + public null | array $active_usernames = null; |
|
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | 55 | * Optional. List of available reactions allowed in the chat. If omitted, then all emoji reactions are allowed. |
| 56 | 56 | * Returned only in getChat. |
| 57 | 57 | * @var reactionType[] |
| 58 | 58 | */ |
| 59 | - public null|array $available_reactions = null; |
|
| 59 | + public null | array $available_reactions = null; |
|
| 60 | 60 | |
| 61 | 61 | /** |
| 62 | 62 | * Optional. Identifier of the accent color for the chat name and backgrounds of the chat photo, reply header, |
| 63 | 63 | * and link preview. See accent colors for more details. Returned only in getChat. Always returned in getChat. |
| 64 | 64 | */ |
| 65 | - public null|int $accent_color_id = null; |
|
| 65 | + public null | int $accent_color_id = null; |
|
| 66 | 66 | |
| 67 | 67 | /** |
| 68 | 68 | * Optional. Custom emoji identifier of emoji chosen by the chat for the reply header and link preview |
| 69 | 69 | * background. Returned only in getChat. |
| 70 | 70 | */ |
| 71 | - public null|string $background_custom_emoji_id = null; |
|
| 71 | + public null | string $background_custom_emoji_id = null; |
|
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | 74 | * Optional. Identifier of the accent color for the chat's profile background. See profile accent colors for more |
| 75 | 75 | * details. Returned only in getChat. |
| 76 | 76 | */ |
| 77 | - public null|int $profile_accent_color_id = null; |
|
| 77 | + public null | int $profile_accent_color_id = null; |
|
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | 80 | * Optional. Custom emoji identifier of the emoji chosen by the chat for its profile background. Returned only in |
| 81 | 81 | * getChat. |
| 82 | 82 | */ |
| 83 | - public null|string $profile_background_custom_emoji_id = null; |
|
| 83 | + public null | string $profile_background_custom_emoji_id = null; |
|
| 84 | 84 | |
| 85 | 85 | /** Optional. Custom emoji identifier of emoji status of the other party in a private chat. Returned only in getChat. */ |
| 86 | - public null|string $emoji_status_custom_emoji_id = null; |
|
| 86 | + public null | string $emoji_status_custom_emoji_id = null; |
|
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | 89 | * Optional. Expiration date of the emoji status of the other party in a private chat, if any. |
| 90 | 90 | * Returned only in getChat. |
| 91 | 91 | */ |
| 92 | - public null|int $emoji_status_expiration_date; |
|
| 92 | + public null | int $emoji_status_expiration_date; |
|
| 93 | 93 | |
| 94 | 94 | /** Optional. Bio of the other party in a private chat. Returned only in getChat. */ |
| 95 | - public null|string $bio = null; |
|
| 95 | + public null | string $bio = null; |
|
| 96 | 96 | |
| 97 | 97 | /** |
| 98 | 98 | * Optional. True, if privacy settings of the other party in the private chat allows to use |
| 99 | 99 | * tg://user?id=<user_id> links only in chats with the user. Returned only in getChat. |
| 100 | 100 | */ |
| 101 | - public null|bool $has_private_forwards = null; |
|
| 101 | + public null | bool $has_private_forwards = null; |
|
| 102 | 102 | |
| 103 | 103 | /** |
| 104 | 104 | * Optional. True, if the privacy settings of the other party restrict sending voice and video note messages in |
| 105 | 105 | * the private chat. Returned only in getChat. |
| 106 | 106 | */ |
| 107 | - public null|bool $has_restricted_voice_and_video_messages = null; |
|
| 107 | + public null | bool $has_restricted_voice_and_video_messages = null; |
|
| 108 | 108 | |
| 109 | 109 | /** Optional. True, if users need to join the supergroup before they can send messages. Returned only in getChat. */ |
| 110 | - public null|bool $join_to_send_messages = null; |
|
| 110 | + public null | bool $join_to_send_messages = null; |
|
| 111 | 111 | |
| 112 | 112 | /** |
| 113 | 113 | * Optional. True, if all users directly joining the supergroup need to be approved by supergroup administrators. |
| 114 | 114 | * Returned only in getChat. |
| 115 | 115 | */ |
| 116 | - public null|bool $join_by_request = null; |
|
| 116 | + public null | bool $join_by_request = null; |
|
| 117 | 117 | |
| 118 | 118 | /** Optional. Description, for groups, supergroups and channel chats. Returned only in getChat. */ |
| 119 | - public null|string $description = null; |
|
| 119 | + public null | string $description = null; |
|
| 120 | 120 | |
| 121 | 121 | /** Optional. Primary invite link, for groups, supergroups and channel chats. Returned only in getChat. */ |
| 122 | - public null|string $invite_link = null; |
|
| 122 | + public null | string $invite_link = null; |
|
| 123 | 123 | |
| 124 | 124 | /** Optional. The most recent pinned message (by sending date). Returned only in getChat. */ |
| 125 | - public null|message $pinned_message = null; |
|
| 125 | + public null | message $pinned_message = null; |
|
| 126 | 126 | |
| 127 | 127 | /** Optional. Default chat member permissions, for groups and supergroups. Returned only in getChat. */ |
| 128 | - public null|chatPermissions $permissions = null; |
|
| 128 | + public null | chatPermissions $permissions = null; |
|
| 129 | 129 | |
| 130 | 130 | /** |
| 131 | 131 | * Optional. For supergroups, the minimum allowed delay between consecutive messages sent by each unpriviledged |
| 132 | 132 | * user; in seconds. Returned only in getChat. |
| 133 | 133 | */ |
| 134 | - public null|int $slow_mode_delay = null; |
|
| 134 | + public null | int $slow_mode_delay = null; |
|
| 135 | 135 | |
| 136 | 136 | /** |
| 137 | 137 | * Optional. The time after which all messages sent to the chat will be automatically deleted; in seconds. |
| 138 | 138 | * Returned only in getChat. |
| 139 | 139 | */ |
| 140 | - public null|int $message_auto_delete_time = null; |
|
| 140 | + public null | int $message_auto_delete_time = null; |
|
| 141 | 141 | |
| 142 | 142 | /** |
| 143 | 143 | * Optional. True, if aggressive anti-spam checks are enabled in the supergroup. |
| 144 | 144 | * The field is only available to chat administrators. Returned only in getChat. |
| 145 | 145 | */ |
| 146 | - public null|bool $has_aggressive_anti_spam_enabled = null; |
|
| 146 | + public null | bool $has_aggressive_anti_spam_enabled = null; |
|
| 147 | 147 | |
| 148 | 148 | /** |
| 149 | 149 | * Optional. True, if non-administrators can only get the list of bots and administrators in the chat. |
| 150 | 150 | * Returned only in getChat. |
| 151 | 151 | */ |
| 152 | - public null|bool $has_hidden_members = null; |
|
| 152 | + public null | bool $has_hidden_members = null; |
|
| 153 | 153 | |
| 154 | 154 | /** Optional. True, if messages from the chat can't be forwarded to other chats. Returned only in getChat. */ |
| 155 | - public null|bool $has_protected_content = null; |
|
| 155 | + public null | bool $has_protected_content = null; |
|
| 156 | 156 | |
| 157 | 157 | /** |
| 158 | 158 | * Optional. True, if new chat members will have access to old messages; available only to chat administrators. |
| 159 | 159 | * Returned only in getChat. |
| 160 | 160 | */ |
| 161 | - public null|bool $has_visible_history = null; |
|
| 161 | + public null | bool $has_visible_history = null; |
|
| 162 | 162 | |
| 163 | 163 | /** Optional. For supergroups, name of group sticker set. Returned only in getChat. */ |
| 164 | - public null|string $sticker_set_name = null; |
|
| 164 | + public null | string $sticker_set_name = null; |
|
| 165 | 165 | |
| 166 | 166 | /** Optional. True, if the bot can change the group sticker set. Returned only in getChat. */ |
| 167 | - public null|bool $can_set_sticker_set = null; |
|
| 167 | + public null | bool $can_set_sticker_set = null; |
|
| 168 | 168 | |
| 169 | 169 | /** |
| 170 | 170 | * Optional. Unique identifier for the linked chat, i.e. the discussion group identifier for a channel and vice |
@@ -172,13 +172,13 @@ discard block |
||
| 172 | 172 | * languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed |
| 173 | 173 | * 64-bit integer or double-precision float type are safe for storing this identifier. Returned only in getChat. |
| 174 | 174 | */ |
| 175 | - public null|int $linked_chat_id = null; |
|
| 175 | + public null | int $linked_chat_id = null; |
|
| 176 | 176 | |
| 177 | 177 | /** Optional. For supergroups, the location to which the supergroup is connected. Returned only in getChat. */ |
| 178 | - public null|chatLocation $location = null; |
|
| 178 | + public null | chatLocation $location = null; |
|
| 179 | 179 | |
| 180 | 180 | |
| 181 | - public function __construct(stdClass|null $object = null) { |
|
| 181 | + public function __construct(stdClass | null $object = null) { |
|
| 182 | 182 | if ($object != null) { |
| 183 | 183 | parent::__construct($object, self::subs); |
| 184 | 184 | } |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | * |
| 190 | 190 | * @return bool |
| 191 | 191 | */ |
| 192 | - public function isPrivate (): bool { |
|
| 192 | + public function isPrivate(): bool { |
|
| 193 | 193 | return $this->type === chatType::PRIVATE; |
| 194 | 194 | } |
| 195 | 195 | |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | * |
| 199 | 199 | * @return bool |
| 200 | 200 | */ |
| 201 | - public function isGroup (): bool { |
|
| 201 | + public function isGroup(): bool { |
|
| 202 | 202 | return $this->type === chatType::GROUP; |
| 203 | 203 | } |
| 204 | 204 | |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | * |
| 208 | 208 | * @return bool |
| 209 | 209 | */ |
| 210 | - public function isSuperGroup (): bool { |
|
| 210 | + public function isSuperGroup(): bool { |
|
| 211 | 211 | return $this->type === chatType::SUPERGROUP; |
| 212 | 212 | } |
| 213 | 213 | |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | * |
| 217 | 217 | * @return bool |
| 218 | 218 | */ |
| 219 | - public function isChannel (): bool { |
|
| 219 | + public function isChannel(): bool { |
|
| 220 | 220 | return $this->type === chatType::CHANNEL; |
| 221 | 221 | } |
| 222 | 222 | |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | * |
| 226 | 226 | * @return responseError|bool |
| 227 | 227 | */ |
| 228 | - public function leave(): responseError|bool { |
|
| 228 | + public function leave(): responseError | bool { |
|
| 229 | 229 | if ($this->isPrivate()) { |
| 230 | 230 | return false; |
| 231 | 231 | } |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | * |
| 241 | 241 | * @return responseError|bool |
| 242 | 242 | */ |
| 243 | - public function setPhoto(CURLFile|array $photo, bool $answer = null): responseError|bool { |
|
| 243 | + public function setPhoto(CURLFile | array $photo, bool $answer = null): responseError | bool { |
|
| 244 | 244 | if ($this->isPrivate()) { |
| 245 | 245 | return false; |
| 246 | 246 | } |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | * |
| 255 | 255 | * @return responseError|bool |
| 256 | 256 | */ |
| 257 | - public function delPhoto(bool $answer = null): responseError|bool { |
|
| 257 | + public function delPhoto(bool $answer = null): responseError | bool { |
|
| 258 | 258 | if ($this->isPrivate()) { |
| 259 | 259 | return false; |
| 260 | 260 | } |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | * |
| 270 | 270 | * @return responseError|bool |
| 271 | 271 | */ |
| 272 | - public function setTitle(string|array $title, bool $answer = null): responseError|bool { |
|
| 272 | + public function setTitle(string | array $title, bool $answer = null): responseError | bool { |
|
| 273 | 273 | if ($this->isPrivate()) { |
| 274 | 274 | return false; |
| 275 | 275 | } |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | * |
| 285 | 285 | * @return responseError|bool |
| 286 | 286 | */ |
| 287 | - public function setDescription(string|null $description = null, bool $answer = null): responseError|bool { |
|
| 287 | + public function setDescription(string | null $description = null, bool $answer = null): responseError | bool { |
|
| 288 | 288 | if ($this->isPrivate()) { |
| 289 | 289 | return false; |
| 290 | 290 | } |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | * |
| 299 | 299 | * @return bool|responseError|array |
| 300 | 300 | */ |
| 301 | - public function getAdmins(bool $answer = null): bool|responseError|array { |
|
| 301 | + public function getAdmins(bool $answer = null): bool | responseError | array { |
|
| 302 | 302 | if ($this->isPrivate()) { |
| 303 | 303 | return false; |
| 304 | 304 | } |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | * |
| 313 | 313 | * @return bool|responseError|int |
| 314 | 314 | */ |
| 315 | - public function getMembersCount(bool $answer = null): bool|responseError|int { |
|
| 315 | + public function getMembersCount(bool $answer = null): bool | responseError | int { |
|
| 316 | 316 | if ($this->isPrivate()) { |
| 317 | 317 | return false; |
| 318 | 318 | } |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | * |
| 328 | 328 | * @return chatMember|bool|responseError |
| 329 | 329 | */ |
| 330 | - public function getMember(int|null $user_id = null, bool $answer = null): chatMember|bool|responseError { |
|
| 330 | + public function getMember(int | null $user_id = null, bool $answer = null): chatMember | bool | responseError { |
|
| 331 | 331 | if ($this->isPrivate()) { |
| 332 | 332 | return false; |
| 333 | 333 | } |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | public int $total_count; |
| 19 | 19 | |
| 20 | 20 | |
| 21 | - public function __construct(stdClass|null $object = null) { |
|
| 21 | + public function __construct(stdClass | null $object = null) { |
|
| 22 | 22 | if ($object != null) { |
| 23 | 23 | parent::__construct($object, self::subs); |
| 24 | 24 | } |
@@ -18,28 +18,28 @@ |
||
| 18 | 18 | public int $date; |
| 19 | 19 | |
| 20 | 20 | /** `user` only. User that sent the message originally */ |
| 21 | - public null|user $sender_user = null; |
|
| 21 | + public null | user $sender_user = null; |
|
| 22 | 22 | |
| 23 | 23 | /** `hidden_user` only. Name of the user that sent the message originally */ |
| 24 | - public null|string $sender_user_name = null; |
|
| 24 | + public null | string $sender_user_name = null; |
|
| 25 | 25 | |
| 26 | 26 | /** `chat` only. Chat that sent the message originally */ |
| 27 | - public null|chat $sender_chat = null; |
|
| 27 | + public null | chat $sender_chat = null; |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * `chat` and `channel` only. Signature of the original post author, For messages originally sent by an anonymous |
| 31 | 31 | * chat administrator, original message author signature |
| 32 | 32 | */ |
| 33 | - public null|string $author_signature = null; |
|
| 33 | + public null | string $author_signature = null; |
|
| 34 | 34 | |
| 35 | 35 | /** `channel` only. Channel chat to which the message was originally sent */ |
| 36 | - public null|chat $chat = null; |
|
| 36 | + public null | chat $chat = null; |
|
| 37 | 37 | |
| 38 | 38 | /** `channel` only. Unique message identifier inside the chat */ |
| 39 | - public null|int $message_id = null; |
|
| 39 | + public null | int $message_id = null; |
|
| 40 | 40 | |
| 41 | 41 | |
| 42 | - public function __construct(stdClass|null $object = null) { |
|
| 42 | + public function __construct(stdClass | null $object = null) { |
|
| 43 | 43 | if ($object != null) { |
| 44 | 44 | parent::__construct($object, self::subs); |
| 45 | 45 | } |
@@ -870,30 +870,30 @@ discard block |
||
| 870 | 870 | 'getGameHighScores' => ['BPT\types\gameHighScore'] |
| 871 | 871 | ]; |
| 872 | 872 | |
| 873 | - public static function __callStatic (string $name, array $arguments) { |
|
| 873 | + public static function __callStatic(string $name, array $arguments) { |
|
| 874 | 874 | if (!$action = self::methodAction($name)) { |
| 875 | - logger::write("$name method is not supported",loggerTypes::ERROR); |
|
| 875 | + logger::write("$name method is not supported", loggerTypes::ERROR); |
|
| 876 | 876 | throw new bptException('METHOD_NOT_FOUND'); |
| 877 | 877 | } |
| 878 | 878 | self::checkArguments($arguments); |
| 879 | - self::keysName($action,$arguments); |
|
| 880 | - self::readyFile($action,$arguments); |
|
| 879 | + self::keysName($action, $arguments); |
|
| 880 | + self::readyFile($action, $arguments); |
|
| 881 | 881 | self::cleanArguments($arguments); |
| 882 | - self::setDefaults($action,$arguments); |
|
| 882 | + self::setDefaults($action, $arguments); |
|
| 883 | 883 | |
| 884 | 884 | if (isset($arguments['answer']) && $arguments['answer'] === true) { |
| 885 | 885 | unset($arguments['answer']); |
| 886 | 886 | if (!answer::isAnswered()) { |
| 887 | - return answer::init($action,$arguments); |
|
| 887 | + return answer::init($action, $arguments); |
|
| 888 | 888 | } |
| 889 | - logger::write('you can use answer mode only once for each webhook update, Others will be called like normal',loggerTypes::WARNING); |
|
| 889 | + logger::write('you can use answer mode only once for each webhook update, Others will be called like normal', loggerTypes::WARNING); |
|
| 890 | 890 | } |
| 891 | - $result = curl::init($action,$arguments); |
|
| 891 | + $result = curl::init($action, $arguments); |
|
| 892 | 892 | if (!is_object($result)) { |
| 893 | - logger::write("Telegram $action method failed : " . $result, loggerTypes::WARNING); |
|
| 893 | + logger::write("Telegram $action method failed : ".$result, loggerTypes::WARNING); |
|
| 894 | 894 | return false; |
| 895 | 895 | } |
| 896 | - return self::processResponse($action,$result); |
|
| 896 | + return self::processResponse($action, $result); |
|
| 897 | 897 | } |
| 898 | 898 | |
| 899 | 899 | private static function checkArguments(array &$arguments): void { |
@@ -902,7 +902,7 @@ discard block |
||
| 902 | 902 | } |
| 903 | 903 | } |
| 904 | 904 | |
| 905 | - private static function keysName (string $name, array &$arguments): void { |
|
| 905 | + private static function keysName(string $name, array &$arguments): void { |
|
| 906 | 906 | foreach ($arguments as $key => $argument) { |
| 907 | 907 | if (is_numeric($key) && isset(self::METHODS_KEYS[$name][$key])) { |
| 908 | 908 | $arguments[self::METHODS_KEYS[$name][$key]] = $argument; |
@@ -911,7 +911,7 @@ discard block |
||
| 911 | 911 | } |
| 912 | 912 | } |
| 913 | 913 | |
| 914 | - private static function methodAction(string $name): string|false { |
|
| 914 | + private static function methodAction(string $name): string | false { |
|
| 915 | 915 | return self::METHODS_ACTION[str_replace('_', '', strtolower($name))] ?? false; |
| 916 | 916 | } |
| 917 | 917 | |
@@ -947,11 +947,11 @@ discard block |
||
| 947 | 947 | } |
| 948 | 948 | } |
| 949 | 949 | |
| 950 | - private static function methodFile(string $name): array|false { |
|
| 950 | + private static function methodFile(string $name): array | false { |
|
| 951 | 951 | return self::METHODS_WITH_FILE[$name] ?? false; |
| 952 | 952 | } |
| 953 | 953 | |
| 954 | - private static function methodReturn(string $name,stdClass $response) { |
|
| 954 | + private static function methodReturn(string $name, stdClass $response) { |
|
| 955 | 955 | if (!settings::$use_types_classes) { |
| 956 | 956 | return $response; |
| 957 | 957 | } |
@@ -973,13 +973,13 @@ discard block |
||
| 973 | 973 | $defaults = self::METHODS_EXTRA_DEFAULTS[$name] ?? []; |
| 974 | 974 | foreach ($defaults as $key => $default) { |
| 975 | 975 | if (is_numeric($key)) { |
| 976 | - if (!isset($arguments[$default])){ |
|
| 976 | + if (!isset($arguments[$default])) { |
|
| 977 | 977 | $arguments[$default] = self::catchFields($default); |
| 978 | 978 | } |
| 979 | 979 | } |
| 980 | 980 | elseif (isset(BPT::$update->{$key}) || $key === 'other') { |
| 981 | 981 | foreach ($default as $def) { |
| 982 | - if (!isset($arguments[$def])){ |
|
| 982 | + if (!isset($arguments[$def])) { |
|
| 983 | 983 | $arguments[$def] = self::catchFields($def); |
| 984 | 984 | } |
| 985 | 985 | } |
@@ -998,14 +998,14 @@ discard block |
||
| 998 | 998 | self::$status = $response->ok; |
| 999 | 999 | self::$pure_response = $response; |
| 1000 | 1000 | if (!$response->ok) { |
| 1001 | - logger::write("Telegram $name method failed : " . json_encode($response), loggerTypes::WARNING); |
|
| 1001 | + logger::write("Telegram $name method failed : ".json_encode($response), loggerTypes::WARNING); |
|
| 1002 | 1002 | unset($response->ok); |
| 1003 | 1003 | return new responseError($response); |
| 1004 | 1004 | } |
| 1005 | - return self::methodReturn($name,$response); |
|
| 1005 | + return self::methodReturn($name, $response); |
|
| 1006 | 1006 | } |
| 1007 | 1007 | |
| 1008 | - private static function cleanArguments (array &$arguments): void { |
|
| 1008 | + private static function cleanArguments(array &$arguments): void { |
|
| 1009 | 1009 | foreach ($arguments as $key => $argument) { |
| 1010 | 1010 | if ($argument == [] || $argument === null) { |
| 1011 | 1011 | unset($arguments[$key]); |
@@ -1020,7 +1020,7 @@ discard block |
||
| 1020 | 1020 | * |
| 1021 | 1021 | * @return int|string|bool |
| 1022 | 1022 | */ |
| 1023 | - public static function catchFields (string $field): int|string|bool { |
|
| 1023 | + public static function catchFields(string $field): int | string | bool { |
|
| 1024 | 1024 | switch ($field) { |
| 1025 | 1025 | case fields::CHAT_ID : |
| 1026 | 1026 | case fields::FROM_CHAT_ID : |
@@ -1167,13 +1167,13 @@ discard block |
||
| 1167 | 1167 | default => false |
| 1168 | 1168 | }; |
| 1169 | 1169 | case fields::URL : |
| 1170 | - return 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; |
|
| 1170 | + return 'https://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; |
|
| 1171 | 1171 | default: |
| 1172 | 1172 | return false; |
| 1173 | 1173 | } |
| 1174 | 1174 | } |
| 1175 | 1175 | |
| 1176 | - public static function fileLink (string|null $file_id = null): bool|string { |
|
| 1176 | + public static function fileLink(string | null $file_id = null): bool | string { |
|
| 1177 | 1177 | $file = request::getFile($file_id); |
| 1178 | 1178 | if (!isset($file->file_path)) { |
| 1179 | 1179 | return false; |
@@ -1195,7 +1195,7 @@ discard block |
||
| 1195 | 1195 | * |
| 1196 | 1196 | * @return bool |
| 1197 | 1197 | */ |
| 1198 | - public static function downloadFile (string $destination, string|null $file_id = null): bool { |
|
| 1198 | + public static function downloadFile(string $destination, string | null $file_id = null): bool { |
|
| 1199 | 1199 | return tools::downloadFile(self::fileLink($file_id), $destination); |
| 1200 | 1200 | } |
| 1201 | 1201 | |
@@ -1213,10 +1213,10 @@ discard block |
||
| 1213 | 1213 | * |
| 1214 | 1214 | * @return message|bool|responseError |
| 1215 | 1215 | */ |
| 1216 | - public static function sendFile (string $file_id, int|string $chat_id = null, int $message_thread_id = null, string $caption = null, string $parse_mode = null, array $caption_entities = null, bool $disable_notification = null, bool $protect_content = null, array|object $reply_parameters = null, inlineKeyboardMarkup|replyKeyboardMarkup|replyKeyboardRemove|forceReply|stdClass|array $reply_markup = null, string $token = null, bool $forgot = null, bool $answer = null): message|bool|responseError { |
|
| 1216 | + public static function sendFile(string $file_id, int | string $chat_id = null, int $message_thread_id = null, string $caption = null, string $parse_mode = null, array $caption_entities = null, bool $disable_notification = null, bool $protect_content = null, array | object $reply_parameters = null, inlineKeyboardMarkup | replyKeyboardMarkup | replyKeyboardRemove | forceReply | stdClass | array $reply_markup = null, string $token = null, bool $forgot = null, bool $answer = null): message | bool | responseError { |
|
| 1217 | 1217 | $type = tools::fileType($file_id); |
| 1218 | 1218 | return match ($type) { |
| 1219 | - fileTypes::VIDEO => request::sendVideo($file_id, $chat_id, $message_thread_id, null, null, null, null, $caption, $parse_mode, $caption_entities, false,null, $disable_notification, $protect_content, $reply_parameters, $reply_markup, $token, $forgot, $answer), |
|
| 1219 | + fileTypes::VIDEO => request::sendVideo($file_id, $chat_id, $message_thread_id, null, null, null, null, $caption, $parse_mode, $caption_entities, false, null, $disable_notification, $protect_content, $reply_parameters, $reply_markup, $token, $forgot, $answer), |
|
| 1220 | 1220 | fileTypes::VIDEO_NOTE => request::sendVideoNote($file_id, $chat_id, $message_thread_id, null, null, null, $disable_notification, $protect_content, $reply_parameters, $reply_markup, $token, $forgot, $answer), |
| 1221 | 1221 | fileTypes::ANIMATION => request::sendAnimation($file_id, $chat_id, $message_thread_id, null, null, null, null, $caption, $parse_mode, $caption_entities, false, $disable_notification, $protect_content, $reply_parameters, $reply_markup, $token, $forgot, $answer), |
| 1222 | 1222 | fileTypes::AUDIO => request::sendAudio($file_id, $chat_id, $message_thread_id, $caption, $parse_mode, $caption_entities, null, null, null, null, $disable_notification, $protect_content, $reply_parameters, $reply_markup, $token, $forgot, $answer), |
@@ -30,12 +30,12 @@ discard block |
||
| 30 | 30 | /** |
| 31 | 31 | * If you want to use it in standalone mode , you MUST set `auto_process` to `false` |
| 32 | 32 | */ |
| 33 | - public static function init (string $host = 'localhost', string $username = 'root', string $password = '', string $dbname = '', bool $auto_process = true, int $port = 3306, bool $auto_load = false): void { |
|
| 33 | + public static function init(string $host = 'localhost', string $username = 'root', string $password = '', string $dbname = '', bool $auto_process = true, int $port = 3306, bool $auto_load = false): void { |
|
| 34 | 34 | self::$auto_process = $auto_process; |
| 35 | 35 | self::$db_name = $dbname; |
| 36 | 36 | self::$connection = new mysqli($host, $username, $password, $dbname, $port); |
| 37 | 37 | if (self::$connection->connect_errno) { |
| 38 | - logger::write('SQL connection has problem : ' . self::$connection->connect_error, loggerTypes::ERROR); |
|
| 38 | + logger::write('SQL connection has problem : '.self::$connection->connect_error, loggerTypes::ERROR); |
|
| 39 | 39 | throw new bptException('SQL_CONNECTION_PROBLEM'); |
| 40 | 40 | } |
| 41 | 41 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - private static function install (bool $auto_load): void { |
|
| 47 | + private static function install(bool $auto_load): void { |
|
| 48 | 48 | if (self::$auto_process) { |
| 49 | 49 | self::pureQuery(" |
| 50 | 50 | CREATE TABLE `users` |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | foreach ($allowed_file_names as $allowed_file_name) { |
| 81 | 81 | if (file_exists($allowed_file_name)) { |
| 82 | 82 | $mysqli->multi_query(file_get_contents($allowed_file_name)); |
| 83 | - while ($mysqli->next_result()){if (!$mysqli->more_results()) break;} |
|
| 83 | + while ($mysqli->next_result()) {if (!$mysqli->more_results()) break; } |
|
| 84 | 84 | $loaded = true; |
| 85 | 85 | } |
| 86 | 86 | } |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | /** |
| 95 | 95 | * @internal Only for BPT self usage , Don't use it in your source! |
| 96 | 96 | */ |
| 97 | - public static function process (): void { |
|
| 97 | + public static function process(): void { |
|
| 98 | 98 | if (self::$auto_process) { |
| 99 | 99 | if (isset(BPT::$update->message)) { |
| 100 | 100 | self::processMessage(BPT::$update->message); |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - private static function processMessage (message $update): void { |
|
| 117 | + private static function processMessage(message $update): void { |
|
| 118 | 118 | $type = $update->chat->type; |
| 119 | 119 | if ($type === chatType::PRIVATE) { |
| 120 | 120 | $user_id = $update->from->id; |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - private static function processCallbackQuery (callbackQuery $update): void { |
|
| 143 | + private static function processCallbackQuery(callbackQuery $update): void { |
|
| 144 | 144 | $type = $update->message->chat->type; |
| 145 | 145 | if ($type === chatType::PRIVATE) { |
| 146 | 146 | $user_id = $update->from->id; |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | } |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - private static function processInlineQuery (inlineQuery $update): void { |
|
| 153 | + private static function processInlineQuery(inlineQuery $update): void { |
|
| 154 | 154 | $type = $update->chat_type; |
| 155 | 155 | if ($type === chatType::PRIVATE || $type === chatType::SENDER) { |
| 156 | 156 | $user_id = $update->from->id; |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - private static function processMyChatMember (chatMemberUpdated $update): void { |
|
| 163 | + private static function processMyChatMember(chatMemberUpdated $update): void { |
|
| 164 | 164 | $type = $update->chat->type; |
| 165 | 165 | if ($type === chatType::PRIVATE) { |
| 166 | 166 | if ($update->new_chat_member->status === chatMemberStatus::MEMBER) { |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | * |
| 184 | 184 | * @return bool |
| 185 | 185 | */ |
| 186 | - public static function addDefaultWhere (array $where): bool { |
|
| 186 | + public static function addDefaultWhere(array $where): bool { |
|
| 187 | 187 | if (empty(self::$default_where)) { |
| 188 | 188 | self::$default_where = $where; |
| 189 | 189 | } |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | * |
| 199 | 199 | * @return mysqli |
| 200 | 200 | */ |
| 201 | - public static function getMysqli (): mysqli|false { |
|
| 201 | + public static function getMysqli(): mysqli | false { |
|
| 202 | 202 | return self::$connection ?? false; |
| 203 | 203 | } |
| 204 | 204 | |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | * |
| 210 | 210 | * @return int|string |
| 211 | 211 | */ |
| 212 | - public static function affected_rows (): int|string { |
|
| 212 | + public static function affected_rows(): int | string { |
|
| 213 | 213 | return self::$connection->affected_rows; |
| 214 | 214 | } |
| 215 | 215 | |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | * |
| 221 | 221 | * @return int|string |
| 222 | 222 | */ |
| 223 | - public static function affectedRows (): int|string { |
|
| 223 | + public static function affectedRows(): int | string { |
|
| 224 | 224 | return self::$connection->affected_rows; |
| 225 | 225 | } |
| 226 | 226 | |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | * |
| 232 | 232 | * @return int|string |
| 233 | 233 | */ |
| 234 | - public static function insert_id (): int|string { |
|
| 234 | + public static function insert_id(): int | string { |
|
| 235 | 235 | return self::$connection->insert_id; |
| 236 | 236 | } |
| 237 | 237 | |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | * |
| 243 | 243 | * @return int|string |
| 244 | 244 | */ |
| 245 | - public static function insertId (): int|string { |
|
| 245 | + public static function insertId(): int | string { |
|
| 246 | 246 | return self::$connection->insert_id; |
| 247 | 247 | } |
| 248 | 248 | |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | * |
| 254 | 254 | * @return string |
| 255 | 255 | */ |
| 256 | - public static function escapeString (string $text): string { |
|
| 256 | + public static function escapeString(string $text): string { |
|
| 257 | 257 | return self::$connection->real_escape_string($text); |
| 258 | 258 | } |
| 259 | 259 | |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | * |
| 263 | 263 | * @return string |
| 264 | 264 | */ |
| 265 | - public static function error (): string { |
|
| 265 | + public static function error(): string { |
|
| 266 | 266 | return self::$connection->error; |
| 267 | 267 | } |
| 268 | 268 | |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | * |
| 272 | 272 | * @return int |
| 273 | 273 | */ |
| 274 | - public static function errno (): int { |
|
| 274 | + public static function errno(): int { |
|
| 275 | 275 | return self::$connection->errno; |
| 276 | 276 | } |
| 277 | 277 | |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | * |
| 283 | 283 | * @return bool |
| 284 | 284 | */ |
| 285 | - public static function setCharset (string $charset): bool { |
|
| 285 | + public static function setCharset(string $charset): bool { |
|
| 286 | 286 | return self::$connection->set_charset($charset); |
| 287 | 287 | } |
| 288 | 288 | |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | * |
| 298 | 298 | * @return mysqli_result|bool |
| 299 | 299 | */ |
| 300 | - public static function pureQuery (string $query): mysqli_result|bool { |
|
| 300 | + public static function pureQuery(string $query): mysqli_result | bool { |
|
| 301 | 301 | return self::$connection->query($query); |
| 302 | 302 | } |
| 303 | 303 | |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | * |
| 319 | 319 | * @return mysqli_result|bool |
| 320 | 320 | */ |
| 321 | - public static function query (string $query, array $vars = [], bool $need_result = true): mysqli_result|bool { |
|
| 321 | + public static function query(string $query, array $vars = [], bool $need_result = true): mysqli_result | bool { |
|
| 322 | 322 | if (empty($vars)) { |
| 323 | 323 | return self::pureQuery($query); |
| 324 | 324 | } |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | $types .= 's'; |
| 336 | 336 | } |
| 337 | 337 | } |
| 338 | - $prepare->bind_param($types,...$vars); |
|
| 338 | + $prepare->bind_param($types, ...$vars); |
|
| 339 | 339 | if (!$prepare->execute()) { |
| 340 | 340 | logger::write(loggerTypes::WARNING, $prepare->error); |
| 341 | 341 | return false; |
@@ -382,8 +382,8 @@ discard block |
||
| 382 | 382 | else { |
| 383 | 383 | $query .= ' AND'; |
| 384 | 384 | } |
| 385 | - $operator = substr($sub_value,0,2); |
|
| 386 | - $operator_value = substr($sub_value,2); |
|
| 385 | + $operator = substr($sub_value, 0, 2); |
|
| 386 | + $operator_value = substr($sub_value, 2); |
|
| 387 | 387 | switch ($operator) { |
| 388 | 388 | case '>=': |
| 389 | 389 | $query .= " `$name` >= ?"; |
@@ -410,8 +410,8 @@ discard block |
||
| 410 | 410 | $sub_value = $operator_value; |
| 411 | 411 | break; |
| 412 | 412 | case '##': |
| 413 | - $operator = substr($operator_value,0,2); |
|
| 414 | - $column = substr($operator_value,2); |
|
| 413 | + $operator = substr($operator_value, 0, 2); |
|
| 414 | + $column = substr($operator_value, 2); |
|
| 415 | 415 | $query .= match ($operator) { |
| 416 | 416 | '>=' => " `$name` >= `$column`", |
| 417 | 417 | '<=' => " `$name` <= `$column`", |
@@ -435,17 +435,17 @@ discard block |
||
| 435 | 435 | return $values; |
| 436 | 436 | } |
| 437 | 437 | |
| 438 | - private static function groupByBuilder(string &$query, string|array $group_by = []): void { |
|
| 438 | + private static function groupByBuilder(string &$query, string | array $group_by = []): void { |
|
| 439 | 439 | if (empty($group_by)) { |
| 440 | 440 | return; |
| 441 | 441 | } |
| 442 | 442 | if (is_string($group_by)) { |
| 443 | 443 | $group_by = [$group_by]; |
| 444 | 444 | } |
| 445 | - $query .= ' GROUP BY `' . implode('`, `',$group_by) . '`'; |
|
| 445 | + $query .= ' GROUP BY `'.implode('`, `', $group_by).'`'; |
|
| 446 | 446 | } |
| 447 | 447 | |
| 448 | - private static function orderByBuilder(string &$query, string|array $order_by = []): void { |
|
| 448 | + private static function orderByBuilder(string &$query, string | array $order_by = []): void { |
|
| 449 | 449 | if (empty($order_by)) { |
| 450 | 450 | return; |
| 451 | 451 | } |
@@ -498,8 +498,8 @@ discard block |
||
| 498 | 498 | continue; |
| 499 | 499 | } |
| 500 | 500 | |
| 501 | - $operator = substr($value,0,2); |
|
| 502 | - $operator_value = substr($value,2); |
|
| 501 | + $operator = substr($value, 0, 2); |
|
| 502 | + $operator_value = substr($value, 2); |
|
| 503 | 503 | switch ($operator) { |
| 504 | 504 | case '+=': |
| 505 | 505 | $query .= " `$name` = `$name` + ?"; |
@@ -532,14 +532,14 @@ discard block |
||
| 532 | 532 | return $values; |
| 533 | 533 | } |
| 534 | 534 | |
| 535 | - private static function insertBuilder(string &$query, string|array $columns, array|string $values): array { |
|
| 536 | - $query .= '(`' . (is_string($columns) ? $columns : implode('`, `', $columns)) . '`) VALUES ('; |
|
| 535 | + private static function insertBuilder(string &$query, string | array $columns, array | string $values): array { |
|
| 536 | + $query .= '(`'.(is_string($columns) ? $columns : implode('`, `', $columns)).'`) VALUES ('; |
|
| 537 | 537 | if (is_string($values)) $values = [$values]; |
| 538 | - $query .= '?' . str_repeat(', ?', count($values) - 1) . ')'; |
|
| 538 | + $query .= '?'.str_repeat(', ?', count($values) - 1).')'; |
|
| 539 | 539 | return $values; |
| 540 | 540 | } |
| 541 | 541 | |
| 542 | - private static function selectBuilder (string &$query, string|array $columns): void { |
|
| 542 | + private static function selectBuilder(string &$query, string | array $columns): void { |
|
| 543 | 543 | if ($columns == '*') { |
| 544 | 544 | $query .= ' * '; |
| 545 | 545 | return; |
@@ -558,7 +558,7 @@ discard block |
||
| 558 | 558 | $formatted = '*'; |
| 559 | 559 | $column = 'all'; |
| 560 | 560 | } |
| 561 | - $query .= strtoupper($function) . "($formatted) as `{$function}_$column`"; |
|
| 561 | + $query .= strtoupper($function)."($formatted) as `{$function}_$column`"; |
|
| 562 | 562 | } |
| 563 | 563 | else { |
| 564 | 564 | $query .= "`$column`"; |
@@ -584,7 +584,7 @@ discard block |
||
| 584 | 584 | * |
| 585 | 585 | * @return bool |
| 586 | 586 | */ |
| 587 | - public static function delete (string $table, array $where = [], int $count = null, int $offset = null, bool $ignore_default_where = false): bool { |
|
| 587 | + public static function delete(string $table, array $where = [], int $count = null, int $offset = null, bool $ignore_default_where = false): bool { |
|
| 588 | 588 | $query = "DELETE FROM `$table`"; |
| 589 | 589 | $vars = self::whereBuilder($query, $where, $ignore_default_where); |
| 590 | 590 | self::countBuilder($query, $count, $offset); |
@@ -605,7 +605,7 @@ discard block |
||
| 605 | 605 | * |
| 606 | 606 | * @return bool |
| 607 | 607 | */ |
| 608 | - public static function update (string $table, array $modify, array $where = [], int $count = null, int $offset = null, bool $ignore_default_where = false): bool { |
|
| 608 | + public static function update(string $table, array $modify, array $where = [], int $count = null, int $offset = null, bool $ignore_default_where = false): bool { |
|
| 609 | 609 | $query = "UPDATE `$table` SET"; |
| 610 | 610 | $modify_vars = self::updateBuilder($query, $modify); |
| 611 | 611 | $where_vars = self::whereBuilder($query, $where, $ignore_default_where); |
@@ -624,7 +624,7 @@ discard block |
||
| 624 | 624 | * |
| 625 | 625 | * @return bool |
| 626 | 626 | */ |
| 627 | - public static function insert (string $table, string|array $columns, array|string $values): bool { |
|
| 627 | + public static function insert(string $table, string | array $columns, array | string $values): bool { |
|
| 628 | 628 | $query = "INSERT INTO `$table`"; |
| 629 | 629 | $values = self::insertBuilder($query, $columns, $values); |
| 630 | 630 | return self::query($query, $values, false); |
@@ -647,7 +647,7 @@ discard block |
||
| 647 | 647 | * |
| 648 | 648 | * @return bool |
| 649 | 649 | */ |
| 650 | - public static function insertUpdate (string $table, string|array $columns, array|string $values, array $modify): bool { |
|
| 650 | + public static function insertUpdate(string $table, string | array $columns, array | string $values, array $modify): bool { |
|
| 651 | 651 | $query = "INSERT INTO `$table`"; |
| 652 | 652 | $values = self::insertBuilder($query, $columns, $values); |
| 653 | 653 | $query .= ' ON DUPLICATE KEY UPDATE'; |
@@ -673,14 +673,14 @@ discard block |
||
| 673 | 673 | * |
| 674 | 674 | * @return mysqli_result|bool |
| 675 | 675 | */ |
| 676 | - public static function select (string $table, array|string $columns = '*', array $where = [], int $count = null, int $offset = null, array|string $group_by = [], array|string $order_by = [], bool $ignore_default_where = false): mysqli_result|bool { |
|
| 676 | + public static function select(string $table, array | string $columns = '*', array $where = [], int $count = null, int $offset = null, array | string $group_by = [], array | string $order_by = [], bool $ignore_default_where = false): mysqli_result | bool { |
|
| 677 | 677 | $query = 'SELECT'; |
| 678 | 678 | self::selectBuilder($query, $columns); |
| 679 | 679 | $query .= "FROM `$table`"; |
| 680 | - $var = self::whereBuilder($query,$where, $ignore_default_where); |
|
| 680 | + $var = self::whereBuilder($query, $where, $ignore_default_where); |
|
| 681 | 681 | self::groupByBuilder($query, $group_by); |
| 682 | 682 | self::orderByBuilder($query, $order_by); |
| 683 | - self::countBuilder($query,$count,$offset); |
|
| 683 | + self::countBuilder($query, $count, $offset); |
|
| 684 | 684 | return self::query($query, $var); |
| 685 | 685 | } |
| 686 | 686 | |
@@ -698,7 +698,7 @@ discard block |
||
| 698 | 698 | * |
| 699 | 699 | * @return null|bool|array |
| 700 | 700 | */ |
| 701 | - public static function selectArray (string $table, array|string $columns = '*', array $where = [], array|string $group_by = [], array|string $order_by = [], bool $ignore_default_where = false): bool|array|null { |
|
| 701 | + public static function selectArray(string $table, array | string $columns = '*', array $where = [], array | string $group_by = [], array | string $order_by = [], bool $ignore_default_where = false): bool | array | null { |
|
| 702 | 702 | $res = self::select($table, $columns, $where, 1, 0, $group_by, $order_by, ignore_default_where: $ignore_default_where); |
| 703 | 703 | if ($res) { |
| 704 | 704 | return $res->fetch_assoc(); |
@@ -720,7 +720,7 @@ discard block |
||
| 720 | 720 | * |
| 721 | 721 | * @return null|object |
| 722 | 722 | */ |
| 723 | - public static function selectObject (string $table, array|string $columns = '*', array $where = [], array|string $group_by = [], array|string $order_by = [], bool $ignore_default_where = false) { |
|
| 723 | + public static function selectObject(string $table, array | string $columns = '*', array $where = [], array | string $group_by = [], array | string $order_by = [], bool $ignore_default_where = false) { |
|
| 724 | 724 | $res = self::select($table, $columns, $where, 1, 0, $group_by, $order_by, ignore_default_where: $ignore_default_where); |
| 725 | 725 | if ($res) { |
| 726 | 726 | return $res->fetch_object(); |
@@ -745,7 +745,7 @@ discard block |
||
| 745 | 745 | * |
| 746 | 746 | * @return bool|Generator |
| 747 | 747 | */ |
| 748 | - public static function selectEach (string $table, array|string $columns = '*', array $where = [], int $count = null, int $offset = null, array|string $group_by = [], array|string $order_by = [], bool $ignore_default_where = false): bool|Generator { |
|
| 748 | + public static function selectEach(string $table, array | string $columns = '*', array $where = [], int $count = null, int $offset = null, array | string $group_by = [], array | string $order_by = [], bool $ignore_default_where = false): bool | Generator { |
|
| 749 | 749 | $res = self::select($table, $columns, $where, $count, $offset, $group_by, $order_by, ignore_default_where: $ignore_default_where); |
| 750 | 750 | if ($res) { |
| 751 | 751 | while ($row = $res->fetch_assoc()) yield $row; |
@@ -763,10 +763,10 @@ discard block |
||
| 763 | 763 | * |
| 764 | 764 | * @return string if save is true , return file name otherwise return sql data |
| 765 | 765 | */ |
| 766 | - public static function backup (array $wanted_tables = [], bool $table_data = true, bool $save = true, string $file_name = ''): string { |
|
| 766 | + public static function backup(array $wanted_tables = [], bool $table_data = true, bool $save = true, string $file_name = ''): string { |
|
| 767 | 767 | self::setCharset('utf8mb4'); |
| 768 | 768 | |
| 769 | - $tables = array_column(self::query('SHOW TABLES')->fetch_all(),0); |
|
| 769 | + $tables = array_column(self::query('SHOW TABLES')->fetch_all(), 0); |
|
| 770 | 770 | if (!empty($wanted_tables)) { |
| 771 | 771 | $tables = array_intersect($tables, $wanted_tables); |
| 772 | 772 | } |
@@ -777,12 +777,12 @@ discard block |
||
| 777 | 777 | logger::write('No table founded for backup, if your database has table : check $wanted_tables argument', loggerTypes::WARNING); |
| 778 | 778 | } |
| 779 | 779 | foreach ($tables as $table) { |
| 780 | - $sql .= self::query("SHOW CREATE TABLE `$table`")->fetch_row()[1] . ";\n\n"; |
|
| 780 | + $sql .= self::query("SHOW CREATE TABLE `$table`")->fetch_row()[1].";\n\n"; |
|
| 781 | 781 | if ($table_data) { |
| 782 | 782 | $total_rows = self::query("SELECT COUNT(*) as `cnt` FROM `$table`")->fetch_object()->cnt; |
| 783 | 783 | for ($i = 0; $i < $total_rows; $i = $i + 1000) { |
| 784 | - $sql .= 'INSERT INTO ' . $table . ' VALUES'; |
|
| 785 | - $result = self::select($table, '*' , [], 1000, $i); |
|
| 784 | + $sql .= 'INSERT INTO '.$table.' VALUES'; |
|
| 785 | + $result = self::select($table, '*', [], 1000, $i); |
|
| 786 | 786 | $field_count = $result->field_count; |
| 787 | 787 | $affected_rows = self::affected_rows(); |
| 788 | 788 | $counter = 1; |
@@ -790,12 +790,12 @@ discard block |
||
| 790 | 790 | $sql .= "\n("; |
| 791 | 791 | for ($column = 0; $column < $field_count; $column++) { |
| 792 | 792 | $row[$column] = str_replace("\n", "\\n", addslashes($row[$column])); |
| 793 | - $sql .= !empty($row[$column]) ? '"' . $row[$column] . '"' : '""'; |
|
| 793 | + $sql .= !empty($row[$column]) ? '"'.$row[$column].'"' : '""'; |
|
| 794 | 794 | if ($column < $field_count - 1) { |
| 795 | 795 | $sql .= ','; |
| 796 | 796 | } |
| 797 | 797 | } |
| 798 | - $sql .= ')' . ($counter == $affected_rows ? ';' : ','); |
|
| 798 | + $sql .= ')'.($counter == $affected_rows ? ';' : ','); |
|
| 799 | 799 | $counter++; |
| 800 | 800 | } |
| 801 | 801 | } |
@@ -811,7 +811,7 @@ discard block |
||
| 811 | 811 | } |
| 812 | 812 | |
| 813 | 813 | if (empty($file_name)) { |
| 814 | - $file_name = self::$db_name . time() . '.sql'; |
|
| 814 | + $file_name = self::$db_name.time().'.sql'; |
|
| 815 | 815 | } |
| 816 | 816 | file_put_contents($file_name, $sql); |
| 817 | 817 | return $file_name; |
@@ -102,8 +102,8 @@ discard block |
||
| 102 | 102 | /** |
| 103 | 103 | * @internal Only for BPT self usage , Don't use it in your source! |
| 104 | 104 | */ |
| 105 | - public static function init (string $bot_name, array $global = [], array $user = [], array $group_user = [], array $group = [], array $supergroup = [], array $channel = []): void { |
|
| 106 | - self::$folder = $bot_name . 'database'; |
|
| 105 | + public static function init(string $bot_name, array $global = [], array $user = [], array $group_user = [], array $group = [], array $supergroup = [], array $channel = []): void { |
|
| 106 | + self::$folder = $bot_name.'database'; |
|
| 107 | 107 | self::$global_default_data = $global ?? self::$global_default_data; |
| 108 | 108 | self::setUserDefaultData($user); |
| 109 | 109 | self::setGroupUserDefaultData($group_user); |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | self::load(); |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - private static function setUserDefaultData (array $user = []): void { |
|
| 117 | + private static function setUserDefaultData(array $user = []): void { |
|
| 118 | 118 | self::$user_default_data = $user ?? self::$user_default_data; |
| 119 | 119 | if (!isset(self::$user_default_data['step'])) { |
| 120 | 120 | self::$user_default_data['step'] = 'none'; |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - private static function setGroupUserDefaultData (array $group_user = []): void { |
|
| 136 | + private static function setGroupUserDefaultData(array $group_user = []): void { |
|
| 137 | 137 | self::$group_user_default_data = $group_user ?? self::$group_user_default_data; |
| 138 | 138 | if (!isset(self::$group_user_default_data['step'])) { |
| 139 | 139 | self::$group_user_default_data['step'] = 'none'; |
@@ -161,10 +161,10 @@ discard block |
||
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | if (!file_exists(realpath(self::$folder.'/global.json'))) { |
| 164 | - file_put_contents(self::$folder.'/global.json',self::$global_default_data); |
|
| 164 | + file_put_contents(self::$folder.'/global.json', self::$global_default_data); |
|
| 165 | 165 | } |
| 166 | 166 | if (!file_exists(realpath(self::$folder.'/ids.json'))) { |
| 167 | - file_put_contents(self::$folder.'/ids.json',json_encode([ |
|
| 167 | + file_put_contents(self::$folder.'/ids.json', json_encode([ |
|
| 168 | 168 | 'privates' => [], |
| 169 | 169 | 'groups' => [], |
| 170 | 170 | 'supergroups' => [], |
@@ -173,25 +173,25 @@ discard block |
||
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - private static function load (): void { |
|
| 176 | + private static function load(): void { |
|
| 177 | 177 | self::$global = json_decode(file_get_contents(self::$folder.'/global.json')); |
| 178 | 178 | self::$old_global = clone self::$global; |
| 179 | - self::$ids = json_decode(file_get_contents(self::$folder.'/ids.json'),true); |
|
| 179 | + self::$ids = json_decode(file_get_contents(self::$folder.'/ids.json'), true); |
|
| 180 | 180 | self::$old_ids = clone self::$ids; |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - private static function read (string $address) { |
|
| 183 | + private static function read(string $address) { |
|
| 184 | 184 | return file_exists(realpath(self::$folder.'/'.$address.'.json')) ? json_decode(file_get_contents(self::$folder.'/'.$address.'.json'), false) : null; |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - private static function write (string $address,string $data): void { |
|
| 188 | - file_put_contents(self::$folder.'/'.$address.'.json',$data); |
|
| 187 | + private static function write(string $address, string $data): void { |
|
| 188 | + file_put_contents(self::$folder.'/'.$address.'.json', $data); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | /** |
| 192 | 192 | * @internal Only for BPT self usage , Don't use it in your source! |
| 193 | 193 | */ |
| 194 | - public static function process (): void { |
|
| 194 | + public static function process(): void { |
|
| 195 | 195 | if (isset(BPT::$update->message)) { |
| 196 | 196 | self::processMessage(BPT::$update->message); |
| 197 | 197 | } |
@@ -214,16 +214,16 @@ discard block |
||
| 214 | 214 | */ |
| 215 | 215 | public static function save(): void { |
| 216 | 216 | if (self::$user !== self::$old_user && !empty(self::$user_id)) { |
| 217 | - self::write('privates/' . self::$user_id,json_encode(self::$user)); |
|
| 217 | + self::write('privates/'.self::$user_id, json_encode(self::$user)); |
|
| 218 | 218 | } |
| 219 | 219 | if (self::$group !== self::$old_group && !empty(self::$group_id)) { |
| 220 | - self::write('groups/' . self::$group_id,json_encode(self::$group)); |
|
| 220 | + self::write('groups/'.self::$group_id, json_encode(self::$group)); |
|
| 221 | 221 | } |
| 222 | 222 | if (self::$supergroup !== self::$old_supergroup && !empty(self::$supergroup_id)) { |
| 223 | - self::write('supergroups/' . self::$supergroup_id,json_encode(self::$supergroup)); |
|
| 223 | + self::write('supergroups/'.self::$supergroup_id, json_encode(self::$supergroup)); |
|
| 224 | 224 | } |
| 225 | 225 | if (self::$channel !== self::$old_channel && !empty(self::$channel_id)) { |
| 226 | - self::write('channels/' . self::$channel_id,json_encode(self::$channel)); |
|
| 226 | + self::write('channels/'.self::$channel_id, json_encode(self::$channel)); |
|
| 227 | 227 | } |
| 228 | 228 | if (self::$group_user !== self::$old_group_user && !empty(self::$group_user_id)) { |
| 229 | 229 | if (empty(self::$group)) { |
@@ -234,13 +234,13 @@ discard block |
||
| 234 | 234 | $category = 'groups'; |
| 235 | 235 | $group_id = self::$group_id; |
| 236 | 236 | } |
| 237 | - self::write($category . '/' . $group_id . '/' . self::$group_user_id,json_encode(self::$group_user)); |
|
| 237 | + self::write($category.'/'.$group_id.'/'.self::$group_user_id, json_encode(self::$group_user)); |
|
| 238 | 238 | } |
| 239 | 239 | if (self::$ids !== self::$old_ids) { |
| 240 | - self::write('ids',json_encode(self::$ids)); |
|
| 240 | + self::write('ids', json_encode(self::$ids)); |
|
| 241 | 241 | } |
| 242 | 242 | if (self::$global !== self::$old_global) { |
| 243 | - self::write('global',json_encode(self::$global)); |
|
| 243 | + self::write('global', json_encode(self::$global)); |
|
| 244 | 244 | } |
| 245 | 245 | if (self::$group_ids !== self::$old_group_ids) { |
| 246 | 246 | if (empty(self::$group)) { |
@@ -251,17 +251,17 @@ discard block |
||
| 251 | 251 | $category = 'groups'; |
| 252 | 252 | $group_id = self::$group_id; |
| 253 | 253 | } |
| 254 | - self::write($category . '/' . $group_id . '/users',json_encode(self::$group_user)); |
|
| 254 | + self::write($category.'/'.$group_id.'/users', json_encode(self::$group_user)); |
|
| 255 | 255 | } |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | private static function processMessage(message $update): void { |
| 259 | 259 | $type = $update->chat->type; |
| 260 | - $category = $type . 's'; |
|
| 260 | + $category = $type.'s'; |
|
| 261 | 261 | if ($type === chatType::PRIVATE) { |
| 262 | 262 | self::$user_id = $update->from->id; |
| 263 | - if (in_array(self::$user_id,self::$ids[$category])) { |
|
| 264 | - self::$user = self::read($category . '/' . self::$user_id); |
|
| 263 | + if (in_array(self::$user_id, self::$ids[$category])) { |
|
| 264 | + self::$user = self::read($category.'/'.self::$user_id); |
|
| 265 | 265 | self::$old_user = clone self::$user; |
| 266 | 266 | self::$user->last_active = time(); |
| 267 | 267 | } |
@@ -269,10 +269,10 @@ discard block |
||
| 269 | 269 | self::$ids[$category][] = self::$user_id; |
| 270 | 270 | self::$user = (object) self::$user_default_data; |
| 271 | 271 | self::$user->first_active = self::$user->last_active = time(); |
| 272 | - if (isset($update->command) && isset($update->command_payload) && $update->command === 'start' && str_starts_with($update->command_payload,'ref_')) { |
|
| 273 | - if (tools::isShorted(substr($update->command_payload,4))) { |
|
| 274 | - $referral = tools::shortDecode(substr($update->command_payload,4)); |
|
| 275 | - if (in_array($referral,self::$ids[$category])) { |
|
| 272 | + if (isset($update->command) && isset($update->command_payload) && $update->command === 'start' && str_starts_with($update->command_payload, 'ref_')) { |
|
| 273 | + if (tools::isShorted(substr($update->command_payload, 4))) { |
|
| 274 | + $referral = tools::shortDecode(substr($update->command_payload, 4)); |
|
| 275 | + if (in_array($referral, self::$ids[$category])) { |
|
| 276 | 276 | self::$user->referral = $referral; |
| 277 | 277 | } |
| 278 | 278 | } |
@@ -281,8 +281,8 @@ discard block |
||
| 281 | 281 | } |
| 282 | 282 | elseif ($type === chatType::CHANNEL) { |
| 283 | 283 | self::$channel_id = $update->chat->id; |
| 284 | - if (in_array(self::$channel_id,self::$ids[$category])) { |
|
| 285 | - self::$channel = self::read($category . '/' . self::$channel_id); |
|
| 284 | + if (in_array(self::$channel_id, self::$ids[$category])) { |
|
| 285 | + self::$channel = self::read($category.'/'.self::$channel_id); |
|
| 286 | 286 | self::$old_channel = clone self::$channel; |
| 287 | 287 | } |
| 288 | 288 | else { |
@@ -296,10 +296,10 @@ discard block |
||
| 296 | 296 | $chat_id = $update->chat->id; |
| 297 | 297 | if ($type === chatType::SUPERGROUP) { |
| 298 | 298 | self::$supergroup_id = $update->chat->id; |
| 299 | - if (in_array($chat_id,self::$ids[$category])) { |
|
| 300 | - self::$supergroup = self::read($category . '/' . $chat_id); |
|
| 299 | + if (in_array($chat_id, self::$ids[$category])) { |
|
| 300 | + self::$supergroup = self::read($category.'/'.$chat_id); |
|
| 301 | 301 | self::$old_supergroup = clone self::$supergroup; |
| 302 | - self::$group_ids = self::read($category . '/' . $chat_id . '/users'); |
|
| 302 | + self::$group_ids = self::read($category.'/'.$chat_id.'/users'); |
|
| 303 | 303 | self::$old_group_ids = clone self::$group_ids; |
| 304 | 304 | } |
| 305 | 305 | else { |
@@ -310,10 +310,10 @@ discard block |
||
| 310 | 310 | } |
| 311 | 311 | else { |
| 312 | 312 | self::$group_id = $update->chat->id; |
| 313 | - if (in_array($chat_id,self::$ids[$category])) { |
|
| 314 | - self::$group = self::read($category . '/' . $chat_id); |
|
| 313 | + if (in_array($chat_id, self::$ids[$category])) { |
|
| 314 | + self::$group = self::read($category.'/'.$chat_id); |
|
| 315 | 315 | self::$old_group = clone self::$group; |
| 316 | - self::$group_ids = self::read($category . '/' . $chat_id . '/users'); |
|
| 316 | + self::$group_ids = self::read($category.'/'.$chat_id.'/users'); |
|
| 317 | 317 | self::$old_group_ids = clone self::$group_ids; |
| 318 | 318 | } |
| 319 | 319 | else { |
@@ -323,8 +323,8 @@ discard block |
||
| 323 | 323 | } |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | - if (in_array(self::$user_id,self::$group_ids)) { |
|
| 327 | - self::$group_user = self::read($category . '/' . $chat_id . '/' . self::$user_id); |
|
| 326 | + if (in_array(self::$user_id, self::$group_ids)) { |
|
| 327 | + self::$group_user = self::read($category.'/'.$chat_id.'/'.self::$user_id); |
|
| 328 | 328 | self::$old_group_user = clone self::$group_user; |
| 329 | 329 | } |
| 330 | 330 | else { |
@@ -340,42 +340,42 @@ discard block |
||
| 340 | 340 | |
| 341 | 341 | private static function processCallbackQuery(callbackQuery $update): void { |
| 342 | 342 | $type = $update->message->chat->type; |
| 343 | - $category = $type . 's'; |
|
| 343 | + $category = $type.'s'; |
|
| 344 | 344 | if ($type === chatType::PRIVATE) { |
| 345 | 345 | self::$user_id = $update->from->id; |
| 346 | - if (in_array(self::$user_id,self::$ids[$category])) { |
|
| 347 | - self::$user = self::read($category . '/' . self::$user_id); |
|
| 346 | + if (in_array(self::$user_id, self::$ids[$category])) { |
|
| 347 | + self::$user = self::read($category.'/'.self::$user_id); |
|
| 348 | 348 | self::$old_user = clone self::$user; |
| 349 | 349 | self::$user->last_active = time(); |
| 350 | 350 | } |
| 351 | 351 | } |
| 352 | 352 | elseif ($type === chatType::CHANNEL) { |
| 353 | 353 | self::$channel_id = $update->message->chat->id; |
| 354 | - if (in_array(self::$channel_id,self::$ids[$category])) { |
|
| 355 | - self::$channel = self::read($category . '/' . self::$channel_id); |
|
| 354 | + if (in_array(self::$channel_id, self::$ids[$category])) { |
|
| 355 | + self::$channel = self::read($category.'/'.self::$channel_id); |
|
| 356 | 356 | self::$old_channel = clone self::$channel; |
| 357 | 357 | } |
| 358 | 358 | } |
| 359 | 359 | else { |
| 360 | 360 | self::$user_id = $update->from->id; |
| 361 | 361 | $chat_id = $update->message->chat->id; |
| 362 | - if (in_array($chat_id,self::$ids[$category])) { |
|
| 362 | + if (in_array($chat_id, self::$ids[$category])) { |
|
| 363 | 363 | if ($type === chatType::SUPERGROUP) { |
| 364 | 364 | self::$supergroup_id = $update->message->chat->id; |
| 365 | - self::$supergroup = self::read($category . '/' . $chat_id); |
|
| 365 | + self::$supergroup = self::read($category.'/'.$chat_id); |
|
| 366 | 366 | self::$old_supergroup = clone self::$supergroup; |
| 367 | 367 | } |
| 368 | 368 | else { |
| 369 | 369 | self::$group_id = $update->message->chat->id; |
| 370 | - self::$group = self::read($category . '/' . $chat_id); |
|
| 370 | + self::$group = self::read($category.'/'.$chat_id); |
|
| 371 | 371 | self::$old_group = clone self::$group; |
| 372 | 372 | } |
| 373 | - self::$group_ids = self::read($category . '/' . $chat_id . '/users'); |
|
| 373 | + self::$group_ids = self::read($category.'/'.$chat_id.'/users'); |
|
| 374 | 374 | self::$old_group_ids = clone self::$group_ids; |
| 375 | 375 | } |
| 376 | 376 | |
| 377 | - if (in_array(self::$user_id,self::$group_ids)) { |
|
| 378 | - self::$group_user = self::read($category . '/' . $chat_id . '/' . self::$user_id); |
|
| 377 | + if (in_array(self::$user_id, self::$group_ids)) { |
|
| 378 | + self::$group_user = self::read($category.'/'.$chat_id.'/'.self::$user_id); |
|
| 379 | 379 | self::$group_user_id = self::$user_id; |
| 380 | 380 | self::$old_group_user = clone self::$group_user; |
| 381 | 381 | } |
@@ -389,10 +389,10 @@ discard block |
||
| 389 | 389 | private static function processInlineQuery(inlineQuery $update): void { |
| 390 | 390 | $type = $update->chat_type; |
| 391 | 391 | if ($type === chatType::PRIVATE || $type === chatType::SENDER) { |
| 392 | - $category = chatType::PRIVATE . 's'; |
|
| 392 | + $category = chatType::PRIVATE.'s'; |
|
| 393 | 393 | self::$user_id = $update->from->id; |
| 394 | - if (in_array(self::$user_id,self::$ids[$category])) { |
|
| 395 | - self::$user = self::read($category . '/' . self::$user_id); |
|
| 394 | + if (in_array(self::$user_id, self::$ids[$category])) { |
|
| 395 | + self::$user = self::read($category.'/'.self::$user_id); |
|
| 396 | 396 | self::$old_user = clone self::$user; |
| 397 | 397 | self::$user->last_active = time(); |
| 398 | 398 | } |
@@ -402,11 +402,11 @@ discard block |
||
| 402 | 402 | private static function processChatMember(chatMemberUpdated $update): void { |
| 403 | 403 | $type = $update->chat->type; |
| 404 | 404 | |
| 405 | - $category = $type . 's'; |
|
| 405 | + $category = $type.'s'; |
|
| 406 | 406 | if ($type === chatType::CHANNEL) { |
| 407 | 407 | self::$channel_id = $update->chat->id; |
| 408 | - if (in_array(self::$channel_id,self::$ids[$category])) { |
|
| 409 | - self::$channel = self::read($category . '/' . self::$channel_id); |
|
| 408 | + if (in_array(self::$channel_id, self::$ids[$category])) { |
|
| 409 | + self::$channel = self::read($category.'/'.self::$channel_id); |
|
| 410 | 410 | self::$old_channel = clone self::$channel; |
| 411 | 411 | } |
| 412 | 412 | else { |
@@ -425,10 +425,10 @@ discard block |
||
| 425 | 425 | |
| 426 | 426 | if ($type === chatType::SUPERGROUP) { |
| 427 | 427 | self::$supergroup_id = $chat_id; |
| 428 | - if (in_array($chat_id,self::$ids[$category])) { |
|
| 429 | - self::$supergroup = self::read($category . '/' . $chat_id); |
|
| 428 | + if (in_array($chat_id, self::$ids[$category])) { |
|
| 429 | + self::$supergroup = self::read($category.'/'.$chat_id); |
|
| 430 | 430 | self::$old_supergroup = clone self::$supergroup; |
| 431 | - self::$group_ids = self::read($category . '/' . $chat_id . '/users'); |
|
| 431 | + self::$group_ids = self::read($category.'/'.$chat_id.'/users'); |
|
| 432 | 432 | self::$old_group_ids = clone self::$group_ids; |
| 433 | 433 | } |
| 434 | 434 | else { |
@@ -439,10 +439,10 @@ discard block |
||
| 439 | 439 | } |
| 440 | 440 | elseif ($type === chatType::GROUP) { |
| 441 | 441 | self::$group_id = $chat_id; |
| 442 | - if (in_array($chat_id,self::$ids[$category])) { |
|
| 443 | - self::$group = self::read($category . '/' . $chat_id); |
|
| 442 | + if (in_array($chat_id, self::$ids[$category])) { |
|
| 443 | + self::$group = self::read($category.'/'.$chat_id); |
|
| 444 | 444 | self::$old_group = clone self::$group; |
| 445 | - self::$group_ids = self::read($category . '/' . $chat_id . '/users'); |
|
| 445 | + self::$group_ids = self::read($category.'/'.$chat_id.'/users'); |
|
| 446 | 446 | self::$old_group_ids = clone self::$group_ids; |
| 447 | 447 | } |
| 448 | 448 | else { |
@@ -452,13 +452,13 @@ discard block |
||
| 452 | 452 | } |
| 453 | 453 | } |
| 454 | 454 | |
| 455 | - if (!in_array($user_id,self::$group_ids)) { |
|
| 455 | + if (!in_array($user_id, self::$group_ids)) { |
|
| 456 | 456 | self::$group_ids[] = $user_id; |
| 457 | 457 | self::$group_user = (object) self::$group_user_default_data; |
| 458 | 458 | } |
| 459 | 459 | else { |
| 460 | 460 | self::$group_user_id = $by_id == $user_id ? $user_id : $by_id; |
| 461 | - self::$group_user = self::read($category . '/' . $chat_id . '/' . self::$group_user_id); |
|
| 461 | + self::$group_user = self::read($category.'/'.$chat_id.'/'.self::$group_user_id); |
|
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | if ($new_user->status === chatMemberStatus::LEFT || $new_user->status === chatMemberStatus::KICKED) { |
@@ -497,9 +497,9 @@ discard block |
||
| 497 | 497 | * @return bool |
| 498 | 498 | * @throws bptException |
| 499 | 499 | */ |
| 500 | - public static function deleteUser (int $user_id = null): bool { |
|
| 500 | + public static function deleteUser(int $user_id = null): bool { |
|
| 501 | 501 | if (empty($user_id)) $user_id = telegram::catchFields(fields::USER_ID); |
| 502 | - if (!file_exists(realpath(self::$folder . '/privates/' . $user_id . '.json'))) { |
|
| 502 | + if (!file_exists(realpath(self::$folder.'/privates/'.$user_id.'.json'))) { |
|
| 503 | 503 | return false; |
| 504 | 504 | } |
| 505 | 505 | unset(self::$ids['privates'][array_search($user_id, self::$ids['privates'])]); |
@@ -507,7 +507,7 @@ discard block |
||
| 507 | 507 | if ($user_id === self::$user_id) { |
| 508 | 508 | self::$user = self::$old_user = null; |
| 509 | 509 | } |
| 510 | - return tools::delete(self::$folder . '/privates/' . $user_id . '.json'); |
|
| 510 | + return tools::delete(self::$folder.'/privates/'.$user_id.'.json'); |
|
| 511 | 511 | } |
| 512 | 512 | |
| 513 | 513 | /** |
@@ -518,18 +518,18 @@ discard block |
||
| 518 | 518 | * @return bool |
| 519 | 519 | * @throws bptException |
| 520 | 520 | */ |
| 521 | - public static function deleteGroup (int $group_id = null): bool { |
|
| 521 | + public static function deleteGroup(int $group_id = null): bool { |
|
| 522 | 522 | if (empty($group_id)) $group_id = telegram::catchFields(fields::CHAT_ID); |
| 523 | - if (!file_exists(realpath(self::$folder . '/groups/' . $group_id . '.json'))) { |
|
| 523 | + if (!file_exists(realpath(self::$folder.'/groups/'.$group_id.'.json'))) { |
|
| 524 | 524 | return false; |
| 525 | 525 | } |
| 526 | 526 | unset(self::$ids['groups'][array_search($group_id, self::$ids['groups'])]); |
| 527 | 527 | sort(self::$ids['groups']); |
| 528 | - tools::delete(self::$folder . '/groups/' . $group_id); |
|
| 528 | + tools::delete(self::$folder.'/groups/'.$group_id); |
|
| 529 | 529 | if ($group_id === self::$group_id) { |
| 530 | 530 | self::$group = self::$old_group = null; |
| 531 | 531 | } |
| 532 | - return tools::delete(self::$folder . '/groups/' . $group_id . '.json'); |
|
| 532 | + return tools::delete(self::$folder.'/groups/'.$group_id.'.json'); |
|
| 533 | 533 | } |
| 534 | 534 | |
| 535 | 535 | /** |
@@ -540,18 +540,18 @@ discard block |
||
| 540 | 540 | * @return bool |
| 541 | 541 | * @throws bptException |
| 542 | 542 | */ |
| 543 | - public static function deleteSuperGroup (int $group_id = null): bool { |
|
| 543 | + public static function deleteSuperGroup(int $group_id = null): bool { |
|
| 544 | 544 | if (empty($group_id)) $group_id = telegram::catchFields(fields::CHAT_ID); |
| 545 | - if (!file_exists(realpath(self::$folder . '/supergroups/' . $group_id . '.json'))) { |
|
| 545 | + if (!file_exists(realpath(self::$folder.'/supergroups/'.$group_id.'.json'))) { |
|
| 546 | 546 | return false; |
| 547 | 547 | } |
| 548 | 548 | unset(self::$ids['supergroups'][array_search($group_id, self::$ids['supergroups'])]); |
| 549 | 549 | sort(self::$ids['supergroups']); |
| 550 | - tools::delete(self::$folder . '/supergroups/' . $group_id); |
|
| 550 | + tools::delete(self::$folder.'/supergroups/'.$group_id); |
|
| 551 | 551 | if ($group_id === self::$supergroup_id) { |
| 552 | 552 | self::$supergroup = self::$old_supergroup = null; |
| 553 | 553 | } |
| 554 | - return tools::delete(self::$folder . '/supergroups/' . $group_id . '.json'); |
|
| 554 | + return tools::delete(self::$folder.'/supergroups/'.$group_id.'.json'); |
|
| 555 | 555 | } |
| 556 | 556 | |
| 557 | 557 | /** |
@@ -562,9 +562,9 @@ discard block |
||
| 562 | 562 | * @return bool |
| 563 | 563 | * @throws bptException |
| 564 | 564 | */ |
| 565 | - public static function deleteChannel (int $channel_id = null): bool { |
|
| 565 | + public static function deleteChannel(int $channel_id = null): bool { |
|
| 566 | 566 | if (empty($channel_id)) $channel_id = telegram::catchFields(fields::CHAT_ID); |
| 567 | - if (!file_exists(realpath(self::$folder . '/channels/' . $channel_id . '.json'))) { |
|
| 567 | + if (!file_exists(realpath(self::$folder.'/channels/'.$channel_id.'.json'))) { |
|
| 568 | 568 | return false; |
| 569 | 569 | } |
| 570 | 570 | unset(self::$ids['channels'][array_search($channel_id, self::$ids['channels'])]); |
@@ -572,7 +572,7 @@ discard block |
||
| 572 | 572 | if ($channel_id === self::$channel_id) { |
| 573 | 573 | self::$channel = self::$old_channel = null; |
| 574 | 574 | } |
| 575 | - return tools::delete(self::$folder . '/channels/' . $channel_id . '.json'); |
|
| 575 | + return tools::delete(self::$folder.'/channels/'.$channel_id.'.json'); |
|
| 576 | 576 | } |
| 577 | 577 | |
| 578 | 578 | /** |
@@ -580,7 +580,7 @@ discard block |
||
| 580 | 580 | * |
| 581 | 581 | * @return int[] |
| 582 | 582 | */ |
| 583 | - public static function getUsers (): array { |
|
| 583 | + public static function getUsers(): array { |
|
| 584 | 584 | return self::$ids['privates'] ?? []; |
| 585 | 585 | } |
| 586 | 586 | |
@@ -589,7 +589,7 @@ discard block |
||
| 589 | 589 | * |
| 590 | 590 | * @return int[] |
| 591 | 591 | */ |
| 592 | - public static function getGroups (): array { |
|
| 592 | + public static function getGroups(): array { |
|
| 593 | 593 | return self::$ids['groups'] ?? []; |
| 594 | 594 | } |
| 595 | 595 | |
@@ -598,7 +598,7 @@ discard block |
||
| 598 | 598 | * |
| 599 | 599 | * @return int[] |
| 600 | 600 | */ |
| 601 | - public static function getSuperGroups (): array { |
|
| 601 | + public static function getSuperGroups(): array { |
|
| 602 | 602 | return self::$ids['supergroups'] ?? []; |
| 603 | 603 | } |
| 604 | 604 | |
@@ -607,7 +607,7 @@ discard block |
||
| 607 | 607 | * |
| 608 | 608 | * @return int[] |
| 609 | 609 | */ |
| 610 | - public static function getChannels (): array { |
|
| 610 | + public static function getChannels(): array { |
|
| 611 | 611 | return self::$ids['channels'] ?? []; |
| 612 | 612 | } |
| 613 | 613 | } |