@@ -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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -6,7 +6,7 @@ |
||
6 | 6 | * telegram class , Adding normal method call to request class and a simple name for being easy to call |
7 | 7 | */ |
8 | 8 | class telegram extends request { |
9 | - public function __call (string $name, array $arguments) { |
|
9 | + public function __call(string $name, array $arguments) { |
|
10 | 10 | return request::$name(...$arguments); |
11 | 11 | } |
12 | 12 | } |
13 | 13 | \ No newline at end of file |
@@ -68,13 +68,13 @@ discard block |
||
68 | 68 | public int $message_id; |
69 | 69 | |
70 | 70 | /** Optional. Unique identifier of a message thread to which the message belongs; for supergroups only */ |
71 | - public null|int $message_thread_id = null; |
|
71 | + public null | int $message_thread_id = null; |
|
72 | 72 | |
73 | 73 | /** |
74 | 74 | * Optional. Sender of the message; empty for messages sent to channels. For backward compatibility, the field |
75 | 75 | * contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat. |
76 | 76 | */ |
77 | - public null|user $from = null; |
|
77 | + public null | user $from = null; |
|
78 | 78 | |
79 | 79 | /** |
80 | 80 | * Optional. Sender of the message, sent on behalf of a chat. For example, the channel itself for channel posts, |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * automatically forwarded to the discussion group. For backward compatibility, the field from contains a fake |
83 | 83 | * sender user in non-channel chats, if the message was sent on behalf of a chat. |
84 | 84 | */ |
85 | - public null|chat $sender_chat = null; |
|
85 | + public null | chat $sender_chat = null; |
|
86 | 86 | |
87 | 87 | /** Date the message was sent in Unix time */ |
88 | 88 | public int $date; |
@@ -91,188 +91,188 @@ discard block |
||
91 | 91 | public chat $chat; |
92 | 92 | |
93 | 93 | /** Optional. For forwarded messages, sender of the original message */ |
94 | - public null|user $forward_from = null; |
|
94 | + public null | user $forward_from = null; |
|
95 | 95 | |
96 | 96 | /** |
97 | 97 | * Optional. For messages forwarded from channels or from anonymous administrators, information about the |
98 | 98 | * original sender chat |
99 | 99 | */ |
100 | - public null|chat $forward_from_chat = null; |
|
100 | + public null | chat $forward_from_chat = null; |
|
101 | 101 | |
102 | 102 | /** Optional. For messages forwarded from channels, identifier of the original message in the channel */ |
103 | - public null|int $forward_from_message_id = null; |
|
103 | + public null | int $forward_from_message_id = null; |
|
104 | 104 | |
105 | 105 | /** |
106 | 106 | * Optional. For forwarded messages that were originally sent in channels or by an anonymous chat administrator, |
107 | 107 | * signature of the message sender if present |
108 | 108 | */ |
109 | - public null|string $forward_signature = null; |
|
109 | + public null | string $forward_signature = null; |
|
110 | 110 | |
111 | 111 | /** |
112 | 112 | * Optional. Sender's name for messages forwarded from users who disallow adding a link to their account in |
113 | 113 | * forwarded messages |
114 | 114 | */ |
115 | - public null|string $forward_sender_name = null; |
|
115 | + public null | string $forward_sender_name = null; |
|
116 | 116 | |
117 | 117 | /** Optional. For forwarded messages, date the original message was sent in Unix time */ |
118 | - public null|int $forward_date = null; |
|
118 | + public null | int $forward_date = null; |
|
119 | 119 | |
120 | 120 | /** Optional. True, if the message is sent to a forum topic */ |
121 | - public null|bool $is_topic_message = null; |
|
121 | + public null | bool $is_topic_message = null; |
|
122 | 122 | |
123 | 123 | /** |
124 | 124 | * Optional. True, if the message is a channel post that was automatically forwarded to the connected discussion |
125 | 125 | * group |
126 | 126 | */ |
127 | - public null|bool $is_automatic_forward = null; |
|
127 | + public null | bool $is_automatic_forward = null; |
|
128 | 128 | |
129 | 129 | /** |
130 | 130 | * Optional. For replies, the original message. Note that the Message object in this field will not contain |
131 | 131 | * further reply_to_message fields even if it itself is a reply. |
132 | 132 | */ |
133 | - public null|message $reply_to_message = null; |
|
133 | + public null | message $reply_to_message = null; |
|
134 | 134 | |
135 | 135 | /** Optional. Bot through which the message was sent */ |
136 | - public null|user $via_bot = null; |
|
136 | + public null | user $via_bot = null; |
|
137 | 137 | |
138 | 138 | /** Optional. Date the message was last edited in Unix time */ |
139 | - public null|int $edit_date = null; |
|
139 | + public null | int $edit_date = null; |
|
140 | 140 | |
141 | 141 | /** Optional. True, if the message can't be forwarded */ |
142 | - public null|bool $has_protected_content = null; |
|
142 | + public null | bool $has_protected_content = null; |
|
143 | 143 | |
144 | 144 | /** Optional. The unique identifier of a media message group this message belongs to */ |
145 | - public null|string $media_group_id = null; |
|
145 | + public null | string $media_group_id = null; |
|
146 | 146 | |
147 | 147 | /** |
148 | 148 | * Optional. Signature of the post author for messages in channels, or the custom title of an anonymous group |
149 | 149 | * administrator |
150 | 150 | */ |
151 | - public null|string $author_signature = null; |
|
151 | + public null | string $author_signature = null; |
|
152 | 152 | |
153 | 153 | /** Optional. For text messages, the actual UTF-8 text of the message */ |
154 | - public null|string $text = null; |
|
154 | + public null | string $text = null; |
|
155 | 155 | |
156 | 156 | /** Optional. If user message was a command , this parameter will be the command */ |
157 | - public string|null $command = null; |
|
157 | + public string | null $command = null; |
|
158 | 158 | |
159 | 159 | /** Optional. If user message was a command , this parameter will be the command username(if exist) */ |
160 | - public string|null $command_username = null; |
|
160 | + public string | null $command_username = null; |
|
161 | 161 | |
162 | 162 | /** Optional. If user message was a command , this parameter will be the command payload(if exist) */ |
163 | - public string|null $command_payload = null; |
|
163 | + public string | null $command_payload = null; |
|
164 | 164 | |
165 | 165 | /** |
166 | 166 | * Optional. For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text |
167 | 167 | * @var messageEntity[] |
168 | 168 | */ |
169 | - public null|array $entities = null; |
|
169 | + public null | array $entities = null; |
|
170 | 170 | |
171 | 171 | /** |
172 | 172 | * Optional. Message is an animation, information about the animation. For backward compatibility, when this |
173 | 173 | * field is set, the document field will also be set |
174 | 174 | */ |
175 | - public null|animation $animation = null; |
|
175 | + public null | animation $animation = null; |
|
176 | 176 | |
177 | 177 | /** Optional. Message is an audio file, information about the file */ |
178 | - public null|audio $audio = null; |
|
178 | + public null | audio $audio = null; |
|
179 | 179 | |
180 | 180 | /** Optional. Message is a general file, information about the file */ |
181 | - public null|document $document = null; |
|
181 | + public null | document $document = null; |
|
182 | 182 | |
183 | 183 | /** |
184 | 184 | * Optional. Message is a photo, available sizes of the photo |
185 | 185 | * @var photoSize[] |
186 | 186 | */ |
187 | - public null|array $photo = null; |
|
187 | + public null | array $photo = null; |
|
188 | 188 | |
189 | 189 | /** Optional. Message is a sticker, information about the sticker */ |
190 | - public null|sticker $sticker = null; |
|
190 | + public null | sticker $sticker = null; |
|
191 | 191 | |
192 | 192 | /** Optional. Message is a video, information about the video */ |
193 | - public null|video $video = null; |
|
193 | + public null | video $video = null; |
|
194 | 194 | |
195 | 195 | /** Optional. Message is a video note, information about the video message */ |
196 | - public null|videoNote $video_note = null; |
|
196 | + public null | videoNote $video_note = null; |
|
197 | 197 | |
198 | 198 | /** Optional. Message is a voice message, information about the file */ |
199 | - public null|voice $voice = null; |
|
199 | + public null | voice $voice = null; |
|
200 | 200 | |
201 | 201 | /** Optional. Caption for the animation, audio, document, photo, video or voice */ |
202 | - public null|string $caption = null; |
|
202 | + public null | string $caption = null; |
|
203 | 203 | |
204 | 204 | /** |
205 | 205 | * Optional. For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear |
206 | 206 | * in the caption |
207 | 207 | * @var messageEntity[] |
208 | 208 | */ |
209 | - public null|array $caption_entities = null; |
|
209 | + public null | array $caption_entities = null; |
|
210 | 210 | |
211 | 211 | /** Optional. True, if the message media is covered by a spoiler animation */ |
212 | - public null|bool $has_media_spoiler = null; |
|
212 | + public null | bool $has_media_spoiler = null; |
|
213 | 213 | |
214 | 214 | /** Optional. Message is a shared contact, information about the contact */ |
215 | - public null|contact $contact = null; |
|
215 | + public null | contact $contact = null; |
|
216 | 216 | |
217 | 217 | /** Optional. Message is a dice with random value */ |
218 | - public null|dice $dice = null; |
|
218 | + public null | dice $dice = null; |
|
219 | 219 | |
220 | 220 | /** Optional. Message is a game, information about the game. More about games » */ |
221 | - public null|game $game = null; |
|
221 | + public null | game $game = null; |
|
222 | 222 | |
223 | 223 | /** Optional. Message is a native poll, information about the poll */ |
224 | - public null|poll $poll = null; |
|
224 | + public null | poll $poll = null; |
|
225 | 225 | |
226 | 226 | /** |
227 | 227 | * Optional. Message is a venue, information about the venue. For backward compatibility, when this field is set, |
228 | 228 | * the location field will also be set |
229 | 229 | */ |
230 | - public null|venue $venue = null; |
|
230 | + public null | venue $venue = null; |
|
231 | 231 | |
232 | 232 | /** Optional. Message is a shared location, information about the location */ |
233 | - public null|location $location = null; |
|
233 | + public null | location $location = null; |
|
234 | 234 | |
235 | 235 | /** |
236 | 236 | * Optional. New members that were added to the group or supergroup and information about them (the bot itself |
237 | 237 | * may be one of these members) |
238 | 238 | * @var user[] |
239 | 239 | */ |
240 | - public null|array $new_chat_members = null; |
|
240 | + public null | array $new_chat_members = null; |
|
241 | 241 | |
242 | 242 | /** Optional. A member was removed from the group, information about them (this member may be the bot itself) */ |
243 | - public null|user $left_chat_member = null; |
|
243 | + public null | user $left_chat_member = null; |
|
244 | 244 | |
245 | 245 | /** Optional. A chat title was changed to this value */ |
246 | - public null|string $new_chat_title = null; |
|
246 | + public null | string $new_chat_title = null; |
|
247 | 247 | |
248 | 248 | /** |
249 | 249 | * Optional. A chat photo was change to this value |
250 | 250 | * @var photoSize[] |
251 | 251 | */ |
252 | - public null|array $new_chat_photo = null; |
|
252 | + public null | array $new_chat_photo = null; |
|
253 | 253 | |
254 | 254 | /** Optional. Service message: the chat photo was deleted */ |
255 | - public null|bool $delete_chat_photo = null; |
|
255 | + public null | bool $delete_chat_photo = null; |
|
256 | 256 | |
257 | 257 | /** Optional. Service message: the group has been created */ |
258 | - public null|bool $group_chat_created = null; |
|
258 | + public null | bool $group_chat_created = null; |
|
259 | 259 | |
260 | 260 | /** |
261 | 261 | * Optional. Service message: the supergroup has been created. This field can't be received in a message coming |
262 | 262 | * through updates, because bot can't be a member of a supergroup when it is created. It can only be found in |
263 | 263 | * reply_to_message if someone replies to a very first message in a directly created supergroup. |
264 | 264 | */ |
265 | - public null|bool $supergroup_chat_created = null; |
|
265 | + public null | bool $supergroup_chat_created = null; |
|
266 | 266 | |
267 | 267 | /** |
268 | 268 | * Optional. Service message: the channel has been created. This field can't be received in a message coming |
269 | 269 | * through updates, because bot can't be a member of a channel when it is created. It can only be found in |
270 | 270 | * reply_to_message if someone replies to a very first message in a channel. |
271 | 271 | */ |
272 | - public null|bool $channel_chat_created = null; |
|
272 | + public null | bool $channel_chat_created = null; |
|
273 | 273 | |
274 | 274 | /** Optional. Service message: auto-delete timer settings changed in the chat */ |
275 | - public null|messageAutoDeleteTimerChanged $message_auto_delete_timer_changed = null; |
|
275 | + public null | messageAutoDeleteTimerChanged $message_auto_delete_timer_changed = null; |
|
276 | 276 | |
277 | 277 | /** |
278 | 278 | * Optional. The group has been migrated to a supergroup with the specified identifier. This number may have more |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | * But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for |
281 | 281 | * storing this identifier. |
282 | 282 | */ |
283 | - public null|int $migrate_to_chat_id = null; |
|
283 | + public null | int $migrate_to_chat_id = null; |
|
284 | 284 | |
285 | 285 | /** |
286 | 286 | * Optional. The supergroup has been migrated from a group with the specified identifier. This number may have |
@@ -288,123 +288,123 @@ discard block |
||
288 | 288 | * interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float |
289 | 289 | * type are safe for storing this identifier. |
290 | 290 | */ |
291 | - public null|int $migrate_from_chat_id = null; |
|
291 | + public null | int $migrate_from_chat_id = null; |
|
292 | 292 | |
293 | 293 | /** |
294 | 294 | * Optional. Specified message was pinned. Note that the Message object in this field will not contain further |
295 | 295 | * reply_to_message fields even if it is itself a reply. |
296 | 296 | */ |
297 | - public null|message $pinned_message = null; |
|
297 | + public null | message $pinned_message = null; |
|
298 | 298 | |
299 | 299 | /** Optional. Message is an invoice for a payment, information about the invoice. More about payments » */ |
300 | - public null|invoice $invoice = null; |
|
300 | + public null | invoice $invoice = null; |
|
301 | 301 | |
302 | 302 | /** |
303 | 303 | * Optional. Message is a service message about a successful payment, information about the payment. More about |
304 | 304 | * payments » |
305 | 305 | */ |
306 | - public null|successfulPayment $successful_payment = null; |
|
306 | + public null | successfulPayment $successful_payment = null; |
|
307 | 307 | |
308 | 308 | /** Optional. Service message: a user was shared with the bot */ |
309 | - public null|userShared $user_shared = null; |
|
309 | + public null | userShared $user_shared = null; |
|
310 | 310 | |
311 | 311 | /** Optional. Service message: a chat was shared with the bot */ |
312 | - public null|chatShared $chat_shared = null; |
|
312 | + public null | chatShared $chat_shared = null; |
|
313 | 313 | |
314 | 314 | /** Optional. The domain name of the website on which the user has logged in. More about Telegram Login » */ |
315 | - public null|string $connected_website = null; |
|
315 | + public null | string $connected_website = null; |
|
316 | 316 | |
317 | 317 | /** Optional. Service message: the user allowed the bot added to the attachment menu to write messages */ |
318 | - public null|writeAccessAllowed $write_access_allowed = null; |
|
318 | + public null | writeAccessAllowed $write_access_allowed = null; |
|
319 | 319 | |
320 | 320 | /** Optional. Telegram Passport data */ |
321 | - public null|passportData $passport_data = null; |
|
321 | + public null | passportData $passport_data = null; |
|
322 | 322 | |
323 | 323 | /** |
324 | 324 | * Optional. Service message. A user in the chat triggered another user's proximity alert while sharing Live |
325 | 325 | * Location. |
326 | 326 | */ |
327 | - public null|proximityAlertTriggered $proximity_alert_triggered = null; |
|
327 | + public null | proximityAlertTriggered $proximity_alert_triggered = null; |
|
328 | 328 | |
329 | 329 | /** Optional. Service message: forum topic created */ |
330 | - public null|forumTopicCreated $forum_topic_created = null; |
|
330 | + public null | forumTopicCreated $forum_topic_created = null; |
|
331 | 331 | |
332 | 332 | /** Optional. Service message: forum topic edited */ |
333 | - public null|forumTopicEdited $forum_topic_edited = null; |
|
333 | + public null | forumTopicEdited $forum_topic_edited = null; |
|
334 | 334 | |
335 | 335 | /** Optional. Service message: forum topic closed */ |
336 | - public null|forumTopicClosed $forum_topic_closed = null; |
|
336 | + public null | forumTopicClosed $forum_topic_closed = null; |
|
337 | 337 | |
338 | 338 | /** Optional. Service message: forum topic reopened */ |
339 | - public null|forumTopicReopened $forum_topic_reopened = null; |
|
339 | + public null | forumTopicReopened $forum_topic_reopened = null; |
|
340 | 340 | |
341 | 341 | /** Optional. Service message: the 'General' forum topic hidden */ |
342 | - public null|generalForumTopicHidden $general_forum_topic_hidden = null; |
|
342 | + public null | generalForumTopicHidden $general_forum_topic_hidden = null; |
|
343 | 343 | |
344 | 344 | /** Optional. Service message: the 'General' forum topic unhidden */ |
345 | - public null|generalForumTopicUnhidden $general_forum_topic_unhidden = null; |
|
345 | + public null | generalForumTopicUnhidden $general_forum_topic_unhidden = null; |
|
346 | 346 | |
347 | 347 | /** Optional. Service message: video chat scheduled */ |
348 | - public null|videoChatScheduled $video_chat_scheduled = null; |
|
348 | + public null | videoChatScheduled $video_chat_scheduled = null; |
|
349 | 349 | |
350 | 350 | /** Optional. Service message: video chat started */ |
351 | - public null|videoChatStarted $video_chat_started = null; |
|
351 | + public null | videoChatStarted $video_chat_started = null; |
|
352 | 352 | |
353 | 353 | /** Optional. Service message: video chat ended */ |
354 | - public null|videoChatEnded $video_chat_ended = null; |
|
354 | + public null | videoChatEnded $video_chat_ended = null; |
|
355 | 355 | |
356 | 356 | /** Optional. Service message: new participants invited to a video chat */ |
357 | - public null|videoChatParticipantsInvited $video_chat_participants_invited = null; |
|
357 | + public null | videoChatParticipantsInvited $video_chat_participants_invited = null; |
|
358 | 358 | |
359 | 359 | /** Optional. Service message: data sent by a Web App */ |
360 | - public null|webAppData $web_app_data = null; |
|
360 | + public null | webAppData $web_app_data = null; |
|
361 | 361 | |
362 | 362 | /** Optional. Inline keyboard attached to the message. login_url buttons are represented as ordinary url buttons. */ |
363 | - public null|inlineKeyboardMarkup $reply_markup = null; |
|
363 | + public null | inlineKeyboardMarkup $reply_markup = null; |
|
364 | 364 | |
365 | 365 | |
366 | - public function __construct(stdClass|null $object = null) { |
|
366 | + public function __construct(stdClass | null $object = null) { |
|
367 | 367 | if ($object != null) { |
368 | 368 | parent::__construct($object, self::subs); |
369 | 369 | } |
370 | 370 | } |
371 | 371 | |
372 | - public function isCommand (): bool { |
|
372 | + public function isCommand(): bool { |
|
373 | 373 | return !empty($this->command); |
374 | 374 | } |
375 | 375 | |
376 | - public function isForwarded (): bool { |
|
376 | + public function isForwarded(): bool { |
|
377 | 377 | return $this->forward_from !== null || $this->forward_from_chat !== null; |
378 | 378 | } |
379 | 379 | |
380 | - public function isAdmin (): bool { |
|
380 | + public function isAdmin(): bool { |
|
381 | 381 | return $this->chat->getMember($this->from->id)->status === chatMemberStatus::ADMINISTRATOR; |
382 | 382 | } |
383 | 383 | |
384 | - public function isOwner (): bool { |
|
384 | + public function isOwner(): bool { |
|
385 | 385 | return $this->chat->getMember($this->from->id)->status === chatMemberStatus::CREATOR; |
386 | 386 | } |
387 | 387 | |
388 | - public function banMember(): responseError|bool { |
|
388 | + public function banMember(): responseError | bool { |
|
389 | 389 | if ($this->chat->isPrivate()) { |
390 | 390 | return false; |
391 | 391 | } |
392 | 392 | return telegram::banChatMember($this->chat->id, $this->from->id); |
393 | 393 | } |
394 | 394 | |
395 | - public function delete (): responseError|bool { |
|
396 | - return telegram::deleteMessage($this->chat->id,$this->id); |
|
395 | + public function delete(): responseError | bool { |
|
396 | + return telegram::deleteMessage($this->chat->id, $this->id); |
|
397 | 397 | } |
398 | 398 | |
399 | - public function editText (string $text): message|responseError|bool { |
|
400 | - return telegram::editMessageText($text,$this->chat->id,$this->message_id); |
|
399 | + public function editText(string $text): message | responseError | bool { |
|
400 | + return telegram::editMessageText($text, $this->chat->id, $this->message_id); |
|
401 | 401 | } |
402 | 402 | |
403 | - public function copy (int|string $chat_id): messageId|responseError { |
|
403 | + public function copy(int | string $chat_id): messageId | responseError { |
|
404 | 404 | return telegram::copyMessage($chat_id); |
405 | 405 | } |
406 | 406 | |
407 | - public function forward (int|string $chat_id): message|responseError { |
|
407 | + public function forward(int | string $chat_id): message | responseError { |
|
408 | 408 | return telegram::forwardMessage($chat_id); |
409 | 409 | } |
410 | 410 | } |
@@ -18,64 +18,64 @@ discard block |
||
18 | 18 | public user $user; |
19 | 19 | |
20 | 20 | /** `creator` and `administrator` only. True, if the user's presence in the chat is hidden */ |
21 | - public null|bool $is_anonymous = null; |
|
21 | + public null | bool $is_anonymous = null; |
|
22 | 22 | |
23 | 23 | /** `creator` and `administrator` only. Custom title for this user */ |
24 | - public null|string $custom_title = null; |
|
24 | + public null | string $custom_title = null; |
|
25 | 25 | |
26 | 26 | /** `administrator` only. True, if the bot is allowed to edit administrator privileges of that user */ |
27 | - public null|bool $can_be_edited = null; |
|
27 | + public null | bool $can_be_edited = null; |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * `administrator` only. True, if the administrator can access the chat event log, chat statistics, message statistics in |
31 | 31 | * channels, see channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any other |
32 | 32 | * administrator privilege |
33 | 33 | */ |
34 | - public null|bool $can_manage_chat = null; |
|
34 | + public null | bool $can_manage_chat = null; |
|
35 | 35 | |
36 | 36 | /** `administrator` only. True, if the administrator can delete messages of other users */ |
37 | - public null|bool $can_delete_messages = null; |
|
37 | + public null | bool $can_delete_messages = null; |
|
38 | 38 | |
39 | 39 | /** `administrator` only. True, if the administrator can manage video chats */ |
40 | - public null|bool $can_manage_video_chats = null; |
|
40 | + public null | bool $can_manage_video_chats = null; |
|
41 | 41 | |
42 | 42 | /** `administrator` only. True, if the administrator can restrict, ban or unban chat members */ |
43 | - public null|bool $can_restrict_members = null; |
|
43 | + public null | bool $can_restrict_members = null; |
|
44 | 44 | |
45 | 45 | /** |
46 | 46 | * `administrator` only. if the administrator can add new administrators with a subset of their own privileges or demote |
47 | 47 | * administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by |
48 | 48 | * the user) |
49 | 49 | */ |
50 | - public null|bool $can_promote_members = null; |
|
50 | + public null | bool $can_promote_members = null; |
|
51 | 51 | |
52 | 52 | /** `administrator` and `restricted` only. True, if the user is allowed to change the chat title, photo and other settings */ |
53 | - public null|bool $can_change_info = null; |
|
53 | + public null | bool $can_change_info = null; |
|
54 | 54 | |
55 | 55 | /** `administrator` and `restricted` only. True, if the user is allowed to invite new users to the chat */ |
56 | - public null|bool $can_invite_users = null; |
|
56 | + public null | bool $can_invite_users = null; |
|
57 | 57 | |
58 | 58 | /** `administrator` only. Optional. True, if the administrator can post in the channel; channels only */ |
59 | - public null|bool $can_post_messages = null; |
|
59 | + public null | bool $can_post_messages = null; |
|
60 | 60 | |
61 | 61 | /** `administrator` only. Optional. True, if the administrator can edit messages of other users and can pin messages; channels only */ |
62 | - public null|bool $can_edit_messages = null; |
|
62 | + public null | bool $can_edit_messages = null; |
|
63 | 63 | |
64 | 64 | /** `administrator` and `restricted` only. Optional. True, if the user is allowed to pin messages; groups and supergroups only */ |
65 | - public null|bool $can_pin_messages = null; |
|
65 | + public null | bool $can_pin_messages = null; |
|
66 | 66 | |
67 | 67 | /** |
68 | 68 | * `administrator` : Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; supergroups only |
69 | 69 | * |
70 | 70 | * `restricted` : True, if the user is allowed to create forum topics |
71 | 71 | */ |
72 | - public null|bool $can_manage_topics = null; |
|
72 | + public null | bool $can_manage_topics = null; |
|
73 | 73 | |
74 | 74 | /** `restricted` only. True, if the user is a member of the chat at the moment of the request */ |
75 | - public null|bool $is_member = null; |
|
75 | + public null | bool $is_member = null; |
|
76 | 76 | |
77 | 77 | /** `restricted` only. True, if the user is allowed to send text messages, contacts, locations and venues */ |
78 | - public null|bool $can_send_messages = null; |
|
78 | + public null | bool $can_send_messages = null; |
|
79 | 79 | |
80 | 80 | /** `restricted` only. Optional. True, if the user is allowed to send audios */ |
81 | 81 | public bool $can_send_audios; |
@@ -96,16 +96,16 @@ discard block |
||
96 | 96 | public bool $can_send_voice_notes; |
97 | 97 | |
98 | 98 | /** `restricted` only. True, if the user is allowed to send polls */ |
99 | - public null|bool $can_send_polls = null; |
|
99 | + public null | bool $can_send_polls = null; |
|
100 | 100 | |
101 | 101 | /** `restricted` only. True, if the user is allowed to send animations, games, stickers and use inline bots */ |
102 | - public null|bool $can_send_other_messages = null; |
|
102 | + public null | bool $can_send_other_messages = null; |
|
103 | 103 | |
104 | 104 | /** `restricted` only. True, if the user is allowed to add web page previews to their messages */ |
105 | - public null|bool $can_add_web_page_previews = null; |
|
105 | + public null | bool $can_add_web_page_previews = null; |
|
106 | 106 | |
107 | 107 | /** `kicked` and `restricted` only. Date when restrictions will be lifted for this user; unix time. If 0, then the user is restricted forever */ |
108 | - public null|int $until_date = null; |
|
108 | + public null | int $until_date = null; |
|
109 | 109 | |
110 | 110 | |
111 | 111 | public function __construct(stdClass $object) { |