@@ -17,7 +17,7 @@ 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 (int $log_size = 10): void { |
|
20 | + public static function init(int $log_size = 10): void { |
|
21 | 21 | self::$log_size = $log_size; |
22 | 22 | if (file_exists(settings::$name.'BPT.log') && !(filesize(settings::$name.'BPT.log') > self::$log_size * 1024 * 1024)) { |
23 | 23 | $mode = 'a'; |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | self::$handler = fopen(settings::$name.'BPT.log', $mode); |
31 | 31 | |
32 | 32 | if ($write) { |
33 | - fwrite(self::$handler,"♥♥♥♥♥♥♥♥♥♥♥♥♥♥ BPT Library ♥♥♥♥♥♥♥♥♥♥♥♥♥♥\nTnx for using our library\nSome information about us :\nAuthor : @Im_Miaad\nHelper : @A_LiReza_ME\nChannel : @BPT_CH\nOur Website : https://bptlib.ir\n\nIf you have any problem with our library\nContact to our supports\n♥♥♥♥♥♥♥♥♥♥♥♥♥♥ BPT Library ♥♥♥♥♥♥♥♥♥♥♥♥♥♥\nINFO : BPT Library LOG STARTED ...\nwarning : this file automatically deleted when its size reached log_size setting, do not delete it manually\n\n"); |
|
33 | + fwrite(self::$handler, "♥♥♥♥♥♥♥♥♥♥♥♥♥♥ BPT Library ♥♥♥♥♥♥♥♥♥♥♥♥♥♥\nTnx for using our library\nSome information about us :\nAuthor : @Im_Miaad\nHelper : @A_LiReza_ME\nChannel : @BPT_CH\nOur Website : https://bptlib.ir\n\nIf you have any problem with our library\nContact to our supports\n♥♥♥♥♥♥♥♥♥♥♥♥♥♥ BPT Library ♥♥♥♥♥♥♥♥♥♥♥♥♥♥\nINFO : BPT Library LOG STARTED ...\nwarning : this file automatically deleted when its size reached log_size setting, do not delete it manually\n\n"); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | if (self::$waited_logs != []) { |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @return void |
52 | 52 | */ |
53 | 53 | public static function write(string $data, string $type = loggerTypes::NONE): void { |
54 | - $text = date('Y/m/d H:i:s') . ( $type === loggerTypes::NONE ? " : $data\n\n" : " : ⤵\n$type : $data\n\n" ); |
|
54 | + $text = date('Y/m/d H:i:s').($type === loggerTypes::NONE ? " : $data\n\n" : " : ⤵\n$type : $data\n\n"); |
|
55 | 55 | if (!is_null(self::$handler)) { |
56 | 56 | fwrite(self::$handler, $text); |
57 | 57 | } |
@@ -9,4 +9,4 @@ |
||
9 | 9 | * |
10 | 10 | * @todo make it usefully (it's not called at all) |
11 | 11 | */ |
12 | -class telegramException extends Exception{} |
|
13 | 12 | \ No newline at end of file |
13 | +class telegramException extends Exception {} |
|
14 | 14 | \ No newline at end of file |
@@ -17,17 +17,17 @@ 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 $method,array $data) { |
|
20 | + public static function init(string $method, array $data) { |
|
21 | 21 | $info = self::getInfo($data); |
22 | 22 | $data = $info['data']; |
23 | 23 | $handler = $info['handler']; |
24 | - self::setTimeout($data,$handler,$method); |
|
24 | + self::setTimeout($data, $handler, $method); |
|
25 | 25 | self::setData($data); |
26 | 26 | $data['method'] = $method; |
27 | 27 | curl_setopt($handler, CURLOPT_POSTFIELDS, $data); |
28 | 28 | $result = curl_exec($handler); |
29 | 29 | if (curl_errno($handler)) { |
30 | - logger::write(curl_error($handler),loggerTypes::WARNING); |
|
30 | + logger::write(curl_error($handler), loggerTypes::WARNING); |
|
31 | 31 | } |
32 | 32 | if ($info['token'] != settings::$token) { |
33 | 33 | curl_close($handler); |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | curl_setopt($curl_handler, CURLOPT_RETURNTRANSFER, true); |
44 | 44 | curl_setopt($curl_handler, CURLOPT_SSL_VERIFYPEER, false); |
45 | 45 | } |
46 | - else{ |
|
46 | + else { |
|
47 | 47 | $token = settings::$token; |
48 | - if (!isset(self::$curl_handler)){ |
|
48 | + if (!isset(self::$curl_handler)) { |
|
49 | 49 | self::$curl_handler = curl_init(settings::$base_url."/bot$token/"); |
50 | 50 | curl_setopt(self::$curl_handler, CURLOPT_RETURNTRANSFER, true); |
51 | 51 | curl_setopt(self::$curl_handler, CURLOPT_SSL_VERIFYPEER, false); |
@@ -61,22 +61,22 @@ discard block |
||
61 | 61 | ]; |
62 | 62 | } |
63 | 63 | |
64 | - private static function setTimeout(array &$data , CurlHandle $curl_handler,string $method): void { |
|
64 | + private static function setTimeout(array &$data, CurlHandle $curl_handler, string $method): void { |
|
65 | 65 | if (isset($data['forgot'])) { |
66 | 66 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, settings::$forgot_time); |
67 | 67 | unset($data['forgot']); |
68 | 68 | } |
69 | - elseif ($method === 'getUpdates'){ |
|
69 | + elseif ($method === 'getUpdates') { |
|
70 | 70 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, 5000); |
71 | 71 | } |
72 | - else{ |
|
72 | + else { |
|
73 | 73 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, 300); |
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
77 | 77 | private static function setData(array &$data): void { |
78 | - foreach ($data as &$value){ |
|
79 | - if (is_array($value) || (is_object($value) && !is_a($value,'CURLFile'))){ |
|
78 | + foreach ($data as &$value) { |
|
79 | + if (is_array($value) || (is_object($value) && !is_a($value, 'CURLFile'))) { |
|
80 | 80 | $value = json_encode($value); |
81 | 81 | } |
82 | 82 | } |
@@ -17,32 +17,32 @@ 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 $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 | } |
@@ -52,11 +52,11 @@ discard block |
||
52 | 52 | unset($data['forgot']); |
53 | 53 | unset($data['return_array']); |
54 | 54 | |
55 | - foreach ($data as $key=>&$value){ |
|
56 | - if (!isset($value)){ |
|
55 | + foreach ($data as $key=>&$value) { |
|
56 | + if (!isset($value)) { |
|
57 | 57 | unset($data[$key]); |
58 | 58 | } |
59 | - elseif (is_array($value) || is_object($value)){ |
|
59 | + elseif (is_array($value) || is_object($value)) { |
|
60 | 60 | $value = json_encode($value); |
61 | 61 | } |
62 | 62 | } |
@@ -450,94 +450,94 @@ discard block |
||
450 | 450 | ]; |
451 | 451 | |
452 | 452 | private const METHODS_KEYS = [ |
453 | - 'getUpdates' => ['offset','limit','timeout','allowed_updates','token','return_array','forgot','answer'], |
|
454 | - 'setWebhook' => ['url','certificate','ip_address','max_connections','allowed_updates','drop_pending_updates','secret_token','token','return_array','forgot','answer'], |
|
455 | - 'deleteWebhook' => ['drop_pending_updates','token','return_array','forgot','answer'], |
|
456 | - 'getWebhookInfo' => ['token','return_array','forgot','answer'], |
|
457 | - 'getMe' => ['token','return_array','forgot','answer'], |
|
458 | - 'logOut' => ['token','return_array','forgot','answer'], |
|
459 | - 'close' => ['token','return_array','forgot','answer'], |
|
460 | - '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','return_array','forgot','answer'], |
|
461 | - 'forwardMessage' => ['chat_id','from_chat_id','disable_notification','protect_content','message_id','token','return_array','forgot','answer'], |
|
462 | - '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','return_array','forgot','answer'], |
|
463 | - 'sendPhoto' => ['photo','chat_id','caption','parse_mode','caption_entities','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
|
464 | - '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','return_array','forgot','answer'], |
|
465 | - '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','return_array','forgot','answer'], |
|
466 | - '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','return_array','forgot','answer'], |
|
467 | - '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','return_array','forgot','answer'], |
|
468 | - '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','return_array','forgot','answer'], |
|
469 | - 'sendVideoNote' => ['video_note','chat_id','duration','length','thumb','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
|
470 | - 'sendMediaGroup' => ['media','chat_id','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','token','return_array','forgot','answer'], |
|
471 | - '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','return_array','forgot','answer'], |
|
472 | - 'editMessageLiveLocation' => ['latitude','longitude','chat_id','message_id','inline_message_id','horizontal_accuracy','heading','proximity_alert_radius','reply_markup','token','return_array','forgot','answer'], |
|
473 | - 'stopMessageLiveLocation' => ['chat_id','message_id','inline_message_id','reply_markup','token','return_array','forgot','answer'], |
|
474 | - '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','return_array','forgot','answer'], |
|
475 | - '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','return_array','forgot','answer'], |
|
476 | - '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','return_array','forgot','answer'], |
|
477 | - 'sendDice' => ['chat_id','emoji','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
|
478 | - 'sendChatAction' => ['chat_id','action','token','return_array','forgot','answer'], |
|
479 | - 'getUserProfilePhotos' => ['user_id','offset','limit','token','return_array','forgot','answer'], |
|
480 | - 'getFile' => ['file_id','token','return_array','forgot','answer'], |
|
481 | - 'banChatMember' => ['chat_id','user_id','until_date','revoke_messages','token','return_array','forgot','answer'], |
|
482 | - 'unbanChatMember' => ['chat_id','user_id','only_if_banned','token','return_array','forgot','answer'], |
|
483 | - 'restrictChatMember' => ['permissions','chat_id','user_id','until_date','token','return_array','forgot','answer'], |
|
484 | - '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','return_array','forgot','answer'], |
|
485 | - 'setChatAdministratorCustomTitle' => ['custom_title','chat_id','user_id','token','return_array','forgot','answer'], |
|
486 | - 'banChatSenderChat' => ['sender_chat_id','chat_id','token','return_array','forgot','answer'], |
|
487 | - 'unbanChatSenderChat' => ['sender_chat_id','chat_id','token','return_array','forgot','answer'], |
|
488 | - 'setChatPermissions' => ['permissions','chat_id','token','return_array','forgot','answer'], |
|
489 | - 'exportChatInviteLink' => ['chat_id','token','return_array','forgot','answer'], |
|
490 | - 'createChatInviteLink' => ['chat_id','name','expire_date','member_limit','creates_join_request','token','return_array','forgot','answer'], |
|
491 | - 'editChatInviteLink' => ['invite_link','chat_id','name','expire_date','member_limit','creates_join_request','token','return_array','forgot','answer'], |
|
492 | - 'revokeChatInviteLink' => ['invite_link','chat_id','token','return_array','forgot','answer'], |
|
493 | - 'approveChatJoinRequest' => ['chat_id','user_id','token','return_array','forgot','answer'], |
|
494 | - 'declineChatJoinRequest' => ['chat_id','user_id','token','return_array','forgot','answer'], |
|
495 | - 'setChatPhoto' => ['photo','chat_id','token','return_array','forgot','answer'], |
|
496 | - 'deleteChatPhoto' => ['chat_id','token','return_array','forgot','answer'], |
|
497 | - 'setChatTitle' => ['title','chat_id','token','return_array','forgot','answer'], |
|
498 | - 'setChatDescription' => ['chat_id','description','token','return_array','forgot','answer'], |
|
499 | - 'pinChatMessage' => ['message_id','chat_id','disable_notification','token','return_array','forgot','answer'], |
|
500 | - 'unpinChatMessage' => ['chat_id','message_id','token','return_array','forgot','answer'], |
|
501 | - 'unpinAllChatMessages' => ['chat_id','token','return_array','forgot','answer'], |
|
502 | - 'leaveChat' => ['chat_id','token','return_array','forgot','answer'], |
|
503 | - 'getChat' => ['chat_id','token','return_array','forgot','answer'], |
|
504 | - 'getChatAdministrators' => ['chat_id','token','return_array','forgot','answer'], |
|
505 | - 'getChatMemberCount' => ['chat_id','token','return_array','forgot','answer'], |
|
506 | - 'getChatMember' => ['chat_id','user_id','token','return_array','forgot','answer'], |
|
507 | - 'setChatStickerSet' => ['sticker_set_name','chat_id','token','return_array','forgot','answer'], |
|
508 | - 'deleteChatStickerSet' => ['chat_id','token','return_array','forgot','answer'], |
|
509 | - 'answerCallbackQuery' => ['callback_query_id','text','show_alert','url','cache_time','token','return_array','forgot','answer'], |
|
510 | - 'setMyCommands' => ['commands','scope','language_code','token','return_array','forgot','answer'], |
|
511 | - 'deleteMyCommands' => ['scope','language_code','token','return_array','forgot','answer'], |
|
512 | - 'getMyCommands' => ['scope','language_code','token','return_array','forgot','answer'], |
|
513 | - 'setChatMenuButton' => ['chat_id','menu_button','token','return_array','forgot','answer'], |
|
514 | - 'getChatMenuButton' => ['chat_id','token','return_array','forgot','answer'], |
|
515 | - 'setMyDefaultAdministratorRights' => ['rights','for_channels','token','return_array','forgot','answer'], |
|
516 | - 'getMyDefaultAdministratorRights' => ['for_channels','token','return_array','forgot','answer'], |
|
517 | - 'editMessageText' => ['text','chat_id','message_id','inline_message_id','parse_mode','entities','disable_web_page_preview','reply_markup','token','return_array','forgot','answer'], |
|
518 | - 'editMessageCaption' => ['chat_id','message_id','inline_message_id','caption','parse_mode','caption_entities','reply_markup','token','return_array','forgot','answer'], |
|
519 | - 'editMessageMedia' => ['media','chat_id','message_id','inline_message_id','reply_markup','token','return_array','forgot','answer'], |
|
520 | - 'editMessageReplyMarkup' => ['chat_id','message_id','inline_message_id','reply_markup','token','return_array','forgot','answer'], |
|
521 | - 'stopPoll' => ['chat_id','message_id','reply_markup','token','return_array','forgot','answer'], |
|
522 | - 'deleteMessage' => ['chat_id','message_id','token','return_array','forgot','answer'], |
|
523 | - 'sendSticker' => ['sticker','chat_id','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
|
524 | - 'getStickerSet' => ['name','token','return_array','forgot','answer'], |
|
525 | - 'uploadStickerFile' => ['png_sticker','user_id','token','return_array','forgot','answer'], |
|
526 | - 'createNewStickerSet' => ['name','title','emojis','user_id','png_sticker','tgs_sticker','webm_sticker','contains_masks','mask_position','token','return_array','forgot','answer'], |
|
527 | - 'addStickerToSet' => ['name','emojis','user_id','png_sticker','tgs_sticker','webm_sticker','mask_position','token','return_array','forgot','answer'], |
|
528 | - 'setStickerPositionInSet' => ['sticker','position','token','return_array','forgot','answer'], |
|
529 | - 'deleteStickerFromSet' => ['sticker','token','return_array','forgot','answer'], |
|
530 | - 'setStickerSetThumb' => ['name','user_id','thumb','token','return_array','forgot','answer'], |
|
531 | - 'answerInlineQuery' => ['results','inline_query_id','cache_time','is_personal','next_offset','switch_pm_text','switch_pm_parameter','token','return_array','forgot','answer'], |
|
532 | - 'answerWebAppQuery' => ['web_app_query_id','result','token','return_array','forgot','answer'], |
|
533 | - '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','return_array','forgot','answer'], |
|
534 | - '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','return_array','forgot','answer'], |
|
535 | - 'answerShippingQuery' => ['ok','shipping_query_id','shipping_options','error_message','token','return_array','forgot','answer'], |
|
536 | - 'answerPreCheckoutQuery' => ['ok','pre_checkout_query_id','error_message','token','return_array','forgot','answer'], |
|
537 | - 'setPassportDataErrors' => ['errors','user_id','token','return_array','forgot','answer'], |
|
538 | - 'sendGame' => ['game_short_name','chat_id','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
|
539 | - 'setGameScore' => ['score','user_id','force','disable_edit_message','chat_id','message_id','inline_message_id','token','return_array','forgot','answer'], |
|
540 | - 'getGameHighScores' => ['user_id','chat_id','message_id','inline_message_id','token','return_array','forgot','answer'], |
|
453 | + 'getUpdates' => ['offset', 'limit', 'timeout', 'allowed_updates', 'token', 'return_array', 'forgot', 'answer'], |
|
454 | + 'setWebhook' => ['url', 'certificate', 'ip_address', 'max_connections', 'allowed_updates', 'drop_pending_updates', 'secret_token', 'token', 'return_array', 'forgot', 'answer'], |
|
455 | + 'deleteWebhook' => ['drop_pending_updates', 'token', 'return_array', 'forgot', 'answer'], |
|
456 | + 'getWebhookInfo' => ['token', 'return_array', 'forgot', 'answer'], |
|
457 | + 'getMe' => ['token', 'return_array', 'forgot', 'answer'], |
|
458 | + 'logOut' => ['token', 'return_array', 'forgot', 'answer'], |
|
459 | + 'close' => ['token', 'return_array', 'forgot', 'answer'], |
|
460 | + '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', 'return_array', 'forgot', 'answer'], |
|
461 | + 'forwardMessage' => ['chat_id', 'from_chat_id', 'disable_notification', 'protect_content', 'message_id', 'token', 'return_array', 'forgot', 'answer'], |
|
462 | + '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', 'return_array', 'forgot', 'answer'], |
|
463 | + 'sendPhoto' => ['photo', 'chat_id', 'caption', 'parse_mode', 'caption_entities', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
464 | + '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', 'return_array', 'forgot', 'answer'], |
|
465 | + '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', 'return_array', 'forgot', 'answer'], |
|
466 | + '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', 'return_array', 'forgot', 'answer'], |
|
467 | + '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', 'return_array', 'forgot', 'answer'], |
|
468 | + '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', 'return_array', 'forgot', 'answer'], |
|
469 | + 'sendVideoNote' => ['video_note', 'chat_id', 'duration', 'length', 'thumb', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
470 | + 'sendMediaGroup' => ['media', 'chat_id', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'token', 'return_array', 'forgot', 'answer'], |
|
471 | + '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', 'return_array', 'forgot', 'answer'], |
|
472 | + 'editMessageLiveLocation' => ['latitude', 'longitude', 'chat_id', 'message_id', 'inline_message_id', 'horizontal_accuracy', 'heading', 'proximity_alert_radius', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
473 | + 'stopMessageLiveLocation' => ['chat_id', 'message_id', 'inline_message_id', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
474 | + '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', 'return_array', 'forgot', 'answer'], |
|
475 | + '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', 'return_array', 'forgot', 'answer'], |
|
476 | + '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', 'return_array', 'forgot', 'answer'], |
|
477 | + 'sendDice' => ['chat_id', 'emoji', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
478 | + 'sendChatAction' => ['chat_id', 'action', 'token', 'return_array', 'forgot', 'answer'], |
|
479 | + 'getUserProfilePhotos' => ['user_id', 'offset', 'limit', 'token', 'return_array', 'forgot', 'answer'], |
|
480 | + 'getFile' => ['file_id', 'token', 'return_array', 'forgot', 'answer'], |
|
481 | + 'banChatMember' => ['chat_id', 'user_id', 'until_date', 'revoke_messages', 'token', 'return_array', 'forgot', 'answer'], |
|
482 | + 'unbanChatMember' => ['chat_id', 'user_id', 'only_if_banned', 'token', 'return_array', 'forgot', 'answer'], |
|
483 | + 'restrictChatMember' => ['permissions', 'chat_id', 'user_id', 'until_date', 'token', 'return_array', 'forgot', 'answer'], |
|
484 | + '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', 'return_array', 'forgot', 'answer'], |
|
485 | + 'setChatAdministratorCustomTitle' => ['custom_title', 'chat_id', 'user_id', 'token', 'return_array', 'forgot', 'answer'], |
|
486 | + 'banChatSenderChat' => ['sender_chat_id', 'chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
487 | + 'unbanChatSenderChat' => ['sender_chat_id', 'chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
488 | + 'setChatPermissions' => ['permissions', 'chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
489 | + 'exportChatInviteLink' => ['chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
490 | + 'createChatInviteLink' => ['chat_id', 'name', 'expire_date', 'member_limit', 'creates_join_request', 'token', 'return_array', 'forgot', 'answer'], |
|
491 | + 'editChatInviteLink' => ['invite_link', 'chat_id', 'name', 'expire_date', 'member_limit', 'creates_join_request', 'token', 'return_array', 'forgot', 'answer'], |
|
492 | + 'revokeChatInviteLink' => ['invite_link', 'chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
493 | + 'approveChatJoinRequest' => ['chat_id', 'user_id', 'token', 'return_array', 'forgot', 'answer'], |
|
494 | + 'declineChatJoinRequest' => ['chat_id', 'user_id', 'token', 'return_array', 'forgot', 'answer'], |
|
495 | + 'setChatPhoto' => ['photo', 'chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
496 | + 'deleteChatPhoto' => ['chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
497 | + 'setChatTitle' => ['title', 'chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
498 | + 'setChatDescription' => ['chat_id', 'description', 'token', 'return_array', 'forgot', 'answer'], |
|
499 | + 'pinChatMessage' => ['message_id', 'chat_id', 'disable_notification', 'token', 'return_array', 'forgot', 'answer'], |
|
500 | + 'unpinChatMessage' => ['chat_id', 'message_id', 'token', 'return_array', 'forgot', 'answer'], |
|
501 | + 'unpinAllChatMessages' => ['chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
502 | + 'leaveChat' => ['chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
503 | + 'getChat' => ['chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
504 | + 'getChatAdministrators' => ['chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
505 | + 'getChatMemberCount' => ['chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
506 | + 'getChatMember' => ['chat_id', 'user_id', 'token', 'return_array', 'forgot', 'answer'], |
|
507 | + 'setChatStickerSet' => ['sticker_set_name', 'chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
508 | + 'deleteChatStickerSet' => ['chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
509 | + 'answerCallbackQuery' => ['callback_query_id', 'text', 'show_alert', 'url', 'cache_time', 'token', 'return_array', 'forgot', 'answer'], |
|
510 | + 'setMyCommands' => ['commands', 'scope', 'language_code', 'token', 'return_array', 'forgot', 'answer'], |
|
511 | + 'deleteMyCommands' => ['scope', 'language_code', 'token', 'return_array', 'forgot', 'answer'], |
|
512 | + 'getMyCommands' => ['scope', 'language_code', 'token', 'return_array', 'forgot', 'answer'], |
|
513 | + 'setChatMenuButton' => ['chat_id', 'menu_button', 'token', 'return_array', 'forgot', 'answer'], |
|
514 | + 'getChatMenuButton' => ['chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
515 | + 'setMyDefaultAdministratorRights' => ['rights', 'for_channels', 'token', 'return_array', 'forgot', 'answer'], |
|
516 | + 'getMyDefaultAdministratorRights' => ['for_channels', 'token', 'return_array', 'forgot', 'answer'], |
|
517 | + 'editMessageText' => ['text', 'chat_id', 'message_id', 'inline_message_id', 'parse_mode', 'entities', 'disable_web_page_preview', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
518 | + 'editMessageCaption' => ['chat_id', 'message_id', 'inline_message_id', 'caption', 'parse_mode', 'caption_entities', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
519 | + 'editMessageMedia' => ['media', 'chat_id', 'message_id', 'inline_message_id', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
520 | + 'editMessageReplyMarkup' => ['chat_id', 'message_id', 'inline_message_id', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
521 | + 'stopPoll' => ['chat_id', 'message_id', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
522 | + 'deleteMessage' => ['chat_id', 'message_id', 'token', 'return_array', 'forgot', 'answer'], |
|
523 | + 'sendSticker' => ['sticker', 'chat_id', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
524 | + 'getStickerSet' => ['name', 'token', 'return_array', 'forgot', 'answer'], |
|
525 | + 'uploadStickerFile' => ['png_sticker', 'user_id', 'token', 'return_array', 'forgot', 'answer'], |
|
526 | + 'createNewStickerSet' => ['name', 'title', 'emojis', 'user_id', 'png_sticker', 'tgs_sticker', 'webm_sticker', 'contains_masks', 'mask_position', 'token', 'return_array', 'forgot', 'answer'], |
|
527 | + 'addStickerToSet' => ['name', 'emojis', 'user_id', 'png_sticker', 'tgs_sticker', 'webm_sticker', 'mask_position', 'token', 'return_array', 'forgot', 'answer'], |
|
528 | + 'setStickerPositionInSet' => ['sticker', 'position', 'token', 'return_array', 'forgot', 'answer'], |
|
529 | + 'deleteStickerFromSet' => ['sticker', 'token', 'return_array', 'forgot', 'answer'], |
|
530 | + 'setStickerSetThumb' => ['name', 'user_id', 'thumb', 'token', 'return_array', 'forgot', 'answer'], |
|
531 | + 'answerInlineQuery' => ['results', 'inline_query_id', 'cache_time', 'is_personal', 'next_offset', 'switch_pm_text', 'switch_pm_parameter', 'token', 'return_array', 'forgot', 'answer'], |
|
532 | + 'answerWebAppQuery' => ['web_app_query_id', 'result', 'token', 'return_array', 'forgot', 'answer'], |
|
533 | + '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', 'return_array', 'forgot', 'answer'], |
|
534 | + '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', 'return_array', 'forgot', 'answer'], |
|
535 | + 'answerShippingQuery' => ['ok', 'shipping_query_id', 'shipping_options', 'error_message', 'token', 'return_array', 'forgot', 'answer'], |
|
536 | + 'answerPreCheckoutQuery' => ['ok', 'pre_checkout_query_id', 'error_message', 'token', 'return_array', 'forgot', 'answer'], |
|
537 | + 'setPassportDataErrors' => ['errors', 'user_id', 'token', 'return_array', 'forgot', 'answer'], |
|
538 | + 'sendGame' => ['game_short_name', 'chat_id', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
539 | + 'setGameScore' => ['score', 'user_id', 'force', 'disable_edit_message', 'chat_id', 'message_id', 'inline_message_id', 'token', 'return_array', 'forgot', 'answer'], |
|
540 | + 'getGameHighScores' => ['user_id', 'chat_id', 'message_id', 'inline_message_id', 'token', 'return_array', 'forgot', 'answer'], |
|
541 | 541 | ]; |
542 | 542 | |
543 | 543 | private const METHODS_WITH_FILE = [ |
@@ -566,8 +566,8 @@ discard block |
||
566 | 566 | 'logOut' => [], |
567 | 567 | 'close' => [], |
568 | 568 | 'sendMessage' => ['chat_id'], |
569 | - 'forwardMessage' => ['from_chat_id','message_id'], |
|
570 | - 'copyMessage' => ['from_chat_id','message_id'], |
|
569 | + 'forwardMessage' => ['from_chat_id', 'message_id'], |
|
570 | + 'copyMessage' => ['from_chat_id', 'message_id'], |
|
571 | 571 | 'sendPhoto' => ['chat_id'], |
572 | 572 | 'sendAudio' => ['chat_id'], |
573 | 573 | 'sendDocument' => ['chat_id'], |
@@ -583,15 +583,15 @@ discard block |
||
583 | 583 | 'sendContact' => ['chat_id'], |
584 | 584 | 'sendPoll' => ['chat_id'], |
585 | 585 | 'sendDice' => ['chat_id'], |
586 | - 'sendChatAction' => ['chat_id','action'], |
|
586 | + 'sendChatAction' => ['chat_id', 'action'], |
|
587 | 587 | 'getUserProfilePhotos' => ['user_id'], |
588 | 588 | 'getFile' => ['file_id'], |
589 | - 'banChatMember' => ['chat_id','user_id'], |
|
590 | - 'kickChatMember' => ['chat_id','user_id'], |
|
591 | - 'unbanChatMember' => ['chat_id','user_id'], |
|
592 | - 'restrictChatMember' => ['chat_id','user_id'], |
|
593 | - 'promoteChatMember' => ['chat_id','user_id'], |
|
594 | - 'setChatAdministratorCustomTitle' => ['chat_id','user_id'], |
|
589 | + 'banChatMember' => ['chat_id', 'user_id'], |
|
590 | + 'kickChatMember' => ['chat_id', 'user_id'], |
|
591 | + 'unbanChatMember' => ['chat_id', 'user_id'], |
|
592 | + 'restrictChatMember' => ['chat_id', 'user_id'], |
|
593 | + 'promoteChatMember' => ['chat_id', 'user_id'], |
|
594 | + 'setChatAdministratorCustomTitle' => ['chat_id', 'user_id'], |
|
595 | 595 | 'banChatSenderChat' => ['chat_id'], |
596 | 596 | 'unbanChatSenderChat' => ['chat_id'], |
597 | 597 | 'setChatPermissions' => ['chat_id'], |
@@ -599,8 +599,8 @@ discard block |
||
599 | 599 | 'createChatInviteLink' => ['chat_id'], |
600 | 600 | 'editChatInviteLink' => ['chat_id'], |
601 | 601 | 'revokeChatInviteLink' => ['chat_id'], |
602 | - 'approveChatJoinRequest' => ['chat_id','user_id'], |
|
603 | - 'declineChatJoinRequest' => ['chat_id','user_id'], |
|
602 | + 'approveChatJoinRequest' => ['chat_id', 'user_id'], |
|
603 | + 'declineChatJoinRequest' => ['chat_id', 'user_id'], |
|
604 | 604 | 'setChatPhoto' => ['chat_id'], |
605 | 605 | 'deleteChatPhoto' => ['chat_id'], |
606 | 606 | 'setChatTitle' => ['chat_id'], |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | 'getChat' => ['chat_id'], |
613 | 613 | 'getChatAdministrators' => ['chat_id'], |
614 | 614 | 'getChatMembersCount' => ['chat_id'], |
615 | - 'getChatMember' => ['chat_id','user_id'], |
|
615 | + 'getChatMember' => ['chat_id', 'user_id'], |
|
616 | 616 | 'setChatStickerSet' => ['chat_id'], |
617 | 617 | 'deleteChatStickerSet' => ['chat_id'], |
618 | 618 | 'answerCallbackQuery' => ['callback_query_id'], |
@@ -623,12 +623,12 @@ discard block |
||
623 | 623 | 'getChatMenuButton' => [], |
624 | 624 | 'setMyDefaultAdministratorRights' => [], |
625 | 625 | 'getMyDefaultAdministratorRights' => [], |
626 | - 'editMessageText' => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
627 | - 'editMessageCaption' => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
628 | - 'editMessageMedia' => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
629 | - 'editMessageReplyMarkup' => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
630 | - 'stopPoll' => ['chat_id','message_id'], |
|
631 | - 'deleteMessage' => ['chat_id','message_id'], |
|
626 | + 'editMessageText' => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
627 | + 'editMessageCaption' => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
628 | + 'editMessageMedia' => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
629 | + 'editMessageReplyMarkup' => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
630 | + 'stopPoll' => ['chat_id', 'message_id'], |
|
631 | + 'deleteMessage' => ['chat_id', 'message_id'], |
|
632 | 632 | 'sendSticker' => ['chat_id'], |
633 | 633 | 'getStickerSet' => [], |
634 | 634 | 'uploadStickerFile' => ['user_id'], |
@@ -644,8 +644,8 @@ discard block |
||
644 | 644 | 'answerPreCheckoutQuery' => ['pre_checkout_query_id'], |
645 | 645 | 'setPassportDataErrors' => ['user_id'], |
646 | 646 | 'sendGame' => ['chat_id'], |
647 | - 'setGameScore' => ['user_id','inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
648 | - 'getGameHighScores' => ['user_id','inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']] |
|
647 | + 'setGameScore' => ['user_id', 'inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
648 | + 'getGameHighScores' => ['user_id', 'inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']] |
|
649 | 649 | ]; |
650 | 650 | |
651 | 651 | private const METHODS_RETURN = [ |
@@ -697,25 +697,25 @@ discard block |
||
697 | 697 | ]; |
698 | 698 | |
699 | 699 | |
700 | - public static function __callStatic (string $name, array $arguments) { |
|
700 | + public static function __callStatic(string $name, array $arguments) { |
|
701 | 701 | if ($action = self::methodAction($name)) { |
702 | - self::keysName($action,$arguments); |
|
703 | - self::readyFile($action,$arguments); |
|
704 | - self::setDefaults($action,$arguments); |
|
702 | + self::keysName($action, $arguments); |
|
703 | + self::readyFile($action, $arguments); |
|
704 | + self::setDefaults($action, $arguments); |
|
705 | 705 | if (isset($arguments['answer'])) { |
706 | - return answer::init($action,$arguments); |
|
706 | + return answer::init($action, $arguments); |
|
707 | 707 | } |
708 | 708 | else { |
709 | - return self::processResponse($action,curl::init($action,$arguments)); |
|
709 | + return self::processResponse($action, curl::init($action, $arguments)); |
|
710 | 710 | } |
711 | 711 | } |
712 | 712 | else { |
713 | - logger::write("$name method is not supported",loggerTypes::ERROR); |
|
713 | + logger::write("$name method is not supported", loggerTypes::ERROR); |
|
714 | 714 | throw new bptException('METHOD_NOT_FOUND'); |
715 | 715 | } |
716 | 716 | } |
717 | 717 | |
718 | - private static function keysName (string $name, array &$arguments): void { |
|
718 | + private static function keysName(string $name, array &$arguments): void { |
|
719 | 719 | foreach ($arguments as $key => $argument) { |
720 | 720 | if (is_numeric($key) && isset(self::METHODS_KEYS[$name][$key])) { |
721 | 721 | $arguments[self::METHODS_KEYS[$name][$key]] = $argument; |
@@ -724,7 +724,7 @@ discard block |
||
724 | 724 | } |
725 | 725 | } |
726 | 726 | |
727 | - private static function methodAction(string $name): string|false { |
|
727 | + private static function methodAction(string $name): string | false { |
|
728 | 728 | return self::METHODS_ACTION[str_replace('_', '', strtolower($name))] ?? false; |
729 | 729 | } |
730 | 730 | |
@@ -745,11 +745,11 @@ discard block |
||
745 | 745 | } |
746 | 746 | } |
747 | 747 | |
748 | - private static function methodFile(string $name): array|false { |
|
748 | + private static function methodFile(string $name): array | false { |
|
749 | 749 | return self::METHODS_WITH_FILE[$name] ?? false; |
750 | 750 | } |
751 | 751 | |
752 | - private static function methodReturn(string $name,stdClass $response) { |
|
752 | + private static function methodReturn(string $name, stdClass $response) { |
|
753 | 753 | if (isset(self::METHODS_RETURN[$name])) { |
754 | 754 | $return = self::METHODS_RETURN[$name]; |
755 | 755 | if (is_array($return)) { |
@@ -772,13 +772,13 @@ discard block |
||
772 | 772 | $defaults = self::METHODS_EXTRA_DEFAULTS[$name]; |
773 | 773 | foreach ($defaults as $key => $default) { |
774 | 774 | if (is_numeric($key)) { |
775 | - if (!isset($arguments[$default])){ |
|
775 | + if (!isset($arguments[$default])) { |
|
776 | 776 | $arguments[$default] = self::catchFields($default); |
777 | 777 | } |
778 | 778 | } |
779 | 779 | elseif (isset(BPT::$update->$key) || $key === 'other') { |
780 | 780 | foreach ($default as $def) { |
781 | - if (!isset($arguments[$def])){ |
|
781 | + if (!isset($arguments[$def])) { |
|
782 | 782 | $arguments[$def] = self::catchFields($def); |
783 | 783 | } |
784 | 784 | } |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | if ($response->ok) { |
792 | 792 | self::$status = true; |
793 | 793 | self::$pure_response = $response; |
794 | - return self::methodReturn($name,$response); |
|
794 | + return self::methodReturn($name, $response); |
|
795 | 795 | } |
796 | 796 | else { |
797 | 797 | self::$status = false; |
@@ -807,7 +807,7 @@ discard block |
||
807 | 807 | * |
808 | 808 | * @return int|string|bool |
809 | 809 | */ |
810 | - public static function catchFields (string $field): int|string|bool { |
|
810 | + public static function catchFields(string $field): int | string | bool { |
|
811 | 811 | switch ($field) { |
812 | 812 | case 'chat_id' : |
813 | 813 | case 'from_chat_id' : |
@@ -943,7 +943,7 @@ discard block |
||
943 | 943 | default => false |
944 | 944 | }; |
945 | 945 | case 'url' : |
946 | - return 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; |
|
946 | + return 'https://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; |
|
947 | 947 | default: |
948 | 948 | return false; |
949 | 949 | } |
@@ -5,7 +5,7 @@ |
||
5 | 5 | * telegram class , Adding normal method call to request class and a simple name for being easy to call |
6 | 6 | */ |
7 | 7 | class telegram extends request { |
8 | - public function __call (string $name, array $arguments) { |
|
8 | + public function __call(string $name, array $arguments) { |
|
9 | 9 | if (!isset($arguments[1]) && isset($arguments[0]) && is_array($arguments[0])) { |
10 | 10 | return request::$name(...$arguments[0]); |
11 | 11 | } |
@@ -14,12 +14,12 @@ 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 | 19 | return self::getUpdate(); |
20 | 20 | } |
21 | 21 | else { |
22 | - logger::write('not authorized access denied. IP : '. $_SERVER['REMOTE_ADDR'] ?? 'unknown',loggerTypes::WARNING); |
|
22 | + logger::write('not authorized access denied. IP : '.$_SERVER['REMOTE_ADDR'] ?? 'unknown', loggerTypes::WARNING); |
|
23 | 23 | BPT::exit(); |
24 | 24 | return null; |
25 | 25 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | return $_SERVER['REMOTE_ADDR'] === $_SERVER['SERVER_ADDR']; |
30 | 30 | } |
31 | 31 | |
32 | - private static function getUpdate (): string { |
|
32 | + private static function getUpdate(): string { |
|
33 | 33 | $input = json_decode(file_get_contents("php://input"), true); |
34 | 34 | webhook::telegramVerify($input['ip']); |
35 | 35 | return $input['update']; |
@@ -42,14 +42,14 @@ discard block |
||
42 | 42 | $urls = self::setURLS(); |
43 | 43 | $file = $urls['file']; |
44 | 44 | $timeout = self::getTimeout($file); |
45 | - self::create($file,$timeout); |
|
45 | + self::create($file, $timeout); |
|
46 | 46 | self::setWebhook($urls['url']); |
47 | 47 | lock::set('BPT-MULTI-CURL'); |
48 | 48 | } |
49 | 49 | |
50 | - private static function getTimeout($url): float|int { |
|
50 | + private static function getTimeout($url): float | int { |
|
51 | 51 | $times = []; |
52 | - for ($i = 0; $i < 10; $i ++) { |
|
52 | + for ($i = 0; $i < 10; $i++) { |
|
53 | 53 | $ch = curl_init($url); |
54 | 54 | 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']]); |
55 | 55 | $start = microtime(true); |
@@ -60,12 +60,12 @@ discard block |
||
60 | 60 | return $timeout > 50 ? $timeout + 10 : 50; |
61 | 61 | } |
62 | 62 | |
63 | - private static function create($file,$timeout) { |
|
64 | - 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);?>'); |
|
63 | + private static function create($file, $timeout) { |
|
64 | + 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);?>'); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | private static function setURLS(): array { |
68 | - $base_url = (isset(settings::$certificate) ? 'http://' : 'https://') . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; |
|
68 | + $base_url = (isset(settings::$certificate) ? 'http://' : 'https://').$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; |
|
69 | 69 | $file = basename($_SERVER['REQUEST_URI']); |
70 | 70 | return [ |
71 | 71 | 'url'=>str_replace($file, 'receiver.php', $base_url), |
@@ -17,8 +17,7 @@ |
||
17 | 17 | public static function init (): string|null { |
18 | 18 | if (self::checkIP()) { |
19 | 19 | return self::getUpdate(); |
20 | - } |
|
21 | - else { |
|
20 | + } else { |
|
22 | 21 | logger::write('not authorized access denied. IP : '. $_SERVER['REMOTE_ADDR'] ?? 'unknown',loggerTypes::WARNING); |
23 | 22 | BPT::exit(); |
24 | 23 | return null; |
@@ -17,11 +17,11 @@ 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 | 27 | $up = end($up); |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | return $update; |
33 | 33 | } |
34 | 34 | else { |
35 | - logger::write('not authorized access denied. IP : '. $_SERVER['REMOTE_ADDR'] ?? 'unknown',loggerTypes::WARNING); |
|
35 | + logger::write('not authorized access denied. IP : '.$_SERVER['REMOTE_ADDR'] ?? 'unknown', loggerTypes::WARNING); |
|
36 | 36 | BPT::exit(); |
37 | 37 | return null; |
38 | 38 | } |
@@ -59,11 +59,11 @@ discard block |
||
59 | 59 | } |
60 | 60 | |
61 | 61 | private static function create($file) { |
62 | - 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 &");'); |
|
62 | + 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 &");'); |
|
63 | 63 | } |
64 | 64 | |
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 | return [ |
68 | 68 | 'url'=>str_replace(basename($_SERVER['REQUEST_URI']), 'receiver.php', $base_url), |
69 | 69 | 'file'=>basename($_SERVER['SCRIPT_NAME']) |
@@ -30,8 +30,7 @@ |
||
30 | 30 | $update = file_get_contents($up); |
31 | 31 | unlink($up); |
32 | 32 | return $update; |
33 | - } |
|
34 | - else { |
|
33 | + } else { |
|
35 | 34 | logger::write('not authorized access denied. IP : '. $_SERVER['REMOTE_ADDR'] ?? 'unknown',loggerTypes::WARNING); |
36 | 35 | BPT::exit(); |
37 | 36 | return null; |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | /** |
20 | 20 | * @internal Only for BPT self usage , Don't use it in your source! |
21 | 21 | */ |
22 | - public static function init () { |
|
22 | + public static function init() { |
|
23 | 23 | if (settings::$multi) { |
24 | 24 | multi::init(); |
25 | 25 | } |
@@ -48,26 +48,26 @@ discard block |
||
48 | 48 | } |
49 | 49 | } |
50 | 50 | |
51 | - protected static function setWebhook(string $url,string $secret = '') { |
|
51 | + protected static function setWebhook(string $url, string $secret = '') { |
|
52 | 52 | $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); |
53 | 53 | if (telegram::$status) { |
54 | - logger::write('Webhook was set successfully',loggerTypes::INFO); |
|
54 | + logger::write('Webhook was set successfully', loggerTypes::INFO); |
|
55 | 55 | } |
56 | 56 | else { |
57 | - logger::write("There is some problem happened , telegram response : \n".json_encode($res),loggerTypes::ERROR); |
|
58 | - BPT::exit(print_r($res,true)); |
|
57 | + logger::write("There is some problem happened , telegram response : \n".json_encode($res), loggerTypes::ERROR); |
|
58 | + BPT::exit(print_r($res, true)); |
|
59 | 59 | } |
60 | 60 | } |
61 | 61 | |
62 | 62 | protected static function checkURL() { |
63 | 63 | if (!(isset($_SERVER['SERVER_NAME']) && isset($_SERVER['REQUEST_URI']))) { |
64 | - logger::write('For using webhook receiver , you should open this file in your webserver(by domain)',loggerTypes::ERROR); |
|
64 | + logger::write('For using webhook receiver , you should open this file in your webserver(by domain)', loggerTypes::ERROR); |
|
65 | 65 | throw new bptException('WEBHOOK_NEED_URL'); |
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
69 | 69 | private static function setURL(): string { |
70 | - return (isset(settings::$certificate) ? 'http://' : 'https://') . $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME']; |
|
70 | + return (isset(settings::$certificate) ? 'http://' : 'https://').$_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME']; |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | protected static function setCertificate() { |
@@ -89,15 +89,15 @@ discard block |
||
89 | 89 | self::setCertificate(); |
90 | 90 | $url = self::setURL(); |
91 | 91 | $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 | } |