@@ -11,7 +11,7 @@ |
||
11 | 11 | /** Keep all of properties which has sub properties */ |
12 | 12 | private const subs = []; |
13 | 13 | |
14 | - public function __construct(stdClass|null $object = null) { |
|
14 | + public function __construct(stdClass | null $object = null) { |
|
15 | 15 | if ($object != null) { |
16 | 16 | parent::__construct($object, self::subs); |
17 | 17 | } |
@@ -32,13 +32,13 @@ discard block |
||
32 | 32 | if (settings::$telegram_verify) { |
33 | 33 | $ip = $ip ?? tools::remoteIP(); |
34 | 34 | if (!tools::isTelegram($ip)) { |
35 | - logger::write('not authorized access denied. IP : '. $ip ?? 'unknown',loggerTypes::WARNING); |
|
35 | + logger::write('not authorized access denied. IP : '.$ip ?? 'unknown', loggerTypes::WARNING); |
|
36 | 36 | BPT::exit(); |
37 | 37 | } |
38 | 38 | } |
39 | 39 | } |
40 | 40 | |
41 | - protected static function processUpdate(string|stdClass|update $update = null): void { |
|
41 | + protected static function processUpdate(string | stdClass | update $update = null): void { |
|
42 | 42 | if (!is_object($update)) { |
43 | 43 | $update = json_decode($update ?? file_get_contents("php://input")); |
44 | 44 | if (!$update) { |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | } |
47 | 47 | } |
48 | 48 | |
49 | - if (!is_a($update,'update')) { |
|
49 | + if (!is_a($update, 'update')) { |
|
50 | 50 | $update = new update($update); |
51 | 51 | } |
52 | 52 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | db::save(); |
58 | 58 | } |
59 | 59 | |
60 | - protected static function setMessageExtra (update &$update): void { |
|
60 | + protected static function setMessageExtra(update & $update): void { |
|
61 | 61 | if ((isset($update->message) && isset($update->message->text)) || (isset($update->edited_message) && isset($update->edited_message->text))) { |
62 | 62 | $type = isset($update->message) ? 'message' : 'edited_message'; |
63 | 63 | $text = &$update->$type->text; |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | BPT::$handler->something_else(BPT::$update); |
131 | 131 | } |
132 | 132 | else { |
133 | - logger::write('Update received but handlers are not set',loggerTypes::WARNING); |
|
133 | + logger::write('Update received but handlers are not set', loggerTypes::WARNING); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | } |
@@ -85,51 +85,41 @@ |
||
85 | 85 | if (self::handlerExist('message')) { |
86 | 86 | BPT::$handler->message(BPT::$update->message); |
87 | 87 | } |
88 | - } |
|
89 | - elseif (isset(BPT::$update->edited_message)) { |
|
88 | + } elseif (isset(BPT::$update->edited_message)) { |
|
90 | 89 | if (self::handlerExist('edited_message')) { |
91 | 90 | BPT::$handler->edited_message(BPT::$update->edited_message); |
92 | 91 | } |
93 | - } |
|
94 | - elseif (isset(BPT::$update->channel_post)) { |
|
92 | + } elseif (isset(BPT::$update->channel_post)) { |
|
95 | 93 | if (self::handlerExist('channel_post')) { |
96 | 94 | BPT::$handler->channel_post(BPT::$update->channel_post); |
97 | 95 | } |
98 | - } |
|
99 | - elseif (isset(BPT::$update->edited_channel_post)) { |
|
96 | + } elseif (isset(BPT::$update->edited_channel_post)) { |
|
100 | 97 | if (self::handlerExist('edited_channel_post')) { |
101 | 98 | BPT::$handler->edited_channel_post(BPT::$update->edited_channel_post); |
102 | 99 | } |
103 | - } |
|
104 | - elseif (isset(BPT::$update->inline_query)) { |
|
100 | + } elseif (isset(BPT::$update->inline_query)) { |
|
105 | 101 | if (self::handlerExist('inline_query')) { |
106 | 102 | BPT::$handler->inline_query(BPT::$update->inline_query); |
107 | 103 | } |
108 | - } |
|
109 | - elseif (isset(BPT::$update->callback_query)) { |
|
104 | + } elseif (isset(BPT::$update->callback_query)) { |
|
110 | 105 | if (self::handlerExist('callback_query')) { |
111 | 106 | BPT::$handler->callback_query(BPT::$update->callback_query); |
112 | 107 | } |
113 | - } |
|
114 | - elseif (isset(BPT::$update->my_chat_member)) { |
|
108 | + } elseif (isset(BPT::$update->my_chat_member)) { |
|
115 | 109 | if (self::handlerExist('my_chat_member')) { |
116 | 110 | BPT::$handler->my_chat_member(BPT::$update->my_chat_member); |
117 | 111 | } |
118 | - } |
|
119 | - elseif (isset(BPT::$update->chat_member)) { |
|
112 | + } elseif (isset(BPT::$update->chat_member)) { |
|
120 | 113 | if (self::handlerExist('chat_member')) { |
121 | 114 | BPT::$handler->chat_member(BPT::$update->chat_member); |
122 | 115 | } |
123 | - } |
|
124 | - elseif (isset(BPT::$update->chat_join_request)) { |
|
116 | + } elseif (isset(BPT::$update->chat_join_request)) { |
|
125 | 117 | if (self::handlerExist('chat_join_request')) { |
126 | 118 | BPT::$handler->chat_join_request(BPT::$update->chat_join_request); |
127 | 119 | } |
128 | - } |
|
129 | - elseif (self::handlerExist('something_else')) { |
|
120 | + } elseif (self::handlerExist('something_else')) { |
|
130 | 121 | BPT::$handler->something_else(BPT::$update); |
131 | - } |
|
132 | - else { |
|
122 | + } else { |
|
133 | 123 | logger::write('Update received but handlers are not set',loggerTypes::WARNING); |
134 | 124 | } |
135 | 125 | } |
@@ -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 | } |
@@ -49,8 +49,7 @@ |
||
49 | 49 | foreach ($data as $key=>&$value){ |
50 | 50 | if (!isset($value)){ |
51 | 51 | unset($data[$key]); |
52 | - } |
|
53 | - elseif (is_array($value) || is_object($value)){ |
|
52 | + } elseif (is_array($value) || is_object($value)){ |
|
54 | 53 | $value = json_encode($value); |
55 | 54 | } |
56 | 55 | } |
@@ -811,19 +811,16 @@ discard block |
||
811 | 811 | foreach ($arguments['media'] as $key => $media) { |
812 | 812 | if ($media['media'] instanceof CURLFile) { |
813 | 813 | $remove_answer = true; |
814 | - } |
|
815 | - elseif (is_string($media['media']) && file_exists(realpath($media['media']))) { |
|
814 | + } elseif (is_string($media['media']) && file_exists(realpath($media['media']))) { |
|
816 | 815 | $arguments['media'][$key]['media'] = new CURLFile($media['media']); |
817 | 816 | $remove_answer = true; |
818 | 817 | } |
819 | 818 | } |
820 | - } |
|
821 | - elseif ($file_params = self::methodFile($name)) { |
|
819 | + } elseif ($file_params = self::methodFile($name)) { |
|
822 | 820 | foreach ($file_params as $param) { |
823 | 821 | if ($arguments[$param] instanceof CURLFile) { |
824 | 822 | $remove_answer = true; |
825 | - } |
|
826 | - elseif (isset($arguments[$param]) && is_string($arguments[$param]) && file_exists(realpath($arguments[$param]))) { |
|
823 | + } elseif (isset($arguments[$param]) && is_string($arguments[$param]) && file_exists(realpath($arguments[$param]))) { |
|
827 | 824 | $arguments[$param] = new CURLFile($arguments[$param]); |
828 | 825 | $remove_answer = true; |
829 | 826 | } |
@@ -861,8 +858,7 @@ discard block |
||
861 | 858 | if (!isset($arguments[$default])){ |
862 | 859 | $arguments[$default] = self::catchFields($default); |
863 | 860 | } |
864 | - } |
|
865 | - elseif (isset(BPT::$update->$key) || $key === 'other') { |
|
861 | + } elseif (isset(BPT::$update->$key) || $key === 'other') { |
|
866 | 862 | foreach ($default as $def) { |
867 | 863 | if (!isset($arguments[$def])){ |
868 | 864 | $arguments[$def] = self::catchFields($def); |
@@ -919,9 +915,13 @@ discard block |
||
919 | 915 | default => false |
920 | 916 | }; |
921 | 917 | case fields::FILE_ID : |
922 | - if (isset(BPT::$update->message)) $type = 'message'; |
|
923 | - elseif (isset(BPT::$update->edited_message)) $type = 'edited_message'; |
|
924 | - else return false; |
|
918 | + if (isset(BPT::$update->message)) { |
|
919 | + $type = 'message'; |
|
920 | + } elseif (isset(BPT::$update->edited_message)) { |
|
921 | + $type = 'edited_message'; |
|
922 | + } else { |
|
923 | + return false; |
|
924 | + } |
|
925 | 925 | |
926 | 926 | return match(true) { |
927 | 927 | isset(BPT::$update->$type->animation) => BPT::$update->$type->animation->file_id, |
@@ -504,95 +504,95 @@ discard block |
||
504 | 504 | ]; |
505 | 505 | |
506 | 506 | private const METHODS_KEYS = [ |
507 | - 'getUpdates' => ['offset','limit','timeout','allowed_updates','token','forgot','answer'], |
|
508 | - 'setWebhook' => ['url','certificate','ip_address','max_connections','allowed_updates','drop_pending_updates','secret_token','token','forgot','answer'], |
|
509 | - 'deleteWebhook' => ['drop_pending_updates','token','forgot','answer'], |
|
510 | - 'getWebhookInfo' => ['token','forgot','answer'], |
|
511 | - 'getMe' => ['token','forgot','answer'], |
|
512 | - 'logOut' => ['token','forgot','answer'], |
|
513 | - 'close' => ['token','forgot','answer'], |
|
514 | - 'sendMessage' => ['text','chat_id','parse_mode','entities','disable_web_page_preview','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
515 | - 'forwardMessage' => ['chat_id','from_chat_id','disable_notification','protect_content','message_id','token','forgot','answer','message_thread_id'], |
|
516 | - 'copyMessage' => ['chat_id','from_chat_id','message_id','caption','parse_mode','caption_entities','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
517 | - 'sendPhoto' => ['photo','chat_id','caption','parse_mode','caption_entities','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','has_spoiler','message_thread_id'], |
|
518 | - 'sendAudio' => ['audio','chat_id','caption','parse_mode','caption_entities','duration','performer','title','thumb','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
519 | - 'sendDocument' => ['document','chat_id','thumb','caption','parse_mode','caption_entities','disable_content_type_detection','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
520 | - 'sendVideo' => ['video','chat_id','duration','width','height','thumb','caption','parse_mode','caption_entities','supports_streaming','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','has_spoiler','message_thread_id'], |
|
521 | - 'sendAnimation' => ['animation','chat_id','duration','width','height','thumb','caption','parse_mode','caption_entities','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','has_spoiler','message_thread_id'], |
|
522 | - 'sendVoice' => ['voice','chat_id','caption','parse_mode','caption_entities','duration','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
523 | - 'sendVideoNote' => ['video_note','chat_id','duration','length','thumb','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
524 | - 'sendMediaGroup' => ['media','chat_id','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','token','forgot','answer','message_thread_id'], |
|
525 | - 'sendLocation' => ['latitude','longitude','chat_id','horizontal_accuracy','live_period','heading','proximity_alert_radius','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
526 | - 'editMessageLiveLocation' => ['latitude','longitude','chat_id','message_id','inline_message_id','horizontal_accuracy','heading','proximity_alert_radius','reply_markup','token','forgot','answer'], |
|
527 | - 'stopMessageLiveLocation' => ['chat_id','message_id','inline_message_id','reply_markup','token','forgot','answer'], |
|
528 | - 'sendVenue' => ['chat_id','latitude','longitude','title','address','foursquare_id','foursquare_type','google_place_id','google_place_type','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
529 | - 'sendContact' => ['phone_number','first_name','chat_id','last_name','vcard','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
530 | - 'sendPoll' => ['question','options','chat_id','is_anonymous','type','allows_multiple_answers','correct_option_id','explanation','explanation_parse_mode','explanation_entities','open_period','close_date','is_closed','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
531 | - 'sendDice' => ['chat_id','emoji','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
532 | - 'sendChatAction' => ['chat_id','action','token','forgot','answer','message_thread_id'], |
|
533 | - 'getUserProfilePhotos' => ['user_id','offset','limit','token','forgot','answer'], |
|
534 | - 'getFile' => ['file_id','token','forgot','answer'], |
|
535 | - 'banChatMember' => ['chat_id','user_id','until_date','revoke_messages','token','forgot','answer'], |
|
536 | - 'unbanChatMember' => ['chat_id','user_id','only_if_banned','token','forgot','answer'], |
|
537 | - 'restrictChatMember' => ['permissions','chat_id','user_id','until_date','token','forgot','answer','use_independent_chat_permissions'], |
|
538 | - 'promoteChatMember' => ['chat_id','user_id','is_anonymous','can_manage_chat','can_post_messages','can_edit_messages','can_delete_messages','can_manage_video_chats','can_restrict_members','can_promote_members','can_change_info','can_invite_users','can_pin_messages','can_manage_topics','token','forgot','answer'], |
|
539 | - 'setChatAdministratorCustomTitle' => ['custom_title','chat_id','user_id','token','forgot','answer'], |
|
540 | - 'banChatSenderChat' => ['sender_chat_id','chat_id','token','forgot','answer'], |
|
541 | - 'unbanChatSenderChat' => ['sender_chat_id','chat_id','token','forgot','answer'], |
|
542 | - 'setChatPermissions' => ['permissions','chat_id','token','forgot','answer','use_independent_chat_permissions'], |
|
543 | - 'exportChatInviteLink' => ['chat_id','token','forgot','answer'], |
|
544 | - 'createChatInviteLink' => ['chat_id','name','expire_date','member_limit','creates_join_request','token','forgot','answer'], |
|
545 | - 'editChatInviteLink' => ['invite_link','chat_id','name','expire_date','member_limit','creates_join_request','token','forgot','answer'], |
|
546 | - 'revokeChatInviteLink' => ['invite_link','chat_id','token','forgot','answer'], |
|
547 | - 'approveChatJoinRequest' => ['chat_id','user_id','token','forgot','answer'], |
|
548 | - 'declineChatJoinRequest' => ['chat_id','user_id','token','forgot','answer'], |
|
549 | - 'setChatPhoto' => ['photo','chat_id','token','forgot','answer'], |
|
550 | - 'deleteChatPhoto' => ['chat_id','token','forgot','answer'], |
|
551 | - 'setChatTitle' => ['title','chat_id','token','forgot','answer'], |
|
552 | - 'setChatDescription' => ['chat_id','description','token','forgot','answer'], |
|
553 | - 'pinChatMessage' => ['message_id','chat_id','disable_notification','token','forgot','answer'], |
|
554 | - 'unpinChatMessage' => ['chat_id','message_id','token','forgot','answer'], |
|
555 | - 'unpinAllChatMessages' => ['chat_id','token','forgot','answer'], |
|
556 | - 'leaveChat' => ['chat_id','token','forgot','answer'], |
|
557 | - 'getChat' => ['chat_id','token','forgot','answer'], |
|
558 | - 'getChatAdministrators' => ['chat_id','token','forgot','answer'], |
|
559 | - 'getChatMemberCount' => ['chat_id','token','forgot','answer'], |
|
560 | - 'getChatMember' => ['chat_id','user_id','token','forgot','answer'], |
|
561 | - 'setChatStickerSet' => ['sticker_set_name','chat_id','token','forgot','answer'], |
|
562 | - 'deleteChatStickerSet' => ['chat_id','token','forgot','answer'], |
|
563 | - 'answerCallbackQuery' => ['callback_query_id','text','show_alert','url','cache_time','token','forgot','answer'], |
|
564 | - 'setMyCommands' => ['commands','scope','language_code','token','forgot','answer'], |
|
565 | - 'deleteMyCommands' => ['scope','language_code','token','forgot','answer'], |
|
566 | - 'getMyCommands' => ['scope','language_code','token','forgot','answer'], |
|
567 | - 'setChatMenuButton' => ['chat_id','menu_button','token','forgot','answer'], |
|
568 | - 'getChatMenuButton' => ['chat_id','token','forgot','answer'], |
|
569 | - 'setMyDefaultAdministratorRights' => ['rights','for_channels','token','forgot','answer'], |
|
570 | - 'getMyDefaultAdministratorRights' => ['for_channels','token','forgot','answer'], |
|
571 | - 'editMessageText' => ['text','chat_id','message_id','inline_message_id','parse_mode','entities','disable_web_page_preview','reply_markup','token','forgot','answer'], |
|
572 | - 'editMessageCaption' => ['chat_id','message_id','inline_message_id','caption','parse_mode','caption_entities','reply_markup','token','forgot','answer'], |
|
573 | - 'editMessageMedia' => ['media','chat_id','message_id','inline_message_id','reply_markup','token','forgot','answer'], |
|
574 | - 'editMessageReplyMarkup' => ['chat_id','message_id','inline_message_id','reply_markup','token','forgot','answer'], |
|
575 | - 'stopPoll' => ['chat_id','message_id','reply_markup','token','forgot','answer'], |
|
576 | - 'deleteMessage' => ['chat_id','message_id','token','forgot','answer'], |
|
577 | - 'sendSticker' => ['sticker','chat_id','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
578 | - 'getStickerSet' => ['name','token','forgot','answer'], |
|
507 | + 'getUpdates' => ['offset', 'limit', 'timeout', 'allowed_updates', 'token', 'forgot', 'answer'], |
|
508 | + 'setWebhook' => ['url', 'certificate', 'ip_address', 'max_connections', 'allowed_updates', 'drop_pending_updates', 'secret_token', 'token', 'forgot', 'answer'], |
|
509 | + 'deleteWebhook' => ['drop_pending_updates', 'token', 'forgot', 'answer'], |
|
510 | + 'getWebhookInfo' => ['token', 'forgot', 'answer'], |
|
511 | + 'getMe' => ['token', 'forgot', 'answer'], |
|
512 | + 'logOut' => ['token', 'forgot', 'answer'], |
|
513 | + 'close' => ['token', 'forgot', 'answer'], |
|
514 | + 'sendMessage' => ['text', 'chat_id', 'parse_mode', 'entities', 'disable_web_page_preview', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
515 | + 'forwardMessage' => ['chat_id', 'from_chat_id', 'disable_notification', 'protect_content', 'message_id', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
516 | + 'copyMessage' => ['chat_id', 'from_chat_id', 'message_id', 'caption', 'parse_mode', 'caption_entities', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
517 | + 'sendPhoto' => ['photo', 'chat_id', 'caption', 'parse_mode', 'caption_entities', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'has_spoiler', 'message_thread_id'], |
|
518 | + 'sendAudio' => ['audio', 'chat_id', 'caption', 'parse_mode', 'caption_entities', 'duration', 'performer', 'title', 'thumb', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
519 | + 'sendDocument' => ['document', 'chat_id', 'thumb', 'caption', 'parse_mode', 'caption_entities', 'disable_content_type_detection', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
520 | + 'sendVideo' => ['video', 'chat_id', 'duration', 'width', 'height', 'thumb', 'caption', 'parse_mode', 'caption_entities', 'supports_streaming', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'has_spoiler', 'message_thread_id'], |
|
521 | + 'sendAnimation' => ['animation', 'chat_id', 'duration', 'width', 'height', 'thumb', 'caption', 'parse_mode', 'caption_entities', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'has_spoiler', 'message_thread_id'], |
|
522 | + 'sendVoice' => ['voice', 'chat_id', 'caption', 'parse_mode', 'caption_entities', 'duration', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
523 | + 'sendVideoNote' => ['video_note', 'chat_id', 'duration', 'length', 'thumb', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
524 | + 'sendMediaGroup' => ['media', 'chat_id', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
525 | + 'sendLocation' => ['latitude', 'longitude', 'chat_id', 'horizontal_accuracy', 'live_period', 'heading', 'proximity_alert_radius', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
526 | + 'editMessageLiveLocation' => ['latitude', 'longitude', 'chat_id', 'message_id', 'inline_message_id', 'horizontal_accuracy', 'heading', 'proximity_alert_radius', 'reply_markup', 'token', 'forgot', 'answer'], |
|
527 | + 'stopMessageLiveLocation' => ['chat_id', 'message_id', 'inline_message_id', 'reply_markup', 'token', 'forgot', 'answer'], |
|
528 | + 'sendVenue' => ['chat_id', 'latitude', 'longitude', 'title', 'address', 'foursquare_id', 'foursquare_type', 'google_place_id', 'google_place_type', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
529 | + 'sendContact' => ['phone_number', 'first_name', 'chat_id', 'last_name', 'vcard', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
530 | + 'sendPoll' => ['question', 'options', 'chat_id', 'is_anonymous', 'type', 'allows_multiple_answers', 'correct_option_id', 'explanation', 'explanation_parse_mode', 'explanation_entities', 'open_period', 'close_date', 'is_closed', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
531 | + 'sendDice' => ['chat_id', 'emoji', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
532 | + 'sendChatAction' => ['chat_id', 'action', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
533 | + 'getUserProfilePhotos' => ['user_id', 'offset', 'limit', 'token', 'forgot', 'answer'], |
|
534 | + 'getFile' => ['file_id', 'token', 'forgot', 'answer'], |
|
535 | + 'banChatMember' => ['chat_id', 'user_id', 'until_date', 'revoke_messages', 'token', 'forgot', 'answer'], |
|
536 | + 'unbanChatMember' => ['chat_id', 'user_id', 'only_if_banned', 'token', 'forgot', 'answer'], |
|
537 | + 'restrictChatMember' => ['permissions', 'chat_id', 'user_id', 'until_date', 'token', 'forgot', 'answer', 'use_independent_chat_permissions'], |
|
538 | + 'promoteChatMember' => ['chat_id', 'user_id', 'is_anonymous', 'can_manage_chat', 'can_post_messages', 'can_edit_messages', 'can_delete_messages', 'can_manage_video_chats', 'can_restrict_members', 'can_promote_members', 'can_change_info', 'can_invite_users', 'can_pin_messages', 'can_manage_topics', 'token', 'forgot', 'answer'], |
|
539 | + 'setChatAdministratorCustomTitle' => ['custom_title', 'chat_id', 'user_id', 'token', 'forgot', 'answer'], |
|
540 | + 'banChatSenderChat' => ['sender_chat_id', 'chat_id', 'token', 'forgot', 'answer'], |
|
541 | + 'unbanChatSenderChat' => ['sender_chat_id', 'chat_id', 'token', 'forgot', 'answer'], |
|
542 | + 'setChatPermissions' => ['permissions', 'chat_id', 'token', 'forgot', 'answer', 'use_independent_chat_permissions'], |
|
543 | + 'exportChatInviteLink' => ['chat_id', 'token', 'forgot', 'answer'], |
|
544 | + 'createChatInviteLink' => ['chat_id', 'name', 'expire_date', 'member_limit', 'creates_join_request', 'token', 'forgot', 'answer'], |
|
545 | + 'editChatInviteLink' => ['invite_link', 'chat_id', 'name', 'expire_date', 'member_limit', 'creates_join_request', 'token', 'forgot', 'answer'], |
|
546 | + 'revokeChatInviteLink' => ['invite_link', 'chat_id', 'token', 'forgot', 'answer'], |
|
547 | + 'approveChatJoinRequest' => ['chat_id', 'user_id', 'token', 'forgot', 'answer'], |
|
548 | + 'declineChatJoinRequest' => ['chat_id', 'user_id', 'token', 'forgot', 'answer'], |
|
549 | + 'setChatPhoto' => ['photo', 'chat_id', 'token', 'forgot', 'answer'], |
|
550 | + 'deleteChatPhoto' => ['chat_id', 'token', 'forgot', 'answer'], |
|
551 | + 'setChatTitle' => ['title', 'chat_id', 'token', 'forgot', 'answer'], |
|
552 | + 'setChatDescription' => ['chat_id', 'description', 'token', 'forgot', 'answer'], |
|
553 | + 'pinChatMessage' => ['message_id', 'chat_id', 'disable_notification', 'token', 'forgot', 'answer'], |
|
554 | + 'unpinChatMessage' => ['chat_id', 'message_id', 'token', 'forgot', 'answer'], |
|
555 | + 'unpinAllChatMessages' => ['chat_id', 'token', 'forgot', 'answer'], |
|
556 | + 'leaveChat' => ['chat_id', 'token', 'forgot', 'answer'], |
|
557 | + 'getChat' => ['chat_id', 'token', 'forgot', 'answer'], |
|
558 | + 'getChatAdministrators' => ['chat_id', 'token', 'forgot', 'answer'], |
|
559 | + 'getChatMemberCount' => ['chat_id', 'token', 'forgot', 'answer'], |
|
560 | + 'getChatMember' => ['chat_id', 'user_id', 'token', 'forgot', 'answer'], |
|
561 | + 'setChatStickerSet' => ['sticker_set_name', 'chat_id', 'token', 'forgot', 'answer'], |
|
562 | + 'deleteChatStickerSet' => ['chat_id', 'token', 'forgot', 'answer'], |
|
563 | + 'answerCallbackQuery' => ['callback_query_id', 'text', 'show_alert', 'url', 'cache_time', 'token', 'forgot', 'answer'], |
|
564 | + 'setMyCommands' => ['commands', 'scope', 'language_code', 'token', 'forgot', 'answer'], |
|
565 | + 'deleteMyCommands' => ['scope', 'language_code', 'token', 'forgot', 'answer'], |
|
566 | + 'getMyCommands' => ['scope', 'language_code', 'token', 'forgot', 'answer'], |
|
567 | + 'setChatMenuButton' => ['chat_id', 'menu_button', 'token', 'forgot', 'answer'], |
|
568 | + 'getChatMenuButton' => ['chat_id', 'token', 'forgot', 'answer'], |
|
569 | + 'setMyDefaultAdministratorRights' => ['rights', 'for_channels', 'token', 'forgot', 'answer'], |
|
570 | + 'getMyDefaultAdministratorRights' => ['for_channels', 'token', 'forgot', 'answer'], |
|
571 | + 'editMessageText' => ['text', 'chat_id', 'message_id', 'inline_message_id', 'parse_mode', 'entities', 'disable_web_page_preview', 'reply_markup', 'token', 'forgot', 'answer'], |
|
572 | + 'editMessageCaption' => ['chat_id', 'message_id', 'inline_message_id', 'caption', 'parse_mode', 'caption_entities', 'reply_markup', 'token', 'forgot', 'answer'], |
|
573 | + 'editMessageMedia' => ['media', 'chat_id', 'message_id', 'inline_message_id', 'reply_markup', 'token', 'forgot', 'answer'], |
|
574 | + 'editMessageReplyMarkup' => ['chat_id', 'message_id', 'inline_message_id', 'reply_markup', 'token', 'forgot', 'answer'], |
|
575 | + 'stopPoll' => ['chat_id', 'message_id', 'reply_markup', 'token', 'forgot', 'answer'], |
|
576 | + 'deleteMessage' => ['chat_id', 'message_id', 'token', 'forgot', 'answer'], |
|
577 | + 'sendSticker' => ['sticker', 'chat_id', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
578 | + 'getStickerSet' => ['name', 'token', 'forgot', 'answer'], |
|
579 | 579 | 'getCustomEmojiStickers' => ['custom_emoji_ids', 'token', 'return_array', 'forgot', 'answer'], |
580 | - 'uploadStickerFile' => ['png_sticker','user_id','token','forgot','answer'], |
|
581 | - 'createNewStickerSet' => ['name','title','emojis','user_id','png_sticker','tgs_sticker','webm_sticker','sticker_type','contains_masks','mask_position','token','forgot','answer'], |
|
582 | - 'addStickerToSet' => ['name','emojis','user_id','png_sticker','tgs_sticker','webm_sticker','mask_position','token','forgot','answer'], |
|
583 | - 'setStickerPositionInSet' => ['sticker','position','token','forgot','answer'], |
|
584 | - 'deleteStickerFromSet' => ['sticker','token','forgot','answer'], |
|
585 | - 'setStickerSetThumb' => ['name','user_id','thumb','token','forgot','answer'], |
|
586 | - 'answerInlineQuery' => ['results','inline_query_id','cache_time','is_personal','next_offset','switch_pm_text','switch_pm_parameter','token','forgot','answer'], |
|
587 | - 'answerWebAppQuery' => ['web_app_query_id','result','token','forgot','answer'], |
|
588 | - 'sendInvoice' => ['title','description','payload','provider_token','currency','prices','chat_id','max_tip_amount','suggested_tip_amounts','start_parameter','provider_data','photo_url','photo_size','photo_width','photo_height','need_name','need_phone_number','need_email','need_shipping_address','send_phone_number_to_provider','send_email_to_provider','is_flexible','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
589 | - 'createInvoiceLink' => ['title','description','payload','provider_token','currency','prices','max_tip_amount','suggested_tip_amounts','provider_data','photo_url','photo_size','photo_width','photo_height','need_name','need_phone_number','need_email','need_shipping_address','send_phone_number_to_provider','send_email_to_provider','is_flexible','token','forgot','answer'], |
|
590 | - 'answerShippingQuery' => ['ok','shipping_query_id','shipping_options','error_message','token','forgot','answer'], |
|
591 | - 'answerPreCheckoutQuery' => ['ok','pre_checkout_query_id','error_message','token','forgot','answer'], |
|
592 | - 'setPassportDataErrors' => ['errors','user_id','token','forgot','answer'], |
|
593 | - 'sendGame' => ['game_short_name','chat_id','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer', 'message_thread_id'], |
|
594 | - 'setGameScore' => ['score','user_id','force','disable_edit_message','chat_id','message_id','inline_message_id','token','forgot','answer'], |
|
595 | - 'getGameHighScores' => ['user_id','chat_id','message_id','inline_message_id','token','forgot','answer'], |
|
580 | + 'uploadStickerFile' => ['png_sticker', 'user_id', 'token', 'forgot', 'answer'], |
|
581 | + 'createNewStickerSet' => ['name', 'title', 'emojis', 'user_id', 'png_sticker', 'tgs_sticker', 'webm_sticker', 'sticker_type', 'contains_masks', 'mask_position', 'token', 'forgot', 'answer'], |
|
582 | + 'addStickerToSet' => ['name', 'emojis', 'user_id', 'png_sticker', 'tgs_sticker', 'webm_sticker', 'mask_position', 'token', 'forgot', 'answer'], |
|
583 | + 'setStickerPositionInSet' => ['sticker', 'position', 'token', 'forgot', 'answer'], |
|
584 | + 'deleteStickerFromSet' => ['sticker', 'token', 'forgot', 'answer'], |
|
585 | + 'setStickerSetThumb' => ['name', 'user_id', 'thumb', 'token', 'forgot', 'answer'], |
|
586 | + 'answerInlineQuery' => ['results', 'inline_query_id', 'cache_time', 'is_personal', 'next_offset', 'switch_pm_text', 'switch_pm_parameter', 'token', 'forgot', 'answer'], |
|
587 | + 'answerWebAppQuery' => ['web_app_query_id', 'result', 'token', 'forgot', 'answer'], |
|
588 | + 'sendInvoice' => ['title', 'description', 'payload', 'provider_token', 'currency', 'prices', 'chat_id', 'max_tip_amount', 'suggested_tip_amounts', 'start_parameter', 'provider_data', 'photo_url', 'photo_size', 'photo_width', 'photo_height', 'need_name', 'need_phone_number', 'need_email', 'need_shipping_address', 'send_phone_number_to_provider', 'send_email_to_provider', 'is_flexible', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
589 | + 'createInvoiceLink' => ['title', 'description', 'payload', 'provider_token', 'currency', 'prices', 'max_tip_amount', 'suggested_tip_amounts', 'provider_data', 'photo_url', 'photo_size', 'photo_width', 'photo_height', 'need_name', 'need_phone_number', 'need_email', 'need_shipping_address', 'send_phone_number_to_provider', 'send_email_to_provider', 'is_flexible', 'token', 'forgot', 'answer'], |
|
590 | + 'answerShippingQuery' => ['ok', 'shipping_query_id', 'shipping_options', 'error_message', 'token', 'forgot', 'answer'], |
|
591 | + 'answerPreCheckoutQuery' => ['ok', 'pre_checkout_query_id', 'error_message', 'token', 'forgot', 'answer'], |
|
592 | + 'setPassportDataErrors' => ['errors', 'user_id', 'token', 'forgot', 'answer'], |
|
593 | + 'sendGame' => ['game_short_name', 'chat_id', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
594 | + 'setGameScore' => ['score', 'user_id', 'force', 'disable_edit_message', 'chat_id', 'message_id', 'inline_message_id', 'token', 'forgot', 'answer'], |
|
595 | + 'getGameHighScores' => ['user_id', 'chat_id', 'message_id', 'inline_message_id', 'token', 'forgot', 'answer'], |
|
596 | 596 | 'getForumTopicIconStickers' => ['token', 'return_array', 'forgot', 'answer'], |
597 | 597 | 'createForumTopic' => ['chat_id', 'name', 'icon_color', 'icon_custom_emoji_id', 'token', 'return_array', 'forgot', 'answer'], |
598 | 598 | 'editForumTopic' => ['chat_id', 'name', 'icon_custom_emoji_id', 'token', 'return_array', 'forgot', 'answer', 'message_thread_id'], |
@@ -633,8 +633,8 @@ discard block |
||
633 | 633 | 'logOut' => [], |
634 | 634 | 'close' => [], |
635 | 635 | 'sendMessage' => ['chat_id'], |
636 | - 'forwardMessage' => ['from_chat_id','message_id'], |
|
637 | - 'copyMessage' => ['from_chat_id','message_id'], |
|
636 | + 'forwardMessage' => ['from_chat_id', 'message_id'], |
|
637 | + 'copyMessage' => ['from_chat_id', 'message_id'], |
|
638 | 638 | 'sendPhoto' => ['chat_id'], |
639 | 639 | 'sendAudio' => ['chat_id'], |
640 | 640 | 'sendDocument' => ['chat_id'], |
@@ -650,15 +650,15 @@ discard block |
||
650 | 650 | 'sendContact' => ['chat_id'], |
651 | 651 | 'sendPoll' => ['chat_id'], |
652 | 652 | 'sendDice' => ['chat_id'], |
653 | - 'sendChatAction' => ['chat_id','action'], |
|
653 | + 'sendChatAction' => ['chat_id', 'action'], |
|
654 | 654 | 'getUserProfilePhotos' => ['user_id'], |
655 | 655 | 'getFile' => ['file_id'], |
656 | - 'banChatMember' => ['chat_id','user_id'], |
|
657 | - 'kickChatMember' => ['chat_id','user_id'], |
|
658 | - 'unbanChatMember' => ['chat_id','user_id'], |
|
659 | - 'restrictChatMember' => ['chat_id','user_id'], |
|
660 | - 'promoteChatMember' => ['chat_id','user_id'], |
|
661 | - 'setChatAdministratorCustomTitle' => ['chat_id','user_id'], |
|
656 | + 'banChatMember' => ['chat_id', 'user_id'], |
|
657 | + 'kickChatMember' => ['chat_id', 'user_id'], |
|
658 | + 'unbanChatMember' => ['chat_id', 'user_id'], |
|
659 | + 'restrictChatMember' => ['chat_id', 'user_id'], |
|
660 | + 'promoteChatMember' => ['chat_id', 'user_id'], |
|
661 | + 'setChatAdministratorCustomTitle' => ['chat_id', 'user_id'], |
|
662 | 662 | 'banChatSenderChat' => ['chat_id'], |
663 | 663 | 'unbanChatSenderChat' => ['chat_id'], |
664 | 664 | 'setChatPermissions' => ['chat_id'], |
@@ -666,8 +666,8 @@ discard block |
||
666 | 666 | 'createChatInviteLink' => ['chat_id'], |
667 | 667 | 'editChatInviteLink' => ['chat_id'], |
668 | 668 | 'revokeChatInviteLink' => ['chat_id'], |
669 | - 'approveChatJoinRequest' => ['chat_id','user_id'], |
|
670 | - 'declineChatJoinRequest' => ['chat_id','user_id'], |
|
669 | + 'approveChatJoinRequest' => ['chat_id', 'user_id'], |
|
670 | + 'declineChatJoinRequest' => ['chat_id', 'user_id'], |
|
671 | 671 | 'setChatPhoto' => ['chat_id'], |
672 | 672 | 'deleteChatPhoto' => ['chat_id'], |
673 | 673 | 'setChatTitle' => ['chat_id'], |
@@ -679,7 +679,7 @@ discard block |
||
679 | 679 | 'getChat' => ['chat_id'], |
680 | 680 | 'getChatAdministrators' => ['chat_id'], |
681 | 681 | 'getChatMembersCount' => ['chat_id'], |
682 | - 'getChatMember' => ['chat_id','user_id'], |
|
682 | + 'getChatMember' => ['chat_id', 'user_id'], |
|
683 | 683 | 'setChatStickerSet' => ['chat_id'], |
684 | 684 | 'deleteChatStickerSet' => ['chat_id'], |
685 | 685 | 'answerCallbackQuery' => ['callback_query_id'], |
@@ -690,12 +690,12 @@ discard block |
||
690 | 690 | 'getChatMenuButton' => [], |
691 | 691 | 'setMyDefaultAdministratorRights' => [], |
692 | 692 | 'getMyDefaultAdministratorRights' => [], |
693 | - 'editMessageText' => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
694 | - 'editMessageCaption' => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
695 | - 'editMessageMedia' => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
696 | - 'editMessageReplyMarkup' => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
697 | - 'stopPoll' => ['chat_id','message_id'], |
|
698 | - 'deleteMessage' => ['chat_id','message_id'], |
|
693 | + 'editMessageText' => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
694 | + 'editMessageCaption' => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
695 | + 'editMessageMedia' => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
696 | + 'editMessageReplyMarkup' => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
697 | + 'stopPoll' => ['chat_id', 'message_id'], |
|
698 | + 'deleteMessage' => ['chat_id', 'message_id'], |
|
699 | 699 | 'sendSticker' => ['chat_id'], |
700 | 700 | 'getStickerSet' => [], |
701 | 701 | 'uploadStickerFile' => ['user_id'], |
@@ -711,8 +711,8 @@ discard block |
||
711 | 711 | 'answerPreCheckoutQuery' => ['pre_checkout_query_id'], |
712 | 712 | 'setPassportDataErrors' => ['user_id'], |
713 | 713 | 'sendGame' => ['chat_id'], |
714 | - 'setGameScore' => ['user_id','inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
715 | - 'getGameHighScores' => ['user_id','inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']] |
|
714 | + 'setGameScore' => ['user_id', 'inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
715 | + 'getGameHighScores' => ['user_id', 'inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']] |
|
716 | 716 | ]; |
717 | 717 | |
718 | 718 | private const METHODS_RETURN = [ |
@@ -766,29 +766,29 @@ discard block |
||
766 | 766 | 'getGameHighScores' => ['BPT\types\gameHighScore'] |
767 | 767 | ]; |
768 | 768 | |
769 | - public static function __callStatic (string $name, array $arguments) { |
|
769 | + public static function __callStatic(string $name, array $arguments) { |
|
770 | 770 | if (!$action = self::methodAction($name)) { |
771 | - logger::write("$name method is not supported",loggerTypes::ERROR); |
|
771 | + logger::write("$name method is not supported", loggerTypes::ERROR); |
|
772 | 772 | throw new bptException('METHOD_NOT_FOUND'); |
773 | 773 | } |
774 | 774 | self::checkArguments($arguments); |
775 | - self::keysName($action,$arguments); |
|
776 | - self::readyFile($action,$arguments); |
|
775 | + self::keysName($action, $arguments); |
|
776 | + self::readyFile($action, $arguments); |
|
777 | 777 | self::cleanArguments($arguments); |
778 | - self::setDefaults($action,$arguments); |
|
778 | + self::setDefaults($action, $arguments); |
|
779 | 779 | |
780 | 780 | if (isset($arguments['answer']) && $arguments['answer'] === true) { |
781 | 781 | unset($arguments['answer']); |
782 | 782 | if (!answer::isAnswered()) { |
783 | - return answer::init($action,$arguments); |
|
783 | + return answer::init($action, $arguments); |
|
784 | 784 | } |
785 | - logger::write('you can use answer mode only once for each webhook update, Others will be called like normal',loggerTypes::WARNING); |
|
785 | + logger::write('you can use answer mode only once for each webhook update, Others will be called like normal', loggerTypes::WARNING); |
|
786 | 786 | } |
787 | - $result = curl::init($action,$arguments); |
|
787 | + $result = curl::init($action, $arguments); |
|
788 | 788 | if (!is_object($result)) { |
789 | 789 | return false; |
790 | 790 | } |
791 | - return self::processResponse($action,$result); |
|
791 | + return self::processResponse($action, $result); |
|
792 | 792 | } |
793 | 793 | |
794 | 794 | private static function checkArguments(array &$arguments): void { |
@@ -797,7 +797,7 @@ discard block |
||
797 | 797 | } |
798 | 798 | } |
799 | 799 | |
800 | - private static function keysName (string $name, array &$arguments): void { |
|
800 | + private static function keysName(string $name, array &$arguments): void { |
|
801 | 801 | foreach ($arguments as $key => $argument) { |
802 | 802 | if (is_numeric($key) && isset(self::METHODS_KEYS[$name][$key])) { |
803 | 803 | $arguments[self::METHODS_KEYS[$name][$key]] = $argument; |
@@ -806,7 +806,7 @@ discard block |
||
806 | 806 | } |
807 | 807 | } |
808 | 808 | |
809 | - private static function methodAction(string $name): string|false { |
|
809 | + private static function methodAction(string $name): string | false { |
|
810 | 810 | return self::METHODS_ACTION[str_replace('_', '', strtolower($name))] ?? false; |
811 | 811 | } |
812 | 812 | |
@@ -839,11 +839,11 @@ discard block |
||
839 | 839 | } |
840 | 840 | } |
841 | 841 | |
842 | - private static function methodFile(string $name): array|false { |
|
842 | + private static function methodFile(string $name): array | false { |
|
843 | 843 | return self::METHODS_WITH_FILE[$name] ?? false; |
844 | 844 | } |
845 | 845 | |
846 | - private static function methodReturn(string $name,stdClass $response) { |
|
846 | + private static function methodReturn(string $name, stdClass $response) { |
|
847 | 847 | if (!isset(self::METHODS_RETURN[$name])) { |
848 | 848 | return $response->result; |
849 | 849 | } |
@@ -862,13 +862,13 @@ discard block |
||
862 | 862 | $defaults = self::METHODS_EXTRA_DEFAULTS[$name]; |
863 | 863 | foreach ($defaults as $key => $default) { |
864 | 864 | if (is_numeric($key)) { |
865 | - if (!isset($arguments[$default])){ |
|
865 | + if (!isset($arguments[$default])) { |
|
866 | 866 | $arguments[$default] = self::catchFields($default); |
867 | 867 | } |
868 | 868 | } |
869 | 869 | elseif (isset(BPT::$update->$key) || $key === 'other') { |
870 | 870 | foreach ($default as $def) { |
871 | - if (!isset($arguments[$def])){ |
|
871 | + if (!isset($arguments[$def])) { |
|
872 | 872 | $arguments[$def] = self::catchFields($def); |
873 | 873 | } |
874 | 874 | } |
@@ -887,13 +887,13 @@ discard block |
||
887 | 887 | self::$status = $response->ok; |
888 | 888 | self::$pure_response = $response; |
889 | 889 | if (!$response->ok) { |
890 | - logger::write("Telegram $name method failed : " . json_encode($response), loggerTypes::WARNING); |
|
890 | + logger::write("Telegram $name method failed : ".json_encode($response), loggerTypes::WARNING); |
|
891 | 891 | return new responseError($response); |
892 | 892 | } |
893 | - return self::methodReturn($name,$response); |
|
893 | + return self::methodReturn($name, $response); |
|
894 | 894 | } |
895 | 895 | |
896 | - private static function cleanArguments (array &$arguments): void { |
|
896 | + private static function cleanArguments(array &$arguments): void { |
|
897 | 897 | foreach ($arguments as $key => $argument) { |
898 | 898 | if ($argument == [] || $argument === null) { |
899 | 899 | unset($arguments[$key]); |
@@ -908,7 +908,7 @@ discard block |
||
908 | 908 | * |
909 | 909 | * @return int|string|bool |
910 | 910 | */ |
911 | - public static function catchFields (string $field): int|string|bool { |
|
911 | + public static function catchFields(string $field): int | string | bool { |
|
912 | 912 | switch ($field) { |
913 | 913 | case fields::CHAT_ID : |
914 | 914 | case fields::FROM_CHAT_ID : |
@@ -1055,13 +1055,13 @@ discard block |
||
1055 | 1055 | default => false |
1056 | 1056 | }; |
1057 | 1057 | case fields::URL : |
1058 | - return 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; |
|
1058 | + return 'https://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; |
|
1059 | 1059 | default: |
1060 | 1060 | return false; |
1061 | 1061 | } |
1062 | 1062 | } |
1063 | 1063 | |
1064 | - public static function fileLink (string|null $file_id = null): bool|string { |
|
1064 | + public static function fileLink(string | null $file_id = null): bool | string { |
|
1065 | 1065 | $file = request::getFile($file_id); |
1066 | 1066 | if (!isset($file->file_path)) { |
1067 | 1067 | return false; |
@@ -1083,7 +1083,7 @@ discard block |
||
1083 | 1083 | * |
1084 | 1084 | * @return bool |
1085 | 1085 | */ |
1086 | - public static function downloadFile (string|null $destination = null, string|null $file_id = null): bool { |
|
1086 | + public static function downloadFile(string | null $destination = null, string | null $file_id = null): bool { |
|
1087 | 1087 | return tools::downloadFile(self::fileLink($file_id), $destination); |
1088 | 1088 | } |
1089 | 1089 | |
@@ -1101,7 +1101,7 @@ discard block |
||
1101 | 1101 | * |
1102 | 1102 | * @return message|bool|responseError |
1103 | 1103 | */ |
1104 | - public static function sendFile (string $file_id, int|string $chat_id = null, int $message_thread_id = null, string $caption = null, string $parse_mode = null, array $caption_entities = null, bool $disable_notification = null, bool $protect_content = null, int $reply_to_message_id = null, bool $allow_sending_without_reply = null, inlineKeyboardMarkup|replyKeyboardMarkup|replyKeyboardRemove|forceReply|stdClass|array $reply_markup = null, string $token = null, bool $forgot = null, bool $answer = null): message|bool|responseError { |
|
1104 | + public static function sendFile(string $file_id, int | string $chat_id = null, int $message_thread_id = null, string $caption = null, string $parse_mode = null, array $caption_entities = null, bool $disable_notification = null, bool $protect_content = null, int $reply_to_message_id = null, bool $allow_sending_without_reply = null, inlineKeyboardMarkup | replyKeyboardMarkup | replyKeyboardRemove | forceReply | stdClass | array $reply_markup = null, string $token = null, bool $forgot = null, bool $answer = null): message | bool | responseError { |
|
1105 | 1105 | $type = tools::fileType($file_id); |
1106 | 1106 | return match ($type) { |
1107 | 1107 | fileTypes::VIDEO => request::sendVideo($file_id, $chat_id, null, null, null, null, $caption, $parse_mode, $caption_entities, null, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer, $message_thread_id), |
@@ -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 |
@@ -12,7 +12,9 @@ discard block |
||
12 | 12 | class jdf { |
13 | 13 | public static function jdate ($format, $timestamp = '', $none = '', $time_zone = 'Asia/Tehran', $tr_num = 'fa') { |
14 | 14 | $T_sec = 0;/* <= رفع خطاي زمان سرور ، با اعداد '+' و '-' بر حسب ثانيه */ |
15 | - if ($time_zone != 'local') date_default_timezone_set(($time_zone === '') ? 'Asia/Tehran' : $time_zone); |
|
15 | + if ($time_zone != 'local') { |
|
16 | + date_default_timezone_set(($time_zone === '') ? 'Asia/Tehran' : $time_zone); |
|
17 | + } |
|
16 | 18 | $ts = $T_sec + (($timestamp === '') ? time() : self::tr_num($timestamp)); |
17 | 19 | $date = explode('_', date('H_i_j_n_O_P_s_w_Y', $ts)); |
18 | 20 | [$j_y, $j_m, $j_d] = self::gregorian_to_jalali($date[8], $date[3], $date[2]); |
@@ -155,16 +157,19 @@ discard block |
||
155 | 157 | break; |
156 | 158 | case 'W': |
157 | 159 | $avs = (($date[7] == 6) ? 0 : $date[7] + 1) - ($doy % 7); |
158 | - if ($avs < 0) $avs += 7; |
|
160 | + if ($avs < 0) { |
|
161 | + $avs += 7; |
|
162 | + } |
|
159 | 163 | $num = (int) (($doy + $avs) / 7); |
160 | 164 | if ($avs < 4) { |
161 | 165 | $num++; |
162 | - } |
|
163 | - elseif ($num < 1) { |
|
166 | + } elseif ($num < 1) { |
|
164 | 167 | $num = ($avs == 4 or $avs == ((((($j_y % 33) % 4) - 2) == ((int) (($j_y % 33) * 0.05))) ? 5 : 4)) ? 53 : 52; |
165 | 168 | } |
166 | 169 | $aks = $avs + $kab; |
167 | - if ($aks == 7) $aks = 0; |
|
170 | + if ($aks == 7) { |
|
171 | + $aks = 0; |
|
172 | + } |
|
168 | 173 | $out .= (($kab + 363 - $doy) < $aks and $aks < 3) ? '01' : (($num < 10) ? '0' . $num : $num); |
169 | 174 | break; |
170 | 175 | case 'y': |
@@ -184,7 +189,9 @@ discard block |
||
184 | 189 | } |
185 | 190 | public static function jstrftime ($format, $timestamp = '', $none = '', $time_zone = 'Asia/Tehran', $tr_num = 'fa') { |
186 | 191 | $T_sec = 0;/* <= رفع خطاي زمان سرور ، با اعداد '+' و '-' بر حسب ثانيه */ |
187 | - if ($time_zone != 'local') date_default_timezone_set(($time_zone === '') ? 'Asia/Tehran' : $time_zone); |
|
192 | + if ($time_zone != 'local') { |
|
193 | + date_default_timezone_set(($time_zone === '') ? 'Asia/Tehran' : $time_zone); |
|
194 | + } |
|
188 | 195 | $ts = $T_sec + (($timestamp === '') ? time() : self::tr_num($timestamp)); |
189 | 196 | $date = explode('_', date('h_H_i_j_n_s_w_Y', $ts)); |
190 | 197 | [$j_y, $j_m, $j_d] = self::gregorian_to_jalali($date[7], $date[4], $date[3]); |
@@ -196,8 +203,7 @@ discard block |
||
196 | 203 | $sub = substr($format, $i, 1); |
197 | 204 | if ($sub == '%') { |
198 | 205 | $sub = substr($format, ++$i, 1); |
199 | - } |
|
200 | - else { |
|
206 | + } else { |
|
201 | 207 | $out .= $sub; |
202 | 208 | continue; |
203 | 209 | } |
@@ -228,30 +234,41 @@ discard block |
||
228 | 234 | /* Week */ |
229 | 235 | case 'U': |
230 | 236 | $avs = (($date[6] < 5) ? $date[6] + 2 : $date[6] - 5) - ($doy % 7); |
231 | - if ($avs < 0) $avs += 7; |
|
237 | + if ($avs < 0) { |
|
238 | + $avs += 7; |
|
239 | + } |
|
232 | 240 | $num = (int) (($doy + $avs) / 7) + 1; |
233 | - if ($avs > 3 or $avs == 1) $num--; |
|
241 | + if ($avs > 3 or $avs == 1) { |
|
242 | + $num--; |
|
243 | + } |
|
234 | 244 | $out .= ($num < 10) ? '0' . $num : $num; |
235 | 245 | break; |
236 | 246 | case 'V': |
237 | 247 | $avs = (($date[6] == 6) ? 0 : $date[6] + 1) - ($doy % 7); |
238 | - if ($avs < 0) $avs += 7; |
|
248 | + if ($avs < 0) { |
|
249 | + $avs += 7; |
|
250 | + } |
|
239 | 251 | $num = (int) (($doy + $avs) / 7); |
240 | 252 | if ($avs < 4) { |
241 | 253 | $num++; |
242 | - } |
|
243 | - elseif ($num < 1) { |
|
254 | + } elseif ($num < 1) { |
|
244 | 255 | $num = ($avs == 4 or $avs == ((((($j_y % 33) % 4) - 2) == ((int) (($j_y % 33) * 0.05))) ? 5 : 4)) ? 53 : 52; |
245 | 256 | } |
246 | 257 | $aks = $avs + $kab; |
247 | - if ($aks == 7) $aks = 0; |
|
258 | + if ($aks == 7) { |
|
259 | + $aks = 0; |
|
260 | + } |
|
248 | 261 | $out .= (($kab + 363 - $doy) < $aks and $aks < 3) ? '01' : (($num < 10) ? '0' . $num : $num); |
249 | 262 | break; |
250 | 263 | case 'W': |
251 | 264 | $avs = (($date[6] == 6) ? 0 : $date[6] + 1) - ($doy % 7); |
252 | - if ($avs < 0) $avs += 7; |
|
265 | + if ($avs < 0) { |
|
266 | + $avs += 7; |
|
267 | + } |
|
253 | 268 | $num = (int) (($doy + $avs) / 7) + 1; |
254 | - if ($avs > 3) $num--; |
|
269 | + if ($avs > 3) { |
|
270 | + $num--; |
|
271 | + } |
|
255 | 272 | $out .= ($num < 10) ? '0' . $num : $num; |
256 | 273 | break; |
257 | 274 | /* Month */ |
@@ -360,11 +377,12 @@ discard block |
||
360 | 377 | return ($tr_num != 'en') ? self::tr_num($out, 'fa', '.') : $out; |
361 | 378 | } |
362 | 379 | public static function jmktime ($h = '', $m = '', $s = '', $jm = '', $jd = '', $jy = '', $none = '', $timezone = 'Asia/Tehran') { |
363 | - if ($timezone != 'local') date_default_timezone_set($timezone); |
|
380 | + if ($timezone != 'local') { |
|
381 | + date_default_timezone_set($timezone); |
|
382 | + } |
|
364 | 383 | if ($h === '') { |
365 | 384 | return time(); |
366 | - } |
|
367 | - else { |
|
385 | + } else { |
|
368 | 386 | [ |
369 | 387 | $h, |
370 | 388 | $m, |
@@ -375,27 +393,22 @@ discard block |
||
375 | 393 | ] = explode('_', self::tr_num($h . '_' . $m . '_' . $s . '_' . $jm . '_' . $jd . '_' . $jy)); |
376 | 394 | if ($m === '') { |
377 | 395 | return mktime($h); |
378 | - } |
|
379 | - else { |
|
396 | + } else { |
|
380 | 397 | if ($s === '') { |
381 | 398 | return mktime($h, $m); |
382 | - } |
|
383 | - else { |
|
399 | + } else { |
|
384 | 400 | if ($jm === '') { |
385 | 401 | return mktime($h, $m, $s); |
386 | - } |
|
387 | - else { |
|
402 | + } else { |
|
388 | 403 | $jdate = explode('_', self::jdate('Y_j', '', '', $timezone, 'en')); |
389 | 404 | if ($jd === '') { |
390 | 405 | [$gy, $gm, $gd] = self::jalali_to_gregorian($jdate[0], $jm, $jdate[1]); |
391 | 406 | return mktime($h, $m, $s, $gm); |
392 | - } |
|
393 | - else { |
|
407 | + } else { |
|
394 | 408 | if ($jy === '') { |
395 | 409 | [$gy, $gm, $gd] = self::jalali_to_gregorian($jdate[0], $jm, $jd); |
396 | 410 | return mktime($h, $m, $s, $gm, $gd); |
397 | - } |
|
398 | - else { |
|
411 | + } else { |
|
399 | 412 | [$gy, $gm, $gd] = self::jalali_to_gregorian($jy, $jm, $jd); |
400 | 413 | return mktime($h, $m, $s, $gm, $gd, $gy); |
401 | 414 | } |
@@ -445,8 +458,7 @@ discard block |
||
445 | 458 | $p34 = ''; |
446 | 459 | $k34 = ['ده', 'یازده', 'دوازده', 'سیزده', 'چهارده', 'پانزده', 'شانزده', 'هفده', 'هجده', 'نوزده']; |
447 | 460 | $h34 = $k34[substr($num, 2 - $sl, 2) - 10]; |
448 | - } |
|
449 | - else { |
|
461 | + } else { |
|
450 | 462 | $xy4 = substr($num, 3 - $sl, 1); |
451 | 463 | $p34 = ($xy3 == 0 or $xy4 == 0) ? '' : ' و '; |
452 | 464 | $k3 = ['', '', 'بیست', 'سی', 'چهل', 'پنجاه', 'شصت', 'هفتاد', 'هشتاد', 'نود']; |
@@ -561,8 +573,7 @@ discard block |
||
561 | 573 | if ($days < 186) { |
562 | 574 | $jm = 1 + (int) ($days / 31); |
563 | 575 | $jd = 1 + ($days % 31); |
564 | - } |
|
565 | - else { |
|
576 | + } else { |
|
566 | 577 | $jm = 7 + (int) (($days - 186) / 30); |
567 | 578 | $jd = 1 + (($days - 186) % 30); |
568 | 579 | } |
@@ -577,7 +588,9 @@ discard block |
||
577 | 588 | if ($days > 36524) { |
578 | 589 | $gy += 100 * ((int) (--$days / 36524)); |
579 | 590 | $days %= 36524; |
580 | - if ($days >= 365) $days++; |
|
591 | + if ($days >= 365) { |
|
592 | + $days++; |
|
593 | + } |
|
581 | 594 | } |
582 | 595 | $gy += 4 * ((int) ($days / 1461)); |
583 | 596 | $days %= 1461; |
@@ -601,7 +614,9 @@ discard block |
||
601 | 614 | 30, |
602 | 615 | 31 |
603 | 616 | ]; |
604 | - for ($gm = 0; $gm < 13 and $gd > $sal_a[$gm]; $gm++) $gd -= $sal_a[$gm]; |
|
617 | + for ($gm = 0; $gm < 13 and $gd > $sal_a[$gm]; $gm++) { |
|
618 | + $gd -= $sal_a[$gm]; |
|
619 | + } |
|
605 | 620 | return ($mod == '') ? [$gy, $gm, $gd] : $gy . $mod . $gm . $mod . $gd; |
606 | 621 | } |
607 | 622 | } |
608 | 623 | \ 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 | } |