@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | |
22 | 22 | public static int $log_size = 10; |
23 | 23 | |
24 | - public static string|CURLFile|null $certificate = null; |
|
24 | + public static string | CURLFile | null $certificate = null; |
|
25 | 25 | |
26 | 26 | public static bool $handler = true; |
27 | 27 | |
@@ -51,10 +51,10 @@ discard block |
||
51 | 51 | |
52 | 52 | public static array $allowed_updates = ['message', 'edited_channel_post', 'callback_query', 'inline_query']; |
53 | 53 | |
54 | - public static array|mysqli|null $db = ['type' => 'json', 'file_name' => 'BPT-DB.json']; |
|
54 | + public static array | mysqli | null $db = ['type' => 'json', 'file_name' => 'BPT-DB.json']; |
|
55 | 55 | |
56 | 56 | |
57 | - public static function init (array|stdClass $settings) { |
|
57 | + public static function init(array | stdClass $settings) { |
|
58 | 58 | $settings = (array) $settings; |
59 | 59 | |
60 | 60 | if (!(isset($settings['logger']) && $settings['logger'] == false)) { |
@@ -62,14 +62,14 @@ discard block |
||
62 | 62 | } |
63 | 63 | |
64 | 64 | foreach ($settings as $setting => $value) { |
65 | - try{ |
|
65 | + try { |
|
66 | 66 | self::$$setting = $value; |
67 | 67 | } |
68 | - catch (TypeError){ |
|
69 | - logger::write("$setting setting has wrong type , its set to default value",'warning'); |
|
68 | + catch (TypeError) { |
|
69 | + logger::write("$setting setting has wrong type , its set to default value", 'warning'); |
|
70 | 70 | } |
71 | - catch (Error){ |
|
72 | - logger::write("$setting setting is not one of library settings",'warning'); |
|
71 | + catch (Error) { |
|
72 | + logger::write("$setting setting is not one of library settings", 'warning'); |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | self::$receiver !== receiver::GETUPDATES ? self::webhook() : self::getUpdates(); |
82 | 82 | } |
83 | 83 | else { |
84 | - logger::write('token format is not right, check it and try again','error'); |
|
84 | + logger::write('token format is not right, check it and try again', 'error'); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | else { |
88 | - logger::write('You must specify token parameter in settings','error'); |
|
88 | + logger::write('You must specify token parameter in settings', 'error'); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | if (self::$secure_folder) { |
109 | 109 | $address = explode('/', $_SERVER['REQUEST_URI']); |
110 | 110 | unset($address[count($address) - 1]); |
111 | - $address = implode('/', $address) . '/BPT.php'; |
|
111 | + $address = implode('/', $address).'/BPT.php'; |
|
112 | 112 | $text = "ErrorDocument 404 $address\nErrorDocument 403 $address\n Options -Indexes\n Order Deny,Allow\nDeny from all\nAllow from 127.0.0.1\n<Files *.php>\n Order Allow,Deny\n Allow from all\n</Files>"; |
113 | 113 | if (!file_exists('.htaccess') || filesize('.htaccess') != strlen($text)) { |
114 | 114 | file_put_contents('.htaccess', $text); |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | getUpdates::init(); |
128 | 128 | } |
129 | 129 | else { |
130 | - logger::write('You can\'t use getUpdates receiver when handler is off , use webhook or use handler','error'); |
|
130 | + logger::write('You can\'t use getUpdates receiver when handler is off , use webhook or use handler', 'error'); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 |
@@ -64,11 +64,9 @@ discard block |
||
64 | 64 | foreach ($settings as $setting => $value) { |
65 | 65 | try{ |
66 | 66 | self::$$setting = $value; |
67 | - } |
|
68 | - catch (TypeError){ |
|
67 | + } catch (TypeError){ |
|
69 | 68 | logger::write("$setting setting has wrong type , its set to default value",'warning'); |
70 | - } |
|
71 | - catch (Error){ |
|
69 | + } catch (Error){ |
|
72 | 70 | logger::write("$setting setting is not one of library settings",'warning'); |
73 | 71 | } |
74 | 72 | } |
@@ -79,12 +77,10 @@ discard block |
||
79 | 77 | self::secureFolder(); |
80 | 78 | self::db(); |
81 | 79 | self::$receiver !== receiver::GETUPDATES ? self::webhook() : self::getUpdates(); |
82 | - } |
|
83 | - else { |
|
80 | + } else { |
|
84 | 81 | logger::write('token format is not right, check it and try again','error'); |
85 | 82 | } |
86 | - } |
|
87 | - else { |
|
83 | + } else { |
|
88 | 84 | logger::write('You must specify token parameter in settings','error'); |
89 | 85 | } |
90 | 86 | } |
@@ -125,8 +121,7 @@ discard block |
||
125 | 121 | private static function getUpdates() { |
126 | 122 | if (self::$handler) { |
127 | 123 | getUpdates::init(); |
128 | - } |
|
129 | - else { |
|
124 | + } else { |
|
130 | 125 | logger::write('You can\'t use getUpdates receiver when handler is off , use webhook or use handler','error'); |
131 | 126 | } |
132 | 127 | } |
@@ -3,7 +3,7 @@ |
||
3 | 3 | namespace BPT\receiver; |
4 | 4 | |
5 | 5 | class getUpdates { |
6 | - public static function init () { |
|
6 | + public static function init() { |
|
7 | 7 | |
8 | 8 | } |
9 | 9 | } |
10 | 10 | \ No newline at end of file |
@@ -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 |
@@ -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]); |
@@ -207,94 +207,94 @@ discard block |
||
207 | 207 | ]; |
208 | 208 | |
209 | 209 | private const METHODS_KEYS = [ |
210 | - 'getUpdates' => ['offset','limit','timeout','allowed_updates','token','return_array','forgot','answer'], |
|
211 | - 'setWebhook' => ['url','certificate','ip_address','max_connections','allowed_updates','drop_pending_updates','secret_token','token','return_array','forgot','answer'], |
|
212 | - 'deleteWebhook' => ['drop_pending_updates','token','return_array','forgot','answer'], |
|
213 | - 'getWebhookInfo' => ['token','return_array','forgot','answer'], |
|
214 | - 'getMe' => ['token','return_array','forgot','answer'], |
|
215 | - 'logOut' => ['token','return_array','forgot','answer'], |
|
216 | - 'close' => ['token','return_array','forgot','answer'], |
|
217 | - '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'], |
|
218 | - 'forwardMessage' => ['chat_id','from_chat_id','disable_notification','protect_content','message_id','token','return_array','forgot','answer'], |
|
219 | - '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'], |
|
220 | - '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'], |
|
221 | - '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'], |
|
222 | - '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'], |
|
223 | - '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'], |
|
224 | - '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'], |
|
225 | - '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'], |
|
226 | - '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'], |
|
227 | - 'sendMediaGroup' => ['media','chat_id','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','token','return_array','forgot','answer'], |
|
228 | - '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'], |
|
229 | - 'editMessageLiveLocation' => ['latitude','longitude','chat_id','message_id','inline_message_id','horizontal_accuracy','heading','proximity_alert_radius','reply_markup','token','return_array','forgot','answer'], |
|
230 | - 'stopMessageLiveLocation' => ['chat_id','message_id','inline_message_id','reply_markup','token','return_array','forgot','answer'], |
|
231 | - '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'], |
|
232 | - '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'], |
|
233 | - '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'], |
|
234 | - 'sendDice' => ['chat_id','emoji','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
|
235 | - 'sendChatAction' => ['chat_id','action','token','return_array','forgot','answer'], |
|
236 | - 'getUserProfilePhotos' => ['user_id','offset','limit','token','return_array','forgot','answer'], |
|
237 | - 'getFile' => ['file_id','token','return_array','forgot','answer'], |
|
238 | - 'banChatMember' => ['chat_id','user_id','until_date','revoke_messages','token','return_array','forgot','answer'], |
|
239 | - 'unbanChatMember' => ['chat_id','user_id','only_if_banned','token','return_array','forgot','answer'], |
|
240 | - 'restrictChatMember' => ['permissions','chat_id','user_id','until_date','token','return_array','forgot','answer'], |
|
241 | - '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'], |
|
242 | - 'setChatAdministratorCustomTitle' => ['custom_title','chat_id','user_id','token','return_array','forgot','answer'], |
|
243 | - 'banChatSenderChat' => ['sender_chat_id','chat_id','token','return_array','forgot','answer'], |
|
244 | - 'unbanChatSenderChat' => ['sender_chat_id','chat_id','token','return_array','forgot','answer'], |
|
245 | - 'setChatPermissions' => ['permissions','chat_id','token','return_array','forgot','answer'], |
|
246 | - 'exportChatInviteLink' => ['chat_id','token','return_array','forgot','answer'], |
|
247 | - 'createChatInviteLink' => ['chat_id','name','expire_date','member_limit','creates_join_request','token','return_array','forgot','answer'], |
|
248 | - 'editChatInviteLink' => ['invite_link','chat_id','name','expire_date','member_limit','creates_join_request','token','return_array','forgot','answer'], |
|
249 | - 'revokeChatInviteLink' => ['invite_link','chat_id','token','return_array','forgot','answer'], |
|
250 | - 'approveChatJoinRequest' => ['chat_id','user_id','token','return_array','forgot','answer'], |
|
251 | - 'declineChatJoinRequest' => ['chat_id','user_id','token','return_array','forgot','answer'], |
|
252 | - 'setChatPhoto' => ['photo','chat_id','token','return_array','forgot','answer'], |
|
253 | - 'deleteChatPhoto' => ['chat_id','token','return_array','forgot','answer'], |
|
254 | - 'setChatTitle' => ['title','chat_id','token','return_array','forgot','answer'], |
|
255 | - 'setChatDescription' => ['chat_id','description','token','return_array','forgot','answer'], |
|
256 | - 'pinChatMessage' => ['message_id','chat_id','disable_notification','token','return_array','forgot','answer'], |
|
257 | - 'unpinChatMessage' => ['chat_id','message_id','token','return_array','forgot','answer'], |
|
258 | - 'unpinAllChatMessages' => ['chat_id','token','return_array','forgot','answer'], |
|
259 | - 'leaveChat' => ['chat_id','token','return_array','forgot','answer'], |
|
260 | - 'getChat' => ['chat_id','token','return_array','forgot','answer'], |
|
261 | - 'getChatAdministrators' => ['chat_id','token','return_array','forgot','answer'], |
|
262 | - 'getChatMemberCount' => ['chat_id','token','return_array','forgot','answer'], |
|
263 | - 'getChatMember' => ['chat_id','user_id','token','return_array','forgot','answer'], |
|
264 | - 'setChatStickerSet' => ['sticker_set_name','chat_id','token','return_array','forgot','answer'], |
|
265 | - 'deleteChatStickerSet' => ['chat_id','token','return_array','forgot','answer'], |
|
266 | - 'answerCallbackQuery' => ['callback_query_id','text','show_alert','url','cache_time','token','return_array','forgot','answer'], |
|
267 | - 'setMyCommands' => ['commands','scope','language_code','token','return_array','forgot','answer'], |
|
268 | - 'deleteMyCommands' => ['scope','language_code','token','return_array','forgot','answer'], |
|
269 | - 'getMyCommands' => ['scope','language_code','token','return_array','forgot','answer'], |
|
270 | - 'setChatMenuButton' => ['chat_id','menu_button','token','return_array','forgot','answer'], |
|
271 | - 'getChatMenuButton' => ['chat_id','token','return_array','forgot','answer'], |
|
272 | - 'setMyDefaultAdministratorRights' => ['rights','for_channels','token','return_array','forgot','answer'], |
|
273 | - 'getMyDefaultAdministratorRights' => ['for_channels','token','return_array','forgot','answer'], |
|
274 | - 'editMessageText' => ['text','chat_id','message_id','inline_message_id','parse_mode','entities','disable_web_page_preview','reply_markup','token','return_array','forgot','answer'], |
|
275 | - 'editMessageCaption' => ['chat_id','message_id','inline_message_id','caption','parse_mode','caption_entities','reply_markup','token','return_array','forgot','answer'], |
|
276 | - 'editMessageMedia' => ['media','chat_id','message_id','inline_message_id','reply_markup','token','return_array','forgot','answer'], |
|
277 | - 'editMessageReplyMarkup' => ['chat_id','message_id','inline_message_id','reply_markup','token','return_array','forgot','answer'], |
|
278 | - 'stopPoll' => ['chat_id','message_id','reply_markup','token','return_array','forgot','answer'], |
|
279 | - 'deleteMessage' => ['chat_id','message_id','token','return_array','forgot','answer'], |
|
280 | - 'sendSticker' => ['sticker','chat_id','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','return_array','forgot','answer'], |
|
281 | - 'getStickerSet' => ['name','token','return_array','forgot','answer'], |
|
282 | - 'uploadStickerFile' => ['png_sticker','user_id','token','return_array','forgot','answer'], |
|
283 | - 'createNewStickerSet' => ['name','title','emojis','user_id','png_sticker','tgs_sticker','webm_sticker','contains_masks','mask_position','token','return_array','forgot','answer'], |
|
284 | - 'addStickerToSet' => ['name','emojis','user_id','png_sticker','tgs_sticker','webm_sticker','mask_position','token','return_array','forgot','answer'], |
|
285 | - 'setStickerPositionInSet' => ['sticker','position','token','return_array','forgot','answer'], |
|
286 | - 'deleteStickerFromSet' => ['sticker','token','return_array','forgot','answer'], |
|
287 | - 'setStickerSetThumb' => ['name','user_id','thumb','token','return_array','forgot','answer'], |
|
288 | - 'answerInlineQuery' => ['results','inline_query_id','cache_time','is_personal','next_offset','switch_pm_text','switch_pm_parameter','token','return_array','forgot','answer'], |
|
289 | - 'answerWebAppQuery' => ['web_app_query_id','result','token','return_array','forgot','answer'], |
|
290 | - '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'], |
|
291 | - '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'], |
|
292 | - 'answerShippingQuery' => ['ok','shipping_query_id','shipping_options','error_message','token','return_array','forgot','answer'], |
|
293 | - 'answerPreCheckoutQuery' => ['ok','pre_checkout_query_id','error_message','token','return_array','forgot','answer'], |
|
294 | - 'setPassportDataErrors' => ['errors','user_id','token','return_array','forgot','answer'], |
|
295 | - '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'], |
|
296 | - 'setGameScore' => ['score','user_id','force','disable_edit_message','chat_id','message_id','inline_message_id','token','return_array','forgot','answer'], |
|
297 | - 'getGameHighScores' => ['user_id','chat_id','message_id','inline_message_id','token','return_array','forgot','answer'], |
|
210 | + 'getUpdates' => ['offset', 'limit', 'timeout', 'allowed_updates', 'token', 'return_array', 'forgot', 'answer'], |
|
211 | + 'setWebhook' => ['url', 'certificate', 'ip_address', 'max_connections', 'allowed_updates', 'drop_pending_updates', 'secret_token', 'token', 'return_array', 'forgot', 'answer'], |
|
212 | + 'deleteWebhook' => ['drop_pending_updates', 'token', 'return_array', 'forgot', 'answer'], |
|
213 | + 'getWebhookInfo' => ['token', 'return_array', 'forgot', 'answer'], |
|
214 | + 'getMe' => ['token', 'return_array', 'forgot', 'answer'], |
|
215 | + 'logOut' => ['token', 'return_array', 'forgot', 'answer'], |
|
216 | + 'close' => ['token', 'return_array', 'forgot', 'answer'], |
|
217 | + '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'], |
|
218 | + 'forwardMessage' => ['chat_id', 'from_chat_id', 'disable_notification', 'protect_content', 'message_id', 'token', 'return_array', 'forgot', 'answer'], |
|
219 | + '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'], |
|
220 | + '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'], |
|
221 | + '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'], |
|
222 | + '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'], |
|
223 | + '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'], |
|
224 | + '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'], |
|
225 | + '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'], |
|
226 | + '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'], |
|
227 | + 'sendMediaGroup' => ['media', 'chat_id', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'token', 'return_array', 'forgot', 'answer'], |
|
228 | + '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'], |
|
229 | + 'editMessageLiveLocation' => ['latitude', 'longitude', 'chat_id', 'message_id', 'inline_message_id', 'horizontal_accuracy', 'heading', 'proximity_alert_radius', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
230 | + 'stopMessageLiveLocation' => ['chat_id', 'message_id', 'inline_message_id', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
231 | + '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'], |
|
232 | + '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'], |
|
233 | + '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'], |
|
234 | + 'sendDice' => ['chat_id', 'emoji', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
235 | + 'sendChatAction' => ['chat_id', 'action', 'token', 'return_array', 'forgot', 'answer'], |
|
236 | + 'getUserProfilePhotos' => ['user_id', 'offset', 'limit', 'token', 'return_array', 'forgot', 'answer'], |
|
237 | + 'getFile' => ['file_id', 'token', 'return_array', 'forgot', 'answer'], |
|
238 | + 'banChatMember' => ['chat_id', 'user_id', 'until_date', 'revoke_messages', 'token', 'return_array', 'forgot', 'answer'], |
|
239 | + 'unbanChatMember' => ['chat_id', 'user_id', 'only_if_banned', 'token', 'return_array', 'forgot', 'answer'], |
|
240 | + 'restrictChatMember' => ['permissions', 'chat_id', 'user_id', 'until_date', 'token', 'return_array', 'forgot', 'answer'], |
|
241 | + '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'], |
|
242 | + 'setChatAdministratorCustomTitle' => ['custom_title', 'chat_id', 'user_id', 'token', 'return_array', 'forgot', 'answer'], |
|
243 | + 'banChatSenderChat' => ['sender_chat_id', 'chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
244 | + 'unbanChatSenderChat' => ['sender_chat_id', 'chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
245 | + 'setChatPermissions' => ['permissions', 'chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
246 | + 'exportChatInviteLink' => ['chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
247 | + 'createChatInviteLink' => ['chat_id', 'name', 'expire_date', 'member_limit', 'creates_join_request', 'token', 'return_array', 'forgot', 'answer'], |
|
248 | + 'editChatInviteLink' => ['invite_link', 'chat_id', 'name', 'expire_date', 'member_limit', 'creates_join_request', 'token', 'return_array', 'forgot', 'answer'], |
|
249 | + 'revokeChatInviteLink' => ['invite_link', 'chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
250 | + 'approveChatJoinRequest' => ['chat_id', 'user_id', 'token', 'return_array', 'forgot', 'answer'], |
|
251 | + 'declineChatJoinRequest' => ['chat_id', 'user_id', 'token', 'return_array', 'forgot', 'answer'], |
|
252 | + 'setChatPhoto' => ['photo', 'chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
253 | + 'deleteChatPhoto' => ['chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
254 | + 'setChatTitle' => ['title', 'chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
255 | + 'setChatDescription' => ['chat_id', 'description', 'token', 'return_array', 'forgot', 'answer'], |
|
256 | + 'pinChatMessage' => ['message_id', 'chat_id', 'disable_notification', 'token', 'return_array', 'forgot', 'answer'], |
|
257 | + 'unpinChatMessage' => ['chat_id', 'message_id', 'token', 'return_array', 'forgot', 'answer'], |
|
258 | + 'unpinAllChatMessages' => ['chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
259 | + 'leaveChat' => ['chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
260 | + 'getChat' => ['chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
261 | + 'getChatAdministrators' => ['chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
262 | + 'getChatMemberCount' => ['chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
263 | + 'getChatMember' => ['chat_id', 'user_id', 'token', 'return_array', 'forgot', 'answer'], |
|
264 | + 'setChatStickerSet' => ['sticker_set_name', 'chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
265 | + 'deleteChatStickerSet' => ['chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
266 | + 'answerCallbackQuery' => ['callback_query_id', 'text', 'show_alert', 'url', 'cache_time', 'token', 'return_array', 'forgot', 'answer'], |
|
267 | + 'setMyCommands' => ['commands', 'scope', 'language_code', 'token', 'return_array', 'forgot', 'answer'], |
|
268 | + 'deleteMyCommands' => ['scope', 'language_code', 'token', 'return_array', 'forgot', 'answer'], |
|
269 | + 'getMyCommands' => ['scope', 'language_code', 'token', 'return_array', 'forgot', 'answer'], |
|
270 | + 'setChatMenuButton' => ['chat_id', 'menu_button', 'token', 'return_array', 'forgot', 'answer'], |
|
271 | + 'getChatMenuButton' => ['chat_id', 'token', 'return_array', 'forgot', 'answer'], |
|
272 | + 'setMyDefaultAdministratorRights' => ['rights', 'for_channels', 'token', 'return_array', 'forgot', 'answer'], |
|
273 | + 'getMyDefaultAdministratorRights' => ['for_channels', 'token', 'return_array', 'forgot', 'answer'], |
|
274 | + 'editMessageText' => ['text', 'chat_id', 'message_id', 'inline_message_id', 'parse_mode', 'entities', 'disable_web_page_preview', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
275 | + 'editMessageCaption' => ['chat_id', 'message_id', 'inline_message_id', 'caption', 'parse_mode', 'caption_entities', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
276 | + 'editMessageMedia' => ['media', 'chat_id', 'message_id', 'inline_message_id', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
277 | + 'editMessageReplyMarkup' => ['chat_id', 'message_id', 'inline_message_id', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
278 | + 'stopPoll' => ['chat_id', 'message_id', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
279 | + 'deleteMessage' => ['chat_id', 'message_id', 'token', 'return_array', 'forgot', 'answer'], |
|
280 | + 'sendSticker' => ['sticker', 'chat_id', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'return_array', 'forgot', 'answer'], |
|
281 | + 'getStickerSet' => ['name', 'token', 'return_array', 'forgot', 'answer'], |
|
282 | + 'uploadStickerFile' => ['png_sticker', 'user_id', 'token', 'return_array', 'forgot', 'answer'], |
|
283 | + 'createNewStickerSet' => ['name', 'title', 'emojis', 'user_id', 'png_sticker', 'tgs_sticker', 'webm_sticker', 'contains_masks', 'mask_position', 'token', 'return_array', 'forgot', 'answer'], |
|
284 | + 'addStickerToSet' => ['name', 'emojis', 'user_id', 'png_sticker', 'tgs_sticker', 'webm_sticker', 'mask_position', 'token', 'return_array', 'forgot', 'answer'], |
|
285 | + 'setStickerPositionInSet' => ['sticker', 'position', 'token', 'return_array', 'forgot', 'answer'], |
|
286 | + 'deleteStickerFromSet' => ['sticker', 'token', 'return_array', 'forgot', 'answer'], |
|
287 | + 'setStickerSetThumb' => ['name', 'user_id', 'thumb', 'token', 'return_array', 'forgot', 'answer'], |
|
288 | + 'answerInlineQuery' => ['results', 'inline_query_id', 'cache_time', 'is_personal', 'next_offset', 'switch_pm_text', 'switch_pm_parameter', 'token', 'return_array', 'forgot', 'answer'], |
|
289 | + 'answerWebAppQuery' => ['web_app_query_id', 'result', 'token', 'return_array', 'forgot', 'answer'], |
|
290 | + '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'], |
|
291 | + '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'], |
|
292 | + 'answerShippingQuery' => ['ok', 'shipping_query_id', 'shipping_options', 'error_message', 'token', 'return_array', 'forgot', 'answer'], |
|
293 | + 'answerPreCheckoutQuery' => ['ok', 'pre_checkout_query_id', 'error_message', 'token', 'return_array', 'forgot', 'answer'], |
|
294 | + 'setPassportDataErrors' => ['errors', 'user_id', 'token', 'return_array', 'forgot', 'answer'], |
|
295 | + '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'], |
|
296 | + 'setGameScore' => ['score', 'user_id', 'force', 'disable_edit_message', 'chat_id', 'message_id', 'inline_message_id', 'token', 'return_array', 'forgot', 'answer'], |
|
297 | + 'getGameHighScores' => ['user_id', 'chat_id', 'message_id', 'inline_message_id', 'token', 'return_array', 'forgot', 'answer'], |
|
298 | 298 | ]; |
299 | 299 | |
300 | 300 | private const METHODS_WITH_FILE = [ |
@@ -315,18 +315,18 @@ discard block |
||
315 | 315 | ]; |
316 | 316 | |
317 | 317 | |
318 | - public static function __callStatic (string $name, array $arguments) { |
|
318 | + public static function __callStatic(string $name, array $arguments) { |
|
319 | 319 | if ($action = self::methodAction($name)) { |
320 | - self::keysName($action,$arguments); |
|
321 | - self::readyFile($action,$arguments); |
|
320 | + self::keysName($action, $arguments); |
|
321 | + self::readyFile($action, $arguments); |
|
322 | 322 | print_r($arguments); |
323 | 323 | } |
324 | 324 | else { |
325 | - logger::write("$name method is not supported",'error'); |
|
325 | + logger::write("$name method is not supported", 'error'); |
|
326 | 326 | } |
327 | 327 | } |
328 | 328 | |
329 | - private static function keysName (string $name, array &$arguments) { |
|
329 | + private static function keysName(string $name, array &$arguments) { |
|
330 | 330 | foreach ($arguments as $key => $argument) { |
331 | 331 | if (is_numeric($key) && isset(self::METHODS_KEYS[$name][$key])) { |
332 | 332 | $arguments[self::METHODS_KEYS[$name][$key]] = $argument; |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | } |
336 | 336 | } |
337 | 337 | |
338 | - private static function methodAction(string $name): string|false { |
|
338 | + private static function methodAction(string $name): string | false { |
|
339 | 339 | return self::METHODS_ACTION[strtolower($name)] ?? false; |
340 | 340 | } |
341 | 341 | |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | } |
357 | 357 | } |
358 | 358 | |
359 | - private static function methodFile(string $name): array|false { |
|
359 | + private static function methodFile(string $name): array | false { |
|
360 | 360 | return self::METHODS_WITH_FILE[$name] ?? false; |
361 | 361 | } |
362 | 362 | } |
363 | 363 | \ No newline at end of file |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | private static $handler; |
9 | 9 | |
10 | 10 | |
11 | - public static function init (int $log_size = 10) { |
|
11 | + public static function init(int $log_size = 10) { |
|
12 | 12 | self::$log_size = $log_size; |
13 | 13 | if (file_exists('BPT.log') && !(filesize('BPT.log') > self::$log_size * 1024 * 1024)) { |
14 | 14 | $mode = 'a'; |
@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | self::$handler = fopen('BPT.log', $mode); |
23 | 23 | |
24 | 24 | if ($write) { |
25 | - 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"); |
|
25 | + 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"); |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
29 | 29 | public static function write($data, $type = '') { |
30 | 30 | if (!is_null(self::$handler)) { |
31 | - $text = date('Y/m/d H:i:s') . ( $type === '' ? " : $data\n\n" : " : ⤵\n$type : $data\n\n" ); |
|
31 | + $text = date('Y/m/d H:i:s').($type === '' ? " : $data\n\n" : " : ⤵\n$type : $data\n\n"); |
|
32 | 32 | fwrite(self::$handler, $text); |
33 | 33 | } |
34 | 34 | } |
@@ -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 | } |
@@ -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]); |
@@ -8,8 +8,7 @@ |
||
8 | 8 | public static function init() { |
9 | 9 | if (lock::exist('BPT-MULTI')) { |
10 | 10 | |
11 | - } |
|
12 | - else { |
|
11 | + } else { |
|
13 | 12 | |
14 | 13 | } |
15 | 14 | } |
@@ -256,15 +256,15 @@ discard block |
||
256 | 256 | curl_exec($ch); |
257 | 257 | $size = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD); |
258 | 258 | curl_close($ch); |
259 | - } |
|
260 | - else { |
|
259 | + } else { |
|
261 | 260 | $size = file_exists($path) ? filesize($path) : false; |
262 | 261 | } |
263 | 262 | |
264 | 263 | if (isset($size) && is_numeric($size)) { |
265 | 264 | return $format ? tools::byteFormat($size) : $size; |
266 | - } |
|
267 | - else return false; |
|
265 | + } else { |
|
266 | + return false; |
|
267 | + } |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | //fix methods after here comments |
@@ -292,15 +292,16 @@ discard block |
||
292 | 292 | $file->isDir() ? rmdir($file->getRealPath()) : unlink($file->getRealPath()); |
293 | 293 | } |
294 | 294 | rmdir($path); |
295 | - } |
|
296 | - else { |
|
295 | + } else { |
|
297 | 296 | logger::write("BPT delete function used\ndelete function cannot delete folder because its have subFiles and sub parameter haven't true value",'error'); |
298 | 297 | return false; |
299 | 298 | } |
300 | - } |
|
301 | - else rmdir($path); |
|
302 | - } |
|
303 | - else unlink($path); |
|
299 | + } else { |
|
300 | + rmdir($path); |
|
301 | + } |
|
302 | + } else { |
|
303 | + unlink($path); |
|
304 | + } |
|
304 | 305 | |
305 | 306 | return true; |
306 | 307 | } |
@@ -327,8 +328,9 @@ discard block |
||
327 | 328 | foreach ($string as $k => &$v) { |
328 | 329 | if ($diff->$v) { |
329 | 330 | $v = $diff->$v; |
330 | - } |
|
331 | - else unset($string[$k]); |
|
331 | + } else { |
|
332 | + unset($string[$k]); |
|
333 | + } |
|
332 | 334 | } |
333 | 335 | $string['status'] = $status; |
334 | 336 | return count($string) > 1 ? $string : ['status' => 'now']; |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * @param string $username Your text to be check is username or not e.g. : 'BPT_CH' | '@BPT_CH' |
22 | 22 | * @return bool |
23 | 23 | */ |
24 | - public static function isUsername (string $username): bool { |
|
24 | + public static function isUsername(string $username): bool { |
|
25 | 25 | $length = strlen($username); |
26 | 26 | return strpos($username, '__') === false && $length >= 5 && $length <= 33 && preg_match('/^@?([a-zA-Z])(\w{4,31})$/', $username); |
27 | 27 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * @param string $range Your range ip for check , if you didn't specify the block , it will be 32 |
38 | 38 | * @return bool |
39 | 39 | */ |
40 | - public static function ipInRange (string $ip, string $range): bool { |
|
40 | + public static function ipInRange(string $ip, string $range): bool { |
|
41 | 41 | if (!str_contains($range, '/')) { |
42 | 42 | $range .= '/32'; |
43 | 43 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @param string $ip Your ip to be check is telegram or not e.g. '192.168.1.1' |
57 | 57 | * @return bool |
58 | 58 | */ |
59 | - public static function isTelegram (string $ip): bool { |
|
59 | + public static function isTelegram(string $ip): bool { |
|
60 | 60 | return self::ipInRange($ip, '149.154.160.0/20') || self::ipInRange($ip, '91.108.4.0/22'); |
61 | 61 | } |
62 | 62 | |
@@ -70,10 +70,10 @@ discard block |
||
70 | 70 | * @param string $ip Your ip to be check is CloudFlare or not e.g. '192.168.1.1' |
71 | 71 | * @return bool |
72 | 72 | */ |
73 | - public static function isCloudFlare (string $ip): bool { |
|
73 | + public static function isCloudFlare(string $ip): bool { |
|
74 | 74 | $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']; |
75 | 75 | foreach ($cf_ips as $cf_ip) { |
76 | - if (self::ipInRange($ip,$cf_ip)) { |
|
76 | + if (self::ipInRange($ip, $cf_ip)) { |
|
77 | 77 | return true; |
78 | 78 | } |
79 | 79 | } |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | * @param bool $verify check token with telegram or not |
95 | 95 | * @return bool|array return array when verify is active and token is true array of telegram getMe result |
96 | 96 | */ |
97 | - public static function isToken (string $token, bool $verify = false): bool|array { |
|
97 | + public static function isToken(string $token, bool $verify = false): bool | array { |
|
98 | 98 | if (preg_match('/^(\d{8,10}):[\w\-]{35}$/', $token)) { |
99 | - if ($verify){ |
|
99 | + if ($verify) { |
|
100 | 100 | $res = telegram::me($token); |
101 | 101 | if ($res['ok']) { |
102 | 102 | return $res['result']; |
@@ -129,14 +129,14 @@ discard block |
||
129 | 129 | * @param int|null $user_id e.g. => '442109602' |
130 | 130 | * @return bool |
131 | 131 | */ |
132 | - public static function isJoined (array|string|int $ids , int|null $user_id = null): bool { |
|
132 | + public static function isJoined(array | string | int $ids, int | null $user_id = null): bool { |
|
133 | 133 | if (!is_array($ids)) { |
134 | 134 | $ids = [$ids]; |
135 | 135 | } |
136 | 136 | //$user_id = $user_id ?? $this->catchFields(['field' => 'user_id']); |
137 | 137 | |
138 | 138 | foreach ($ids as $id) { |
139 | - $check = telegram::getChatMember($id,$user_id); |
|
139 | + $check = telegram::getChatMember($id, $user_id); |
|
140 | 140 | if (isset($check['result'])) { |
141 | 141 | $check = $check['result']['status']; |
142 | 142 | return !($check === chatMemberStatus::LEFT || $check === chatMemberStatus::KICKED); |
@@ -164,10 +164,10 @@ discard block |
||
164 | 164 | * @param string $characters e.g. => 'abcdefg' |
165 | 165 | * @return string |
166 | 166 | */ |
167 | - public static function randomString (int $length = 16, string $characters = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'): string { |
|
167 | + public static function randomString(int $length = 16, string $characters = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'): string { |
|
168 | 168 | $rand_string = ''; |
169 | 169 | $char_len = strlen($characters) - 1; |
170 | - for ($i = 0; $i < $length; $i ++) { |
|
170 | + for ($i = 0; $i < $length; $i++) { |
|
171 | 171 | $rand_string .= $characters[rand(0, $char_len)]; |
172 | 172 | } |
173 | 173 | return $rand_string; |
@@ -186,10 +186,10 @@ discard block |
||
186 | 186 | * @param string $mode Your selected mode e.g. => `parseMode::HTML` | `HTML` |
187 | 187 | * @return string|false return false when mode is incorrect |
188 | 188 | */ |
189 | - public static function modeEscape (string $text, string $mode = parseMode::HTML): string|false { |
|
189 | + public static function modeEscape(string $text, string $mode = parseMode::HTML): string | false { |
|
190 | 190 | return match ($mode) { |
191 | - parseMode::HTML => str_replace(['&', '<', '>',], ["&", "<", ">",], $text), |
|
192 | - parseMode::MARKDOWN => str_replace(['\\', '_', '*', '`', '['], ['\\\\', '\_', '\*', '\`', '\[',], $text), |
|
191 | + parseMode::HTML => str_replace(['&', '<', '>', ], ["&", "<", ">", ], $text), |
|
192 | + parseMode::MARKDOWN => str_replace(['\\', '_', '*', '`', '['], ['\\\\', '\_', '\*', '\`', '\[', ], $text), |
|
193 | 193 | parseMode::MARKDOWNV2 => str_replace( |
194 | 194 | ['_', '*', '[', ']', '(', ')', '~', '`', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!', '\\'], |
195 | 195 | ['\_', '\*', '\[', '\]', '\(', '\)', '\~', '\`', '\>', '\#', '\+', '\-', '\=', '\|', '\{', '\}', '\.', '\!', '\\\\'], |
@@ -215,10 +215,10 @@ discard block |
||
215 | 215 | * @param int $precision e.g. => 2 |
216 | 216 | * @return string |
217 | 217 | */ |
218 | - public static function byteFormat (int $byte, int $precision = 2): string { |
|
218 | + public static function byteFormat(int $byte, int $precision = 2): string { |
|
219 | 219 | $rate_counter = 0; |
220 | 220 | |
221 | - while ($byte > 1024){ |
|
221 | + while ($byte > 1024) { |
|
222 | 222 | $byte /= 1024; |
223 | 223 | $rate_counter++; |
224 | 224 | } |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | $byte = round($byte, $precision); |
228 | 228 | } |
229 | 229 | |
230 | - return $byte . ' ' . ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'][$rate_counter]; |
|
230 | + return $byte.' '.['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'][$rate_counter]; |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | * @param bool $format if you set this true , you will receive symbolic string like 2.76MB |
248 | 248 | * @return string|int|false string for formatted data , int for normal data , false when size can not be found(file not found or ...) |
249 | 249 | */ |
250 | - public static function size (string $path, bool $format = true): string|int|false { |
|
250 | + public static function size(string $path, bool $format = true): string | int | false { |
|
251 | 251 | if (filter_var($path, FILTER_VALIDATE_URL)) { |
252 | 252 | $ch = curl_init($path); |
253 | 253 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * @param array $array e.g. => ['path'=>'xfolder/yfolder','sub'=>true] |
283 | 283 | * @return bool |
284 | 284 | */ |
285 | - public static function delete (string $path, bool $sub = true): bool { |
|
285 | + public static function delete(string $path, bool $sub = true): bool { |
|
286 | 286 | if (is_dir($path)) { |
287 | 287 | if (count(scandir($path)) > 2) { |
288 | 288 | if ($sub) { |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | rmdir($path); |
295 | 295 | } |
296 | 296 | else { |
297 | - logger::write("BPT delete function used\ndelete function cannot delete folder because its have subFiles and sub parameter haven't true value",'error'); |
|
297 | + logger::write("BPT delete function used\ndelete function cannot delete folder because its have subFiles and sub parameter haven't true value", 'error'); |
|
298 | 298 | return false; |
299 | 299 | } |
300 | 300 | } |
@@ -317,9 +317,9 @@ discard block |
||
317 | 317 | * @return array |
318 | 318 | * @throws Exception |
319 | 319 | */ |
320 | - public static function time2string (int $datetime): array { |
|
320 | + public static function time2string(int $datetime): array { |
|
321 | 321 | $now = new DateTime; |
322 | - $input = new DateTime('@' . $datetime); |
|
322 | + $input = new DateTime('@'.$datetime); |
|
323 | 323 | $status = $now < $input ? 'later' : 'ago'; |
324 | 324 | $diff = $now->diff($input); |
325 | 325 | $diff->w = floor($diff->d / 7); |