@@ -13,8 +13,7 @@ |
||
| 13 | 13 | if (file_exists('BPT.log') && !(filesize('BPT.log') > self::$log_size * 1024 * 1024)) {
|
| 14 | 14 | $mode = 'a'; |
| 15 | 15 | $write = false; |
| 16 | - } |
|
| 17 | - else {
|
|
| 16 | + } else {
|
|
| 18 | 17 | $mode = 'w'; |
| 19 | 18 | $write = true; |
| 20 | 19 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | private static $handler; |
| 11 | 11 | |
| 12 | 12 | |
| 13 | - public static function init (int $log_size = 10) {
|
|
| 13 | + public static function init(int $log_size = 10) {
|
|
| 14 | 14 | self::$log_size = $log_size; |
| 15 | 15 | if (file_exists('BPT.log') && !(filesize('BPT.log') > self::$log_size * 1024 * 1024)) {
|
| 16 | 16 | $mode = 'a'; |
@@ -24,13 +24,13 @@ discard block |
||
| 24 | 24 | self::$handler = fopen('BPT.log', $mode);
|
| 25 | 25 | |
| 26 | 26 | if ($write) {
|
| 27 | - 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"); |
|
| 27 | + 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"); |
|
| 28 | 28 | } |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | public static function write(string $data, string $type = loggerTypes::NONE) {
|
| 32 | 32 | if (!is_null(self::$handler)) {
|
| 33 | - $text = date('Y/m/d H:i:s') . ( $type === loggerTypes::NONE ? " : $data\n\n" : " : ⤵\n$type : $data\n\n" );
|
|
| 33 | + $text = date('Y/m/d H:i:s').($type === loggerTypes::NONE ? " : $data\n\n" : " : ⤵\n$type : $data\n\n");
|
|
| 34 | 34 | fwrite(self::$handler, $text); |
| 35 | 35 | } |
| 36 | 36 | } |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | * @method static getGameHigh (int|null $user_id = null, int|null $chat_id = null, int|null $message_id = null, string|null $inline_message_id = null, string|null $token = null, bool|null $return_array = null, bool|null $forgot = null, bool|null $answer = null) Use this method to get data for high score tables. Will return the score of the specified user and several of their neighbors in a game. On success, returns an Array of GameHighScore objects. |
| 215 | 215 | */ |
| 216 | 216 | class telegram {
|
| 217 | - public function __call (string $name, array $arguments) {
|
|
| 217 | + public function __call(string $name, array $arguments) {
|
|
| 218 | 218 | if (!isset($arguments[1]) && is_array($arguments[0])) {
|
| 219 | 219 | request::$name(...$arguments[0]); |
| 220 | 220 | } |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | } |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - public static function __callStatic (string $name, array $arguments) {
|
|
| 226 | + public static function __callStatic(string $name, array $arguments) {
|
|
| 227 | 227 | if (!isset($arguments[1]) && is_array($arguments[0])) {
|
| 228 | 228 | request::$name(...$arguments[0]); |
| 229 | 229 | } |
@@ -6,8 +6,7 @@ discard block |
||
| 6 | 6 | public function __call (string $name, array $arguments) {
|
| 7 | 7 | if (!isset($arguments[1]) && is_array($arguments[0])) {
|
| 8 | 8 | request::$name(...$arguments[0]); |
| 9 | - } |
|
| 10 | - else {
|
|
| 9 | + } else {
|
|
| 11 | 10 | request::$name($arguments); |
| 12 | 11 | } |
| 13 | 12 | } |
@@ -15,8 +14,7 @@ discard block |
||
| 15 | 14 | public static function __callStatic (string $name, array $arguments) {
|
| 16 | 15 | if (!isset($arguments[1]) && is_array($arguments[0])) {
|
| 17 | 16 | request::$name(...$arguments[0]); |
| 18 | - } |
|
| 19 | - else {
|
|
| 17 | + } else {
|
|
| 20 | 18 | request::$name(...$arguments); |
| 21 | 19 | } |
| 22 | 20 | } |
@@ -225,18 +225,18 @@ discard block |
||
| 225 | 225 | ]; |
| 226 | 226 | |
| 227 | 227 | |
| 228 | - public static function __callStatic (string $name, array $arguments) {
|
|
| 228 | + public static function __callStatic(string $name, array $arguments) {
|
|
| 229 | 229 | if ($action = self::methodAction($name)) {
|
| 230 | - self::keysName($action,$arguments); |
|
| 231 | - self::readyFile($action,$arguments); |
|
| 230 | + self::keysName($action, $arguments); |
|
| 231 | + self::readyFile($action, $arguments); |
|
| 232 | 232 | print_r($arguments); |
| 233 | 233 | } |
| 234 | 234 | else {
|
| 235 | - logger::write("$name method is not supported",'error');
|
|
| 235 | + logger::write("$name method is not supported", 'error');
|
|
| 236 | 236 | } |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - private static function keysName (string $name, array &$arguments) {
|
|
| 239 | + private static function keysName(string $name, array &$arguments) {
|
|
| 240 | 240 | foreach ($arguments as $key => $argument) {
|
| 241 | 241 | if (is_numeric($key) && isset(self::METHODS_KEYS[$name][$key])) {
|
| 242 | 242 | $arguments[self::METHODS_KEYS[$name][$key]] = $argument; |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | } |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - private static function methodAction(string $name): string|false {
|
|
| 248 | + private static function methodAction(string $name): string | false {
|
|
| 249 | 249 | return self::METHODS_ACTION[strtolower($name)] ?? false; |
| 250 | 250 | } |
| 251 | 251 | |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | } |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - private static function methodFile(string $name): array|false {
|
|
| 269 | + private static function methodFile(string $name): array | false {
|
|
| 270 | 270 | return self::METHODS_WITH_FILE[$name] ?? false; |
| 271 | 271 | } |
| 272 | 272 | } |
| 273 | 273 | \ No newline at end of file |
@@ -230,8 +230,7 @@ discard block |
||
| 230 | 230 | self::keysName($action,$arguments); |
| 231 | 231 | self::readyFile($action,$arguments); |
| 232 | 232 | print_r($arguments); |
| 233 | - } |
|
| 234 | - else {
|
|
| 233 | + } else {
|
|
| 235 | 234 | logger::write("$name method is not supported",'error');
|
| 236 | 235 | } |
| 237 | 236 | } |
@@ -256,8 +255,7 @@ discard block |
||
| 256 | 255 | $arguments['media'][$key]['media'] = new CURLFile($media['media']); |
| 257 | 256 | } |
| 258 | 257 | } |
| 259 | - } |
|
| 260 | - elseif ($file_params = self::methodFile($name)) {
|
|
| 258 | + } elseif ($file_params = self::methodFile($name)) {
|
|
| 261 | 259 | foreach ($file_params as $param) {
|
| 262 | 260 | if (isset($arguments[$param]) && file_exists($arguments[$param])) {
|
| 263 | 261 | $arguments[$param] = new CURLFile($arguments[$param]); |
@@ -11,16 +11,16 @@ |
||
| 11 | 11 | return touch("$name.lock");
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | - public static function save(string $name, string $data): bool|int {
|
|
| 14 | + public static function save(string $name, string $data): bool | int {
|
|
| 15 | 15 | return file_put_contents("$name.lock", $data);
|
| 16 | 16 | |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - public static function read(string $name): bool|string {
|
|
| 19 | + public static function read(string $name): bool | string {
|
|
| 20 | 20 | return file_get_contents("$name.lock");
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - public static function mtime(string $name): bool|int {
|
|
| 23 | + public static function mtime(string $name): bool | int {
|
|
| 24 | 24 | return filemtime("$name.lock");
|
| 25 | 25 | } |
| 26 | 26 | |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | if (lock::exist('BPT-MULTI-EXEC')) {
|
| 14 | 14 | self::setUpdate(exec::init()); |
| 15 | 15 | } |
| 16 | - elseif(lock::exist('BPT-MULTI-CURL')) {
|
|
| 16 | + elseif (lock::exist('BPT-MULTI-CURL')) {
|
|
| 17 | 17 | self::setUpdate(curl::init()); |
| 18 | 18 | } |
| 19 | 19 | else {
|
@@ -12,11 +12,9 @@ |
||
| 12 | 12 | public static function init() {
|
| 13 | 13 | if (lock::exist('BPT-MULTI-EXEC')) {
|
| 14 | 14 | self::setUpdate(exec::init()); |
| 15 | - } |
|
| 16 | - elseif(lock::exist('BPT-MULTI-CURL')) {
|
|
| 15 | + } elseif(lock::exist('BPT-MULTI-CURL')) {
|
|
| 17 | 16 | self::setUpdate(curl::init()); |
| 18 | - } |
|
| 19 | - else {
|
|
| 17 | + } else {
|
|
| 20 | 18 | self::deleteOldLocks(); |
| 21 | 19 | self::checkURL(); |
| 22 | 20 | self::setCertificate(); |
@@ -9,19 +9,19 @@ discard block |
||
| 9 | 9 | use stdClass; |
| 10 | 10 | |
| 11 | 11 | class getUpdates extends receiver {
|
| 12 | - public static function init () {
|
|
| 12 | + public static function init() {
|
|
| 13 | 13 | $last_update_id = self::loadData(); |
| 14 | - while(true) {
|
|
| 14 | + while (true) {
|
|
| 15 | 15 | if (!lock::exist('getUpdate')) {
|
| 16 | - $updates = telegram::getUpdates($last_update_id,allowed_updates: settings::$allowed_updates)->result; |
|
| 16 | + $updates = telegram::getUpdates($last_update_id, allowed_updates: settings::$allowed_updates)->result; |
|
| 17 | 17 | self::handleUpdates($updates); |
| 18 | - lock::save('getUpdate',BPT::$update->update_id+1);
|
|
| 19 | - $last_update_id = BPT::$update->update_id+1; |
|
| 18 | + lock::save('getUpdate', BPT::$update->update_id + 1);
|
|
| 19 | + $last_update_id = BPT::$update->update_id + 1; |
|
| 20 | 20 | } |
| 21 | 21 | } |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - private static function loadData(): bool|int|string {
|
|
| 24 | + private static function loadData(): bool | int | string {
|
|
| 25 | 25 | if (lock::exist('getUpdate')) {
|
| 26 | 26 | $last_update_id = lock::read('getUpdate');
|
| 27 | 27 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | self::deleteOldLocks(); |
| 30 | 30 | telegram::deleteWebhook(); |
| 31 | 31 | $last_update_id = 0; |
| 32 | - lock::save('getUpdate',0);
|
|
| 32 | + lock::save('getUpdate', 0);
|
|
| 33 | 33 | } |
| 34 | 34 | return $last_update_id; |
| 35 | 35 | } |
@@ -24,8 +24,7 @@ |
||
| 24 | 24 | private static function loadData(): bool|int|string {
|
| 25 | 25 | if (lock::exist('getUpdate')) {
|
| 26 | 26 | $last_update_id = lock::read('getUpdate');
|
| 27 | - } |
|
| 28 | - else {
|
|
| 27 | + } else {
|
|
| 29 | 28 | self::deleteOldLocks(); |
| 30 | 29 | telegram::deleteWebhook(); |
| 31 | 30 | $last_update_id = 0; |
@@ -14,14 +14,12 @@ discard block |
||
| 14 | 14 | public static function init () {
|
| 15 | 15 | if (settings::$multi) {
|
| 16 | 16 | multi::init(); |
| 17 | - } |
|
| 18 | - else {
|
|
| 17 | + } else {
|
|
| 19 | 18 | if (lock::exist('BPT-HOOK')) {
|
| 20 | 19 | receiver::telegramVerify(); |
| 21 | 20 | receiver::processUpdate(); |
| 22 | 21 | logger::write('Update received , lets process it ;)');
|
| 23 | - } |
|
| 24 | - else {
|
|
| 22 | + } else {
|
|
| 25 | 23 | self::deleteOldLocks(); |
| 26 | 24 | self::checkURL(); |
| 27 | 25 | self::setCertificate(); |
@@ -49,8 +47,7 @@ discard block |
||
| 49 | 47 | $res = telegram::setWebhook($url, settings::$certificate, max_connections:settings::$max_connection, allowed_updates : settings::$allowed_updates); |
| 50 | 48 | if ($res->ok) {
|
| 51 | 49 | logger::write('Webhook was set successfully',loggerTypes::INFO);
|
| 52 | - } |
|
| 53 | - else {
|
|
| 50 | + } else {
|
|
| 54 | 51 | logger::write("There is some problem happened , telegram response : \n".json_encode($res),loggerTypes::ERROR);
|
| 55 | 52 | BPT::exit(print_r($res,true)); |
| 56 | 53 | } |
@@ -72,8 +69,7 @@ discard block |
||
| 72 | 69 | if (is_string(settings::$certificate)) {
|
| 73 | 70 | if (file_exists(settings::$certificate)) {
|
| 74 | 71 | settings::$certificate = new CURLFile(settings::$certificate); |
| 75 | - } |
|
| 76 | - else {
|
|
| 72 | + } else {
|
|
| 77 | 73 | settings::$certificate = null; |
| 78 | 74 | } |
| 79 | 75 | } |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | use CURLFile; |
| 13 | 13 | |
| 14 | 14 | class webhook extends receiver {
|
| 15 | - public static function init () {
|
|
| 15 | + public static function init() {
|
|
| 16 | 16 | if (settings::$multi) {
|
| 17 | 17 | multi::init(); |
| 18 | 18 | } |
@@ -49,23 +49,23 @@ discard block |
||
| 49 | 49 | protected static function setWebhook(string $url) {
|
| 50 | 50 | $res = telegram::setWebhook($url, settings::$certificate, max_connections:settings::$max_connection, allowed_updates : settings::$allowed_updates); |
| 51 | 51 | if ($res->ok) {
|
| 52 | - logger::write('Webhook was set successfully',loggerTypes::INFO);
|
|
| 52 | + logger::write('Webhook was set successfully', loggerTypes::INFO);
|
|
| 53 | 53 | } |
| 54 | 54 | else {
|
| 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 | 58 | } |
| 59 | 59 | |
| 60 | 60 | protected static function checkURL() {
|
| 61 | 61 | if (!(isset($_SERVER['SERVER_NAME']) && isset($_SERVER['REQUEST_URI']))) {
|
| 62 | - logger::write('For using webhook receiver , you should open this file in your webserver(by domain)',loggerTypes::ERROR);
|
|
| 62 | + logger::write('For using webhook receiver , you should open this file in your webserver(by domain)', loggerTypes::ERROR);
|
|
| 63 | 63 | throw new bptException('WEBHOOK_NEED_URL');
|
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | private static function setURL(): string {
|
| 68 | - return (isset(settings::$certificate) ? 'http://' : 'https://') . $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME']; |
|
| 68 | + return (isset(settings::$certificate) ? 'http://' : 'https://').$_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME']; |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | protected static function setCertificate() {
|
@@ -63,26 +63,21 @@ |
||
| 63 | 63 | if (self::handlerExist('message')) {
|
| 64 | 64 | BPT::$handler->message(BPT::$update->message); |
| 65 | 65 | } |
| 66 | - } |
|
| 67 | - elseif (isset(BPT::$update->callback_query)) {
|
|
| 66 | + } elseif (isset(BPT::$update->callback_query)) {
|
|
| 68 | 67 | if (self::handlerExist('callback_query')) {
|
| 69 | 68 | BPT::$handler->callback_query(BPT::$update->callback_query); |
| 70 | 69 | } |
| 71 | - } |
|
| 72 | - elseif (isset(BPT::$update->inline_query)) {
|
|
| 70 | + } elseif (isset(BPT::$update->inline_query)) {
|
|
| 73 | 71 | if (self::handlerExist('inline_query')) {
|
| 74 | 72 | BPT::$handler->inline_query(BPT::$update->inline_query); |
| 75 | 73 | } |
| 76 | - } |
|
| 77 | - elseif (isset(BPT::$update->edited_message)) {
|
|
| 74 | + } elseif (isset(BPT::$update->edited_message)) {
|
|
| 78 | 75 | if (self::handlerExist('edited_message')) {
|
| 79 | 76 | BPT::$handler->edited_message(BPT::$update->edited_message); |
| 80 | 77 | } |
| 81 | - } |
|
| 82 | - elseif (self::handlerExist('something_else')) {
|
|
| 78 | + } elseif (self::handlerExist('something_else')) {
|
|
| 83 | 79 | BPT::$handler->something_else(BPT::$update); |
| 84 | - } |
|
| 85 | - else {
|
|
| 80 | + } else {
|
|
| 86 | 81 | logger::write('Update received but handlers does not set',loggerTypes::WARNING);
|
| 87 | 82 | } |
| 88 | 83 | } |
@@ -22,13 +22,13 @@ discard block |
||
| 22 | 22 | protected static function telegramVerify(string $ip = null) {
|
| 23 | 23 | if (settings::$telegram_verify) {
|
| 24 | 24 | if (!tools::isTelegram($ip ?? $_SERVER['REMOTE_ADDR'] ?? '')) {
|
| 25 | - logger::write('not authorized access denied. IP : '. $ip ?? $_SERVER['REMOTE_ADDR'] ?? 'unknown',loggerTypes::WARNING);
|
|
| 25 | + logger::write('not authorized access denied. IP : '.$ip ?? $_SERVER['REMOTE_ADDR'] ?? 'unknown', loggerTypes::WARNING);
|
|
| 26 | 26 | BPT::exit(); |
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - protected static function processUpdate(string|stdClass $update = null) {
|
|
| 31 | + protected static function processUpdate(string | stdClass $update = null) {
|
|
| 32 | 32 | if (!is_object($update)) {
|
| 33 | 33 | $update = json_decode($update ?? file_get_contents("php://input"));
|
| 34 | 34 | if (!$update) {
|
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | self::processHandler(); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - protected static function setMessageExtra (update &$update) {
|
|
| 44 | + protected static function setMessageExtra(update & $update) {
|
|
| 45 | 45 | if ((isset($update->message) && isset($update->message->text)) || (isset($update->edited_message) && isset($update->edited_message->text))) {
|
| 46 | 46 | $type = isset($update->message) ? 'message' : 'edited_message'; |
| 47 | 47 | $text = &$update->$type->text; |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | BPT::$handler->something_else(BPT::$update); |
| 90 | 90 | } |
| 91 | 91 | else {
|
| 92 | - logger::write('Update received but handlers does not set',loggerTypes::WARNING);
|
|
| 92 | + logger::write('Update received but handlers does not set', loggerTypes::WARNING);
|
|
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | } |
@@ -36,8 +36,7 @@ discard block |
||
| 36 | 36 | $curl_handler = curl_init(settings::$base_url."$token/"); |
| 37 | 37 | curl_setopt($curl_handler, CURLOPT_RETURNTRANSFER, true); |
| 38 | 38 | curl_setopt($curl_handler, CURLOPT_SSL_VERIFYPEER, false); |
| 39 | - } |
|
| 40 | - else{
|
|
| 39 | + } else{
|
|
| 41 | 40 | $token = settings::$token; |
| 42 | 41 | if (!isset(self::$curl_handler)){
|
| 43 | 42 | self::$curl_handler = curl_init(settings::$base_url."$token/"); |
@@ -59,11 +58,9 @@ discard block |
||
| 59 | 58 | if (isset($data['forgot'])) {
|
| 60 | 59 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, settings::$forgot_time); |
| 61 | 60 | unset($data['forgot']); |
| 62 | - } |
|
| 63 | - elseif ($method === 'getUpdates'){
|
|
| 61 | + } elseif ($method === 'getUpdates'){
|
|
| 64 | 62 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, 5000); |
| 65 | - } |
|
| 66 | - else{
|
|
| 63 | + } else{
|
|
| 67 | 64 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, 300); |
| 68 | 65 | } |
| 69 | 66 | } |
@@ -10,17 +10,17 @@ discard block |
||
| 10 | 10 | class curl {
|
| 11 | 11 | private static CurlHandle $curl_handler; |
| 12 | 12 | |
| 13 | - public static function init(string $method,array $data) {
|
|
| 13 | + public static function init(string $method, array $data) {
|
|
| 14 | 14 | $info = self::getInfo($data); |
| 15 | 15 | $data = $info['data']; |
| 16 | 16 | $handler = $info['handler']; |
| 17 | - self::setTimeout($data,$handler,$method); |
|
| 17 | + self::setTimeout($data, $handler, $method); |
|
| 18 | 18 | self::setData($data); |
| 19 | 19 | $data['method'] = $method; |
| 20 | 20 | curl_setopt($handler, CURLOPT_POSTFIELDS, $data); |
| 21 | 21 | $result = curl_exec($handler); |
| 22 | 22 | if (curl_errno($handler)) {
|
| 23 | - logger::write(curl_error($handler),loggerTypes::WARNING); |
|
| 23 | + logger::write(curl_error($handler), loggerTypes::WARNING); |
|
| 24 | 24 | } |
| 25 | 25 | if ($info['token'] != settings::$token) {
|
| 26 | 26 | curl_close($handler); |
@@ -36,9 +36,9 @@ discard block |
||
| 36 | 36 | curl_setopt($curl_handler, CURLOPT_RETURNTRANSFER, true); |
| 37 | 37 | curl_setopt($curl_handler, CURLOPT_SSL_VERIFYPEER, false); |
| 38 | 38 | } |
| 39 | - else{
|
|
| 39 | + else {
|
|
| 40 | 40 | $token = settings::$token; |
| 41 | - if (!isset(self::$curl_handler)){
|
|
| 41 | + if (!isset(self::$curl_handler)) {
|
|
| 42 | 42 | self::$curl_handler = curl_init(settings::$base_url."$token/"); |
| 43 | 43 | curl_setopt(self::$curl_handler, CURLOPT_RETURNTRANSFER, true); |
| 44 | 44 | curl_setopt(self::$curl_handler, CURLOPT_SSL_VERIFYPEER, false); |
@@ -54,22 +54,22 @@ discard block |
||
| 54 | 54 | ]; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - private static function setTimeout(array &$data , CurlHandle $curl_handler,string $method) {
|
|
| 57 | + private static function setTimeout(array &$data, CurlHandle $curl_handler, string $method) {
|
|
| 58 | 58 | if (isset($data['forgot'])) {
|
| 59 | 59 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, settings::$forgot_time); |
| 60 | 60 | unset($data['forgot']); |
| 61 | 61 | } |
| 62 | - elseif ($method === 'getUpdates'){
|
|
| 62 | + elseif ($method === 'getUpdates') {
|
|
| 63 | 63 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, 5000); |
| 64 | 64 | } |
| 65 | - else{
|
|
| 65 | + else {
|
|
| 66 | 66 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, 300); |
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | private static function setData(array &$data) {
|
| 71 | - foreach ($data as &$value){
|
|
| 72 | - if (is_array($value) || (is_object($value) && !is_a($value,'CURLFile'))){
|
|
| 71 | + foreach ($data as &$value) {
|
|
| 72 | + if (is_array($value) || (is_object($value) && !is_a($value, 'CURLFile'))) {
|
|
| 73 | 73 | $value = json_encode($value); |
| 74 | 74 | } |
| 75 | 75 | } |