@@ -17,44 +17,44 @@ |
||
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::checkAnswered(); |
22 | 22 | self::checkWebhook(); |
23 | 23 | self::sieveData($data); |
24 | 24 | self::$is_answered = true; |
25 | 25 | $data['method'] = $method; |
26 | 26 | $payload = json_encode($data); |
27 | - header('Content-Type: application/json;Content-Length: ' . strlen($payload)); |
|
27 | + header('Content-Type: application/json;Content-Length: '.strlen($payload)); |
|
28 | 28 | echo $payload; |
29 | 29 | return true; |
30 | 30 | } |
31 | 31 | |
32 | 32 | private static function checkAnswered(): void { |
33 | 33 | if (self::$is_answered) { |
34 | - logger::write('You can use answer mode only once for each webhook update , You already did it!',loggerTypes::ERROR); |
|
34 | + logger::write('You can use answer mode only once for each webhook update , You already did it!', loggerTypes::ERROR); |
|
35 | 35 | throw new bptException('ANSWER_MODE_USED'); |
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
39 | 39 | private static function checkWebhook(): void { |
40 | - if(settings::$receiver === receiver::GETUPDATES) { |
|
41 | - logger::write('Answer mode only work when receiver is webhook',loggerTypes::ERROR); |
|
40 | + if (settings::$receiver === receiver::GETUPDATES) { |
|
41 | + logger::write('Answer mode only work when receiver is webhook', loggerTypes::ERROR); |
|
42 | 42 | throw new bptException('ANSWER_MODE_GETUPDATES'); |
43 | 43 | } |
44 | - elseif(settings::$multi) { |
|
45 | - logger::write('You can not use answer mode when multi setting is on',loggerTypes::ERROR); |
|
44 | + elseif (settings::$multi) { |
|
45 | + logger::write('You can not use answer mode when multi setting is on', loggerTypes::ERROR); |
|
46 | 46 | throw new bptException('ANSWER_MODE_MULTI'); |
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
50 | 50 | private static function sieveData(array &$data): void { |
51 | - unset($data['token'],$data['forgot'],$data['return_array']); |
|
51 | + unset($data['token'], $data['forgot'], $data['return_array']); |
|
52 | 52 | |
53 | - foreach ($data as $key=>&$value){ |
|
54 | - if (!isset($value)){ |
|
53 | + foreach ($data as $key=>&$value) { |
|
54 | + if (!isset($value)) { |
|
55 | 55 | unset($data[$key]); |
56 | 56 | } |
57 | - elseif (is_array($value) || is_object($value)){ |
|
57 | + elseif (is_array($value) || is_object($value)) { |
|
58 | 58 | $value = json_encode($value); |
59 | 59 | } |
60 | 60 | } |
@@ -34,8 +34,7 @@ discard block |
||
34 | 34 | if(settings::$receiver === receiver::GETUPDATES) { |
35 | 35 | logger::write('Answer mode only work when receiver is webhook',loggerTypes::ERROR); |
36 | 36 | throw new bptException('ANSWER_MODE_GETUPDATES'); |
37 | - } |
|
38 | - elseif(settings::$multi) { |
|
37 | + } elseif(settings::$multi) { |
|
39 | 38 | logger::write('You can not use answer mode when multi setting is on',loggerTypes::ERROR); |
40 | 39 | throw new bptException('ANSWER_MODE_MULTI'); |
41 | 40 | } |
@@ -49,8 +48,7 @@ discard block |
||
49 | 48 | foreach ($data as $key=>&$value){ |
50 | 49 | if (!isset($value)){ |
51 | 50 | unset($data[$key]); |
52 | - } |
|
53 | - elseif (is_array($value) || is_object($value)){ |
|
51 | + } elseif (is_array($value) || is_object($value)){ |
|
54 | 52 | $value = json_encode($value); |
55 | 53 | } |
56 | 54 | } |
@@ -16,17 +16,17 @@ discard block |
||
16 | 16 | /** |
17 | 17 | * @internal Only for BPT self usage , Don't use it in your source! |
18 | 18 | */ |
19 | - public static function init(string $method,array $data) { |
|
19 | + public static function init(string $method, array $data) { |
|
20 | 20 | $info = self::getInfo($data); |
21 | 21 | $data = $info['data']; |
22 | 22 | $handler = $info['handler']; |
23 | - self::setTimeout($data,$handler,$method); |
|
23 | + self::setTimeout($data, $handler, $method); |
|
24 | 24 | self::setData($data); |
25 | 25 | $data['method'] = $method; |
26 | 26 | curl_setopt($handler, CURLOPT_POSTFIELDS, $data); |
27 | 27 | $result = curl_exec($handler); |
28 | 28 | if (curl_errno($handler)) { |
29 | - logger::write(curl_error($handler),loggerTypes::WARNING); |
|
29 | + logger::write(curl_error($handler), loggerTypes::WARNING); |
|
30 | 30 | } |
31 | 31 | if ($info['token'] != settings::$token) { |
32 | 32 | curl_close($handler); |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | curl_setopt($curl_handler, CURLOPT_RETURNTRANSFER, true); |
43 | 43 | curl_setopt($curl_handler, CURLOPT_SSL_VERIFYPEER, false); |
44 | 44 | } |
45 | - else{ |
|
45 | + else { |
|
46 | 46 | $token = settings::$token; |
47 | - if (!isset(self::$curl_handler)){ |
|
47 | + if (!isset(self::$curl_handler)) { |
|
48 | 48 | self::$curl_handler = curl_init(settings::$base_url."/bot$token/"); |
49 | 49 | curl_setopt(self::$curl_handler, CURLOPT_RETURNTRANSFER, true); |
50 | 50 | curl_setopt(self::$curl_handler, CURLOPT_SSL_VERIFYPEER, false); |
@@ -60,22 +60,22 @@ discard block |
||
60 | 60 | ]; |
61 | 61 | } |
62 | 62 | |
63 | - private static function setTimeout(array &$data , CurlHandle $curl_handler,string $method): void { |
|
63 | + private static function setTimeout(array &$data, CurlHandle $curl_handler, string $method): void { |
|
64 | 64 | if (isset($data['forgot'])) { |
65 | 65 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, settings::$forgot_time); |
66 | 66 | unset($data['forgot']); |
67 | 67 | } |
68 | - elseif ($method === 'getUpdates' || $method === 'setWebhook'){ |
|
68 | + elseif ($method === 'getUpdates' || $method === 'setWebhook') { |
|
69 | 69 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, 5000); |
70 | 70 | } |
71 | - else{ |
|
71 | + else { |
|
72 | 72 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, settings::$base_timeout); |
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
76 | 76 | private static function setData(array &$data): void { |
77 | - foreach ($data as &$value){ |
|
78 | - if (is_array($value) || (is_object($value) && !is_a($value,'CURLFile'))){ |
|
77 | + foreach ($data as &$value) { |
|
78 | + if (is_array($value) || (is_object($value) && !is_a($value, 'CURLFile'))) { |
|
79 | 79 | $value = json_encode($value); |
80 | 80 | } |
81 | 81 | } |
@@ -41,8 +41,7 @@ discard block |
||
41 | 41 | $curl_handler = curl_init(settings::$base_url."/bot$token/"); |
42 | 42 | curl_setopt($curl_handler, CURLOPT_RETURNTRANSFER, true); |
43 | 43 | curl_setopt($curl_handler, CURLOPT_SSL_VERIFYPEER, false); |
44 | - } |
|
45 | - else{ |
|
44 | + } else{ |
|
46 | 45 | $token = settings::$token; |
47 | 46 | if (!isset(self::$curl_handler)){ |
48 | 47 | self::$curl_handler = curl_init(settings::$base_url."/bot$token/"); |
@@ -64,11 +63,9 @@ discard block |
||
64 | 63 | if (isset($data['forgot'])) { |
65 | 64 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, settings::$forgot_time); |
66 | 65 | unset($data['forgot']); |
67 | - } |
|
68 | - elseif ($method === 'getUpdates' || $method === 'setWebhook'){ |
|
66 | + } elseif ($method === 'getUpdates' || $method === 'setWebhook'){ |
|
69 | 67 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, 5000); |
70 | - } |
|
71 | - else{ |
|
68 | + } else{ |
|
72 | 69 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, settings::$base_timeout); |
73 | 70 | } |
74 | 71 | } |
@@ -78,11 +78,9 @@ |
||
78 | 78 | $value = 'bots_files/' . $value . '/'; |
79 | 79 | } |
80 | 80 | self::$$setting = $value; |
81 | - } |
|
82 | - catch (TypeError) { |
|
81 | + } catch (TypeError) { |
|
83 | 82 | logger::write("$setting setting has wrong type , its set to default value", loggerTypes::WARNING); |
84 | - } |
|
85 | - catch (Error) { |
|
83 | + } catch (Error) { |
|
86 | 84 | logger::write("$setting setting is not one of library settings", loggerTypes::WARNING); |
87 | 85 | } |
88 | 86 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | public static int $log_size = 10; |
27 | 27 | |
28 | - public static string|CURLFile|null $certificate = null; |
|
28 | + public static string | CURLFile | null $certificate = null; |
|
29 | 29 | |
30 | 30 | public static bool $handler = true; |
31 | 31 | |
@@ -59,12 +59,12 @@ discard block |
||
59 | 59 | |
60 | 60 | public static array $allowed_updates = ['message', 'edited_channel_post', 'callback_query', 'inline_query']; |
61 | 61 | |
62 | - public static array|null $db = ['type' => 'json']; |
|
62 | + public static array | null $db = ['type' => 'json']; |
|
63 | 63 | |
64 | 64 | /** |
65 | 65 | * @internal Only for BPT self usage , Don't use it in your source! |
66 | 66 | */ |
67 | - public static function init (array|stdClass $settings): void { |
|
67 | + public static function init(array | stdClass $settings): void { |
|
68 | 68 | $settings = (array) $settings; |
69 | 69 | foreach ($settings as $setting => $value) { |
70 | 70 | try { |
@@ -72,10 +72,10 @@ discard block |
||
72 | 72 | if (!is_dir(realpath('bots_files'))) { |
73 | 73 | mkdir('bots_files'); |
74 | 74 | } |
75 | - if (!is_dir(realpath('bots_files/' . $value))) { |
|
76 | - mkdir('bots_files/' . $value); |
|
75 | + if (!is_dir(realpath('bots_files/'.$value))) { |
|
76 | + mkdir('bots_files/'.$value); |
|
77 | 77 | } |
78 | - $value = 'bots_files/' . $value . '/'; |
|
78 | + $value = 'bots_files/'.$value.'/'; |
|
79 | 79 | } |
80 | 80 | self::$$setting = $value; |
81 | 81 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | /** |
109 | 109 | * @internal Only for BPT self usage , Don't use it in your source! |
110 | 110 | */ |
111 | - public static function done (): void { |
|
111 | + public static function done(): void { |
|
112 | 112 | if (self::$logger) { |
113 | 113 | $estimated = round((microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']) * 1000, 2); |
114 | 114 | $status_message = match (true) { |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
126 | - private static function security (): void { |
|
126 | + private static function security(): void { |
|
127 | 127 | if (self::$security) { |
128 | 128 | ini_set('magic_quotes_gpc', 'off'); |
129 | 129 | ini_set('sql.safe_mode', 'on'); |
@@ -138,11 +138,11 @@ discard block |
||
138 | 138 | } |
139 | 139 | } |
140 | 140 | |
141 | - private static function secureFolder (): void { |
|
141 | + private static function secureFolder(): void { |
|
142 | 142 | if (self::$secure_folder) { |
143 | 143 | $address = explode('/', $_SERVER['REQUEST_URI']); |
144 | 144 | unset($address[count($address) - 1]); |
145 | - $address = implode('/', $address) . '/BPT.php'; |
|
145 | + $address = implode('/', $address).'/BPT.php'; |
|
146 | 146 | $text = "ErrorDocument 404 $address\nErrorDocument 403 $address\n Options -Indexes\n Order Deny,Allow\nDeny from all\nAllow from 127.0.0.1\n<Files *.php>\n Order Allow,Deny\n Allow from all\n</Files>"; |
147 | 147 | $htaccess = realpath('.htaccess'); |
148 | 148 | if (!file_exists($htaccess) || filesize($htaccess) != strlen($text)) { |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
154 | - private static function getUpdates (): void { |
|
154 | + private static function getUpdates(): void { |
|
155 | 155 | if (!self::$handler) { |
156 | 156 | logger::write('You can\'t use getUpdates receiver when handler is off , use webhook or use handler', loggerTypes::ERROR); |
157 | 157 | throw new bptException('GETUPDATE_NEED_HANDLER'); |
@@ -480,95 +480,95 @@ discard block |
||
480 | 480 | ]; |
481 | 481 | |
482 | 482 | private const METHODS_KEYS = [ |
483 | - 'getUpdates' => ['offset','limit','timeout','allowed_updates','token','forgot','answer'], |
|
484 | - 'setWebhook' => ['url','certificate','ip_address','max_connections','allowed_updates','drop_pending_updates','secret_token','token','forgot','answer'], |
|
485 | - 'deleteWebhook' => ['drop_pending_updates','token','forgot','answer'], |
|
486 | - 'getWebhookInfo' => ['token','forgot','answer'], |
|
487 | - 'getMe' => ['token','forgot','answer'], |
|
488 | - 'logOut' => ['token','forgot','answer'], |
|
489 | - 'close' => ['token','forgot','answer'], |
|
490 | - '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'], |
|
491 | - 'forwardMessage' => ['chat_id','from_chat_id','disable_notification','protect_content','message_id','token','forgot','answer'], |
|
492 | - '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'], |
|
493 | - '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'], |
|
494 | - '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'], |
|
495 | - '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'], |
|
496 | - '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'], |
|
497 | - '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'], |
|
498 | - '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'], |
|
499 | - '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'], |
|
500 | - 'sendMediaGroup' => ['media','chat_id','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','token','forgot','answer'], |
|
501 | - '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'], |
|
502 | - 'editMessageLiveLocation' => ['latitude','longitude','chat_id','message_id','inline_message_id','horizontal_accuracy','heading','proximity_alert_radius','reply_markup','token','forgot','answer'], |
|
503 | - 'stopMessageLiveLocation' => ['chat_id','message_id','inline_message_id','reply_markup','token','forgot','answer'], |
|
504 | - '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'], |
|
505 | - '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'], |
|
506 | - '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'], |
|
507 | - 'sendDice' => ['chat_id','emoji','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer'], |
|
508 | - 'sendChatAction' => ['chat_id','action','token','forgot','answer'], |
|
509 | - 'getUserProfilePhotos' => ['user_id','offset','limit','token','forgot','answer'], |
|
510 | - 'getFile' => ['file_id','token','forgot','answer'], |
|
511 | - 'banChatMember' => ['chat_id','user_id','until_date','revoke_messages','token','forgot','answer'], |
|
512 | - 'unbanChatMember' => ['chat_id','user_id','only_if_banned','token','forgot','answer'], |
|
513 | - 'restrictChatMember' => ['permissions','chat_id','user_id','until_date','token','forgot','answer'], |
|
514 | - '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','token','forgot','answer'], |
|
515 | - 'setChatAdministratorCustomTitle' => ['custom_title','chat_id','user_id','token','forgot','answer'], |
|
516 | - 'banChatSenderChat' => ['sender_chat_id','chat_id','token','forgot','answer'], |
|
517 | - 'unbanChatSenderChat' => ['sender_chat_id','chat_id','token','forgot','answer'], |
|
518 | - 'setChatPermissions' => ['permissions','chat_id','token','forgot','answer'], |
|
519 | - 'exportChatInviteLink' => ['chat_id','token','forgot','answer'], |
|
520 | - 'createChatInviteLink' => ['chat_id','name','expire_date','member_limit','creates_join_request','token','forgot','answer'], |
|
521 | - 'editChatInviteLink' => ['invite_link','chat_id','name','expire_date','member_limit','creates_join_request','token','forgot','answer'], |
|
522 | - 'revokeChatInviteLink' => ['invite_link','chat_id','token','forgot','answer'], |
|
523 | - 'approveChatJoinRequest' => ['chat_id','user_id','token','forgot','answer'], |
|
524 | - 'declineChatJoinRequest' => ['chat_id','user_id','token','forgot','answer'], |
|
525 | - 'setChatPhoto' => ['photo','chat_id','token','forgot','answer'], |
|
526 | - 'deleteChatPhoto' => ['chat_id','token','forgot','answer'], |
|
527 | - 'setChatTitle' => ['title','chat_id','token','forgot','answer'], |
|
528 | - 'setChatDescription' => ['chat_id','description','token','forgot','answer'], |
|
529 | - 'pinChatMessage' => ['message_id','chat_id','disable_notification','token','forgot','answer'], |
|
530 | - 'unpinChatMessage' => ['chat_id','message_id','token','forgot','answer'], |
|
531 | - 'unpinAllChatMessages' => ['chat_id','token','forgot','answer'], |
|
532 | - 'leaveChat' => ['chat_id','token','forgot','answer'], |
|
533 | - 'getChat' => ['chat_id','token','forgot','answer'], |
|
534 | - 'getChatAdministrators' => ['chat_id','token','forgot','answer'], |
|
535 | - 'getChatMemberCount' => ['chat_id','token','forgot','answer'], |
|
536 | - 'getChatMember' => ['chat_id','user_id','token','forgot','answer'], |
|
537 | - 'setChatStickerSet' => ['sticker_set_name','chat_id','token','forgot','answer'], |
|
538 | - 'deleteChatStickerSet' => ['chat_id','token','forgot','answer'], |
|
539 | - 'answerCallbackQuery' => ['callback_query_id','text','show_alert','url','cache_time','token','forgot','answer'], |
|
540 | - 'setMyCommands' => ['commands','scope','language_code','token','forgot','answer'], |
|
541 | - 'deleteMyCommands' => ['scope','language_code','token','forgot','answer'], |
|
542 | - 'getMyCommands' => ['scope','language_code','token','forgot','answer'], |
|
543 | - 'setChatMenuButton' => ['chat_id','menu_button','token','forgot','answer'], |
|
544 | - 'getChatMenuButton' => ['chat_id','token','forgot','answer'], |
|
545 | - 'setMyDefaultAdministratorRights' => ['rights','for_channels','token','forgot','answer'], |
|
546 | - 'getMyDefaultAdministratorRights' => ['for_channels','token','forgot','answer'], |
|
547 | - 'editMessageText' => ['text','chat_id','message_id','inline_message_id','parse_mode','entities','disable_web_page_preview','reply_markup','token','forgot','answer'], |
|
548 | - 'editMessageCaption' => ['chat_id','message_id','inline_message_id','caption','parse_mode','caption_entities','reply_markup','token','forgot','answer'], |
|
549 | - 'editMessageMedia' => ['media','chat_id','message_id','inline_message_id','reply_markup','token','forgot','answer'], |
|
550 | - 'editMessageReplyMarkup' => ['chat_id','message_id','inline_message_id','reply_markup','token','forgot','answer'], |
|
551 | - 'stopPoll' => ['chat_id','message_id','reply_markup','token','forgot','answer'], |
|
552 | - 'deleteMessage' => ['chat_id','message_id','token','forgot','answer'], |
|
553 | - 'sendSticker' => ['sticker','chat_id','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer'], |
|
554 | - 'getStickerSet' => ['name','token','forgot','answer'], |
|
483 | + 'getUpdates' => ['offset', 'limit', 'timeout', 'allowed_updates', 'token', 'forgot', 'answer'], |
|
484 | + 'setWebhook' => ['url', 'certificate', 'ip_address', 'max_connections', 'allowed_updates', 'drop_pending_updates', 'secret_token', 'token', 'forgot', 'answer'], |
|
485 | + 'deleteWebhook' => ['drop_pending_updates', 'token', 'forgot', 'answer'], |
|
486 | + 'getWebhookInfo' => ['token', 'forgot', 'answer'], |
|
487 | + 'getMe' => ['token', 'forgot', 'answer'], |
|
488 | + 'logOut' => ['token', 'forgot', 'answer'], |
|
489 | + 'close' => ['token', 'forgot', 'answer'], |
|
490 | + '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'], |
|
491 | + 'forwardMessage' => ['chat_id', 'from_chat_id', 'disable_notification', 'protect_content', 'message_id', 'token', 'forgot', 'answer'], |
|
492 | + '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'], |
|
493 | + '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'], |
|
494 | + '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'], |
|
495 | + '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'], |
|
496 | + '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'], |
|
497 | + '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'], |
|
498 | + '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'], |
|
499 | + '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'], |
|
500 | + 'sendMediaGroup' => ['media', 'chat_id', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'token', 'forgot', 'answer'], |
|
501 | + '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'], |
|
502 | + 'editMessageLiveLocation' => ['latitude', 'longitude', 'chat_id', 'message_id', 'inline_message_id', 'horizontal_accuracy', 'heading', 'proximity_alert_radius', 'reply_markup', 'token', 'forgot', 'answer'], |
|
503 | + 'stopMessageLiveLocation' => ['chat_id', 'message_id', 'inline_message_id', 'reply_markup', 'token', 'forgot', 'answer'], |
|
504 | + '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'], |
|
505 | + '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'], |
|
506 | + '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'], |
|
507 | + 'sendDice' => ['chat_id', 'emoji', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer'], |
|
508 | + 'sendChatAction' => ['chat_id', 'action', 'token', 'forgot', 'answer'], |
|
509 | + 'getUserProfilePhotos' => ['user_id', 'offset', 'limit', 'token', 'forgot', 'answer'], |
|
510 | + 'getFile' => ['file_id', 'token', 'forgot', 'answer'], |
|
511 | + 'banChatMember' => ['chat_id', 'user_id', 'until_date', 'revoke_messages', 'token', 'forgot', 'answer'], |
|
512 | + 'unbanChatMember' => ['chat_id', 'user_id', 'only_if_banned', 'token', 'forgot', 'answer'], |
|
513 | + 'restrictChatMember' => ['permissions', 'chat_id', 'user_id', 'until_date', 'token', 'forgot', 'answer'], |
|
514 | + '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', 'token', 'forgot', 'answer'], |
|
515 | + 'setChatAdministratorCustomTitle' => ['custom_title', 'chat_id', 'user_id', 'token', 'forgot', 'answer'], |
|
516 | + 'banChatSenderChat' => ['sender_chat_id', 'chat_id', 'token', 'forgot', 'answer'], |
|
517 | + 'unbanChatSenderChat' => ['sender_chat_id', 'chat_id', 'token', 'forgot', 'answer'], |
|
518 | + 'setChatPermissions' => ['permissions', 'chat_id', 'token', 'forgot', 'answer'], |
|
519 | + 'exportChatInviteLink' => ['chat_id', 'token', 'forgot', 'answer'], |
|
520 | + 'createChatInviteLink' => ['chat_id', 'name', 'expire_date', 'member_limit', 'creates_join_request', 'token', 'forgot', 'answer'], |
|
521 | + 'editChatInviteLink' => ['invite_link', 'chat_id', 'name', 'expire_date', 'member_limit', 'creates_join_request', 'token', 'forgot', 'answer'], |
|
522 | + 'revokeChatInviteLink' => ['invite_link', 'chat_id', 'token', 'forgot', 'answer'], |
|
523 | + 'approveChatJoinRequest' => ['chat_id', 'user_id', 'token', 'forgot', 'answer'], |
|
524 | + 'declineChatJoinRequest' => ['chat_id', 'user_id', 'token', 'forgot', 'answer'], |
|
525 | + 'setChatPhoto' => ['photo', 'chat_id', 'token', 'forgot', 'answer'], |
|
526 | + 'deleteChatPhoto' => ['chat_id', 'token', 'forgot', 'answer'], |
|
527 | + 'setChatTitle' => ['title', 'chat_id', 'token', 'forgot', 'answer'], |
|
528 | + 'setChatDescription' => ['chat_id', 'description', 'token', 'forgot', 'answer'], |
|
529 | + 'pinChatMessage' => ['message_id', 'chat_id', 'disable_notification', 'token', 'forgot', 'answer'], |
|
530 | + 'unpinChatMessage' => ['chat_id', 'message_id', 'token', 'forgot', 'answer'], |
|
531 | + 'unpinAllChatMessages' => ['chat_id', 'token', 'forgot', 'answer'], |
|
532 | + 'leaveChat' => ['chat_id', 'token', 'forgot', 'answer'], |
|
533 | + 'getChat' => ['chat_id', 'token', 'forgot', 'answer'], |
|
534 | + 'getChatAdministrators' => ['chat_id', 'token', 'forgot', 'answer'], |
|
535 | + 'getChatMemberCount' => ['chat_id', 'token', 'forgot', 'answer'], |
|
536 | + 'getChatMember' => ['chat_id', 'user_id', 'token', 'forgot', 'answer'], |
|
537 | + 'setChatStickerSet' => ['sticker_set_name', 'chat_id', 'token', 'forgot', 'answer'], |
|
538 | + 'deleteChatStickerSet' => ['chat_id', 'token', 'forgot', 'answer'], |
|
539 | + 'answerCallbackQuery' => ['callback_query_id', 'text', 'show_alert', 'url', 'cache_time', 'token', 'forgot', 'answer'], |
|
540 | + 'setMyCommands' => ['commands', 'scope', 'language_code', 'token', 'forgot', 'answer'], |
|
541 | + 'deleteMyCommands' => ['scope', 'language_code', 'token', 'forgot', 'answer'], |
|
542 | + 'getMyCommands' => ['scope', 'language_code', 'token', 'forgot', 'answer'], |
|
543 | + 'setChatMenuButton' => ['chat_id', 'menu_button', 'token', 'forgot', 'answer'], |
|
544 | + 'getChatMenuButton' => ['chat_id', 'token', 'forgot', 'answer'], |
|
545 | + 'setMyDefaultAdministratorRights' => ['rights', 'for_channels', 'token', 'forgot', 'answer'], |
|
546 | + 'getMyDefaultAdministratorRights' => ['for_channels', 'token', 'forgot', 'answer'], |
|
547 | + 'editMessageText' => ['text', 'chat_id', 'message_id', 'inline_message_id', 'parse_mode', 'entities', 'disable_web_page_preview', 'reply_markup', 'token', 'forgot', 'answer'], |
|
548 | + 'editMessageCaption' => ['chat_id', 'message_id', 'inline_message_id', 'caption', 'parse_mode', 'caption_entities', 'reply_markup', 'token', 'forgot', 'answer'], |
|
549 | + 'editMessageMedia' => ['media', 'chat_id', 'message_id', 'inline_message_id', 'reply_markup', 'token', 'forgot', 'answer'], |
|
550 | + 'editMessageReplyMarkup' => ['chat_id', 'message_id', 'inline_message_id', 'reply_markup', 'token', 'forgot', 'answer'], |
|
551 | + 'stopPoll' => ['chat_id', 'message_id', 'reply_markup', 'token', 'forgot', 'answer'], |
|
552 | + 'deleteMessage' => ['chat_id', 'message_id', 'token', 'forgot', 'answer'], |
|
553 | + 'sendSticker' => ['sticker', 'chat_id', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer'], |
|
554 | + 'getStickerSet' => ['name', 'token', 'forgot', 'answer'], |
|
555 | 555 | 'getCustomEmojiStickers' => ['custom_emoji_ids', 'token', 'return_array', 'forgot', 'answer'], |
556 | - 'uploadStickerFile' => ['png_sticker','user_id','token','forgot','answer'], |
|
557 | - 'createNewStickerSet' => ['name','title','emojis','user_id','png_sticker','tgs_sticker','webm_sticker','sticker_type','contains_masks','mask_position','token','forgot','answer'], |
|
558 | - 'addStickerToSet' => ['name','emojis','user_id','png_sticker','tgs_sticker','webm_sticker','mask_position','token','forgot','answer'], |
|
559 | - 'setStickerPositionInSet' => ['sticker','position','token','forgot','answer'], |
|
560 | - 'deleteStickerFromSet' => ['sticker','token','forgot','answer'], |
|
561 | - 'setStickerSetThumb' => ['name','user_id','thumb','token','forgot','answer'], |
|
562 | - 'answerInlineQuery' => ['results','inline_query_id','cache_time','is_personal','next_offset','switch_pm_text','switch_pm_parameter','token','forgot','answer'], |
|
563 | - 'answerWebAppQuery' => ['web_app_query_id','result','token','forgot','answer'], |
|
564 | - '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'], |
|
565 | - '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'], |
|
566 | - 'answerShippingQuery' => ['ok','shipping_query_id','shipping_options','error_message','token','forgot','answer'], |
|
567 | - 'answerPreCheckoutQuery' => ['ok','pre_checkout_query_id','error_message','token','forgot','answer'], |
|
568 | - 'setPassportDataErrors' => ['errors','user_id','token','forgot','answer'], |
|
569 | - 'sendGame' => ['game_short_name','chat_id','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer'], |
|
570 | - 'setGameScore' => ['score','user_id','force','disable_edit_message','chat_id','message_id','inline_message_id','token','forgot','answer'], |
|
571 | - 'getGameHighScores' => ['user_id','chat_id','message_id','inline_message_id','token','forgot','answer'], |
|
556 | + 'uploadStickerFile' => ['png_sticker', 'user_id', 'token', 'forgot', 'answer'], |
|
557 | + 'createNewStickerSet' => ['name', 'title', 'emojis', 'user_id', 'png_sticker', 'tgs_sticker', 'webm_sticker', 'sticker_type', 'contains_masks', 'mask_position', 'token', 'forgot', 'answer'], |
|
558 | + 'addStickerToSet' => ['name', 'emojis', 'user_id', 'png_sticker', 'tgs_sticker', 'webm_sticker', 'mask_position', 'token', 'forgot', 'answer'], |
|
559 | + 'setStickerPositionInSet' => ['sticker', 'position', 'token', 'forgot', 'answer'], |
|
560 | + 'deleteStickerFromSet' => ['sticker', 'token', 'forgot', 'answer'], |
|
561 | + 'setStickerSetThumb' => ['name', 'user_id', 'thumb', 'token', 'forgot', 'answer'], |
|
562 | + 'answerInlineQuery' => ['results', 'inline_query_id', 'cache_time', 'is_personal', 'next_offset', 'switch_pm_text', 'switch_pm_parameter', 'token', 'forgot', 'answer'], |
|
563 | + 'answerWebAppQuery' => ['web_app_query_id', 'result', 'token', 'forgot', 'answer'], |
|
564 | + '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'], |
|
565 | + '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'], |
|
566 | + 'answerShippingQuery' => ['ok', 'shipping_query_id', 'shipping_options', 'error_message', 'token', 'forgot', 'answer'], |
|
567 | + 'answerPreCheckoutQuery' => ['ok', 'pre_checkout_query_id', 'error_message', 'token', 'forgot', 'answer'], |
|
568 | + 'setPassportDataErrors' => ['errors', 'user_id', 'token', 'forgot', 'answer'], |
|
569 | + 'sendGame' => ['game_short_name', 'chat_id', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer'], |
|
570 | + 'setGameScore' => ['score', 'user_id', 'force', 'disable_edit_message', 'chat_id', 'message_id', 'inline_message_id', 'token', 'forgot', 'answer'], |
|
571 | + 'getGameHighScores' => ['user_id', 'chat_id', 'message_id', 'inline_message_id', 'token', 'forgot', 'answer'], |
|
572 | 572 | 'getForumTopicIconStickers' => ['token', 'return_array', 'forgot', 'answer'], |
573 | 573 | 'createForumTopic' => ['chat_id', 'name', 'icon_color', 'icon_custom_emoji_id', 'token', 'return_array', 'forgot', 'answer'], |
574 | 574 | 'editForumTopic' => ['chat_id', 'message_thread_id', 'name', 'icon_custom_emoji_id', 'token', 'return_array', 'forgot', 'answer'], |
@@ -604,8 +604,8 @@ discard block |
||
604 | 604 | 'logOut' => [], |
605 | 605 | 'close' => [], |
606 | 606 | 'sendMessage' => ['chat_id'], |
607 | - 'forwardMessage' => ['from_chat_id','message_id'], |
|
608 | - 'copyMessage' => ['from_chat_id','message_id'], |
|
607 | + 'forwardMessage' => ['from_chat_id', 'message_id'], |
|
608 | + 'copyMessage' => ['from_chat_id', 'message_id'], |
|
609 | 609 | 'sendPhoto' => ['chat_id'], |
610 | 610 | 'sendAudio' => ['chat_id'], |
611 | 611 | 'sendDocument' => ['chat_id'], |
@@ -621,15 +621,15 @@ discard block |
||
621 | 621 | 'sendContact' => ['chat_id'], |
622 | 622 | 'sendPoll' => ['chat_id'], |
623 | 623 | 'sendDice' => ['chat_id'], |
624 | - 'sendChatAction' => ['chat_id','action'], |
|
624 | + 'sendChatAction' => ['chat_id', 'action'], |
|
625 | 625 | 'getUserProfilePhotos' => ['user_id'], |
626 | 626 | 'getFile' => ['file_id'], |
627 | - 'banChatMember' => ['chat_id','user_id'], |
|
628 | - 'kickChatMember' => ['chat_id','user_id'], |
|
629 | - 'unbanChatMember' => ['chat_id','user_id'], |
|
630 | - 'restrictChatMember' => ['chat_id','user_id'], |
|
631 | - 'promoteChatMember' => ['chat_id','user_id'], |
|
632 | - 'setChatAdministratorCustomTitle' => ['chat_id','user_id'], |
|
627 | + 'banChatMember' => ['chat_id', 'user_id'], |
|
628 | + 'kickChatMember' => ['chat_id', 'user_id'], |
|
629 | + 'unbanChatMember' => ['chat_id', 'user_id'], |
|
630 | + 'restrictChatMember' => ['chat_id', 'user_id'], |
|
631 | + 'promoteChatMember' => ['chat_id', 'user_id'], |
|
632 | + 'setChatAdministratorCustomTitle' => ['chat_id', 'user_id'], |
|
633 | 633 | 'banChatSenderChat' => ['chat_id'], |
634 | 634 | 'unbanChatSenderChat' => ['chat_id'], |
635 | 635 | 'setChatPermissions' => ['chat_id'], |
@@ -637,8 +637,8 @@ discard block |
||
637 | 637 | 'createChatInviteLink' => ['chat_id'], |
638 | 638 | 'editChatInviteLink' => ['chat_id'], |
639 | 639 | 'revokeChatInviteLink' => ['chat_id'], |
640 | - 'approveChatJoinRequest' => ['chat_id','user_id'], |
|
641 | - 'declineChatJoinRequest' => ['chat_id','user_id'], |
|
640 | + 'approveChatJoinRequest' => ['chat_id', 'user_id'], |
|
641 | + 'declineChatJoinRequest' => ['chat_id', 'user_id'], |
|
642 | 642 | 'setChatPhoto' => ['chat_id'], |
643 | 643 | 'deleteChatPhoto' => ['chat_id'], |
644 | 644 | 'setChatTitle' => ['chat_id'], |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | 'getChat' => ['chat_id'], |
651 | 651 | 'getChatAdministrators' => ['chat_id'], |
652 | 652 | 'getChatMembersCount' => ['chat_id'], |
653 | - 'getChatMember' => ['chat_id','user_id'], |
|
653 | + 'getChatMember' => ['chat_id', 'user_id'], |
|
654 | 654 | 'setChatStickerSet' => ['chat_id'], |
655 | 655 | 'deleteChatStickerSet' => ['chat_id'], |
656 | 656 | 'answerCallbackQuery' => ['callback_query_id'], |
@@ -661,12 +661,12 @@ discard block |
||
661 | 661 | 'getChatMenuButton' => [], |
662 | 662 | 'setMyDefaultAdministratorRights' => [], |
663 | 663 | 'getMyDefaultAdministratorRights' => [], |
664 | - 'editMessageText' => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
665 | - 'editMessageCaption' => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
666 | - 'editMessageMedia' => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
667 | - 'editMessageReplyMarkup' => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
668 | - 'stopPoll' => ['chat_id','message_id'], |
|
669 | - 'deleteMessage' => ['chat_id','message_id'], |
|
664 | + 'editMessageText' => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
665 | + 'editMessageCaption' => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
666 | + 'editMessageMedia' => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
667 | + 'editMessageReplyMarkup' => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
668 | + 'stopPoll' => ['chat_id', 'message_id'], |
|
669 | + 'deleteMessage' => ['chat_id', 'message_id'], |
|
670 | 670 | 'sendSticker' => ['chat_id'], |
671 | 671 | 'getStickerSet' => [], |
672 | 672 | 'uploadStickerFile' => ['user_id'], |
@@ -682,8 +682,8 @@ discard block |
||
682 | 682 | 'answerPreCheckoutQuery' => ['pre_checkout_query_id'], |
683 | 683 | 'setPassportDataErrors' => ['user_id'], |
684 | 684 | 'sendGame' => ['chat_id'], |
685 | - 'setGameScore' => ['user_id','inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
686 | - 'getGameHighScores' => ['user_id','inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']] |
|
685 | + 'setGameScore' => ['user_id', 'inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
686 | + 'getGameHighScores' => ['user_id', 'inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']] |
|
687 | 687 | ]; |
688 | 688 | |
689 | 689 | private const METHODS_RETURN = [ |
@@ -737,24 +737,24 @@ discard block |
||
737 | 737 | 'getGameHighScores' => ['BPT\types\gameHighScore'] |
738 | 738 | ]; |
739 | 739 | |
740 | - public static function __callStatic (string $name, array $arguments) { |
|
740 | + public static function __callStatic(string $name, array $arguments) { |
|
741 | 741 | if (!$action = self::methodAction($name)) { |
742 | - logger::write("$name method is not supported",loggerTypes::ERROR); |
|
742 | + logger::write("$name method is not supported", loggerTypes::ERROR); |
|
743 | 743 | throw new bptException('METHOD_NOT_FOUND'); |
744 | 744 | } |
745 | 745 | self::checkArguments($arguments); |
746 | - self::keysName($action,$arguments); |
|
747 | - self::readyFile($action,$arguments); |
|
748 | - self::setDefaults($action,$arguments); |
|
746 | + self::keysName($action, $arguments); |
|
747 | + self::readyFile($action, $arguments); |
|
748 | + self::setDefaults($action, $arguments); |
|
749 | 749 | if (isset($arguments['answer'])) { |
750 | - return answer::init($action,$arguments); |
|
750 | + return answer::init($action, $arguments); |
|
751 | 751 | } |
752 | 752 | else { |
753 | - $result = curl::init($action,$arguments); |
|
753 | + $result = curl::init($action, $arguments); |
|
754 | 754 | if (!is_object($result)) { |
755 | 755 | return false; |
756 | 756 | } |
757 | - return self::processResponse($action,$result); |
|
757 | + return self::processResponse($action, $result); |
|
758 | 758 | } |
759 | 759 | } |
760 | 760 | |
@@ -764,7 +764,7 @@ discard block |
||
764 | 764 | } |
765 | 765 | } |
766 | 766 | |
767 | - private static function keysName (string $name, array &$arguments): void { |
|
767 | + private static function keysName(string $name, array &$arguments): void { |
|
768 | 768 | foreach ($arguments as $key => $argument) { |
769 | 769 | if (is_numeric($key) && isset(self::METHODS_KEYS[$name][$key])) { |
770 | 770 | $arguments[self::METHODS_KEYS[$name][$key]] = $argument; |
@@ -773,7 +773,7 @@ discard block |
||
773 | 773 | } |
774 | 774 | } |
775 | 775 | |
776 | - private static function methodAction(string $name): string|false { |
|
776 | + private static function methodAction(string $name): string | false { |
|
777 | 777 | return self::METHODS_ACTION[str_replace('_', '', strtolower($name))] ?? false; |
778 | 778 | } |
779 | 779 | |
@@ -794,11 +794,11 @@ discard block |
||
794 | 794 | } |
795 | 795 | } |
796 | 796 | |
797 | - private static function methodFile(string $name): array|false { |
|
797 | + private static function methodFile(string $name): array | false { |
|
798 | 798 | return self::METHODS_WITH_FILE[$name] ?? false; |
799 | 799 | } |
800 | 800 | |
801 | - private static function methodReturn(string $name,stdClass $response) { |
|
801 | + private static function methodReturn(string $name, stdClass $response) { |
|
802 | 802 | if (isset(self::METHODS_RETURN[$name])) { |
803 | 803 | $return = self::METHODS_RETURN[$name]; |
804 | 804 | if (is_array($return)) { |
@@ -821,13 +821,13 @@ discard block |
||
821 | 821 | $defaults = self::METHODS_EXTRA_DEFAULTS[$name]; |
822 | 822 | foreach ($defaults as $key => $default) { |
823 | 823 | if (is_numeric($key)) { |
824 | - if (!isset($arguments[$default])){ |
|
824 | + if (!isset($arguments[$default])) { |
|
825 | 825 | $arguments[$default] = self::catchFields($default); |
826 | 826 | } |
827 | 827 | } |
828 | 828 | elseif (isset(BPT::$update->$key) || $key === 'other') { |
829 | 829 | foreach ($default as $def) { |
830 | - if (!isset($arguments[$def])){ |
|
830 | + if (!isset($arguments[$def])) { |
|
831 | 831 | $arguments[$def] = self::catchFields($def); |
832 | 832 | } |
833 | 833 | } |
@@ -840,7 +840,7 @@ discard block |
||
840 | 840 | if ($response->ok) { |
841 | 841 | self::$status = true; |
842 | 842 | self::$pure_response = $response; |
843 | - return self::methodReturn($name,$response); |
|
843 | + return self::methodReturn($name, $response); |
|
844 | 844 | } |
845 | 845 | else { |
846 | 846 | self::$status = false; |
@@ -856,7 +856,7 @@ discard block |
||
856 | 856 | * |
857 | 857 | * @return int|string|bool |
858 | 858 | */ |
859 | - public static function catchFields (string $field): int|string|bool { |
|
859 | + public static function catchFields(string $field): int | string | bool { |
|
860 | 860 | switch ($field) { |
861 | 861 | case fields::CHAT_ID : |
862 | 862 | case fields::FROM_CHAT_ID : |
@@ -992,7 +992,7 @@ discard block |
||
992 | 992 | default => false |
993 | 993 | }; |
994 | 994 | case fields::URL : |
995 | - return 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; |
|
995 | + return 'https://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; |
|
996 | 996 | default: |
997 | 997 | return false; |
998 | 998 | } |
@@ -748,8 +748,7 @@ discard block |
||
748 | 748 | self::setDefaults($action,$arguments); |
749 | 749 | if (isset($arguments['answer'])) { |
750 | 750 | return answer::init($action,$arguments); |
751 | - } |
|
752 | - else { |
|
751 | + } else { |
|
753 | 752 | $result = curl::init($action,$arguments); |
754 | 753 | if (!is_object($result)) { |
755 | 754 | return false; |
@@ -784,8 +783,7 @@ discard block |
||
784 | 783 | $arguments['media'][$key]['media'] = new CURLFile($media['media']); |
785 | 784 | } |
786 | 785 | } |
787 | - } |
|
788 | - elseif ($file_params = self::methodFile($name)) { |
|
786 | + } elseif ($file_params = self::methodFile($name)) { |
|
789 | 787 | foreach ($file_params as $param) { |
790 | 788 | if (isset($arguments[$param]) && is_string($arguments[$param]) && file_exists(realpath($arguments[$param]))) { |
791 | 789 | $arguments[$param] = new CURLFile($arguments[$param]); |
@@ -807,12 +805,10 @@ discard block |
||
807 | 805 | $value = new ($return[0]) ($value); |
808 | 806 | } |
809 | 807 | return $response; |
810 | - } |
|
811 | - else { |
|
808 | + } else { |
|
812 | 809 | return new ($return) ($response->result); |
813 | 810 | } |
814 | - } |
|
815 | - else { |
|
811 | + } else { |
|
816 | 812 | return $response->result; |
817 | 813 | } |
818 | 814 | } |
@@ -824,8 +820,7 @@ discard block |
||
824 | 820 | if (!isset($arguments[$default])){ |
825 | 821 | $arguments[$default] = self::catchFields($default); |
826 | 822 | } |
827 | - } |
|
828 | - elseif (isset(BPT::$update->$key) || $key === 'other') { |
|
823 | + } elseif (isset(BPT::$update->$key) || $key === 'other') { |
|
829 | 824 | foreach ($default as $def) { |
830 | 825 | if (!isset($arguments[$def])){ |
831 | 826 | $arguments[$def] = self::catchFields($def); |
@@ -841,8 +836,7 @@ discard block |
||
841 | 836 | self::$status = true; |
842 | 837 | self::$pure_response = $response; |
843 | 838 | return self::methodReturn($name,$response); |
844 | - } |
|
845 | - else { |
|
839 | + } else { |
|
846 | 840 | self::$status = false; |
847 | 841 | self::$pure_response = $response; |
848 | 842 | return new responseError($response); |
@@ -885,9 +879,13 @@ discard block |
||
885 | 879 | default => false |
886 | 880 | }; |
887 | 881 | case fields::FILE_ID : |
888 | - if (isset(BPT::$update->message)) $type = 'message'; |
|
889 | - elseif (isset(BPT::$update->edited_message)) $type = 'edited_message'; |
|
890 | - else return false; |
|
882 | + if (isset(BPT::$update->message)) { |
|
883 | + $type = 'message'; |
|
884 | + } elseif (isset(BPT::$update->edited_message)) { |
|
885 | + $type = 'edited_message'; |
|
886 | + } else { |
|
887 | + return false; |
|
888 | + } |
|
891 | 889 | |
892 | 890 | return match(true) { |
893 | 891 | isset(BPT::$update->$type->animation) => BPT::$update->$type->animation->file_id, |
@@ -61,28 +61,22 @@ |
||
61 | 61 | $type = tools::fileType($file_id); |
62 | 62 | if ($type === fileTypes::VIDEO) { |
63 | 63 | return self::sendVideo($file_id,$chat_id,$message_thread_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); |
64 | - } |
|
65 | - elseif ($type === fileTypes::VIDEO_NOTE) { |
|
64 | + } elseif ($type === fileTypes::VIDEO_NOTE) { |
|
66 | 65 | return self::sendVideoNote($file_id,$chat_id,$message_thread_id,null,null,null,$disable_notification,$protect_content,$reply_to_message_id,$allow_sending_without_reply,$reply_markup,$token,$forgot,$answer); |
67 | - } |
|
68 | - elseif ($type === fileTypes::ANIMATION) { |
|
66 | + } elseif ($type === fileTypes::ANIMATION) { |
|
69 | 67 | return self::sendAnimation($file_id,$chat_id,$message_thread_id,null,null,null,null,$caption,$parse_mode,$caption_entities,$disable_notification,$protect_content,$reply_to_message_id,$allow_sending_without_reply,$reply_markup,$token,$forgot,$answer); |
70 | - } |
|
71 | - elseif ($type === fileTypes::AUDIO) { |
|
68 | + } elseif ($type === fileTypes::AUDIO) { |
|
72 | 69 | return self::sendAudio($file_id,$chat_id,$message_thread_id,$caption,$parse_mode,$caption_entities,null,null,null,null,$disable_notification,$protect_content,$reply_to_message_id,$allow_sending_without_reply,$reply_markup,$token,$forgot,$answer); |
73 | - } |
|
74 | - elseif ($type === fileTypes::PHOTO || $type === fileTypes::PROFILE_PHOTO) { |
|
70 | + } elseif ($type === fileTypes::PHOTO || $type === fileTypes::PROFILE_PHOTO) { |
|
75 | 71 | return self::sendPhoto($file_id,$chat_id,$message_thread_id,$caption,$parse_mode,$caption_entities,$disable_notification,$protect_content,$reply_to_message_id,$allow_sending_without_reply,$reply_markup,$token,$forgot,$answer); |
76 | - } |
|
77 | - elseif ($type === fileTypes::VOICE) { |
|
72 | + } elseif ($type === fileTypes::VOICE) { |
|
78 | 73 | return self::sendVoice($file_id,$chat_id,$message_thread_id,$caption,$parse_mode,$caption_entities,null,$disable_notification,$protect_content,$reply_to_message_id,$allow_sending_without_reply,$reply_markup,$token,$forgot,$answer); |
79 | - } |
|
80 | - elseif ($type === fileTypes::STICKER) { |
|
74 | + } elseif ($type === fileTypes::STICKER) { |
|
81 | 75 | return self::sendSticker($file_id,$chat_id,$message_thread_id,$disable_notification,$protect_content,$reply_to_message_id,$allow_sending_without_reply,$reply_markup,$token,$forgot,$answer); |
82 | - } |
|
83 | - elseif ($type === fileTypes::DOCUMENT) { |
|
76 | + } elseif ($type === fileTypes::DOCUMENT) { |
|
84 | 77 | return self::sendDocument($file_id,$chat_id,$message_thread_id,null,$caption,$parse_mode,$caption_entities,null,$disable_notification,$protect_content,$reply_to_message_id,$allow_sending_without_reply,$reply_markup,$token,$forgot,$answer); |
78 | + } else { |
|
79 | + return false; |
|
85 | 80 | } |
86 | - else return false; |
|
87 | 81 | } |
88 | 82 | } |
89 | 83 | \ No newline at end of file |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * telegram class , Adding normal method call to request class and a simple name for being easy to call |
16 | 16 | */ |
17 | 17 | class telegram extends request { |
18 | - public function __call (string $name, array $arguments) { |
|
18 | + public function __call(string $name, array $arguments) { |
|
19 | 19 | return request::$name(...$arguments); |
20 | 20 | } |
21 | 21 | |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @return bool |
35 | 35 | */ |
36 | - public static function downloadFile (string|null $destination = null, string|null $file_id = null): bool { |
|
36 | + public static function downloadFile(string | null $destination = null, string | null $file_id = null): bool { |
|
37 | 37 | return tools::downloadFile(self::fileLink($file_id), $destination); |
38 | 38 | } |
39 | 39 | |
40 | - public static function fileLink(string|null $file_id = null): bool|string { |
|
40 | + public static function fileLink(string | null $file_id = null): bool | string { |
|
41 | 41 | $file = self::getFile($file_id); |
42 | 42 | if (!isset($file->file_path)) { |
43 | 43 | return false; |
@@ -59,31 +59,31 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @return message|bool|responseError |
61 | 61 | */ |
62 | - 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 { |
|
62 | + 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 { |
|
63 | 63 | $type = tools::fileType($file_id); |
64 | 64 | if ($type === fileTypes::VIDEO) { |
65 | - return self::sendVideo($file_id,$chat_id,$message_thread_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); |
|
65 | + return self::sendVideo($file_id, $chat_id, $message_thread_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); |
|
66 | 66 | } |
67 | 67 | elseif ($type === fileTypes::VIDEO_NOTE) { |
68 | - return self::sendVideoNote($file_id,$chat_id,$message_thread_id,null,null,null,$disable_notification,$protect_content,$reply_to_message_id,$allow_sending_without_reply,$reply_markup,$token,$forgot,$answer); |
|
68 | + return self::sendVideoNote($file_id, $chat_id, $message_thread_id, null, null, null, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer); |
|
69 | 69 | } |
70 | 70 | elseif ($type === fileTypes::ANIMATION) { |
71 | - return self::sendAnimation($file_id,$chat_id,$message_thread_id,null,null,null,null,$caption,$parse_mode,$caption_entities,$disable_notification,$protect_content,$reply_to_message_id,$allow_sending_without_reply,$reply_markup,$token,$forgot,$answer); |
|
71 | + return self::sendAnimation($file_id, $chat_id, $message_thread_id, null, null, null, null, $caption, $parse_mode, $caption_entities, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer); |
|
72 | 72 | } |
73 | 73 | elseif ($type === fileTypes::AUDIO) { |
74 | - return self::sendAudio($file_id,$chat_id,$message_thread_id,$caption,$parse_mode,$caption_entities,null,null,null,null,$disable_notification,$protect_content,$reply_to_message_id,$allow_sending_without_reply,$reply_markup,$token,$forgot,$answer); |
|
74 | + return self::sendAudio($file_id, $chat_id, $message_thread_id, $caption, $parse_mode, $caption_entities, null, null, null, null, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer); |
|
75 | 75 | } |
76 | 76 | elseif ($type === fileTypes::PHOTO || $type === fileTypes::PROFILE_PHOTO) { |
77 | - return self::sendPhoto($file_id,$chat_id,$message_thread_id,$caption,$parse_mode,$caption_entities,$disable_notification,$protect_content,$reply_to_message_id,$allow_sending_without_reply,$reply_markup,$token,$forgot,$answer); |
|
77 | + return self::sendPhoto($file_id, $chat_id, $message_thread_id, $caption, $parse_mode, $caption_entities, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer); |
|
78 | 78 | } |
79 | 79 | elseif ($type === fileTypes::VOICE) { |
80 | - return self::sendVoice($file_id,$chat_id,$message_thread_id,$caption,$parse_mode,$caption_entities,null,$disable_notification,$protect_content,$reply_to_message_id,$allow_sending_without_reply,$reply_markup,$token,$forgot,$answer); |
|
80 | + return self::sendVoice($file_id, $chat_id, $message_thread_id, $caption, $parse_mode, $caption_entities, null, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer); |
|
81 | 81 | } |
82 | 82 | elseif ($type === fileTypes::STICKER) { |
83 | - return self::sendSticker($file_id,$chat_id,$message_thread_id,$disable_notification,$protect_content,$reply_to_message_id,$allow_sending_without_reply,$reply_markup,$token,$forgot,$answer); |
|
83 | + return self::sendSticker($file_id, $chat_id, $message_thread_id, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer); |
|
84 | 84 | } |
85 | 85 | elseif ($type === fileTypes::DOCUMENT) { |
86 | - return self::sendDocument($file_id,$chat_id,$message_thread_id,null,$caption,$parse_mode,$caption_entities,null,$disable_notification,$protect_content,$reply_to_message_id,$allow_sending_without_reply,$reply_markup,$token,$forgot,$answer); |
|
86 | + return self::sendDocument($file_id, $chat_id, $message_thread_id, null, $caption, $parse_mode, $caption_entities, null, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer); |
|
87 | 87 | } |
88 | 88 | else return false; |
89 | 89 | } |
@@ -17,14 +17,14 @@ discard block |
||
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|null { |
|
20 | + public static function init(): string | null { |
|
21 | 21 | return self::getUpdate(); |
22 | 22 | } |
23 | 23 | |
24 | - private static function getUpdate (): string|null { |
|
24 | + private static function getUpdate(): string | null { |
|
25 | 25 | $up = glob('*.update'); |
26 | 26 | if (!isset($up[0])) { |
27 | - logger::write('not authorized access denied. IP : '. $_SERVER['REMOTE_ADDR'] ?? 'unknown',loggerTypes::WARNING); |
|
27 | + logger::write('not authorized access denied. IP : '.$_SERVER['REMOTE_ADDR'] ?? 'unknown', loggerTypes::WARNING); |
|
28 | 28 | BPT::exit(); |
29 | 29 | } |
30 | 30 | $up = end($up); |
@@ -56,12 +56,12 @@ discard block |
||
56 | 56 | } |
57 | 57 | |
58 | 58 | private static function create($file) { |
59 | - file_put_contents('receiver.php', '<?php $BPT = file_get_contents("php://input");$id = json_decode($BPT, true)[\'update_id\'];file_put_contents("{$_SERVER[\'REMOTE_ADDR\']}-$id.update",$BPT);exec("php ' . $file . ' > /dev/null &");'); |
|
59 | + file_put_contents('receiver.php', '<?php $BPT = file_get_contents("php://input");$id = json_decode($BPT, true)[\'update_id\'];file_put_contents("{$_SERVER[\'REMOTE_ADDR\']}-$id.update",$BPT);exec("php '.$file.' > /dev/null &");'); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | #[ArrayShape(['url' => "array|string|string[]", 'file' => "string"])] |
63 | 63 | private static function setURLS(): array { |
64 | - $base_url = (isset(settings::$certificate) ? 'http://' : 'https://') . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; |
|
64 | + $base_url = (isset(settings::$certificate) ? 'http://' : 'https://').$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; |
|
65 | 65 | return [ |
66 | 66 | 'url'=>str_replace(basename($_SERVER['REQUEST_URI']), 'receiver.php', $base_url), |
67 | 67 | 'file'=>basename($_SERVER['SCRIPT_NAME']) |
@@ -14,9 +14,9 @@ discard block |
||
14 | 14 | * curl class , for multiprocessing with curl tricks |
15 | 15 | */ |
16 | 16 | class curl extends webhook { |
17 | - public static function init (): string|null { |
|
17 | + public static function init(): string | null { |
|
18 | 18 | if (!self::checkIP()) { |
19 | - logger::write('not authorized access denied. IP : '. $_SERVER['REMOTE_ADDR'] ?? 'unknown',loggerTypes::WARNING); |
|
19 | + logger::write('not authorized access denied. IP : '.$_SERVER['REMOTE_ADDR'] ?? 'unknown', loggerTypes::WARNING); |
|
20 | 20 | BPT::exit(); |
21 | 21 | } |
22 | 22 | return self::getUpdate(); |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | return $_SERVER['REMOTE_ADDR'] === $_SERVER['SERVER_ADDR']; |
27 | 27 | } |
28 | 28 | |
29 | - private static function getUpdate (): string { |
|
29 | + private static function getUpdate(): string { |
|
30 | 30 | $input = json_decode(file_get_contents("php://input"), true); |
31 | 31 | webhook::telegramVerify($input['ip']); |
32 | 32 | return $input['update']; |
@@ -39,14 +39,14 @@ discard block |
||
39 | 39 | $urls = self::setURLS(); |
40 | 40 | $file = $urls['file']; |
41 | 41 | $timeout = self::getTimeout($file); |
42 | - self::create($file,$timeout); |
|
42 | + self::create($file, $timeout); |
|
43 | 43 | self::setWebhook($urls['url']); |
44 | 44 | lock::set('BPT-MULTI-CURL'); |
45 | 45 | } |
46 | 46 | |
47 | - private static function getTimeout($url): float|int { |
|
47 | + private static function getTimeout($url): float | int { |
|
48 | 48 | $times = []; |
49 | - for ($i = 0; $i < 10; $i ++) { |
|
49 | + for ($i = 0; $i < 10; $i++) { |
|
50 | 50 | $ch = curl_init($url); |
51 | 51 | curl_setopt_array($ch, [CURLOPT_POSTFIELDS => json_encode([]), CURLOPT_TIMEOUT_MS => 100, CURLOPT_NOBODY => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_CONNECTTIMEOUT_MS => 100, CURLOPT_HTTPHEADER => ['accept: application/json', 'content-type: application/json']]); |
52 | 52 | $start = microtime(true); |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | return $timeout > 50 ? $timeout + 10 : 50; |
58 | 58 | } |
59 | 59 | |
60 | - private static function create($file,$timeout) { |
|
61 | - file_put_contents('receiver.php', '<?php http_response_code(200);ignore_user_abort();$ch = curl_init(\'' . $file . '\');curl_setopt_array($ch, [CURLOPT_POSTFIELDS => json_encode([\'update\'=>file_get_contents(\'php://input\'),\'ip\'=>$_SERVER[\'REMOTE_ADDR\']]), CURLOPT_TIMEOUT_MS => ' . $timeout . ', CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_CONNECTTIMEOUT_MS => ' . $timeout . ', CURLOPT_HTTPHEADER => [\'accept: application/json\', \'content-type: application/json\']]);curl_exec($ch);curl_close($ch);?>'); |
|
60 | + private static function create($file, $timeout) { |
|
61 | + file_put_contents('receiver.php', '<?php http_response_code(200);ignore_user_abort();$ch = curl_init(\''.$file.'\');curl_setopt_array($ch, [CURLOPT_POSTFIELDS => json_encode([\'update\'=>file_get_contents(\'php://input\'),\'ip\'=>$_SERVER[\'REMOTE_ADDR\']]), CURLOPT_TIMEOUT_MS => '.$timeout.', CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_CONNECTTIMEOUT_MS => '.$timeout.', CURLOPT_HTTPHEADER => [\'accept: application/json\', \'content-type: application/json\']]);curl_exec($ch);curl_close($ch);?>'); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | #[ArrayShape(['url' => "array|string|string[]", 'file' => "array|string|string[]"])] |
65 | 65 | private static function setURLS(): array { |
66 | - $base_url = (isset(settings::$certificate) ? 'http://' : 'https://') . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; |
|
66 | + $base_url = (isset(settings::$certificate) ? 'http://' : 'https://').$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; |
|
67 | 67 | $file = basename($_SERVER['REQUEST_URI']); |
68 | 68 | return [ |
69 | 69 | 'url'=>str_replace($file, 'receiver.php', $base_url), |
@@ -16,23 +16,23 @@ discard block |
||
16 | 16 | */ |
17 | 17 | class getUpdates extends receiver { |
18 | 18 | #[NoReturn] |
19 | - public static function init () { |
|
19 | + public static function init() { |
|
20 | 20 | $last_update_id = self::loadData(); |
21 | - while(true) { |
|
21 | + while (true) { |
|
22 | 22 | if (!lock::exist('getUpdate')) { |
23 | - $updates = telegram::getUpdates($last_update_id,allowed_updates: settings::$allowed_updates); |
|
23 | + $updates = telegram::getUpdates($last_update_id, allowed_updates: settings::$allowed_updates); |
|
24 | 24 | if (!telegram::$status) { |
25 | - logger::write("There is some problem happened , telegram response : \n".json_encode($updates),loggerTypes::ERROR); |
|
26 | - BPT::exit(print_r($updates,true)); |
|
25 | + logger::write("There is some problem happened , telegram response : \n".json_encode($updates), loggerTypes::ERROR); |
|
26 | + BPT::exit(print_r($updates, true)); |
|
27 | 27 | } |
28 | 28 | self::handleUpdates($updates); |
29 | - lock::save('getUpdate',BPT::$update->update_id+1); |
|
30 | - $last_update_id = BPT::$update->update_id+1; |
|
29 | + lock::save('getUpdate', BPT::$update->update_id + 1); |
|
30 | + $last_update_id = BPT::$update->update_id + 1; |
|
31 | 31 | } |
32 | 32 | } |
33 | 33 | } |
34 | 34 | |
35 | - private static function loadData(): bool|int|string { |
|
35 | + private static function loadData(): bool | int | string { |
|
36 | 36 | if (lock::exist('getUpdate')) { |
37 | 37 | $last_update_id = lock::read('getUpdate'); |
38 | 38 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | self::deleteOldLocks(); |
41 | 41 | telegram::deleteWebhook(); |
42 | 42 | $last_update_id = 0; |
43 | - lock::save('getUpdate',0); |
|
43 | + lock::save('getUpdate', 0); |
|
44 | 44 | } |
45 | 45 | return $last_update_id; |
46 | 46 | } |
@@ -35,8 +35,7 @@ |
||
35 | 35 | private static function loadData(): bool|int|string { |
36 | 36 | if (lock::exist('getUpdate')) { |
37 | 37 | $last_update_id = lock::read('getUpdate'); |
38 | - } |
|
39 | - else { |
|
38 | + } else { |
|
40 | 39 | self::deleteOldLocks(); |
41 | 40 | telegram::deleteWebhook(); |
42 | 41 | $last_update_id = 0; |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | /** |
21 | 21 | * @internal Only for BPT self usage , Don't use it in your source! |
22 | 22 | */ |
23 | - public static function init () { |
|
23 | + public static function init() { |
|
24 | 24 | if (settings::$multi) { |
25 | 25 | multi::init(); |
26 | 26 | } |
@@ -49,24 +49,24 @@ discard block |
||
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
52 | - protected static function setWebhook(string $url,string $secret = '') { |
|
52 | + protected static function setWebhook(string $url, string $secret = '') { |
|
53 | 53 | $res = telegram::setWebhook($url, settings::$certificate, max_connections: settings::$max_connection, allowed_updates: settings::$allowed_updates, drop_pending_updates: settings::$skip_old_updates, secret_token: $secret); |
54 | 54 | if (!telegram::$status) { |
55 | - logger::write("There is some problem happened , telegram response : \n".json_encode($res),loggerTypes::ERROR); |
|
56 | - BPT::exit(print_r($res,true)); |
|
55 | + logger::write("There is some problem happened , telegram response : \n".json_encode($res), loggerTypes::ERROR); |
|
56 | + BPT::exit(print_r($res, true)); |
|
57 | 57 | } |
58 | - logger::write('Webhook was set successfully',loggerTypes::INFO); |
|
58 | + logger::write('Webhook was set successfully', loggerTypes::INFO); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | protected static function checkURL() { |
62 | 62 | if (!(isset($_SERVER['SERVER_NAME']) && isset($_SERVER['REQUEST_URI']))) { |
63 | - logger::write('For using webhook receiver , you should open this file in your webserver(by domain)',loggerTypes::ERROR); |
|
63 | + logger::write('For using webhook receiver , you should open this file in your webserver(by domain)', loggerTypes::ERROR); |
|
64 | 64 | throw new bptException('WEBHOOK_NEED_URL'); |
65 | 65 | } |
66 | 66 | } |
67 | 67 | |
68 | 68 | private static function setURL(): string { |
69 | - return (isset(settings::$certificate) ? 'http://' : 'https://') . $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME']; |
|
69 | + return (isset(settings::$certificate) ? 'http://' : 'https://').$_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME']; |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | protected static function setCertificate() { |
@@ -89,15 +89,15 @@ discard block |
||
89 | 89 | self::setCertificate(); |
90 | 90 | $url = self::setURL(); |
91 | 91 | $secret = !empty(settings::$secret) ? settings::$secret : tools::randomString(64); |
92 | - self::setWebhook($url,$secret); |
|
93 | - lock::save('BPT-HOOK',$secret); |
|
92 | + self::setWebhook($url, $secret); |
|
93 | + lock::save('BPT-HOOK', $secret); |
|
94 | 94 | BPT::exit('Done'); |
95 | 95 | } |
96 | 96 | |
97 | 97 | private static function checkSecret() { |
98 | 98 | $secret = lock::read('BPT-HOOK'); |
99 | 99 | if ($secret !== self::getSecret()) { |
100 | - logger::write('This is not webhook set by BPT, webhook will reset',loggerTypes::WARNING); |
|
100 | + logger::write('This is not webhook set by BPT, webhook will reset', loggerTypes::WARNING); |
|
101 | 101 | self::processSetWebhook(); |
102 | 102 | } |
103 | 103 | } |
@@ -23,15 +23,13 @@ discard block |
||
23 | 23 | public static function init () { |
24 | 24 | if (settings::$multi) { |
25 | 25 | multi::init(); |
26 | - } |
|
27 | - else { |
|
26 | + } else { |
|
28 | 27 | if (lock::exist('BPT-HOOK')) { |
29 | 28 | receiver::telegramVerify(); |
30 | 29 | self::checkSecret(); |
31 | 30 | logger::write('Update received , lets process it ;)'); |
32 | 31 | receiver::processUpdate(); |
33 | - } |
|
34 | - else { |
|
32 | + } else { |
|
35 | 33 | self::processSetWebhook(); |
36 | 34 | } |
37 | 35 | } |
@@ -74,8 +72,7 @@ discard block |
||
74 | 72 | if (is_string(settings::$certificate)) { |
75 | 73 | if (file_exists(realpath(settings::$certificate))) { |
76 | 74 | settings::$certificate = new CURLFile(settings::$certificate); |
77 | - } |
|
78 | - else { |
|
75 | + } else { |
|
79 | 76 | settings::$certificate = null; |
80 | 77 | } |
81 | 78 | } |