@@ -6,3525 +6,3525 @@ |
||
| 6 | 6 | * Emojis class for simple emoji usage |
| 7 | 7 | */ |
| 8 | 8 | class emojis { |
| 9 | - public const GRINNING_FACE = ' |
|
@@ -6,19 +6,19 @@ |
||
| 6 | 6 | * types of message entity |
| 7 | 7 | */ |
| 8 | 8 | class messageEntityTypes { |
| 9 | - public const MENTION = 'mention'; |
|
| 10 | - public const HASHTAG = 'hashtag'; |
|
| 11 | - public const CASHTAG = 'cashtag'; |
|
| 12 | - public const BOT_COMMAND = 'bot_command'; |
|
| 13 | - public const URL = 'url'; |
|
| 14 | - public const EMAIL = 'email'; |
|
| 15 | - public const PHONE_NUMBER = 'phone_number'; |
|
| 16 | - public const BOLD = 'bold'; |
|
| 17 | - public const ITALIC = 'italic'; |
|
| 18 | - public const UNDERLINE = 'underline'; |
|
| 19 | - public const STRIKETHROUGH = 'strikethrough'; |
|
| 20 | - public const CODE = 'code'; |
|
| 21 | - public const PRE = 'pre'; |
|
| 22 | - public const TEXT_LINK = 'text_link'; |
|
| 23 | - public const TEXT_MENTION = 'text_mention'; |
|
| 9 | + public const MENTION = 'mention'; |
|
| 10 | + public const HASHTAG = 'hashtag'; |
|
| 11 | + public const CASHTAG = 'cashtag'; |
|
| 12 | + public const BOT_COMMAND = 'bot_command'; |
|
| 13 | + public const URL = 'url'; |
|
| 14 | + public const EMAIL = 'email'; |
|
| 15 | + public const PHONE_NUMBER = 'phone_number'; |
|
| 16 | + public const BOLD = 'bold'; |
|
| 17 | + public const ITALIC = 'italic'; |
|
| 18 | + public const UNDERLINE = 'underline'; |
|
| 19 | + public const STRIKETHROUGH = 'strikethrough'; |
|
| 20 | + public const CODE = 'code'; |
|
| 21 | + public const PRE = 'pre'; |
|
| 22 | + public const TEXT_LINK = 'text_link'; |
|
| 23 | + public const TEXT_MENTION = 'text_mention'; |
|
| 24 | 24 | } |
@@ -6,21 +6,21 @@ |
||
| 6 | 6 | * User status in the chat |
| 7 | 7 | */ |
| 8 | 8 | class chatMemberStatus { |
| 9 | - /** The creator of the chat */ |
|
| 10 | - public const CREATOR = 'creator'; |
|
| 9 | + /** The creator of the chat */ |
|
| 10 | + public const CREATOR = 'creator'; |
|
| 11 | 11 | |
| 12 | - /** The admin of the chat */ |
|
| 13 | - public const ADMINISTRATOR = 'administrator'; |
|
| 12 | + /** The admin of the chat */ |
|
| 13 | + public const ADMINISTRATOR = 'administrator'; |
|
| 14 | 14 | |
| 15 | - /** The member of the chat */ |
|
| 16 | - public const MEMBER = 'member'; |
|
| 15 | + /** The member of the chat */ |
|
| 16 | + public const MEMBER = 'member'; |
|
| 17 | 17 | |
| 18 | - /** Restricted in the chat */ |
|
| 19 | - public const RESTRICTED = 'restricted'; |
|
| 18 | + /** Restricted in the chat */ |
|
| 19 | + public const RESTRICTED = 'restricted'; |
|
| 20 | 20 | |
| 21 | - /** Left or not joined in the chat */ |
|
| 22 | - public const LEFT = 'left'; |
|
| 21 | + /** Left or not joined in the chat */ |
|
| 22 | + public const LEFT = 'left'; |
|
| 23 | 23 | |
| 24 | - /** Kicked in the chat */ |
|
| 25 | - public const KICKED = 'kicked'; |
|
| 24 | + /** Kicked in the chat */ |
|
| 25 | + public const KICKED = 'kicked'; |
|
| 26 | 26 | } |
@@ -6,10 +6,10 @@ |
||
| 6 | 6 | * Different type of passport sources |
| 7 | 7 | */ |
| 8 | 8 | class passportSources { |
| 9 | - public const DATA = 'data'; |
|
| 10 | - public const FRONT_SIDE = 'front_side'; |
|
| 11 | - public const REVERSE_SIDE = 'reverse_side'; |
|
| 12 | - public const SELFIE = 'selfie'; |
|
| 13 | - public const FILE = 'file'; |
|
| 14 | - public const FILES = 'files'; |
|
| 9 | + public const DATA = 'data'; |
|
| 10 | + public const FRONT_SIDE = 'front_side'; |
|
| 11 | + public const REVERSE_SIDE = 'reverse_side'; |
|
| 12 | + public const SELFIE = 'selfie'; |
|
| 13 | + public const FILE = 'file'; |
|
| 14 | + public const FILES = 'files'; |
|
| 15 | 15 | } |
@@ -6,8 +6,8 @@ |
||
| 6 | 6 | * Mask positions point which you can use in Sticker |
| 7 | 7 | */ |
| 8 | 8 | class maskPositionPoint { |
| 9 | - public const FOREHEAD = 'forehead'; |
|
| 10 | - public const EYES = 'eyes'; |
|
| 11 | - public const MOUTH = 'mouth'; |
|
| 12 | - public const CHIN = 'chin'; |
|
| 9 | + public const FOREHEAD = 'forehead'; |
|
| 10 | + public const EYES = 'eyes'; |
|
| 11 | + public const MOUTH = 'mouth'; |
|
| 12 | + public const CHIN = 'chin'; |
|
| 13 | 13 | } |
@@ -6,24 +6,24 @@ |
||
| 6 | 6 | * types of message entity |
| 7 | 7 | */ |
| 8 | 8 | class telegramLimits { |
| 9 | - /** Download file limit in Byte. (20 MB). For the moment, bots can download files of up to 20MB in size. */ |
|
| 10 | - public const DOWNLOAD = '20971520'; |
|
| 9 | + /** Download file limit in Byte. (20 MB). For the moment, bots can download files of up to 20MB in size. */ |
|
| 10 | + public const DOWNLOAD = '20971520'; |
|
| 11 | 11 | |
| 12 | - /** Upload file limit in Byte. (50 MB) */ |
|
| 13 | - public const UPLOAD = '52428800'; |
|
| 12 | + /** Upload file limit in Byte. (50 MB) */ |
|
| 13 | + public const UPLOAD = '52428800'; |
|
| 14 | 14 | |
| 15 | - /** Caption max characters length */ |
|
| 16 | - public const CAPTION_LENGTH = '1024'; |
|
| 15 | + /** Caption max characters length */ |
|
| 16 | + public const CAPTION_LENGTH = '1024'; |
|
| 17 | 17 | |
| 18 | - /** Text max characters length */ |
|
| 19 | - public const TEXT_LENGTH = '4096'; |
|
| 18 | + /** Text max characters length */ |
|
| 19 | + public const TEXT_LENGTH = '4096'; |
|
| 20 | 20 | |
| 21 | - /** Minimum period in seconds for which the location will be updated (1 minute) */ |
|
| 22 | - public const MIN_LIVE_PERIOD = '60'; |
|
| 21 | + /** Minimum period in seconds for which the location will be updated (1 minute) */ |
|
| 22 | + public const MIN_LIVE_PERIOD = '60'; |
|
| 23 | 23 | |
| 24 | - /** Maximum period in seconds for which the location will be updated (24 hours) */ |
|
| 25 | - public const MAX_LIVE_PERIOD = '86400'; |
|
| 24 | + /** Maximum period in seconds for which the location will be updated (24 hours) */ |
|
| 25 | + public const MAX_LIVE_PERIOD = '86400'; |
|
| 26 | 26 | |
| 27 | - /** Maximum poll question length */ |
|
| 28 | - public const POLL_QUESTION_LENGTH = '300'; |
|
| 27 | + /** Maximum poll question length */ |
|
| 28 | + public const POLL_QUESTION_LENGTH = '300'; |
|
| 29 | 29 | } |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * @param string $range Your range ip for check , if you didn't specify the block , it will be 32 |
| 33 | 33 | * @return bool |
| 34 | 34 | */ |
| 35 | - public static function ipInRange (string $ip, string $range): bool {
|
|
| 35 | + public static function ipInRange(string $ip, string $range): bool {
|
|
| 36 | 36 | if (!str_contains($range, '/')) {
|
| 37 | 37 | $range .= '/32'; |
| 38 | 38 | } |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * @param string $ip Your ip to be check is telegram or not e.g. '192.168.1.1' |
| 52 | 52 | * @return bool |
| 53 | 53 | */ |
| 54 | - public static function isTelegram (string $ip): bool {
|
|
| 54 | + public static function isTelegram(string $ip): bool {
|
|
| 55 | 55 | return self::ipInRange($ip, '149.154.160.0/20') || self::ipInRange($ip, '91.108.4.0/22'); |
| 56 | 56 | } |
| 57 | 57 | |
@@ -65,10 +65,10 @@ discard block |
||
| 65 | 65 | * @param string $ip Your ip to be check is CloudFlare or not e.g. '192.168.1.1' |
| 66 | 66 | * @return bool |
| 67 | 67 | */ |
| 68 | - public static function isCloudFlare (string $ip): bool {
|
|
| 68 | + public static function isCloudFlare(string $ip): bool {
|
|
| 69 | 69 | $cf_ips = ['173.245.48.0/20', '103.21.244.0/22', '103.22.200.0/22', '103.31.4.0/22', '141.101.64.0/18', '108.162.192.0/18', '190.93.240.0/20', '188.114.96.0/20', '197.234.240.0/22', '198.41.128.0/17', '162.158.0.0/15', '104.16.0.0/12', '172.64.0.0/13', '131.0.72.0/22']; |
| 70 | 70 | foreach ($cf_ips as $cf_ip) {
|
| 71 | - if (self::ipInRange($ip,$cf_ip)) {
|
|
| 71 | + if (self::ipInRange($ip, $cf_ip)) {
|
|
| 72 | 72 | return true; |
| 73 | 73 | } |
| 74 | 74 | } |
@@ -89,9 +89,9 @@ discard block |
||
| 89 | 89 | * @param bool $verify check token with telegram or not |
| 90 | 90 | * @return bool|array return array when verify is active and token is true array of telegram getMe result |
| 91 | 91 | */ |
| 92 | - public static function isToken (string $token, bool $verify = false): bool|array {
|
|
| 92 | + public static function isToken(string $token, bool $verify = false): bool | array {
|
|
| 93 | 93 | if (preg_match('/^(\d{8,10}):[\w\-]{35}$/', $token)) {
|
| 94 | - if ($verify){
|
|
| 94 | + if ($verify) {
|
|
| 95 | 95 | $res = telegram::me($token); |
| 96 | 96 | if ($res['ok']) {
|
| 97 | 97 | return $res['result']; |
@@ -122,10 +122,10 @@ discard block |
||
| 122 | 122 | * @param string $characters e.g. => 'abcdefg' |
| 123 | 123 | * @return string |
| 124 | 124 | */ |
| 125 | - public static function randomString (int $length = 16, string $characters = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'): string {
|
|
| 125 | + public static function randomString(int $length = 16, string $characters = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'): string {
|
|
| 126 | 126 | $rand_string = ''; |
| 127 | 127 | $char_len = strlen($characters) - 1; |
| 128 | - for ($i = 0; $i < $length; $i ++) {
|
|
| 128 | + for ($i = 0; $i < $length; $i++) {
|
|
| 129 | 129 | $rand_string .= $characters[rand(0, $char_len)]; |
| 130 | 130 | } |
| 131 | 131 | return $rand_string; |
@@ -144,10 +144,10 @@ discard block |
||
| 144 | 144 | * @param string $mode Your selected mode e.g. => `parseMode::HTML` | `HTML` |
| 145 | 145 | * @return string|false return false when mode is incorrect |
| 146 | 146 | */ |
| 147 | - public static function modeEscape (string $text, string $mode = parseMode::HTML): string|false {
|
|
| 147 | + public static function modeEscape(string $text, string $mode = parseMode::HTML): string | false {
|
|
| 148 | 148 | return match ($mode) {
|
| 149 | - parseMode::HTML => str_replace(['&', '<', '>',], ["&", "<", ">",], $text), |
|
| 150 | - parseMode::MARKDOWN => str_replace(['\\', '_', '*', '`', '['], ['\\\\', '\_', '\*', '\`', '\[',], $text), |
|
| 149 | + parseMode::HTML => str_replace(['&', '<', '>', ], ["&", "<", ">", ], $text), |
|
| 150 | + parseMode::MARKDOWN => str_replace(['\\', '_', '*', '`', '['], ['\\\\', '\_', '\*', '\`', '\[', ], $text), |
|
| 151 | 151 | parseMode::MARKDOWNV2 => str_replace( |
| 152 | 152 | ['_', '*', '[', ']', '(', ')', '~', '`', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!', '\\'],
|
| 153 | 153 | ['\_', '\*', '\[', '\]', '\(', '\)', '\~', '\`', '\>', '\#', '\+', '\-', '\=', '\|', '\{', '\}', '\.', '\!', '\\\\'],
|
@@ -173,10 +173,10 @@ discard block |
||
| 173 | 173 | * @param int $precision e.g. => 2 |
| 174 | 174 | * @return string |
| 175 | 175 | */ |
| 176 | - public static function byteFormat (int $byte, int $precision = 2): string {
|
|
| 176 | + public static function byteFormat(int $byte, int $precision = 2): string {
|
|
| 177 | 177 | $rate_counter = 0; |
| 178 | 178 | |
| 179 | - while ($byte > 1024){
|
|
| 179 | + while ($byte > 1024) {
|
|
| 180 | 180 | $byte /= 1024; |
| 181 | 181 | $rate_counter++; |
| 182 | 182 | } |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | $byte = round($byte, $precision); |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - return $byte . ' ' . ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'][$rate_counter]; |
|
| 188 | + return $byte.' '.['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'][$rate_counter]; |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | /** |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | * @param bool $format if you set this true , you will receive symbolic string like 2.76MB |
| 206 | 206 | * @return string|int|false string for formatted data , int for normal data , false when size can not be found(file not found or ...) |
| 207 | 207 | */ |
| 208 | - public static function size (string $path, bool $format = true): string|int|false {
|
|
| 208 | + public static function size(string $path, bool $format = true): string | int | false {
|
|
| 209 | 209 | if (filter_var($path, FILTER_VALIDATE_URL)) {
|
| 210 | 210 | $ch = curl_init($path); |
| 211 | 211 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | else return false; |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - public static function error2trace (\Throwable $error,$seen = null): string {
|
|
| 228 | + public static function error2trace(\Throwable $error, $seen = null): string {
|
|
| 229 | 229 | $starter = $seen ? 'Caused by: ' : ''; |
| 230 | 230 | $result = []; |
| 231 | 231 | if (!$seen) $seen = []; |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | $file = $error->getFile(); |
| 236 | 236 | $line = $error->getLine(); |
| 237 | 237 | |
| 238 | - while (true){
|
|
| 238 | + while (true) {
|
|
| 239 | 239 | $current = "$file:$line"; |
| 240 | 240 | if (is_array($seen) && in_array($current, $seen)) {
|
| 241 | 241 | $result[] = sprintf(' ... %d more', count($trace) + 1);
|
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | |
| 262 | 262 | $result = join("\n", $result);
|
| 263 | 263 | if ($prev) {
|
| 264 | - $result .= "\n" . self::error2trace($prev, $seen); |
|
| 264 | + $result .= "\n".self::error2trace($prev, $seen); |
|
| 265 | 265 | } |
| 266 | 266 | return $result; |
| 267 | 267 | } |
@@ -214,21 +214,23 @@ |
||
| 214 | 214 | curl_exec($ch); |
| 215 | 215 | $size = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD); |
| 216 | 216 | curl_close($ch); |
| 217 | - } |
|
| 218 | - else {
|
|
| 217 | + } else {
|
|
| 219 | 218 | $size = file_exists($path) ? filesize($path) : false; |
| 220 | 219 | } |
| 221 | 220 | |
| 222 | 221 | if (isset($size) && is_numeric($size)) {
|
| 223 | 222 | return $format ? tools::rateConverter($size) : $size; |
| 224 | - } |
|
| 225 | - else return false; |
|
| 223 | + } else { |
|
| 224 | + return false; |
|
| 225 | + } |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | public static function error2trace (\Throwable $error,$seen = null): string {
|
| 229 | 229 | $starter = $seen ? 'Caused by: ' : ''; |
| 230 | 230 | $result = []; |
| 231 | - if (!$seen) $seen = []; |
|
| 231 | + if (!$seen) { |
|
| 232 | + $seen = []; |
|
| 233 | + } |
|
| 232 | 234 | $trace = $error->getTrace(); |
| 233 | 235 | $prev = $error->getPrevious(); |
| 234 | 236 | //$result[] = sprintf('%s%s: %s', $starter, get_class($error), $error->getMessage());
|
@@ -5,7 +5,7 @@ |
||
| 5 | 5 | use mysqli; |
| 6 | 6 | |
| 7 | 7 | class db {
|
| 8 | - public static function init (array|mysqli $db) {
|
|
| 8 | + public static function init(array | mysqli $db) {
|
|
| 9 | 9 | |
| 10 | 10 | } |
| 11 | 11 | } |
| 12 | 12 | \ No newline at end of file |
@@ -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]); |