@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | public static int $log_size = 10; |
| 30 | 30 | |
| 31 | - public static string|CURLFile|null $certificate = null; |
|
| 31 | + public static string | CURLFile | null $certificate = null; |
|
| 32 | 32 | |
| 33 | 33 | public static bool $handler = true; |
| 34 | 34 | |
@@ -62,14 +62,14 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | public static array $allowed_updates = ['message', 'edited_channel_post', 'callback_query', 'inline_query']; |
| 64 | 64 | |
| 65 | - public static array|null $db = null; |
|
| 65 | + public static array | null $db = null; |
|
| 66 | 66 | |
| 67 | - public static array|null $pay = null; |
|
| 67 | + public static array | null $pay = null; |
|
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | 70 | * @internal Only for BPT self usage , Don't use it in your source! |
| 71 | 71 | */ |
| 72 | - public static function init (array|stdClass $settings): void { |
|
| 72 | + public static function init(array | stdClass $settings): void { |
|
| 73 | 73 | $settings = (array) $settings; |
| 74 | 74 | foreach ($settings as $setting => $value) { |
| 75 | 75 | try { |
@@ -77,10 +77,10 @@ discard block |
||
| 77 | 77 | if (!is_dir(realpath('bots_files'))) { |
| 78 | 78 | mkdir('bots_files'); |
| 79 | 79 | } |
| 80 | - if (!is_dir(realpath('bots_files/' . $value))) { |
|
| 81 | - mkdir('bots_files/' . $value); |
|
| 80 | + if (!is_dir(realpath('bots_files/'.$value))) { |
|
| 81 | + mkdir('bots_files/'.$value); |
|
| 82 | 82 | } |
| 83 | - $value = 'bots_files/' . $value . '/'; |
|
| 83 | + $value = 'bots_files/'.$value.'/'; |
|
| 84 | 84 | } |
| 85 | 85 | self::$$setting = $value; |
| 86 | 86 | } |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | /** |
| 120 | 120 | * @internal Only for BPT self usage , Don't use it in your source! |
| 121 | 121 | */ |
| 122 | - public static function done (): void { |
|
| 122 | + public static function done(): void { |
|
| 123 | 123 | if (self::$logger) { |
| 124 | 124 | $estimated = round((microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']) * 1000, 2); |
| 125 | 125 | $status_message = match (true) { |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - private static function security (): void { |
|
| 137 | + private static function security(): void { |
|
| 138 | 138 | if (self::$security) { |
| 139 | 139 | ini_set('magic_quotes_gpc', 'off'); |
| 140 | 140 | ini_set('sql.safe_mode', 'on'); |
@@ -149,11 +149,11 @@ discard block |
||
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - private static function secureFolder (): void { |
|
| 152 | + private static function secureFolder(): void { |
|
| 153 | 153 | if (self::$secure_folder) { |
| 154 | 154 | $address = explode('/', $_SERVER['REQUEST_URI']); |
| 155 | 155 | unset($address[count($address) - 1]); |
| 156 | - $address = implode('/', $address) . '/BPT.php'; |
|
| 156 | + $address = implode('/', $address).'/BPT.php'; |
|
| 157 | 157 | $text = "ErrorDocument 404 $address\nErrorDocument 403 $address\n Options -Indexes\n Order Deny,Allow\nDeny from all\nAllow from 127.0.0.1\n<Files *.php>\n Order Allow,Deny\n Allow from all\n</Files>"; |
| 158 | 158 | $htaccess = realpath('.htaccess'); |
| 159 | 159 | if (!file_exists($htaccess) || filesize($htaccess) != strlen($text)) { |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - private static function getUpdates (): void { |
|
| 165 | + private static function getUpdates(): void { |
|
| 166 | 166 | if (!self::$handler) { |
| 167 | 167 | logger::write('You can\'t use getUpdates receiver when handler is off , use webhook or use handler', loggerTypes::ERROR); |
| 168 | 168 | throw new bptException('GETUPDATE_NEED_HANDLER'); |
@@ -17,40 +17,40 @@ |
||
| 17 | 17 | /** |
| 18 | 18 | * @internal Only for BPT self usage , Don't use it in your source! |
| 19 | 19 | */ |
| 20 | - public static function init(string $method,array $data): bool { |
|
| 20 | + public static function init(string $method, array $data): bool { |
|
| 21 | 21 | self::checkWebhook(); |
| 22 | 22 | self::sieveData($data); |
| 23 | 23 | self::$is_answered = true; |
| 24 | 24 | $data['method'] = $method; |
| 25 | 25 | $payload = json_encode($data); |
| 26 | - header('Content-Type: application/json;Content-Length: ' . strlen($payload)); |
|
| 26 | + header('Content-Type: application/json;Content-Length: '.strlen($payload)); |
|
| 27 | 27 | echo $payload; |
| 28 | 28 | return true; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - public static function isAnswered (): bool { |
|
| 31 | + public static function isAnswered(): bool { |
|
| 32 | 32 | return self::$is_answered; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | private static function checkWebhook(): void { |
| 36 | - if(settings::$receiver === receiver::GETUPDATES) { |
|
| 37 | - logger::write('Answer mode only work when receiver is webhook',loggerTypes::ERROR); |
|
| 36 | + if (settings::$receiver === receiver::GETUPDATES) { |
|
| 37 | + logger::write('Answer mode only work when receiver is webhook', loggerTypes::ERROR); |
|
| 38 | 38 | throw new bptException('ANSWER_MODE_GETUPDATES'); |
| 39 | 39 | } |
| 40 | - if(settings::$multi) { |
|
| 41 | - logger::write('You can not use answer mode when multi setting is on',loggerTypes::ERROR); |
|
| 40 | + if (settings::$multi) { |
|
| 41 | + logger::write('You can not use answer mode when multi setting is on', loggerTypes::ERROR); |
|
| 42 | 42 | throw new bptException('ANSWER_MODE_MULTI'); |
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | private static function sieveData(array &$data): void { |
| 47 | - unset($data['token'],$data['forgot'],$data['return_array']); |
|
| 47 | + unset($data['token'], $data['forgot'], $data['return_array']); |
|
| 48 | 48 | |
| 49 | - foreach ($data as $key=>&$value){ |
|
| 50 | - if (!isset($value)){ |
|
| 49 | + foreach ($data as $key=>&$value) { |
|
| 50 | + if (!isset($value)) { |
|
| 51 | 51 | unset($data[$key]); |
| 52 | 52 | } |
| 53 | - elseif (is_array($value) || is_object($value)){ |
|
| 53 | + elseif (is_array($value) || is_object($value)) { |
|
| 54 | 54 | $value = json_encode($value); |
| 55 | 55 | } |
| 56 | 56 | } |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | /** |
| 104 | 104 | * @internal Only for BPT self usage , Don't use it in your source! |
| 105 | 105 | */ |
| 106 | - public static function init (): void { |
|
| 106 | + public static function init(): void { |
|
| 107 | 107 | self::$folder = settings::$name.'database'; |
| 108 | 108 | self::$global_default_data = settings::$db['global'] ?? self::$global_default_data; |
| 109 | 109 | self::setUserDefaultData(); |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | self::load(); |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - private static function setUserDefaultData (): void { |
|
| 118 | + private static function setUserDefaultData(): void { |
|
| 119 | 119 | self::$user_default_data = settings::$db['user'] ?? self::$user_default_data; |
| 120 | 120 | if (!isset(self::$user_default_data['step'])) { |
| 121 | 121 | self::$user_default_data['step'] = 'none'; |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - private static function setGroupUserDefaultData (): void { |
|
| 137 | + private static function setGroupUserDefaultData(): void { |
|
| 138 | 138 | self::$group_user_default_data = settings::$db['group_user'] ?? self::$group_user_default_data; |
| 139 | 139 | if (!isset(self::$group_user_default_data['step'])) { |
| 140 | 140 | self::$group_user_default_data['step'] = 'none'; |
@@ -162,10 +162,10 @@ discard block |
||
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | if (!file_exists(realpath(self::$folder.'/global.json'))) { |
| 165 | - file_put_contents(self::$folder.'/global.json',self::$global_default_data); |
|
| 165 | + file_put_contents(self::$folder.'/global.json', self::$global_default_data); |
|
| 166 | 166 | } |
| 167 | 167 | if (!file_exists(realpath(self::$folder.'/ids.json'))) { |
| 168 | - file_put_contents(self::$folder.'/ids.json',json_encode([ |
|
| 168 | + file_put_contents(self::$folder.'/ids.json', json_encode([ |
|
| 169 | 169 | 'privates' => [], |
| 170 | 170 | 'groups' => [], |
| 171 | 171 | 'supergroups' => [], |
@@ -174,25 +174,25 @@ discard block |
||
| 174 | 174 | } |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - private static function load (): void { |
|
| 177 | + private static function load(): void { |
|
| 178 | 178 | self::$global = json_decode(file_get_contents(self::$folder.'/global.json')); |
| 179 | 179 | self::$old_global = clone self::$global; |
| 180 | - self::$ids = json_decode(file_get_contents(self::$folder.'/ids.json'),true); |
|
| 180 | + self::$ids = json_decode(file_get_contents(self::$folder.'/ids.json'), true); |
|
| 181 | 181 | self::$old_ids = clone self::$ids; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - private static function read (string $address) { |
|
| 184 | + private static function read(string $address) { |
|
| 185 | 185 | return file_exists(realpath(self::$folder.'/'.$address.'.json')) ? json_decode(file_get_contents(self::$folder.'/'.$address.'.json'), false) : null; |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - private static function write (string $address,string $data): void { |
|
| 189 | - file_put_contents(self::$folder.'/'.$address.'.json',$data); |
|
| 188 | + private static function write(string $address, string $data): void { |
|
| 189 | + file_put_contents(self::$folder.'/'.$address.'.json', $data); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | /** |
| 193 | 193 | * @internal Only for BPT self usage , Don't use it in your source! |
| 194 | 194 | */ |
| 195 | - public static function process (): void { |
|
| 195 | + public static function process(): void { |
|
| 196 | 196 | if (isset(BPT::$update->message)) { |
| 197 | 197 | self::processMessage(BPT::$update->message); |
| 198 | 198 | } |
@@ -215,16 +215,16 @@ discard block |
||
| 215 | 215 | */ |
| 216 | 216 | public static function save(): void { |
| 217 | 217 | if (self::$user !== self::$old_user && !empty(self::$user_id)) { |
| 218 | - self::write('privates/' . self::$user_id,json_encode(self::$user)); |
|
| 218 | + self::write('privates/'.self::$user_id, json_encode(self::$user)); |
|
| 219 | 219 | } |
| 220 | 220 | if (self::$group !== self::$old_group && !empty(self::$group_id)) { |
| 221 | - self::write('groups/' . self::$group_id,json_encode(self::$group)); |
|
| 221 | + self::write('groups/'.self::$group_id, json_encode(self::$group)); |
|
| 222 | 222 | } |
| 223 | 223 | if (self::$supergroup !== self::$old_supergroup && !empty(self::$supergroup_id)) { |
| 224 | - self::write('supergroups/' . self::$supergroup_id,json_encode(self::$supergroup)); |
|
| 224 | + self::write('supergroups/'.self::$supergroup_id, json_encode(self::$supergroup)); |
|
| 225 | 225 | } |
| 226 | 226 | if (self::$channel !== self::$old_channel && !empty(self::$channel_id)) { |
| 227 | - self::write('channels/' . self::$channel_id,json_encode(self::$channel)); |
|
| 227 | + self::write('channels/'.self::$channel_id, json_encode(self::$channel)); |
|
| 228 | 228 | } |
| 229 | 229 | if (self::$group_user !== self::$old_group_user && !empty(self::$group_user_id)) { |
| 230 | 230 | if (empty(self::$group)) { |
@@ -235,13 +235,13 @@ discard block |
||
| 235 | 235 | $category = 'groups'; |
| 236 | 236 | $group_id = self::$group_id; |
| 237 | 237 | } |
| 238 | - self::write($category . '/' . $group_id . '/' . self::$group_user_id,json_encode(self::$group_user)); |
|
| 238 | + self::write($category.'/'.$group_id.'/'.self::$group_user_id, json_encode(self::$group_user)); |
|
| 239 | 239 | } |
| 240 | 240 | if (self::$ids !== self::$old_ids) { |
| 241 | - self::write('ids',json_encode(self::$ids)); |
|
| 241 | + self::write('ids', json_encode(self::$ids)); |
|
| 242 | 242 | } |
| 243 | 243 | if (self::$global !== self::$old_global) { |
| 244 | - self::write('global',json_encode(self::$global)); |
|
| 244 | + self::write('global', json_encode(self::$global)); |
|
| 245 | 245 | } |
| 246 | 246 | if (self::$group_ids !== self::$old_group_ids) { |
| 247 | 247 | if (empty(self::$group)) { |
@@ -252,17 +252,17 @@ discard block |
||
| 252 | 252 | $category = 'groups'; |
| 253 | 253 | $group_id = self::$group_id; |
| 254 | 254 | } |
| 255 | - self::write($category . '/' . $group_id . '/users',json_encode(self::$group_user)); |
|
| 255 | + self::write($category.'/'.$group_id.'/users', json_encode(self::$group_user)); |
|
| 256 | 256 | } |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | private static function processMessage(message $update): void { |
| 260 | 260 | $type = $update->chat->type; |
| 261 | - $category = $type . 's'; |
|
| 261 | + $category = $type.'s'; |
|
| 262 | 262 | if ($type === chatType::PRIVATE) { |
| 263 | 263 | self::$user_id = $update->from->id; |
| 264 | - if (in_array(self::$user_id,self::$ids[$category])) { |
|
| 265 | - self::$user = self::read($category . '/' . self::$user_id); |
|
| 264 | + if (in_array(self::$user_id, self::$ids[$category])) { |
|
| 265 | + self::$user = self::read($category.'/'.self::$user_id); |
|
| 266 | 266 | self::$old_user = clone self::$user; |
| 267 | 267 | self::$user->last_active = time(); |
| 268 | 268 | } |
@@ -270,10 +270,10 @@ discard block |
||
| 270 | 270 | self::$ids[$category][] = self::$user_id; |
| 271 | 271 | self::$user = (object) self::$user_default_data; |
| 272 | 272 | self::$user->first_active = self::$user->last_active = time(); |
| 273 | - if (isset($update->command) && isset($update->command_payload) && $update->command === 'start' && str_starts_with($update->command_payload,'ref_')) { |
|
| 274 | - if (tools::isShorted(substr($update->command_payload,4))) { |
|
| 275 | - $referral = tools::shortDecode(substr($update->command_payload,4)); |
|
| 276 | - if (in_array($referral,self::$ids[$category])) { |
|
| 273 | + if (isset($update->command) && isset($update->command_payload) && $update->command === 'start' && str_starts_with($update->command_payload, 'ref_')) { |
|
| 274 | + if (tools::isShorted(substr($update->command_payload, 4))) { |
|
| 275 | + $referral = tools::shortDecode(substr($update->command_payload, 4)); |
|
| 276 | + if (in_array($referral, self::$ids[$category])) { |
|
| 277 | 277 | self::$user->referral = $referral; |
| 278 | 278 | } |
| 279 | 279 | } |
@@ -282,8 +282,8 @@ discard block |
||
| 282 | 282 | } |
| 283 | 283 | elseif ($type === chatType::CHANNEL) { |
| 284 | 284 | self::$channel_id = $update->chat->id; |
| 285 | - if (in_array(self::$channel_id,self::$ids[$category])) { |
|
| 286 | - self::$channel = self::read($category . '/' . self::$channel_id); |
|
| 285 | + if (in_array(self::$channel_id, self::$ids[$category])) { |
|
| 286 | + self::$channel = self::read($category.'/'.self::$channel_id); |
|
| 287 | 287 | self::$old_channel = clone self::$channel; |
| 288 | 288 | } |
| 289 | 289 | else { |
@@ -297,10 +297,10 @@ discard block |
||
| 297 | 297 | $chat_id = $update->chat->id; |
| 298 | 298 | if ($type === chatType::SUPERGROUP) { |
| 299 | 299 | self::$supergroup_id = $update->chat->id; |
| 300 | - if (in_array($chat_id,self::$ids[$category])) { |
|
| 301 | - self::$supergroup = self::read($category . '/' . $chat_id); |
|
| 300 | + if (in_array($chat_id, self::$ids[$category])) { |
|
| 301 | + self::$supergroup = self::read($category.'/'.$chat_id); |
|
| 302 | 302 | self::$old_supergroup = clone self::$supergroup; |
| 303 | - self::$group_ids = self::read($category . '/' . $chat_id . '/users'); |
|
| 303 | + self::$group_ids = self::read($category.'/'.$chat_id.'/users'); |
|
| 304 | 304 | self::$old_group_ids = clone self::$group_ids; |
| 305 | 305 | } |
| 306 | 306 | else { |
@@ -311,10 +311,10 @@ discard block |
||
| 311 | 311 | } |
| 312 | 312 | else { |
| 313 | 313 | self::$group_id = $update->chat->id; |
| 314 | - if (in_array($chat_id,self::$ids[$category])) { |
|
| 315 | - self::$group = self::read($category . '/' . $chat_id); |
|
| 314 | + if (in_array($chat_id, self::$ids[$category])) { |
|
| 315 | + self::$group = self::read($category.'/'.$chat_id); |
|
| 316 | 316 | self::$old_group = clone self::$group; |
| 317 | - self::$group_ids = self::read($category . '/' . $chat_id . '/users'); |
|
| 317 | + self::$group_ids = self::read($category.'/'.$chat_id.'/users'); |
|
| 318 | 318 | self::$old_group_ids = clone self::$group_ids; |
| 319 | 319 | } |
| 320 | 320 | else { |
@@ -324,8 +324,8 @@ discard block |
||
| 324 | 324 | } |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | - if (in_array(self::$user_id,self::$group_ids)) { |
|
| 328 | - self::$group_user = self::read($category . '/' . $chat_id . '/' . self::$user_id); |
|
| 327 | + if (in_array(self::$user_id, self::$group_ids)) { |
|
| 328 | + self::$group_user = self::read($category.'/'.$chat_id.'/'.self::$user_id); |
|
| 329 | 329 | self::$old_group_user = clone self::$group_user; |
| 330 | 330 | } |
| 331 | 331 | else { |
@@ -341,42 +341,42 @@ discard block |
||
| 341 | 341 | |
| 342 | 342 | private static function processCallbackQuery(callbackQuery $update): void { |
| 343 | 343 | $type = $update->message->chat->type; |
| 344 | - $category = $type . 's'; |
|
| 344 | + $category = $type.'s'; |
|
| 345 | 345 | if ($type === chatType::PRIVATE) { |
| 346 | 346 | self::$user_id = $update->from->id; |
| 347 | - if (in_array(self::$user_id,self::$ids[$category])) { |
|
| 348 | - self::$user = self::read($category . '/' . self::$user_id); |
|
| 347 | + if (in_array(self::$user_id, self::$ids[$category])) { |
|
| 348 | + self::$user = self::read($category.'/'.self::$user_id); |
|
| 349 | 349 | self::$old_user = clone self::$user; |
| 350 | 350 | self::$user->last_active = time(); |
| 351 | 351 | } |
| 352 | 352 | } |
| 353 | 353 | elseif ($type === chatType::CHANNEL) { |
| 354 | 354 | self::$channel_id = $update->message->chat->id; |
| 355 | - if (in_array(self::$channel_id,self::$ids[$category])) { |
|
| 356 | - self::$channel = self::read($category . '/' . self::$channel_id); |
|
| 355 | + if (in_array(self::$channel_id, self::$ids[$category])) { |
|
| 356 | + self::$channel = self::read($category.'/'.self::$channel_id); |
|
| 357 | 357 | self::$old_channel = clone self::$channel; |
| 358 | 358 | } |
| 359 | 359 | } |
| 360 | 360 | else { |
| 361 | 361 | self::$user_id = $update->from->id; |
| 362 | 362 | $chat_id = $update->message->chat->id; |
| 363 | - if (in_array($chat_id,self::$ids[$category])) { |
|
| 363 | + if (in_array($chat_id, self::$ids[$category])) { |
|
| 364 | 364 | if ($type === chatType::SUPERGROUP) { |
| 365 | 365 | self::$supergroup_id = $update->message->chat->id; |
| 366 | - self::$supergroup = self::read($category . '/' . $chat_id); |
|
| 366 | + self::$supergroup = self::read($category.'/'.$chat_id); |
|
| 367 | 367 | self::$old_supergroup = clone self::$supergroup; |
| 368 | 368 | } |
| 369 | 369 | else { |
| 370 | 370 | self::$group_id = $update->message->chat->id; |
| 371 | - self::$group = self::read($category . '/' . $chat_id); |
|
| 371 | + self::$group = self::read($category.'/'.$chat_id); |
|
| 372 | 372 | self::$old_group = clone self::$group; |
| 373 | 373 | } |
| 374 | - self::$group_ids = self::read($category . '/' . $chat_id . '/users'); |
|
| 374 | + self::$group_ids = self::read($category.'/'.$chat_id.'/users'); |
|
| 375 | 375 | self::$old_group_ids = clone self::$group_ids; |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | - if (in_array(self::$user_id,self::$group_ids)) { |
|
| 379 | - self::$group_user = self::read($category . '/' . $chat_id . '/' . self::$user_id); |
|
| 378 | + if (in_array(self::$user_id, self::$group_ids)) { |
|
| 379 | + self::$group_user = self::read($category.'/'.$chat_id.'/'.self::$user_id); |
|
| 380 | 380 | self::$group_user_id = self::$user_id; |
| 381 | 381 | self::$old_group_user = clone self::$group_user; |
| 382 | 382 | } |
@@ -390,10 +390,10 @@ discard block |
||
| 390 | 390 | private static function processInlineQuery(inlineQuery $update): void { |
| 391 | 391 | $type = $update->chat_type; |
| 392 | 392 | if ($type === chatType::PRIVATE || $type === chatType::SENDER) { |
| 393 | - $category = chatType::PRIVATE . 's'; |
|
| 393 | + $category = chatType::PRIVATE.'s'; |
|
| 394 | 394 | self::$user_id = $update->from->id; |
| 395 | - if (in_array(self::$user_id,self::$ids[$category])) { |
|
| 396 | - self::$user = self::read($category . '/' . self::$user_id); |
|
| 395 | + if (in_array(self::$user_id, self::$ids[$category])) { |
|
| 396 | + self::$user = self::read($category.'/'.self::$user_id); |
|
| 397 | 397 | self::$old_user = clone self::$user; |
| 398 | 398 | self::$user->last_active = time(); |
| 399 | 399 | } |
@@ -403,11 +403,11 @@ discard block |
||
| 403 | 403 | private static function processChatMember(chatMemberUpdated $update): void { |
| 404 | 404 | $type = $update->chat->type; |
| 405 | 405 | |
| 406 | - $category = $type . 's'; |
|
| 406 | + $category = $type.'s'; |
|
| 407 | 407 | if ($type === chatType::CHANNEL) { |
| 408 | 408 | self::$channel_id = $update->chat->id; |
| 409 | - if (in_array(self::$channel_id,self::$ids[$category])) { |
|
| 410 | - self::$channel = self::read($category . '/' . self::$channel_id); |
|
| 409 | + if (in_array(self::$channel_id, self::$ids[$category])) { |
|
| 410 | + self::$channel = self::read($category.'/'.self::$channel_id); |
|
| 411 | 411 | self::$old_channel = clone self::$channel; |
| 412 | 412 | } |
| 413 | 413 | else { |
@@ -426,10 +426,10 @@ discard block |
||
| 426 | 426 | |
| 427 | 427 | if ($type === chatType::SUPERGROUP) { |
| 428 | 428 | self::$supergroup_id = $chat_id; |
| 429 | - if (in_array($chat_id,self::$ids[$category])) { |
|
| 430 | - self::$supergroup = self::read($category . '/' . $chat_id); |
|
| 429 | + if (in_array($chat_id, self::$ids[$category])) { |
|
| 430 | + self::$supergroup = self::read($category.'/'.$chat_id); |
|
| 431 | 431 | self::$old_supergroup = clone self::$supergroup; |
| 432 | - self::$group_ids = self::read($category . '/' . $chat_id . '/users'); |
|
| 432 | + self::$group_ids = self::read($category.'/'.$chat_id.'/users'); |
|
| 433 | 433 | self::$old_group_ids = clone self::$group_ids; |
| 434 | 434 | } |
| 435 | 435 | else { |
@@ -440,10 +440,10 @@ discard block |
||
| 440 | 440 | } |
| 441 | 441 | elseif ($type === chatType::GROUP) { |
| 442 | 442 | self::$group_id = $chat_id; |
| 443 | - if (in_array($chat_id,self::$ids[$category])) { |
|
| 444 | - self::$group = self::read($category . '/' . $chat_id); |
|
| 443 | + if (in_array($chat_id, self::$ids[$category])) { |
|
| 444 | + self::$group = self::read($category.'/'.$chat_id); |
|
| 445 | 445 | self::$old_group = clone self::$group; |
| 446 | - self::$group_ids = self::read($category . '/' . $chat_id . '/users'); |
|
| 446 | + self::$group_ids = self::read($category.'/'.$chat_id.'/users'); |
|
| 447 | 447 | self::$old_group_ids = clone self::$group_ids; |
| 448 | 448 | } |
| 449 | 449 | else { |
@@ -453,13 +453,13 @@ discard block |
||
| 453 | 453 | } |
| 454 | 454 | } |
| 455 | 455 | |
| 456 | - if (!in_array($user_id,self::$group_ids)) { |
|
| 456 | + if (!in_array($user_id, self::$group_ids)) { |
|
| 457 | 457 | self::$group_ids[] = $user_id; |
| 458 | 458 | self::$group_user = (object) self::$group_user_default_data; |
| 459 | 459 | } |
| 460 | 460 | else { |
| 461 | 461 | self::$group_user_id = $by_id == $user_id ? $user_id : $by_id; |
| 462 | - self::$group_user = self::read($category . '/' . $chat_id . '/' . self::$group_user_id); |
|
| 462 | + self::$group_user = self::read($category.'/'.$chat_id.'/'.self::$group_user_id); |
|
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | if ($new_user->status === chatMemberStatus::LEFT || $new_user->status === chatMemberStatus::KICKED) { |
@@ -500,9 +500,9 @@ discard block |
||
| 500 | 500 | * @return bool |
| 501 | 501 | * @throws bptException |
| 502 | 502 | */ |
| 503 | - public static function deleteUser (int $user_id = null): bool { |
|
| 503 | + public static function deleteUser(int $user_id = null): bool { |
|
| 504 | 504 | if (empty($user_id)) $user_id = telegram::catchFields(fields::USER_ID); |
| 505 | - if (!file_exists(realpath(self::$folder . '/privates/' . $user_id . '.json'))) { |
|
| 505 | + if (!file_exists(realpath(self::$folder.'/privates/'.$user_id.'.json'))) { |
|
| 506 | 506 | return false; |
| 507 | 507 | } |
| 508 | 508 | unset(self::$ids['privates'][array_search($user_id, self::$ids['privates'])]); |
@@ -510,7 +510,7 @@ discard block |
||
| 510 | 510 | if ($user_id === self::$user_id) { |
| 511 | 511 | self::$user = self::$old_user = null; |
| 512 | 512 | } |
| 513 | - return tools::delete(self::$folder . '/privates/' . $user_id . '.json'); |
|
| 513 | + return tools::delete(self::$folder.'/privates/'.$user_id.'.json'); |
|
| 514 | 514 | } |
| 515 | 515 | |
| 516 | 516 | /** |
@@ -521,18 +521,18 @@ discard block |
||
| 521 | 521 | * @return bool |
| 522 | 522 | * @throws bptException |
| 523 | 523 | */ |
| 524 | - public static function deleteGroup (int $group_id = null): bool { |
|
| 524 | + public static function deleteGroup(int $group_id = null): bool { |
|
| 525 | 525 | if (empty($group_id)) $group_id = telegram::catchFields(fields::CHAT_ID); |
| 526 | - if (!file_exists(realpath(self::$folder . '/groups/' . $group_id . '.json'))) { |
|
| 526 | + if (!file_exists(realpath(self::$folder.'/groups/'.$group_id.'.json'))) { |
|
| 527 | 527 | return false; |
| 528 | 528 | } |
| 529 | 529 | unset(self::$ids['groups'][array_search($group_id, self::$ids['groups'])]); |
| 530 | 530 | sort(self::$ids['groups']); |
| 531 | - tools::delete(self::$folder . '/groups/' . $group_id); |
|
| 531 | + tools::delete(self::$folder.'/groups/'.$group_id); |
|
| 532 | 532 | if ($group_id === self::$group_id) { |
| 533 | 533 | self::$group = self::$old_group = null; |
| 534 | 534 | } |
| 535 | - return tools::delete(self::$folder . '/groups/' . $group_id . '.json'); |
|
| 535 | + return tools::delete(self::$folder.'/groups/'.$group_id.'.json'); |
|
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | /** |
@@ -543,18 +543,18 @@ discard block |
||
| 543 | 543 | * @return bool |
| 544 | 544 | * @throws bptException |
| 545 | 545 | */ |
| 546 | - public static function deleteSuperGroup (int $group_id = null): bool { |
|
| 546 | + public static function deleteSuperGroup(int $group_id = null): bool { |
|
| 547 | 547 | if (empty($group_id)) $group_id = telegram::catchFields(fields::CHAT_ID); |
| 548 | - if (!file_exists(realpath(self::$folder . '/supergroups/' . $group_id . '.json'))) { |
|
| 548 | + if (!file_exists(realpath(self::$folder.'/supergroups/'.$group_id.'.json'))) { |
|
| 549 | 549 | return false; |
| 550 | 550 | } |
| 551 | 551 | unset(self::$ids['supergroups'][array_search($group_id, self::$ids['supergroups'])]); |
| 552 | 552 | sort(self::$ids['supergroups']); |
| 553 | - tools::delete(self::$folder . '/supergroups/' . $group_id); |
|
| 553 | + tools::delete(self::$folder.'/supergroups/'.$group_id); |
|
| 554 | 554 | if ($group_id === self::$supergroup_id) { |
| 555 | 555 | self::$supergroup = self::$old_supergroup = null; |
| 556 | 556 | } |
| 557 | - return tools::delete(self::$folder . '/supergroups/' . $group_id . '.json'); |
|
| 557 | + return tools::delete(self::$folder.'/supergroups/'.$group_id.'.json'); |
|
| 558 | 558 | } |
| 559 | 559 | |
| 560 | 560 | /** |
@@ -565,9 +565,9 @@ discard block |
||
| 565 | 565 | * @return bool |
| 566 | 566 | * @throws bptException |
| 567 | 567 | */ |
| 568 | - public static function deleteChannel (int $channel_id = null): bool { |
|
| 568 | + public static function deleteChannel(int $channel_id = null): bool { |
|
| 569 | 569 | if (empty($channel_id)) $channel_id = telegram::catchFields(fields::CHAT_ID); |
| 570 | - if (!file_exists(realpath(self::$folder . '/channels/' . $channel_id . '.json'))) { |
|
| 570 | + if (!file_exists(realpath(self::$folder.'/channels/'.$channel_id.'.json'))) { |
|
| 571 | 571 | return false; |
| 572 | 572 | } |
| 573 | 573 | unset(self::$ids['channels'][array_search($channel_id, self::$ids['channels'])]); |
@@ -575,7 +575,7 @@ discard block |
||
| 575 | 575 | if ($channel_id === self::$channel_id) { |
| 576 | 576 | self::$channel = self::$old_channel = null; |
| 577 | 577 | } |
| 578 | - return tools::delete(self::$folder . '/channels/' . $channel_id . '.json'); |
|
| 578 | + return tools::delete(self::$folder.'/channels/'.$channel_id.'.json'); |
|
| 579 | 579 | } |
| 580 | 580 | |
| 581 | 581 | /** |
@@ -583,7 +583,7 @@ discard block |
||
| 583 | 583 | * |
| 584 | 584 | * @return int[] |
| 585 | 585 | */ |
| 586 | - public static function getUsers (): array { |
|
| 586 | + public static function getUsers(): array { |
|
| 587 | 587 | return self::$ids['privates'] ?? []; |
| 588 | 588 | } |
| 589 | 589 | |
@@ -592,7 +592,7 @@ discard block |
||
| 592 | 592 | * |
| 593 | 593 | * @return int[] |
| 594 | 594 | */ |
| 595 | - public static function getGroups (): array { |
|
| 595 | + public static function getGroups(): array { |
|
| 596 | 596 | return self::$ids['groups'] ?? []; |
| 597 | 597 | } |
| 598 | 598 | |
@@ -601,7 +601,7 @@ discard block |
||
| 601 | 601 | * |
| 602 | 602 | * @return int[] |
| 603 | 603 | */ |
| 604 | - public static function getSuperGroups (): array { |
|
| 604 | + public static function getSuperGroups(): array { |
|
| 605 | 605 | return self::$ids['supergroups'] ?? []; |
| 606 | 606 | } |
| 607 | 607 | |
@@ -610,7 +610,7 @@ discard block |
||
| 610 | 610 | * |
| 611 | 611 | * @return int[] |
| 612 | 612 | */ |
| 613 | - public static function getChannels (): array { |
|
| 613 | + public static function getChannels(): array { |
|
| 614 | 614 | return self::$ids['channels'] ?? []; |
| 615 | 615 | } |
| 616 | 616 | } |
@@ -10,8 +10,8 @@ discard block |
||
| 10 | 10 | * @Version: 2.76 =>[ 1399/11/28 = 1442/07/04 = 2021/02/16 ] |
| 11 | 11 | */ |
| 12 | 12 | class jdf { |
| 13 | - public static function jdate ($format, $timestamp = '', $none = '', $time_zone = 'Asia/Tehran', $tr_num = 'fa') { |
|
| 14 | - $T_sec = 0;/* <= رفع خطاي زمان سرور ، با اعداد '+' و '-' بر حسب ثانيه */ |
|
| 13 | + public static function jdate($format, $timestamp = '', $none = '', $time_zone = 'Asia/Tehran', $tr_num = 'fa') { |
|
| 14 | + $T_sec = 0; /* <= رفع خطاي زمان سرور ، با اعداد '+' و '-' بر حسب ثانيه */ |
|
| 15 | 15 | if ($time_zone != 'local') date_default_timezone_set(($time_zone === '') ? 'Asia/Tehran' : $time_zone); |
| 16 | 16 | $ts = $T_sec + (($timestamp === '') ? time() : self::tr_num($timestamp)); |
| 17 | 17 | $date = explode('_', date('H_i_j_n_O_P_s_w_Y', $ts)); |
@@ -55,13 +55,13 @@ discard block |
||
| 55 | 55 | $out .= (int) ($j_m / 3.1) + 1; |
| 56 | 56 | break; |
| 57 | 57 | case 'c': |
| 58 | - $out .= $j_y . '/' . $j_m . '/' . $j_d . ' ،' . $date[0] . ':' . $date[1] . ':' . $date[6] . ' ' . $date[5]; |
|
| 58 | + $out .= $j_y.'/'.$j_m.'/'.$j_d.' ،'.$date[0].':'.$date[1].':'.$date[6].' '.$date[5]; |
|
| 59 | 59 | break; |
| 60 | 60 | case 'C': |
| 61 | 61 | $out .= (int) (($j_y + 99) / 100); |
| 62 | 62 | break; |
| 63 | 63 | case 'd': |
| 64 | - $out .= ($j_d < 10) ? '0' . $j_d : $j_d; |
|
| 64 | + $out .= ($j_d < 10) ? '0'.$j_d : $j_d; |
|
| 65 | 65 | break; |
| 66 | 66 | case 'D': |
| 67 | 67 | $out .= self::jdate_words(['kh' => $date[7]], ' '); |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | $out .= $kab; |
| 98 | 98 | break; |
| 99 | 99 | case 'm': |
| 100 | - $out .= ($j_m > 9) ? $j_m : '0' . $j_m; |
|
| 100 | + $out .= ($j_m > 9) ? $j_m : '0'.$j_m; |
|
| 101 | 101 | break; |
| 102 | 102 | case 'M': |
| 103 | 103 | $out .= self::jdate_words(['km' => $j_m], ' '); |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | break; |
| 131 | 131 | case 'r': |
| 132 | 132 | $key = self::jdate_words(['rh' => $date[7], 'mm' => $j_m]); |
| 133 | - $out .= $date[0] . ':' . $date[1] . ':' . $date[6] . ' ' . $date[4] . ' ' . $key['rh'] . '، ' . $j_d . ' ' . $key['mm'] . ' ' . $j_y; |
|
| 133 | + $out .= $date[0].':'.$date[1].':'.$date[6].' '.$date[4].' '.$key['rh'].'، '.$j_d.' '.$key['mm'].' '.$j_y; |
|
| 134 | 134 | break; |
| 135 | 135 | case 's': |
| 136 | 136 | $out .= $date[6]; |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | } |
| 166 | 166 | $aks = $avs + $kab; |
| 167 | 167 | if ($aks == 7) $aks = 0; |
| 168 | - $out .= (($kab + 363 - $doy) < $aks and $aks < 3) ? '01' : (($num < 10) ? '0' . $num : $num); |
|
| 168 | + $out .= (($kab + 363 - $doy) < $aks and $aks < 3) ? '01' : (($num < 10) ? '0'.$num : $num); |
|
| 169 | 169 | break; |
| 170 | 170 | case 'y': |
| 171 | 171 | $out .= substr($j_y, 2, 2); |
@@ -182,8 +182,8 @@ discard block |
||
| 182 | 182 | } |
| 183 | 183 | return ($tr_num != 'en') ? self::tr_num($out, 'fa', '.') : $out; |
| 184 | 184 | } |
| 185 | - public static function jstrftime ($format, $timestamp = '', $none = '', $time_zone = 'Asia/Tehran', $tr_num = 'fa') { |
|
| 186 | - $T_sec = 0;/* <= رفع خطاي زمان سرور ، با اعداد '+' و '-' بر حسب ثانيه */ |
|
| 185 | + public static function jstrftime($format, $timestamp = '', $none = '', $time_zone = 'Asia/Tehran', $tr_num = 'fa') { |
|
| 186 | + $T_sec = 0; /* <= رفع خطاي زمان سرور ، با اعداد '+' و '-' بر حسب ثانيه */ |
|
| 187 | 187 | if ($time_zone != 'local') date_default_timezone_set(($time_zone === '') ? 'Asia/Tehran' : $time_zone); |
| 188 | 188 | $ts = $T_sec + (($timestamp === '') ? time() : self::tr_num($timestamp)); |
| 189 | 189 | $date = explode('_', date('h_H_i_j_n_s_w_Y', $ts)); |
@@ -211,10 +211,10 @@ discard block |
||
| 211 | 211 | $out .= self::jdate_words(['rh' => $date[6]], ' '); |
| 212 | 212 | break; |
| 213 | 213 | case 'd': |
| 214 | - $out .= ($j_d < 10) ? '0' . $j_d : $j_d; |
|
| 214 | + $out .= ($j_d < 10) ? '0'.$j_d : $j_d; |
|
| 215 | 215 | break; |
| 216 | 216 | case 'e': |
| 217 | - $out .= ($j_d < 10) ? ' ' . $j_d : $j_d; |
|
| 217 | + $out .= ($j_d < 10) ? ' '.$j_d : $j_d; |
|
| 218 | 218 | break; |
| 219 | 219 | case 'j': |
| 220 | 220 | $out .= str_pad($doy + 1, 3, 0, STR_PAD_LEFT); |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | if ($avs < 0) $avs += 7; |
| 232 | 232 | $num = (int) (($doy + $avs) / 7) + 1; |
| 233 | 233 | if ($avs > 3 or $avs == 1) $num--; |
| 234 | - $out .= ($num < 10) ? '0' . $num : $num; |
|
| 234 | + $out .= ($num < 10) ? '0'.$num : $num; |
|
| 235 | 235 | break; |
| 236 | 236 | case 'V': |
| 237 | 237 | $avs = (($date[6] == 6) ? 0 : $date[6] + 1) - ($doy % 7); |
@@ -245,14 +245,14 @@ discard block |
||
| 245 | 245 | } |
| 246 | 246 | $aks = $avs + $kab; |
| 247 | 247 | if ($aks == 7) $aks = 0; |
| 248 | - $out .= (($kab + 363 - $doy) < $aks and $aks < 3) ? '01' : (($num < 10) ? '0' . $num : $num); |
|
| 248 | + $out .= (($kab + 363 - $doy) < $aks and $aks < 3) ? '01' : (($num < 10) ? '0'.$num : $num); |
|
| 249 | 249 | break; |
| 250 | 250 | case 'W': |
| 251 | 251 | $avs = (($date[6] == 6) ? 0 : $date[6] + 1) - ($doy % 7); |
| 252 | 252 | if ($avs < 0) $avs += 7; |
| 253 | 253 | $num = (int) (($doy + $avs) / 7) + 1; |
| 254 | 254 | if ($avs > 3) $num--; |
| 255 | - $out .= ($num < 10) ? '0' . $num : $num; |
|
| 255 | + $out .= ($num < 10) ? '0'.$num : $num; |
|
| 256 | 256 | break; |
| 257 | 257 | /* Month */ |
| 258 | 258 | case 'b': |
@@ -263,12 +263,12 @@ discard block |
||
| 263 | 263 | $out .= self::jdate_words(['mm' => $j_m], ' '); |
| 264 | 264 | break; |
| 265 | 265 | case 'm': |
| 266 | - $out .= ($j_m > 9) ? $j_m : '0' . $j_m; |
|
| 266 | + $out .= ($j_m > 9) ? $j_m : '0'.$j_m; |
|
| 267 | 267 | break; |
| 268 | 268 | /* Year */ |
| 269 | 269 | case 'C': |
| 270 | 270 | $tmp = (int) ($j_y / 100); |
| 271 | - $out .= ($tmp > 9) ? $tmp : '0' . $tmp; |
|
| 271 | + $out .= ($tmp > 9) ? $tmp : '0'.$tmp; |
|
| 272 | 272 | break; |
| 273 | 273 | case 'g': |
| 274 | 274 | $jdw = ($date[6] == 6) ? 0 : $date[6] + 1; |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | $out .= $date[0]; |
| 295 | 295 | break; |
| 296 | 296 | case 'l': |
| 297 | - $out .= ($date[0] > 9) ? $date[0] : ' ' . (int) $date[0]; |
|
| 297 | + $out .= ($date[0] > 9) ? $date[0] : ' '.(int) $date[0]; |
|
| 298 | 298 | break; |
| 299 | 299 | case 'M': |
| 300 | 300 | $out .= $date[2]; |
@@ -306,19 +306,19 @@ discard block |
||
| 306 | 306 | $out .= ($date[1] < 12) ? 'ق.ظ' : 'ب.ظ'; |
| 307 | 307 | break; |
| 308 | 308 | case 'r': |
| 309 | - $out .= $date[0] . ':' . $date[2] . ':' . $date[5] . ' ' . (($date[1] < 12) ? 'قبل از ظهر' : 'بعد از ظهر'); |
|
| 309 | + $out .= $date[0].':'.$date[2].':'.$date[5].' '.(($date[1] < 12) ? 'قبل از ظهر' : 'بعد از ظهر'); |
|
| 310 | 310 | break; |
| 311 | 311 | case 'R': |
| 312 | - $out .= $date[1] . ':' . $date[2]; |
|
| 312 | + $out .= $date[1].':'.$date[2]; |
|
| 313 | 313 | break; |
| 314 | 314 | case 'S': |
| 315 | 315 | $out .= $date[5]; |
| 316 | 316 | break; |
| 317 | 317 | case 'T': |
| 318 | - $out .= $date[1] . ':' . $date[2] . ':' . $date[5]; |
|
| 318 | + $out .= $date[1].':'.$date[2].':'.$date[5]; |
|
| 319 | 319 | break; |
| 320 | 320 | case 'X': |
| 321 | - $out .= $date[0] . ':' . $date[2] . ':' . $date[5]; |
|
| 321 | + $out .= $date[0].':'.$date[2].':'.$date[5]; |
|
| 322 | 322 | break; |
| 323 | 323 | case 'z': |
| 324 | 324 | $out .= date('O', $ts); |
@@ -329,19 +329,19 @@ discard block |
||
| 329 | 329 | /* Time and Date Stamps */ |
| 330 | 330 | case 'c': |
| 331 | 331 | $key = self::jdate_words(['rh' => $date[6], 'mm' => $j_m]); |
| 332 | - $out .= $date[1] . ':' . $date[2] . ':' . $date[5] . ' ' . date('P', $ts) . ' ' . $key['rh'] . '، ' . $j_d . ' ' . $key['mm'] . ' ' . $j_y; |
|
| 332 | + $out .= $date[1].':'.$date[2].':'.$date[5].' '.date('P', $ts).' '.$key['rh'].'، '.$j_d.' '.$key['mm'].' '.$j_y; |
|
| 333 | 333 | break; |
| 334 | 334 | case 'D': |
| 335 | - $out .= substr($j_y, 2, 2) . '/' . (($j_m > 9) ? $j_m : '0' . $j_m) . '/' . (($j_d < 10) ? '0' . $j_d : $j_d); |
|
| 335 | + $out .= substr($j_y, 2, 2).'/'.(($j_m > 9) ? $j_m : '0'.$j_m).'/'.(($j_d < 10) ? '0'.$j_d : $j_d); |
|
| 336 | 336 | break; |
| 337 | 337 | case 'F': |
| 338 | - $out .= $j_y . '-' . (($j_m > 9) ? $j_m : '0' . $j_m) . '-' . (($j_d < 10) ? '0' . $j_d : $j_d); |
|
| 338 | + $out .= $j_y.'-'.(($j_m > 9) ? $j_m : '0'.$j_m).'-'.(($j_d < 10) ? '0'.$j_d : $j_d); |
|
| 339 | 339 | break; |
| 340 | 340 | case 's': |
| 341 | 341 | $out .= $ts; |
| 342 | 342 | break; |
| 343 | 343 | case 'x': |
| 344 | - $out .= substr($j_y, 2, 2) . '/' . (($j_m > 9) ? $j_m : '0' . $j_m) . '/' . (($j_d < 10) ? '0' . $j_d : $j_d); |
|
| 344 | + $out .= substr($j_y, 2, 2).'/'.(($j_m > 9) ? $j_m : '0'.$j_m).'/'.(($j_d < 10) ? '0'.$j_d : $j_d); |
|
| 345 | 345 | break; |
| 346 | 346 | /* Miscellaneous */ |
| 347 | 347 | case 'n': |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | } |
| 360 | 360 | return ($tr_num != 'en') ? self::tr_num($out, 'fa', '.') : $out; |
| 361 | 361 | } |
| 362 | - public static function jmktime ($h = '', $m = '', $s = '', $jm = '', $jd = '', $jy = '', $none = '', $timezone = 'Asia/Tehran') { |
|
| 362 | + public static function jmktime($h = '', $m = '', $s = '', $jm = '', $jd = '', $jy = '', $none = '', $timezone = 'Asia/Tehran') { |
|
| 363 | 363 | if ($timezone != 'local') date_default_timezone_set($timezone); |
| 364 | 364 | if ($h === '') { |
| 365 | 365 | return time(); |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | $jm, |
| 373 | 373 | $jd, |
| 374 | 374 | $jy |
| 375 | - ] = explode('_', self::tr_num($h . '_' . $m . '_' . $s . '_' . $jm . '_' . $jd . '_' . $jy)); |
|
| 375 | + ] = explode('_', self::tr_num($h.'_'.$m.'_'.$s.'_'.$jm.'_'.$jd.'_'.$jy)); |
|
| 376 | 376 | if ($m === '') { |
| 377 | 377 | return mktime($h); |
| 378 | 378 | } |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | } |
| 406 | 406 | } |
| 407 | 407 | } |
| 408 | - public static function jgetdate ($timestamp = '', $none = '', $timezone = 'Asia/Tehran', $tn = 'en') { |
|
| 408 | + public static function jgetdate($timestamp = '', $none = '', $timezone = 'Asia/Tehran', $tn = 'en') { |
|
| 409 | 409 | $ts = ($timestamp === '') ? time() : self::tr_num($timestamp); |
| 410 | 410 | $jdate = explode('_', self::jdate('F_G_i_j_l_n_s_w_Y_z', $ts, '', $timezone, $tn)); |
| 411 | 411 | return [ |
@@ -422,17 +422,17 @@ discard block |
||
| 422 | 422 | 0 => self::tr_num($ts, $tn) |
| 423 | 423 | ]; |
| 424 | 424 | } |
| 425 | - public static function jcheckdate ($jm, $jd, $jy) { |
|
| 426 | - [$jm, $jd, $jy] = explode('_', self::tr_num($jm . '_' . $jd . '_' . $jy)); |
|
| 425 | + public static function jcheckdate($jm, $jd, $jy) { |
|
| 426 | + [$jm, $jd, $jy] = explode('_', self::tr_num($jm.'_'.$jd.'_'.$jy)); |
|
| 427 | 427 | $l_d = ($jm == 12 and ((($jy + 12) % 33) % 4) != 1) ? 29 : (31 - (int) ($jm / 6.5)); |
| 428 | 428 | return ($jm > 12 or $jd > $l_d or $jm < 1 or $jd < 1 or $jy < 1) ? false : true; |
| 429 | 429 | } |
| 430 | - public static function tr_num ($str, $mod = 'en', $mf = '٫') { |
|
| 430 | + public static function tr_num($str, $mod = 'en', $mf = '٫') { |
|
| 431 | 431 | $num_a = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.']; |
| 432 | 432 | $key_a = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹', $mf]; |
| 433 | 433 | return ($mod == 'fa') ? str_replace($num_a, $key_a, $str) : str_replace($key_a, $num_a, $str); |
| 434 | 434 | } |
| 435 | - public static function jdate_words ($array, $mod = '') { |
|
| 435 | + public static function jdate_words($array, $mod = '') { |
|
| 436 | 436 | foreach ($array as $type => $num) { |
| 437 | 437 | $num = (int) self::tr_num($num); |
| 438 | 438 | switch ($type) { |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | 'هزار و چهارصد', |
| 461 | 461 | 'هزار و نهصد', |
| 462 | 462 | 'دوهزار' |
| 463 | - ], substr($num, 0, 2)) . ((substr($num, 2, 2) == '00') ? '' : ' و ') : '') . $h3 . $p34 . $h34 . $h4; |
|
| 463 | + ], substr($num, 0, 2)).((substr($num, 2, 2) == '00') ? '' : ' و ') : '').$h3.$p34.$h34.$h4; |
|
| 464 | 464 | break; |
| 465 | 465 | case 'mm': |
| 466 | 466 | $key = [ |
@@ -545,8 +545,8 @@ discard block |
||
| 545 | 545 | } |
| 546 | 546 | return ($mod === '') ? $array : implode($mod, $array); |
| 547 | 547 | } |
| 548 | - public static function gregorian_to_jalali ($gy, $gm, $gd, $mod = '') { |
|
| 549 | - [$gy, $gm, $gd] = explode('_', self::tr_num($gy . '_' . $gm . '_' . $gd));/* <= Extra :اين سطر ، جزء تابع اصلي نيست */ |
|
| 548 | + public static function gregorian_to_jalali($gy, $gm, $gd, $mod = '') { |
|
| 549 | + [$gy, $gm, $gd] = explode('_', self::tr_num($gy.'_'.$gm.'_'.$gd)); /* <= Extra :اين سطر ، جزء تابع اصلي نيست */ |
|
| 550 | 550 | $g_d_m = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334]; |
| 551 | 551 | $gy2 = ($gm > 2) ? ($gy + 1) : $gy; |
| 552 | 552 | $days = 355666 + (365 * $gy) + ((int) (($gy2 + 3) / 4)) - ((int) (($gy2 + 99) / 100)) + ((int) (($gy2 + 399) / 400)) + $gd + $g_d_m[$gm - 1]; |
@@ -566,10 +566,10 @@ discard block |
||
| 566 | 566 | $jm = 7 + (int) (($days - 186) / 30); |
| 567 | 567 | $jd = 1 + (($days - 186) % 30); |
| 568 | 568 | } |
| 569 | - return ($mod == '') ? [$jy, $jm, $jd] : $jy . $mod . $jm . $mod . $jd; |
|
| 569 | + return ($mod == '') ? [$jy, $jm, $jd] : $jy.$mod.$jm.$mod.$jd; |
|
| 570 | 570 | } |
| 571 | - public static function jalali_to_gregorian ($jy, $jm, $jd, $mod = '') { |
|
| 572 | - [$jy, $jm, $jd] = explode('_', self::tr_num($jy . '_' . $jm . '_' . $jd));/* <= Extra :اين سطر ، جزء تابع اصلي نيست */ |
|
| 571 | + public static function jalali_to_gregorian($jy, $jm, $jd, $mod = '') { |
|
| 572 | + [$jy, $jm, $jd] = explode('_', self::tr_num($jy.'_'.$jm.'_'.$jd)); /* <= Extra :اين سطر ، جزء تابع اصلي نيست */ |
|
| 573 | 573 | $jy += 1595; |
| 574 | 574 | $days = -355668 + (365 * $jy) + (((int) ($jy / 33)) * 8) + ((int) ((($jy % 33) + 3) / 4)) + $jd + (($jm < 7) ? ($jm - 1) * 31 : (($jm - 7) * 30) + 186); |
| 575 | 575 | $gy = 400 * ((int) ($days / 146097)); |
@@ -602,6 +602,6 @@ discard block |
||
| 602 | 602 | 31 |
| 603 | 603 | ]; |
| 604 | 604 | for ($gm = 0; $gm < 13 and $gd > $sal_a[$gm]; $gm++) $gd -= $sal_a[$gm]; |
| 605 | - return ($mod == '') ? [$gy, $gm, $gd] : $gy . $mod . $gm . $mod . $gd; |
|
| 605 | + return ($mod == '') ? [$gy, $gm, $gd] : $gy.$mod.$gm.$mod.$gd; |
|
| 606 | 606 | } |
| 607 | 607 | } |
| 608 | 608 | \ No newline at end of file |
@@ -25,13 +25,13 @@ |
||
| 25 | 25 | public shippingAddress $shipping_address; |
| 26 | 26 | |
| 27 | 27 | |
| 28 | - public function __construct(stdClass|null $object = null) { |
|
| 28 | + public function __construct(stdClass | null $object = null) { |
|
| 29 | 29 | if ($object != null) { |
| 30 | 30 | parent::__construct($object, self::subs); |
| 31 | 31 | } |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - public function answer (bool $ok, null|array $shipping_options = null, string|null $error_message = null): responseError|bool { |
|
| 34 | + public function answer(bool $ok, null | array $shipping_options = null, string | null $error_message = null): responseError | bool { |
|
| 35 | 35 | return telegram::answerShippingQuery($ok, $this->id, $shipping_options, $error_message); |
| 36 | 36 | } |
| 37 | 37 | } |
@@ -31,19 +31,19 @@ |
||
| 31 | 31 | * should be always known for requests sent from official clients and most third-party clients, unless the |
| 32 | 32 | * request was sent from a secret chat |
| 33 | 33 | */ |
| 34 | - public null|string $chat_type = null; |
|
| 34 | + public null | string $chat_type = null; |
|
| 35 | 35 | |
| 36 | 36 | /** Optional. Sender location, only for bots that request user location */ |
| 37 | - public null|location $location = null; |
|
| 37 | + public null | location $location = null; |
|
| 38 | 38 | |
| 39 | 39 | |
| 40 | - public function __construct(stdClass|null $object = null) { |
|
| 40 | + public function __construct(stdClass | null $object = null) { |
|
| 41 | 41 | if ($object != null) { |
| 42 | 42 | parent::__construct($object, self::subs); |
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - public function answer(array $results, int|null $cache_time = null, bool|null $is_personal = null, string|null $next_offset = null, string|null $switch_pm_text = null, string|null $switch_pm_parameter = null): responseError|bool { |
|
| 46 | + public function answer(array $results, int | null $cache_time = null, bool | null $is_personal = null, string | null $next_offset = null, string | null $switch_pm_text = null, string | null $switch_pm_parameter = null): responseError | bool { |
|
| 47 | 47 | return telegram::answerInlineQuery($results, $this->id, $cache_time, $is_personal, $next_offset, $switch_pm_text, $switch_pm_parameter); |
| 48 | 48 | } |
| 49 | 49 | } |
@@ -38,10 +38,10 @@ discard block |
||
| 38 | 38 | * Optional. Chat invite link, which was used by the user to join the chat; for joining by invite link events |
| 39 | 39 | * only. |
| 40 | 40 | */ |
| 41 | - public null|chatInviteLink $invite_link = null; |
|
| 41 | + public null | chatInviteLink $invite_link = null; |
|
| 42 | 42 | |
| 43 | 43 | |
| 44 | - public function __construct(stdClass|null $object = null) { |
|
| 44 | + public function __construct(stdClass | null $object = null) { |
|
| 45 | 45 | if ($object != null) { |
| 46 | 46 | parent::__construct($object, self::subs); |
| 47 | 47 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | return $this->chat->isPrivate() && $this->isMe() && $this->isKicked(); |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - public function isMe (): bool { |
|
| 58 | + public function isMe(): bool { |
|
| 59 | 59 | return $this->new_chat_member->user->id == settings::$bot_id; |
| 60 | 60 | } |
| 61 | 61 | |
@@ -71,19 +71,19 @@ discard block |
||
| 71 | 71 | return $this->isJoined() && !empty($this->invite_link); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - public function isLeaved (): bool { |
|
| 74 | + public function isLeaved(): bool { |
|
| 75 | 75 | return $this->new_chat_member->status === chatMemberStatus::LEFT; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - public function isKicked (): bool { |
|
| 78 | + public function isKicked(): bool { |
|
| 79 | 79 | return $this->new_chat_member->status === chatMemberStatus::KICKED; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - public function isOldAdmin (): bool { |
|
| 82 | + public function isOldAdmin(): bool { |
|
| 83 | 83 | return $this->old_chat_member->status === chatMemberStatus::ADMINISTRATOR && $this->isJoined(); |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - public function isNewAdmin (): bool { |
|
| 86 | + public function isNewAdmin(): bool { |
|
| 87 | 87 | return $this->new_chat_member->status === chatMemberStatus::ADMINISTRATOR; |
| 88 | 88 | } |
| 89 | 89 | } |
@@ -32,19 +32,19 @@ |
||
| 32 | 32 | public string $invoice_payload; |
| 33 | 33 | |
| 34 | 34 | /** Optional. Identifier of the shipping option chosen by the user */ |
| 35 | - public null|string $shipping_option_id = null; |
|
| 35 | + public null | string $shipping_option_id = null; |
|
| 36 | 36 | |
| 37 | 37 | /** Optional. Order information provided by the user */ |
| 38 | - public null|orderInfo $order_info = null; |
|
| 38 | + public null | orderInfo $order_info = null; |
|
| 39 | 39 | |
| 40 | 40 | |
| 41 | - public function __construct(stdClass|null $object = null) { |
|
| 41 | + public function __construct(stdClass | null $object = null) { |
|
| 42 | 42 | if ($object != null) { |
| 43 | 43 | parent::__construct($object, self::subs); |
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - public function answer (bool $ok, string|null $error_message = null): responseError|bool { |
|
| 47 | + public function answer(bool $ok, string | null $error_message = null): responseError | bool { |
|
| 48 | 48 | return telegram::answerPreCheckoutQuery($ok, $this->id, $error_message); |
| 49 | 49 | } |
| 50 | 50 | } |
@@ -25,50 +25,50 @@ |
||
| 25 | 25 | * Optional. Message with the callback button that originated the query. Note that message content and message |
| 26 | 26 | * date will not be available if the message is too old |
| 27 | 27 | */ |
| 28 | - public null|message $message = null; |
|
| 28 | + public null | message $message = null; |
|
| 29 | 29 | |
| 30 | 30 | /** Optional. Identifier of the message sent via the bot in inline mode, that originated the query. */ |
| 31 | - public null|string $inline_message_id = null; |
|
| 31 | + public null | string $inline_message_id = null; |
|
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | 34 | * Global identifier, uniquely corresponding to the chat to which the message with the callback button was sent. |
| 35 | 35 | * Useful for high scores in games. |
| 36 | 36 | */ |
| 37 | - public null|string $chat_instance = null; |
|
| 37 | + public null | string $chat_instance = null; |
|
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | 40 | * Optional. Data associated with the callback button. Be aware that the message originated the query can contain |
| 41 | 41 | * no callback buttons with this data. |
| 42 | 42 | */ |
| 43 | - public null|string $data = null; |
|
| 43 | + public null | string $data = null; |
|
| 44 | 44 | |
| 45 | 45 | /** Optional. Short name of a Game to be returned, serves as the unique identifier for the game */ |
| 46 | - public null|string $game_short_name = null; |
|
| 46 | + public null | string $game_short_name = null; |
|
| 47 | 47 | |
| 48 | 48 | |
| 49 | - public function __construct(stdClass|null $object = null) { |
|
| 49 | + public function __construct(stdClass | null $object = null) { |
|
| 50 | 50 | if ($object != null) { |
| 51 | 51 | parent::__construct($object, self::subs); |
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - public function answer (string|null $text = null, bool|null $show_alert = null, string|null $url = null, int|null $cache_time = null): responseError|bool { |
|
| 55 | + public function answer(string | null $text = null, bool | null $show_alert = null, string | null $url = null, int | null $cache_time = null): responseError | bool { |
|
| 56 | 56 | return telegram::answerCallbackQuery($this->id, $text, $show_alert, $url, $cache_time); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - public function editText (string $text): message|responseError|bool { |
|
| 59 | + public function editText(string $text): message | responseError | bool { |
|
| 60 | 60 | return telegram::editMessageText($text); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - public function editCaption (string $text = ''): message|responseError|bool { |
|
| 63 | + public function editCaption(string $text = ''): message | responseError | bool { |
|
| 64 | 64 | return telegram::editMessageCaption(caption: $text); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - public function editKeyboard (inlineKeyboardMarkup|stdClass|array $reply_markup = null): message|responseError|bool { |
|
| 67 | + public function editKeyboard(inlineKeyboardMarkup | stdClass | array $reply_markup = null): message | responseError | bool { |
|
| 68 | 68 | return telegram::editMessageReplyMarkup(reply_markup: $reply_markup); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - public function editMedia (inputMedia|array|stdClass $media): message|responseError|bool { |
|
| 71 | + public function editMedia(inputMedia | array | stdClass $media): message | responseError | bool { |
|
| 72 | 72 | return telegram::editMessageMedia($media); |
| 73 | 73 | } |
| 74 | 74 | } |