@@ -25,29 +25,29 @@ discard block |
||
25 | 25 | public int $duration; |
26 | 26 | |
27 | 27 | /** Optional. Performer of the audio as defined by sender or by audio tags */ |
28 | - public null|string $performer = null; |
|
28 | + public null | string $performer = null; |
|
29 | 29 | |
30 | 30 | /** Optional. Title of the audio as defined by sender or by audio tags */ |
31 | - public null|string $title = null; |
|
31 | + public null | string $title = null; |
|
32 | 32 | |
33 | 33 | /** Optional. Original filename as defined by sender */ |
34 | - public null|string $file_name = null; |
|
34 | + public null | string $file_name = null; |
|
35 | 35 | |
36 | 36 | /** Optional. MIME type of the file as defined by sender */ |
37 | - public null|string $mime_type = null; |
|
37 | + public null | string $mime_type = null; |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * Optional. File size in bytes. It can be bigger than 2^31 and some programming languages may have |
41 | 41 | * difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit |
42 | 42 | * integer or double-precision float type are safe for storing this value. |
43 | 43 | */ |
44 | - public null|int $file_size = null; |
|
44 | + public null | int $file_size = null; |
|
45 | 45 | |
46 | 46 | /** Optional. Thumbnail of the album cover to which the music file belongs */ |
47 | - public null|photoSize $thumbnail = null; |
|
47 | + public null | photoSize $thumbnail = null; |
|
48 | 48 | |
49 | 49 | |
50 | - public function __construct(stdClass|null $object = null) { |
|
50 | + public function __construct(stdClass | null $object = null) { |
|
51 | 51 | if ($object != null) { |
52 | 52 | parent::__construct($object, self::subs); |
53 | 53 | } |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | * |
69 | 69 | * @return bool|string string will be returned when destination doesn't set |
70 | 70 | */ |
71 | - public function download(string|null $destination = null): bool|string { |
|
72 | - return telegram::downloadFile($destination ?? $this->file_name ?? 'unknown.mp3',$this->file_id); |
|
71 | + public function download(string | null $destination = null): bool | string { |
|
72 | + return telegram::downloadFile($destination ?? $this->file_name ?? 'unknown.mp3', $this->file_id); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -31,22 +31,22 @@ discard block |
||
31 | 31 | public bool $is_revoked; |
32 | 32 | |
33 | 33 | /** Optional. Invite link name */ |
34 | - public null|string $name = null; |
|
34 | + public null | string $name = null; |
|
35 | 35 | |
36 | 36 | /** Optional. Point in time (Unix timestamp) when the link will expire or has been expired */ |
37 | - public null|int $expire_date = null; |
|
37 | + public null | int $expire_date = null; |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * Optional. The maximum number of users that can be members of the chat simultaneously after joining the chat |
41 | 41 | * via this invite link; 1-99999 |
42 | 42 | */ |
43 | - public null|int $member_limit = null; |
|
43 | + public null | int $member_limit = null; |
|
44 | 44 | |
45 | 45 | /** Optional. Number of pending join requests created using this link */ |
46 | - public null|int $pending_join_request_count = null; |
|
46 | + public null | int $pending_join_request_count = null; |
|
47 | 47 | |
48 | 48 | |
49 | - public function __construct(stdClass|null $object = null) { |
|
49 | + public function __construct(stdClass | null $object = null) { |
|
50 | 50 | if ($object != null) { |
51 | 51 | parent::__construct($object, self::subs); |
52 | 52 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @return responseError|bool|self |
59 | 59 | */ |
60 | - public function revoke(): self|responseError|bool { |
|
60 | + public function revoke(): self | responseError | bool { |
|
61 | 61 | return $this->is_revoked ?? telegram::revokeChatInviteLink($this->invite_link); |
62 | 62 | } |
63 | 63 | } |
@@ -11,7 +11,7 @@ |
||
11 | 11 | /** Keep all properties which has sub properties */ |
12 | 12 | private const subs = []; |
13 | 13 | |
14 | - public function __construct(stdClass|null $object = null) { |
|
14 | + public function __construct(stdClass | null $object = null) { |
|
15 | 15 | if ($object != null) { |
16 | 16 | parent::__construct($object, self::subs); |
17 | 17 | } |
@@ -25,28 +25,28 @@ discard block |
||
25 | 25 | * Optional. Message with the callback button that originated the query. Note that message content and message |
26 | 26 | * date will not be available if the message is too old |
27 | 27 | */ |
28 | - public null|message $message = null; |
|
28 | + public null | message $message = null; |
|
29 | 29 | |
30 | 30 | /** Optional. Identifier of the message sent via the bot in inline mode, that originated the query. */ |
31 | - public null|string $inline_message_id = null; |
|
31 | + public null | string $inline_message_id = null; |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Global identifier, uniquely corresponding to the chat to which the message with the callback button was sent. |
35 | 35 | * Useful for high scores in games. |
36 | 36 | */ |
37 | - public null|string $chat_instance = null; |
|
37 | + public null | string $chat_instance = null; |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * Optional. Data associated with the callback button. Be aware that the message originated the query can contain |
41 | 41 | * no callback buttons with this data. |
42 | 42 | */ |
43 | - public null|string $data = null; |
|
43 | + public null | string $data = null; |
|
44 | 44 | |
45 | 45 | /** Optional. Short name of a Game to be returned, serves as the unique identifier for the game */ |
46 | - public null|string $game_short_name = null; |
|
46 | + public null | string $game_short_name = null; |
|
47 | 47 | |
48 | 48 | |
49 | - public function __construct(stdClass|null $object = null) { |
|
49 | + public function __construct(stdClass | null $object = null) { |
|
50 | 50 | if ($object != null) { |
51 | 51 | parent::__construct($object, self::subs); |
52 | 52 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @return responseError|bool |
67 | 67 | */ |
68 | - public function answer (string|null $text = null, bool|null $show_alert = null, string|null $url = null, int|null $cache_time = null, bool $answer = null): responseError|bool { |
|
68 | + public function answer(string | null $text = null, bool | null $show_alert = null, string | null $url = null, int | null $cache_time = null, bool $answer = null): responseError | bool { |
|
69 | 69 | return telegram::answerCallbackQuery($this->id, $text, $show_alert, $url, $cache_time, answer: $answer); |
70 | 70 | } |
71 | 71 | |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * |
78 | 78 | * @return message|responseError|bool |
79 | 79 | */ |
80 | - public function editText (string $text, bool $answer = null): message|responseError|bool { |
|
80 | + public function editText(string $text, bool $answer = null): message | responseError | bool { |
|
81 | 81 | return telegram::editMessageText($text, answer: $answer); |
82 | 82 | } |
83 | 83 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @return message|responseError|bool |
91 | 91 | */ |
92 | - public function editCaption (string $text = '', bool $answer = null): message|responseError|bool { |
|
92 | + public function editCaption(string $text = '', bool $answer = null): message | responseError | bool { |
|
93 | 93 | return telegram::editMessageCaption(caption: $text, answer: $answer); |
94 | 94 | } |
95 | 95 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return message|responseError|bool |
103 | 103 | */ |
104 | - public function editKeyboard (inlineKeyboardMarkup|stdClass|array $reply_markup = null, bool $answer = null): message|responseError|bool { |
|
104 | + public function editKeyboard(inlineKeyboardMarkup | stdClass | array $reply_markup = null, bool $answer = null): message | responseError | bool { |
|
105 | 105 | return telegram::editMessageReplyMarkup(reply_markup: $reply_markup, answer: $answer); |
106 | 106 | } |
107 | 107 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return message|responseError|bool |
115 | 115 | */ |
116 | - public function editMedia (inputMedia|array|stdClass $media, bool $answer = null): message|responseError|bool { |
|
116 | + public function editMedia(inputMedia | array | stdClass $media, bool $answer = null): message | responseError | bool { |
|
117 | 117 | return telegram::editMessageMedia($media, answer: $answer); |
118 | 118 | } |
119 | 119 | } |
@@ -73,13 +73,13 @@ discard block |
||
73 | 73 | public int $message_id; |
74 | 74 | |
75 | 75 | /** Optional. Unique identifier of a message thread to which the message belongs; for supergroups only */ |
76 | - public null|int $message_thread_id = null; |
|
76 | + public null | int $message_thread_id = null; |
|
77 | 77 | |
78 | 78 | /** |
79 | 79 | * Optional. Sender of the message; empty for messages sent to channels. For backward compatibility, the field |
80 | 80 | * contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat. |
81 | 81 | */ |
82 | - public null|user $from = null; |
|
82 | + public null | user $from = null; |
|
83 | 83 | |
84 | 84 | /** |
85 | 85 | * Optional. Sender of the message, sent on behalf of a chat. For example, the channel itself for channel posts, |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * automatically forwarded to the discussion group. For backward compatibility, the field from contains a fake |
88 | 88 | * sender user in non-channel chats, if the message was sent on behalf of a chat. |
89 | 89 | */ |
90 | - public null|chat $sender_chat = null; |
|
90 | + public null | chat $sender_chat = null; |
|
91 | 91 | |
92 | 92 | /** Date the message was sent in Unix time */ |
93 | 93 | public int $date; |
@@ -96,191 +96,191 @@ discard block |
||
96 | 96 | public chat $chat; |
97 | 97 | |
98 | 98 | /** Optional. For forwarded messages, sender of the original message */ |
99 | - public null|user $forward_from = null; |
|
99 | + public null | user $forward_from = null; |
|
100 | 100 | |
101 | 101 | /** |
102 | 102 | * Optional. For messages forwarded from channels or from anonymous administrators, information about the |
103 | 103 | * original sender chat |
104 | 104 | */ |
105 | - public null|chat $forward_from_chat = null; |
|
105 | + public null | chat $forward_from_chat = null; |
|
106 | 106 | |
107 | 107 | /** Optional. For messages forwarded from channels, identifier of the original message in the channel */ |
108 | - public null|int $forward_from_message_id = null; |
|
108 | + public null | int $forward_from_message_id = null; |
|
109 | 109 | |
110 | 110 | /** |
111 | 111 | * Optional. For forwarded messages that were originally sent in channels or by an anonymous chat administrator, |
112 | 112 | * signature of the message sender if present |
113 | 113 | */ |
114 | - public null|string $forward_signature = null; |
|
114 | + public null | string $forward_signature = null; |
|
115 | 115 | |
116 | 116 | /** |
117 | 117 | * Optional. Sender's name for messages forwarded from users who disallow adding a link to their account in |
118 | 118 | * forwarded messages |
119 | 119 | */ |
120 | - public null|string $forward_sender_name = null; |
|
120 | + public null | string $forward_sender_name = null; |
|
121 | 121 | |
122 | 122 | /** Optional. For forwarded messages, date the original message was sent in Unix time */ |
123 | - public null|int $forward_date = null; |
|
123 | + public null | int $forward_date = null; |
|
124 | 124 | |
125 | 125 | /** Optional. True, if the message is sent to a forum topic */ |
126 | - public null|bool $is_topic_message = null; |
|
126 | + public null | bool $is_topic_message = null; |
|
127 | 127 | |
128 | 128 | /** |
129 | 129 | * Optional. True, if the message is a channel post that was automatically forwarded to the connected discussion |
130 | 130 | * group |
131 | 131 | */ |
132 | - public null|bool $is_automatic_forward = null; |
|
132 | + public null | bool $is_automatic_forward = null; |
|
133 | 133 | |
134 | 134 | /** |
135 | 135 | * Optional. For replies, the original message. Note that the Message object in this field will not contain |
136 | 136 | * further reply_to_message fields even if it itself is a reply. |
137 | 137 | */ |
138 | - public null|message $reply_to_message = null; |
|
138 | + public null | message $reply_to_message = null; |
|
139 | 139 | |
140 | 140 | /** Optional. Bot through which the message was sent */ |
141 | - public null|user $via_bot = null; |
|
141 | + public null | user $via_bot = null; |
|
142 | 142 | |
143 | 143 | /** Optional. Date the message was last edited in Unix time */ |
144 | - public null|int $edit_date = null; |
|
144 | + public null | int $edit_date = null; |
|
145 | 145 | |
146 | 146 | /** Optional. True, if the message can't be forwarded */ |
147 | - public null|bool $has_protected_content = null; |
|
147 | + public null | bool $has_protected_content = null; |
|
148 | 148 | |
149 | 149 | /** Optional. The unique identifier of a media message group this message belongs to */ |
150 | - public null|string $media_group_id = null; |
|
150 | + public null | string $media_group_id = null; |
|
151 | 151 | |
152 | 152 | /** |
153 | 153 | * Optional. Signature of the post author for messages in channels, or the custom title of an anonymous group |
154 | 154 | * administrator |
155 | 155 | */ |
156 | - public null|string $author_signature = null; |
|
156 | + public null | string $author_signature = null; |
|
157 | 157 | |
158 | 158 | /** Optional. For text messages, the actual UTF-8 text of the message */ |
159 | - public null|string $text = null; |
|
159 | + public null | string $text = null; |
|
160 | 160 | |
161 | 161 | /** Optional. If user message was a command , this parameter will be the command */ |
162 | - public string|null $command = null; |
|
162 | + public string | null $command = null; |
|
163 | 163 | |
164 | 164 | /** Optional. If user message was a command , this parameter will be the command username(if exist) */ |
165 | - public string|null $command_username = null; |
|
165 | + public string | null $command_username = null; |
|
166 | 166 | |
167 | 167 | /** Optional. If user message was a command , this parameter will be the command payload(if exist) */ |
168 | - public string|null $command_payload = null; |
|
168 | + public string | null $command_payload = null; |
|
169 | 169 | |
170 | 170 | /** |
171 | 171 | * Optional. For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text |
172 | 172 | * @var messageEntity[] |
173 | 173 | */ |
174 | - public null|array $entities = null; |
|
174 | + public null | array $entities = null; |
|
175 | 175 | |
176 | 176 | /** |
177 | 177 | * Optional. Message is an animation, information about the animation. For backward compatibility, when this |
178 | 178 | * field is set, the document field will also be set |
179 | 179 | */ |
180 | - public null|animation $animation = null; |
|
180 | + public null | animation $animation = null; |
|
181 | 181 | |
182 | 182 | /** Optional. Message is an audio file, information about the file */ |
183 | - public null|audio $audio = null; |
|
183 | + public null | audio $audio = null; |
|
184 | 184 | |
185 | 185 | /** Optional. Message is a general file, information about the file */ |
186 | - public null|document $document = null; |
|
186 | + public null | document $document = null; |
|
187 | 187 | |
188 | 188 | /** |
189 | 189 | * Optional. Message is a photo, available sizes of the photo |
190 | 190 | * @var photoSize[] |
191 | 191 | */ |
192 | - public null|array $photo = null; |
|
192 | + public null | array $photo = null; |
|
193 | 193 | |
194 | 194 | /** Optional. Message is a sticker, information about the sticker */ |
195 | - public null|sticker $sticker = null; |
|
195 | + public null | sticker $sticker = null; |
|
196 | 196 | |
197 | 197 | /** Optional. Message is a forwarded story */ |
198 | - public null|story $story; |
|
198 | + public null | story $story; |
|
199 | 199 | |
200 | 200 | /** Optional. Message is a video, information about the video */ |
201 | - public null|video $video = null; |
|
201 | + public null | video $video = null; |
|
202 | 202 | |
203 | 203 | /** Optional. Message is a video note, information about the video message */ |
204 | - public null|videoNote $video_note = null; |
|
204 | + public null | videoNote $video_note = null; |
|
205 | 205 | |
206 | 206 | /** Optional. Message is a voice message, information about the file */ |
207 | - public null|voice $voice = null; |
|
207 | + public null | voice $voice = null; |
|
208 | 208 | |
209 | 209 | /** Optional. Caption for the animation, audio, document, photo, video or voice */ |
210 | - public null|string $caption = null; |
|
210 | + public null | string $caption = null; |
|
211 | 211 | |
212 | 212 | /** |
213 | 213 | * Optional. For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear |
214 | 214 | * in the caption |
215 | 215 | * @var messageEntity[] |
216 | 216 | */ |
217 | - public null|array $caption_entities = null; |
|
217 | + public null | array $caption_entities = null; |
|
218 | 218 | |
219 | 219 | /** Optional. True, if the message media is covered by a spoiler animation */ |
220 | - public null|bool $has_media_spoiler = null; |
|
220 | + public null | bool $has_media_spoiler = null; |
|
221 | 221 | |
222 | 222 | /** Optional. Message is a shared contact, information about the contact */ |
223 | - public null|contact $contact = null; |
|
223 | + public null | contact $contact = null; |
|
224 | 224 | |
225 | 225 | /** Optional. Message is a dice with random value */ |
226 | - public null|dice $dice = null; |
|
226 | + public null | dice $dice = null; |
|
227 | 227 | |
228 | 228 | /** Optional. Message is a game, information about the game. More about games » */ |
229 | - public null|game $game = null; |
|
229 | + public null | game $game = null; |
|
230 | 230 | |
231 | 231 | /** Optional. Message is a native poll, information about the poll */ |
232 | - public null|poll $poll = null; |
|
232 | + public null | poll $poll = null; |
|
233 | 233 | |
234 | 234 | /** |
235 | 235 | * Optional. Message is a venue, information about the venue. For backward compatibility, when this field is set, |
236 | 236 | * the location field will also be set |
237 | 237 | */ |
238 | - public null|venue $venue = null; |
|
238 | + public null | venue $venue = null; |
|
239 | 239 | |
240 | 240 | /** Optional. Message is a shared location, information about the location */ |
241 | - public null|location $location = null; |
|
241 | + public null | location $location = null; |
|
242 | 242 | |
243 | 243 | /** |
244 | 244 | * Optional. New members that were added to the group or supergroup and information about them (the bot itself |
245 | 245 | * may be one of these members) |
246 | 246 | * @var user[] |
247 | 247 | */ |
248 | - public null|array $new_chat_members = null; |
|
248 | + public null | array $new_chat_members = null; |
|
249 | 249 | |
250 | 250 | /** Optional. A member was removed from the group, information about them (this member may be the bot itself) */ |
251 | - public null|user $left_chat_member = null; |
|
251 | + public null | user $left_chat_member = null; |
|
252 | 252 | |
253 | 253 | /** Optional. A chat title was changed to this value */ |
254 | - public null|string $new_chat_title = null; |
|
254 | + public null | string $new_chat_title = null; |
|
255 | 255 | |
256 | 256 | /** |
257 | 257 | * Optional. A chat photo was change to this value |
258 | 258 | * @var photoSize[] |
259 | 259 | */ |
260 | - public null|array $new_chat_photo = null; |
|
260 | + public null | array $new_chat_photo = null; |
|
261 | 261 | |
262 | 262 | /** Optional. Service message: the chat photo was deleted */ |
263 | - public null|bool $delete_chat_photo = null; |
|
263 | + public null | bool $delete_chat_photo = null; |
|
264 | 264 | |
265 | 265 | /** Optional. Service message: the group has been created */ |
266 | - public null|bool $group_chat_created = null; |
|
266 | + public null | bool $group_chat_created = null; |
|
267 | 267 | |
268 | 268 | /** |
269 | 269 | * Optional. Service message: the supergroup has been created. This field can't be received in a message coming |
270 | 270 | * through updates, because bot can't be a member of a supergroup when it is created. It can only be found in |
271 | 271 | * reply_to_message if someone replies to a very first message in a directly created supergroup. |
272 | 272 | */ |
273 | - public null|bool $supergroup_chat_created = null; |
|
273 | + public null | bool $supergroup_chat_created = null; |
|
274 | 274 | |
275 | 275 | /** |
276 | 276 | * Optional. Service message: the channel has been created. This field can't be received in a message coming |
277 | 277 | * through updates, because bot can't be a member of a channel when it is created. It can only be found in |
278 | 278 | * reply_to_message if someone replies to a very first message in a channel. |
279 | 279 | */ |
280 | - public null|bool $channel_chat_created = null; |
|
280 | + public null | bool $channel_chat_created = null; |
|
281 | 281 | |
282 | 282 | /** Optional. Service message: auto-delete timer settings changed in the chat */ |
283 | - public null|messageAutoDeleteTimerChanged $message_auto_delete_timer_changed = null; |
|
283 | + public null | messageAutoDeleteTimerChanged $message_auto_delete_timer_changed = null; |
|
284 | 284 | |
285 | 285 | /** |
286 | 286 | * Optional. The group has been migrated to a supergroup with the specified identifier. This number may have more |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | * But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for |
289 | 289 | * storing this identifier. |
290 | 290 | */ |
291 | - public null|int $migrate_to_chat_id = null; |
|
291 | + public null | int $migrate_to_chat_id = null; |
|
292 | 292 | |
293 | 293 | /** |
294 | 294 | * Optional. The supergroup has been migrated from a group with the specified identifier. This number may have |
@@ -296,82 +296,82 @@ discard block |
||
296 | 296 | * interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float |
297 | 297 | * type are safe for storing this identifier. |
298 | 298 | */ |
299 | - public null|int $migrate_from_chat_id = null; |
|
299 | + public null | int $migrate_from_chat_id = null; |
|
300 | 300 | |
301 | 301 | /** |
302 | 302 | * Optional. Specified message was pinned. Note that the Message object in this field will not contain further |
303 | 303 | * reply_to_message fields even if it is itself a reply. |
304 | 304 | */ |
305 | - public null|message $pinned_message = null; |
|
305 | + public null | message $pinned_message = null; |
|
306 | 306 | |
307 | 307 | /** Optional. Message is an invoice for a payment, information about the invoice. More about payments » */ |
308 | - public null|invoice $invoice = null; |
|
308 | + public null | invoice $invoice = null; |
|
309 | 309 | |
310 | 310 | /** |
311 | 311 | * Optional. Message is a service message about a successful payment, information about the payment. More about |
312 | 312 | * payments » |
313 | 313 | */ |
314 | - public null|successfulPayment $successful_payment = null; |
|
314 | + public null | successfulPayment $successful_payment = null; |
|
315 | 315 | |
316 | 316 | /** Optional. Service message: a user was shared with the bot */ |
317 | - public null|userShared $user_shared = null; |
|
317 | + public null | userShared $user_shared = null; |
|
318 | 318 | |
319 | 319 | /** Optional. Service message: a chat was shared with the bot */ |
320 | - public null|chatShared $chat_shared = null; |
|
320 | + public null | chatShared $chat_shared = null; |
|
321 | 321 | |
322 | 322 | /** Optional. The domain name of the website on which the user has logged in. More about Telegram Login » */ |
323 | - public null|string $connected_website = null; |
|
323 | + public null | string $connected_website = null; |
|
324 | 324 | |
325 | 325 | /** Optional. Service message: the user allowed the bot added to the attachment menu to write messages */ |
326 | - public null|writeAccessAllowed $write_access_allowed = null; |
|
326 | + public null | writeAccessAllowed $write_access_allowed = null; |
|
327 | 327 | |
328 | 328 | /** Optional. Telegram Passport data */ |
329 | - public null|passportData $passport_data = null; |
|
329 | + public null | passportData $passport_data = null; |
|
330 | 330 | |
331 | 331 | /** |
332 | 332 | * Optional. Service message. A user in the chat triggered another user's proximity alert while sharing Live |
333 | 333 | * Location. |
334 | 334 | */ |
335 | - public null|proximityAlertTriggered $proximity_alert_triggered = null; |
|
335 | + public null | proximityAlertTriggered $proximity_alert_triggered = null; |
|
336 | 336 | |
337 | 337 | /** Optional. Service message: forum topic created */ |
338 | - public null|forumTopicCreated $forum_topic_created = null; |
|
338 | + public null | forumTopicCreated $forum_topic_created = null; |
|
339 | 339 | |
340 | 340 | /** Optional. Service message: forum topic edited */ |
341 | - public null|forumTopicEdited $forum_topic_edited = null; |
|
341 | + public null | forumTopicEdited $forum_topic_edited = null; |
|
342 | 342 | |
343 | 343 | /** Optional. Service message: forum topic closed */ |
344 | - public null|forumTopicClosed $forum_topic_closed = null; |
|
344 | + public null | forumTopicClosed $forum_topic_closed = null; |
|
345 | 345 | |
346 | 346 | /** Optional. Service message: forum topic reopened */ |
347 | - public null|forumTopicReopened $forum_topic_reopened = null; |
|
347 | + public null | forumTopicReopened $forum_topic_reopened = null; |
|
348 | 348 | |
349 | 349 | /** Optional. Service message: the 'General' forum topic hidden */ |
350 | - public null|generalForumTopicHidden $general_forum_topic_hidden = null; |
|
350 | + public null | generalForumTopicHidden $general_forum_topic_hidden = null; |
|
351 | 351 | |
352 | 352 | /** Optional. Service message: the 'General' forum topic unhidden */ |
353 | - public null|generalForumTopicUnhidden $general_forum_topic_unhidden = null; |
|
353 | + public null | generalForumTopicUnhidden $general_forum_topic_unhidden = null; |
|
354 | 354 | |
355 | 355 | /** Optional. Service message: video chat scheduled */ |
356 | - public null|videoChatScheduled $video_chat_scheduled = null; |
|
356 | + public null | videoChatScheduled $video_chat_scheduled = null; |
|
357 | 357 | |
358 | 358 | /** Optional. Service message: video chat started */ |
359 | - public null|videoChatStarted $video_chat_started = null; |
|
359 | + public null | videoChatStarted $video_chat_started = null; |
|
360 | 360 | |
361 | 361 | /** Optional. Service message: video chat ended */ |
362 | - public null|videoChatEnded $video_chat_ended = null; |
|
362 | + public null | videoChatEnded $video_chat_ended = null; |
|
363 | 363 | |
364 | 364 | /** Optional. Service message: new participants invited to a video chat */ |
365 | - public null|videoChatParticipantsInvited $video_chat_participants_invited = null; |
|
365 | + public null | videoChatParticipantsInvited $video_chat_participants_invited = null; |
|
366 | 366 | |
367 | 367 | /** Optional. Service message: data sent by a Web App */ |
368 | - public null|webAppData $web_app_data = null; |
|
368 | + public null | webAppData $web_app_data = null; |
|
369 | 369 | |
370 | 370 | /** Optional. Inline keyboard attached to the message. login_url buttons are represented as ordinary url buttons. */ |
371 | - public null|inlineKeyboardMarkup $reply_markup = null; |
|
371 | + public null | inlineKeyboardMarkup $reply_markup = null; |
|
372 | 372 | |
373 | 373 | |
374 | - public function __construct(stdClass|null $object = null) { |
|
374 | + public function __construct(stdClass | null $object = null) { |
|
375 | 375 | if ($object != null) { |
376 | 376 | parent::__construct($object, self::subs); |
377 | 377 | } |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | * |
383 | 383 | * @return bool |
384 | 384 | */ |
385 | - public function isCommand (): bool { |
|
385 | + public function isCommand(): bool { |
|
386 | 386 | return !empty($this->command); |
387 | 387 | } |
388 | 388 | |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | * |
392 | 392 | * @return bool |
393 | 393 | */ |
394 | - public function isForwarded (): bool { |
|
394 | + public function isForwarded(): bool { |
|
395 | 395 | return $this->forward_from !== null || $this->forward_from_chat !== null; |
396 | 396 | } |
397 | 397 | |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | * |
403 | 403 | * @return bool |
404 | 404 | */ |
405 | - public function isAdmin (): bool { |
|
405 | + public function isAdmin(): bool { |
|
406 | 406 | return $this->chat->getMember($this->from->id)->status === chatMemberStatus::ADMINISTRATOR; |
407 | 407 | } |
408 | 408 | |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | * |
414 | 414 | * @return bool |
415 | 415 | */ |
416 | - public function isOwner (): bool { |
|
416 | + public function isOwner(): bool { |
|
417 | 417 | return $this->chat->getMember($this->from->id)->status === chatMemberStatus::CREATOR; |
418 | 418 | } |
419 | 419 | |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | * |
427 | 427 | * @return responseError|bool |
428 | 428 | */ |
429 | - public function banMember(bool $answer = null): responseError|bool { |
|
429 | + public function banMember(bool $answer = null): responseError | bool { |
|
430 | 430 | if ($this->chat->isPrivate()) { |
431 | 431 | return false; |
432 | 432 | } |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | * |
443 | 443 | * @return responseError|bool |
444 | 444 | */ |
445 | - public function kickMember(bool $answer = null): responseError|bool { |
|
445 | + public function kickMember(bool $answer = null): responseError | bool { |
|
446 | 446 | if ($this->chat->isPrivate()) { |
447 | 447 | return false; |
448 | 448 | } |
@@ -456,8 +456,8 @@ discard block |
||
456 | 456 | * |
457 | 457 | * @return responseError|bool |
458 | 458 | */ |
459 | - public function delete (bool $answer = null): responseError|bool { |
|
460 | - return telegram::deleteMessage($this->chat->id,$this->id, answer: $answer); |
|
459 | + public function delete(bool $answer = null): responseError | bool { |
|
460 | + return telegram::deleteMessage($this->chat->id, $this->id, answer: $answer); |
|
461 | 461 | } |
462 | 462 | |
463 | 463 | /** |
@@ -467,8 +467,8 @@ discard block |
||
467 | 467 | * |
468 | 468 | * @return responseError|bool |
469 | 469 | */ |
470 | - public function pinChatMessage (bool $answer = null): responseError|bool { |
|
471 | - return telegram::deleteMessage($this->chat->id,$this->id, answer: $answer); |
|
470 | + public function pinChatMessage(bool $answer = null): responseError | bool { |
|
471 | + return telegram::deleteMessage($this->chat->id, $this->id, answer: $answer); |
|
472 | 472 | } |
473 | 473 | |
474 | 474 | /** |
@@ -479,8 +479,8 @@ discard block |
||
479 | 479 | * |
480 | 480 | * @return message|responseError|bool |
481 | 481 | */ |
482 | - public function editText (string $text, bool $answer = null): message|responseError|bool { |
|
483 | - return telegram::editMessageText($text, $this->chat->id, $this->message_id, answer: $answer); |
|
482 | + public function editText(string $text, bool $answer = null): message | responseError | bool { |
|
483 | + return telegram::editMessageText($text, $this->chat->id, $this->message_id, answer: $answer); |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | /** |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | * |
492 | 492 | * @return messageId|responseError |
493 | 493 | */ |
494 | - public function copy (int|string $chat_id, bool $answer = null): messageId|responseError { |
|
494 | + public function copy(int | string $chat_id, bool $answer = null): messageId | responseError { |
|
495 | 495 | return telegram::copyMessage($chat_id, answer: $answer); |
496 | 496 | } |
497 | 497 | |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | * |
504 | 504 | * @return message|responseError |
505 | 505 | */ |
506 | - public function forward (int|string $chat_id, bool $answer = null): message|responseError { |
|
506 | + public function forward(int | string $chat_id, bool $answer = null): message | responseError { |
|
507 | 507 | return telegram::forwardMessage($chat_id, answer: $answer); |
508 | 508 | } |
509 | 509 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | public function __toString(): string { |
12 | 12 | $array = json_decode(json_encode($this), true); |
13 | 13 | |
14 | - $cleanArray = function ($array) use (&$cleanArray) { |
|
14 | + $cleanArray = function($array) use (&$cleanArray) { |
|
15 | 15 | return array_filter(array_map(fn($value) => is_array($value) ? $cleanArray($value) : $value, $array)); |
16 | 16 | }; |
17 | 17 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | } |
41 | 41 | else { |
42 | 42 | $this->{$key} = $value; |
43 | - if (ucfirst($key) === basename(get_class($this)) . '_id') { |
|
43 | + if (ucfirst($key) === basename(get_class($this)).'_id') { |
|
44 | 44 | $this->{'id'} = $value; |
45 | 45 | } |
46 | 46 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | public function __call(string $name, array $arguments) { |
51 | 51 | $name = strtolower($name); |
52 | 52 | if (str_starts_with($name, 'set')) { |
53 | - $name = substr($name,3); |
|
53 | + $name = substr($name, 3); |
|
54 | 54 | if (isset($arguments[0])) { |
55 | 55 | $this->{$name} = $arguments[0]; |
56 | 56 | } |
@@ -22,23 +22,19 @@ discard block |
||
22 | 22 | foreach ($object as $key=>$value) { |
23 | 23 | if (isset($subs[$key])) { |
24 | 24 | $this->{$key} = new ($subs[$key]) ($value); |
25 | - } |
|
26 | - elseif (is_array($value) && isset($subs['array'])) { |
|
25 | + } elseif (is_array($value) && isset($subs['array'])) { |
|
27 | 26 | foreach ($value as $sub_key => $sub_value) { |
28 | 27 | if (is_array($sub_value) && isset($subs['array']['array'])) { |
29 | 28 | foreach ($sub_value as $sub2_value) { |
30 | 29 | $this->{$key}[$sub_key][] = new ($subs['array']['array'][$key]) ($sub2_value); |
31 | 30 | } |
32 | - } |
|
33 | - elseif (isset($subs['array'][$key])) { |
|
31 | + } elseif (isset($subs['array'][$key])) { |
|
34 | 32 | $this->{$key}[] = new ($subs['array'][$key]) ($sub_value); |
35 | - } |
|
36 | - else { |
|
33 | + } else { |
|
37 | 34 | $this->{$key}[] = $sub_value; |
38 | 35 | } |
39 | 36 | } |
40 | - } |
|
41 | - else { |
|
37 | + } else { |
|
42 | 38 | $this->{$key} = $value; |
43 | 39 | if (ucfirst($key) === basename(get_class($this)) . '_id') { |
44 | 40 | $this->{'id'} = $value; |
@@ -53,8 +49,7 @@ discard block |
||
53 | 49 | $name = substr($name,3); |
54 | 50 | if (isset($arguments[0])) { |
55 | 51 | $this->{$name} = $arguments[0]; |
56 | - } |
|
57 | - elseif (isset($arguments['value'])) { |
|
52 | + } elseif (isset($arguments['value'])) { |
|
58 | 53 | $this->{$name} = $arguments['value']; |
59 | 54 | } |
60 | 55 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | /** |
32 | 32 | * tools class , gather what ever you need |
33 | 33 | */ |
34 | -class tools{ |
|
34 | +class tools { |
|
35 | 35 | /** |
36 | 36 | * Check the given username format |
37 | 37 | * |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @return bool |
45 | 45 | */ |
46 | - public static function isUsername (string $username): bool { |
|
46 | + public static function isUsername(string $username): bool { |
|
47 | 47 | $length = strlen($username); |
48 | 48 | return !str_contains($username, '__') && $length >= 4 && $length <= 33 && preg_match('/^@?([a-zA-Z])(\w{4,31})$/', $username); |
49 | 49 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @return bool |
62 | 62 | */ |
63 | - public static function ipInRange (string $ip, string $range): bool { |
|
63 | + public static function ipInRange(string $ip, string $range): bool { |
|
64 | 64 | if (!str_contains($range, '/')) { |
65 | 65 | $range .= '/32'; |
66 | 66 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return bool |
82 | 82 | */ |
83 | - public static function isTelegram (string $ip): bool { |
|
83 | + public static function isTelegram(string $ip): bool { |
|
84 | 84 | return tools::ipInRange($ip, '149.154.160.0/20') || tools::ipInRange($ip, '91.108.4.0/22'); |
85 | 85 | } |
86 | 86 | |
@@ -95,10 +95,10 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @return bool |
97 | 97 | */ |
98 | - public static function isCloudFlare (string $ip): bool { |
|
98 | + public static function isCloudFlare(string $ip): bool { |
|
99 | 99 | $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', '104.24.0.0/14', '172.64.0.0/13', '131.0.72.0/22']; |
100 | 100 | foreach ($cf_ips as $cf_ip) { |
101 | - if (self::ipInRange($ip,$cf_ip)) { |
|
101 | + if (self::ipInRange($ip, $cf_ip)) { |
|
102 | 102 | return true; |
103 | 103 | } |
104 | 104 | } |
@@ -116,10 +116,10 @@ discard block |
||
116 | 116 | * |
117 | 117 | * @return bool |
118 | 118 | */ |
119 | - public static function isArvanCloud (string $ip): bool { |
|
119 | + public static function isArvanCloud(string $ip): bool { |
|
120 | 120 | $ar_ips = ['185.143.232.0/22', '92.114.16.80/28', '2.146.0.0/28', '46.224.2.32/29', '89.187.178.96/29', '195.181.173.128/29', '89.187.169.88/29', '188.229.116.16/29', '83.123.255.56/31', '164.138.128.28/31', '94.182.182.28/30', '185.17.115.176/30', '5.213.255.36/31', '138.128.139.144/29', '5.200.14.8/29', '188.122.68.224/29', '188.122.83.176/29', '213.179.217.16/29', '185.179.201.192/29', '43.239.139.192/29', '213.179.197.16/29', '213.179.201.192/29', '109.200.214.248/29', '138.128.141.16/29', '188.122.78.136/29', '213.179.211.32/29', '103.194.164.24/29', '185.50.105.136/29', '213.179.213.16/29', '162.244.52.120/29', '188.122.80.240/29', '109.200.195.64/29', '109.200.199.224/29', '185.228.238.0/28', '94.182.153.24/29', '94.101.182.0/27', '37.152.184.208/28', '78.39.156.192/28', '158.255.77.238/31', '81.12.28.16/29', '176.65.192.202/31', '2.144.3.128/28', '89.45.48.64/28', '37.32.16.0/27', '37.32.17.0/27', '37.32.18.0/27']; |
121 | 121 | foreach ($ar_ips as $ar_ip) { |
122 | - if (self::ipInRange($ip,$ar_ip)) { |
|
122 | + if (self::ipInRange($ip, $ar_ip)) { |
|
123 | 123 | return true; |
124 | 124 | } |
125 | 125 | } |
@@ -139,11 +139,11 @@ discard block |
||
139 | 139 | * |
140 | 140 | * @return bool|user return array when verify is active and token is true array of telegram getMe result |
141 | 141 | */ |
142 | - public static function isToken (string $token, bool $verify = false): bool|user { |
|
142 | + public static function isToken(string $token, bool $verify = false): bool | user { |
|
143 | 143 | if (!preg_match('/^(\d{8,10}):[\w\-]{35}$/', $token)) { |
144 | 144 | return false; |
145 | 145 | } |
146 | - if (!$verify){ |
|
146 | + if (!$verify) { |
|
147 | 147 | return true; |
148 | 148 | } |
149 | 149 | $res = telegram::me($token); |
@@ -173,14 +173,14 @@ discard block |
||
173 | 173 | * |
174 | 174 | * @return bool |
175 | 175 | */ |
176 | - public static function isJoined (array|string|int $ids , int|null $user_id = null): bool { |
|
176 | + public static function isJoined(array | string | int $ids, int | null $user_id = null): bool { |
|
177 | 177 | if (!is_array($ids)) { |
178 | 178 | $ids = [$ids]; |
179 | 179 | } |
180 | 180 | $user_id = $user_id ?? request::catchFields('user_id'); |
181 | 181 | |
182 | 182 | foreach ($ids as $id) { |
183 | - $check = telegram::getChatMember($id,$user_id); |
|
183 | + $check = telegram::getChatMember($id, $user_id); |
|
184 | 184 | if (telegram::$status) { |
185 | 185 | $check = $check->status; |
186 | 186 | if ($check === chatMemberStatus::LEFT || $check === chatMemberStatus::KICKED) { |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @return array keys will be id and values will be bool(null for not founded ids) |
209 | 209 | */ |
210 | - public static function joinChecker (array|string|int $ids , int|null $user_id = null): array { |
|
210 | + public static function joinChecker(array | string | int $ids, int | null $user_id = null): array { |
|
211 | 211 | if (!is_array($ids)) { |
212 | 212 | $ids = [$ids]; |
213 | 213 | } |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | |
216 | 216 | $result = []; |
217 | 217 | foreach ($ids as $id) { |
218 | - $check = telegram::getChatMember($id,$user_id); |
|
218 | + $check = telegram::getChatMember($id, $user_id); |
|
219 | 219 | if (telegram::$status) { |
220 | 220 | $check = $check->status; |
221 | 221 | $result[$id] = $check !== chatMemberStatus::LEFT && $check !== chatMemberStatus::KICKED; |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | * @return bool |
236 | 236 | */ |
237 | 237 | public static function isShorted(string $text): bool{ |
238 | - return preg_match('/^[a-zA-Z0-9]+$/',$text); |
|
238 | + return preg_match('/^[a-zA-Z0-9]+$/', $text); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | /** |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @return string|int|false string for formatted data , int for normal data , false when size can not be found(file not found or ...) |
255 | 255 | */ |
256 | - public static function size (string $path, bool $format = true, bool $space_between = true): string|int|false { |
|
256 | + public static function size(string $path, bool $format = true, bool $space_between = true): string | int | false { |
|
257 | 257 | if (filter_var($path, FILTER_VALIDATE_URL)) { |
258 | 258 | $ch = curl_init($path); |
259 | 259 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | $size = file_exists($path) ? filesize($path) : false; |
269 | 269 | } |
270 | 270 | if (isset($size) && is_numeric($size)) { |
271 | - return $format ? tools::byteFormat($size, space_between: $space_between) : $size; |
|
271 | + return $format ? tools::byteFormat($size, space_between : $space_between) : $size; |
|
272 | 272 | } |
273 | 273 | return false; |
274 | 274 | } |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | * @return bool |
287 | 287 | * @throws bptException |
288 | 288 | */ |
289 | - public static function delete (string $path, bool $sub = true): bool { |
|
289 | + public static function delete(string $path, bool $sub = true): bool { |
|
290 | 290 | $path = realpath($path); |
291 | 291 | if (!is_dir($path)) { |
292 | 292 | return unlink($path); |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | return rmdir($path); |
296 | 296 | } |
297 | 297 | if (!$sub) { |
298 | - logger::write("tools::delete function used\ndelete function cannot delete folder because its have subFiles and sub parameter haven't true value",loggerTypes::ERROR); |
|
298 | + logger::write("tools::delete function used\ndelete function cannot delete folder because its have subFiles and sub parameter haven't true value", loggerTypes::ERROR); |
|
299 | 299 | throw new bptException('DELETE_FOLDER_HAS_SUB'); |
300 | 300 | } |
301 | 301 | $it = new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS); |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | * @return bool |
318 | 318 | * @throws bptException when zip extension not found |
319 | 319 | */ |
320 | - public static function zip (string $path, string $destination): bool { |
|
320 | + public static function zip(string $path, string $destination): bool { |
|
321 | 321 | if (!extension_loaded('zip')) { |
322 | 322 | logger::write("tools::zip function used\nzip extension is not found , It may not be installed or enabled", loggerTypes::ERROR); |
323 | 323 | throw new bptException('ZIP_EXTENSION_MISSING'); |
@@ -351,14 +351,14 @@ discard block |
||
351 | 351 | * |
352 | 352 | * @return bool true on success and false in failure |
353 | 353 | */ |
354 | - public static function downloadFile (string $url, string $path, int $chunk_size = 512): bool { |
|
354 | + public static function downloadFile(string $url, string $path, int $chunk_size = 512): bool { |
|
355 | 355 | $file = fopen($url, 'rb'); |
356 | 356 | if (!$file) return false; |
357 | 357 | $path = fopen($path, 'wb'); |
358 | 358 | if (!$path) return false; |
359 | 359 | |
360 | 360 | $length = $chunk_size * 1024; |
361 | - while (!feof($file)){ |
|
361 | + while (!feof($file)) { |
|
362 | 362 | fwrite($path, fread($file, $length), $length); |
363 | 363 | } |
364 | 364 | fclose($path); |
@@ -382,10 +382,10 @@ discard block |
||
382 | 382 | * |
383 | 383 | * @return string |
384 | 384 | */ |
385 | - public static function byteFormat (int $byte, int $precision = 2, bool $space_between = true): string { |
|
385 | + public static function byteFormat(int $byte, int $precision = 2, bool $space_between = true): string { |
|
386 | 386 | $rate_counter = 0; |
387 | 387 | |
388 | - while ($byte > 1024){ |
|
388 | + while ($byte > 1024) { |
|
389 | 389 | $byte /= 1024; |
390 | 390 | $rate_counter++; |
391 | 391 | } |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | $byte = round($byte, $precision); |
395 | 395 | } |
396 | 396 | |
397 | - return $byte . ($space_between ? ' ' : '') . ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'][$rate_counter]; |
|
397 | + return $byte.($space_between ? ' ' : '').['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'][$rate_counter]; |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | /** |
@@ -411,10 +411,10 @@ discard block |
||
411 | 411 | * |
412 | 412 | * @return string|false return false when mode is incorrect |
413 | 413 | */ |
414 | - public static function modeEscape (string $text, string $mode = parseMode::HTML): string|false { |
|
414 | + public static function modeEscape(string $text, string $mode = parseMode::HTML): string | false { |
|
415 | 415 | return match ($mode) { |
416 | - parseMode::HTML => str_replace(['&', '<', '>',], ['&', '<', '>',], $text), |
|
417 | - parseMode::MARKDOWN => str_replace(['\\', '_', '*', '`', '['], ['\\\\', '\_', '\*', '\`', '\[',], $text), |
|
416 | + parseMode::HTML => str_replace(['&', '<', '>', ], ['&', '<', '>', ], $text), |
|
417 | + parseMode::MARKDOWN => str_replace(['\\', '_', '*', '`', '['], ['\\\\', '\_', '\*', '\`', '\[', ], $text), |
|
418 | 418 | parseMode::MARKDOWNV2 => str_replace( |
419 | 419 | ['\\', '_', '*', '[', ']', '(', ')', '~', '`', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!'], |
420 | 420 | ['\\\\', '\_', '\*', '\[', '\]', '\(', '\)', '\~', '\`', '\>', '\#', '\+', '\-', '\=', '\|', '\{', '\}', '\.', '\!'], |
@@ -453,9 +453,9 @@ discard block |
||
453 | 453 | * @return array{status: string,year: string,month: string,day: string,hour: string,minute: string,second: string} |
454 | 454 | * @throws Exception |
455 | 455 | */ |
456 | - public static function timeDiff (int|string $target_time, int|string|null $base_time = null): array { |
|
456 | + public static function timeDiff(int | string $target_time, int | string | null $base_time = null): array { |
|
457 | 457 | $base_time = new DateTime($base_time ?? '@'.time()); |
458 | - $target_time = new DateTime(is_numeric($target_time) ? '@' . $target_time : $target_time . ' +00:00'); |
|
458 | + $target_time = new DateTime(is_numeric($target_time) ? '@'.$target_time : $target_time.' +00:00'); |
|
459 | 459 | |
460 | 460 | $diff = $base_time->diff($target_time); |
461 | 461 | $string = ['year' => 'y', 'month' => 'm', 'day' => 'd', 'hour' => 'h', 'minute' => 'i', 'second' => 's']; |
@@ -481,12 +481,12 @@ discard block |
||
481 | 481 | * |
482 | 482 | * @return string[]|string |
483 | 483 | */ |
484 | - public static function realEscapeString(string|array $input): string|array { |
|
485 | - if(is_array($input)) { |
|
484 | + public static function realEscapeString(string | array $input): string | array { |
|
485 | + if (is_array($input)) { |
|
486 | 486 | return array_map(__METHOD__, $input); |
487 | 487 | } |
488 | 488 | |
489 | - if(!empty($input) && is_string($input)) { |
|
489 | + if (!empty($input) && is_string($input)) { |
|
490 | 490 | return str_replace(['\\', "\0", "\n", "\r", "'", '"', "\x1a"], ['\\\\', '\\0', '\\n', '\\r', "\\'", '\\"', '\\Z'], $input); |
491 | 491 | } |
492 | 492 | |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | * |
505 | 505 | * @return string[]|string |
506 | 506 | */ |
507 | - public static function strReplaceFirst(string|array $search, string|array $replace, string|array $subject): string|array { |
|
507 | + public static function strReplaceFirst(string | array $search, string | array $replace, string | array $subject): string | array { |
|
508 | 508 | $pos = strpos($subject, $search); |
509 | 509 | if ($pos !== false) { |
510 | 510 | return substr_replace($subject, $replace, $pos, strlen($search)); |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | * |
522 | 522 | * @return string see possible values in fileType class |
523 | 523 | */ |
524 | - public static function fileType (string $file_id): string { |
|
524 | + public static function fileType(string $file_id): string { |
|
525 | 525 | $data = base64_decode(str_pad(strtr($file_id, '-_', '+/'), strlen($file_id) % 4, '=')); |
526 | 526 | $new = ''; |
527 | 527 | $last = ''; |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | $last = $char; |
536 | 536 | } |
537 | 537 | } |
538 | - $data = unpack('VtypeId/Vdc_id', $new . $last); |
|
538 | + $data = unpack('VtypeId/Vdc_id', $new.$last); |
|
539 | 539 | $data['typeId'] = $data['typeId'] & ~33554432 & ~16777216; |
540 | 540 | return [ |
541 | 541 | fileTypes::THUMBNAIL, |
@@ -573,10 +573,10 @@ discard block |
||
573 | 573 | * |
574 | 574 | * @return string |
575 | 575 | */ |
576 | - public static function randomString (int $length = 16, string $characters = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'): string { |
|
576 | + public static function randomString(int $length = 16, string $characters = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'): string { |
|
577 | 577 | $rand_string = ''; |
578 | 578 | $char_len = strlen($characters) - 1; |
579 | - for ($i = 0; $i < $length; $i ++) { |
|
579 | + for ($i = 0; $i < $length; $i++) { |
|
580 | 580 | $rand_string .= $characters[rand(0, $char_len)]; |
581 | 581 | } |
582 | 582 | return $rand_string; |
@@ -605,7 +605,7 @@ discard block |
||
605 | 605 | * @return inlineKeyboardMarkup|replyKeyboardMarkup replyKeyboardMarkup for keyboard and inlineKeyboardMarkup for inline |
606 | 606 | * @throws bptException |
607 | 607 | */ |
608 | - public static function easyKey(array $keyboard = [], array $inline = []): inlineKeyboardMarkup|replyKeyboardMarkup { |
|
608 | + public static function easyKey(array $keyboard = [], array $inline = []): inlineKeyboardMarkup | replyKeyboardMarkup { |
|
609 | 609 | if (!empty($keyboard)) { |
610 | 610 | $keyboard_object = new replyKeyboardMarkup(); |
611 | 611 | $keyboard_object->setResize_keyboard($keyboard['resize'] ?? true); |
@@ -669,7 +669,7 @@ discard block |
||
669 | 669 | $keyboard_object->setInline_keyboard($rows); |
670 | 670 | return $keyboard_object; |
671 | 671 | } |
672 | - logger::write("tools::eKey function used\nkeyboard or inline parameter must be set",loggerTypes::ERROR); |
|
672 | + logger::write("tools::eKey function used\nkeyboard or inline parameter must be set", loggerTypes::ERROR); |
|
673 | 673 | throw new bptException('ARGUMENT_NOT_FOUND_KEYBOARD_INLINE'); |
674 | 674 | } |
675 | 675 | |
@@ -685,10 +685,10 @@ discard block |
||
685 | 685 | * |
686 | 686 | * @return string |
687 | 687 | */ |
688 | - public static function inviteLink (int $user_id = null, string $bot_username = null): string { |
|
688 | + public static function inviteLink(int $user_id = null, string $bot_username = null): string { |
|
689 | 689 | if (empty($user_id)) $user_id = telegram::catchFields(fields::USER_ID); |
690 | 690 | if (empty($bot_username)) $bot_username = telegram::getMe()->username; |
691 | - return 'https://t.me/' . str_replace('@', '', $bot_username) . '?start=ref_' . tools::shortEncode($user_id); |
|
691 | + return 'https://t.me/'.str_replace('@', '', $bot_username).'?start=ref_'.tools::shortEncode($user_id); |
|
692 | 692 | } |
693 | 693 | |
694 | 694 | /** |
@@ -714,9 +714,9 @@ discard block |
||
714 | 714 | * @return string|bool|array{hash:string, key:string, iv:string} |
715 | 715 | * @throws bptException |
716 | 716 | */ |
717 | - public static function codec (string $action, string $text, string $key = null, string $iv = null): bool|array|string { |
|
717 | + public static function codec(string $action, string $text, string $key = null, string $iv = null): bool | array | string { |
|
718 | 718 | if (!extension_loaded('openssl')) { |
719 | - logger::write("tools::codec function used\nopenssl extension is not found , It may not be installed or enabled",loggerTypes::ERROR); |
|
719 | + logger::write("tools::codec function used\nopenssl extension is not found , It may not be installed or enabled", loggerTypes::ERROR); |
|
720 | 720 | throw new bptException('OPENSSL_EXTENSION_MISSING'); |
721 | 721 | } |
722 | 722 | if ($action === codecAction::ENCRYPT) { |
@@ -727,16 +727,16 @@ discard block |
||
727 | 727 | } |
728 | 728 | if ($action === codecAction::DECRYPT) { |
729 | 729 | if (empty($key)) { |
730 | - logger::write("tools::codec function used\nkey parameter is not set",loggerTypes::ERROR); |
|
730 | + logger::write("tools::codec function used\nkey parameter is not set", loggerTypes::ERROR); |
|
731 | 731 | throw new bptException('ARGUMENT_NOT_FOUND_KEY'); |
732 | 732 | } |
733 | 733 | if (empty($iv)) { |
734 | - logger::write("tools::codec function used\niv parameter is not set",loggerTypes::ERROR); |
|
734 | + logger::write("tools::codec function used\niv parameter is not set", loggerTypes::ERROR); |
|
735 | 735 | throw new bptException('ARGUMENT_NOT_FOUND_IV'); |
736 | 736 | } |
737 | 737 | return openssl_decrypt(base64_decode($text), 'AES-256-CBC', $key, 1, $iv); |
738 | 738 | } |
739 | - logger::write("tools::codec function used\naction is not right, its must be `encode` or `decode`",loggerTypes::WARNING); |
|
739 | + logger::write("tools::codec function used\naction is not right, its must be `encode` or `decode`", loggerTypes::WARNING); |
|
740 | 740 | return false; |
741 | 741 | } |
742 | 742 | |
@@ -752,7 +752,7 @@ discard block |
||
752 | 752 | public static function shortEncode(int $num): string { |
753 | 753 | $codes = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; |
754 | 754 | $array = []; |
755 | - while ($num > 0){ |
|
755 | + while ($num > 0) { |
|
756 | 756 | $array[] = $num % 62; |
757 | 757 | $num = floor($num / 62); |
758 | 758 | } |
@@ -760,7 +760,7 @@ discard block |
||
760 | 760 | foreach ($array as &$value) { |
761 | 761 | $value = $codes[$value]; |
762 | 762 | } |
763 | - return strrev(implode('',$array)); |
|
763 | + return strrev(implode('', $array)); |
|
764 | 764 | } |
765 | 765 | |
766 | 766 | /** |
@@ -777,7 +777,7 @@ discard block |
||
777 | 777 | $num = 0; |
778 | 778 | $text = str_split(strrev($text)); |
779 | 779 | foreach ($text as $key=>$value) { |
780 | - $num += strpos($codes,$value) * pow(62,$key); |
|
780 | + $num += strpos($codes, $value) * pow(62, $key); |
|
781 | 781 | } |
782 | 782 | return $num; |
783 | 783 | } |
@@ -219,8 +219,9 @@ discard block |
||
219 | 219 | if (telegram::$status) { |
220 | 220 | $check = $check->status; |
221 | 221 | $result[$id] = $check !== chatMemberStatus::LEFT && $check !== chatMemberStatus::KICKED; |
222 | + } else { |
|
223 | + $result[$id] = null; |
|
222 | 224 | } |
223 | - else $result[$id] = null; |
|
224 | 225 | } |
225 | 226 | return $result; |
226 | 227 | } |
@@ -262,8 +263,7 @@ discard block |
||
262 | 263 | curl_exec($ch); |
263 | 264 | $size = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD); |
264 | 265 | curl_close($ch); |
265 | - } |
|
266 | - else { |
|
266 | + } else { |
|
267 | 267 | $path = realpath($path); |
268 | 268 | $size = file_exists($path) ? filesize($path) : false; |
269 | 269 | } |
@@ -353,9 +353,13 @@ discard block |
||
353 | 353 | */ |
354 | 354 | public static function downloadFile (string $url, string $path, int $chunk_size = 512): bool { |
355 | 355 | $file = fopen($url, 'rb'); |
356 | - if (!$file) return false; |
|
356 | + if (!$file) { |
|
357 | + return false; |
|
358 | + } |
|
357 | 359 | $path = fopen($path, 'wb'); |
358 | - if (!$path) return false; |
|
360 | + if (!$path) { |
|
361 | + return false; |
|
362 | + } |
|
359 | 363 | |
360 | 364 | $length = $chunk_size * 1024; |
361 | 365 | while (!feof($file)){ |
@@ -462,8 +466,9 @@ discard block |
||
462 | 466 | foreach ($string as $k => &$v) { |
463 | 467 | if ($diff->{$v}) { |
464 | 468 | $v = $diff->{$v}; |
469 | + } else { |
|
470 | + unset($string[$k]); |
|
465 | 471 | } |
466 | - else unset($string[$k]); |
|
467 | 472 | } |
468 | 473 | $string['status'] = $base_time < $target_time ? 'later' : 'ago'; |
469 | 474 | |
@@ -529,8 +534,7 @@ discard block |
||
529 | 534 | if ($last === "\0") { |
530 | 535 | $new .= str_repeat($last, ord($char)); |
531 | 536 | $last = ''; |
532 | - } |
|
533 | - else { |
|
537 | + } else { |
|
534 | 538 | $new .= $last; |
535 | 539 | $last = $char; |
536 | 540 | } |
@@ -614,7 +618,9 @@ discard block |
||
614 | 618 | } |
615 | 619 | $rows = []; |
616 | 620 | foreach ($keyboard as $row) { |
617 | - if (!is_array($row)) continue; |
|
621 | + if (!is_array($row)) { |
|
622 | + continue; |
|
623 | + } |
|
618 | 624 | $buttons = []; |
619 | 625 | foreach ($row as $base_button) { |
620 | 626 | $button_info = explode('||', $base_button); |
@@ -623,15 +629,12 @@ discard block |
||
623 | 629 | if (count($button_info) > 1) { |
624 | 630 | if ($button_info[1] === 'con') { |
625 | 631 | $button->setRequest_contact(true); |
626 | - } |
|
627 | - elseif ($button_info[1] === 'loc') { |
|
632 | + } elseif ($button_info[1] === 'loc') { |
|
628 | 633 | $button->setRequest_location(true); |
629 | - } |
|
630 | - elseif ($button_info[1] === 'poll') { |
|
634 | + } elseif ($button_info[1] === 'poll') { |
|
631 | 635 | $type = $button_info[2] === pollType::QUIZ ? pollType::QUIZ : pollType::REGULAR; |
632 | 636 | $button->setRequest_poll((new keyboardButtonPollType())->setType($type)); |
633 | - } |
|
634 | - elseif ($button_info[1] === 'web' && isset($button_info[2])) { |
|
637 | + } elseif ($button_info[1] === 'web' && isset($button_info[2])) { |
|
635 | 638 | $url = $button_info[2]; |
636 | 639 | $button->setWeb_app((new webAppInfo())->setUrl($url)); |
637 | 640 | } |
@@ -654,12 +657,10 @@ discard block |
||
654 | 657 | if (isset($button_info[1])) { |
655 | 658 | if (filter_var($button_info[1], FILTER_VALIDATE_URL) && str_starts_with($button_info[1], 'http')) { |
656 | 659 | $button->setUrl($button_info[1]); |
657 | - } |
|
658 | - else { |
|
660 | + } else { |
|
659 | 661 | $button->setCallback_data($button_info[1]); |
660 | 662 | } |
661 | - } |
|
662 | - else { |
|
663 | + } else { |
|
663 | 664 | $button->setUrl('https://t.me/BPT_CH'); |
664 | 665 | } |
665 | 666 | $buttons[] = $button; |
@@ -686,8 +687,12 @@ discard block |
||
686 | 687 | * @return string |
687 | 688 | */ |
688 | 689 | public static function inviteLink (int $user_id = null, string $bot_username = null): string { |
689 | - if (empty($user_id)) $user_id = telegram::catchFields(fields::USER_ID); |
|
690 | - if (empty($bot_username)) $bot_username = telegram::getMe()->username; |
|
690 | + if (empty($user_id)) { |
|
691 | + $user_id = telegram::catchFields(fields::USER_ID); |
|
692 | + } |
|
693 | + if (empty($bot_username)) { |
|
694 | + $bot_username = telegram::getMe()->username; |
|
695 | + } |
|
691 | 696 | return 'https://t.me/' . str_replace('@', '', $bot_username) . '?start=ref_' . tools::shortEncode($user_id); |
692 | 697 | } |
693 | 698 | |
@@ -756,7 +761,9 @@ discard block |
||
756 | 761 | $array[] = $num % 62; |
757 | 762 | $num = floor($num / 62); |
758 | 763 | } |
759 | - if (count($array) < 1) $array = [0]; |
|
764 | + if (count($array) < 1) { |
|
765 | + $array = [0]; |
|
766 | + } |
|
760 | 767 | foreach ($array as &$value) { |
761 | 768 | $value = $codes[$value]; |
762 | 769 | } |
@@ -831,30 +831,30 @@ discard block |
||
831 | 831 | 'getGameHighScores' => ['BPT\types\gameHighScore'] |
832 | 832 | ]; |
833 | 833 | |
834 | - public static function __callStatic (string $name, array $arguments) { |
|
834 | + public static function __callStatic(string $name, array $arguments) { |
|
835 | 835 | if (!$action = self::methodAction($name)) { |
836 | - logger::write("$name method is not supported",loggerTypes::ERROR); |
|
836 | + logger::write("$name method is not supported", loggerTypes::ERROR); |
|
837 | 837 | throw new bptException('METHOD_NOT_FOUND'); |
838 | 838 | } |
839 | 839 | self::checkArguments($arguments); |
840 | - self::keysName($action,$arguments); |
|
841 | - self::readyFile($action,$arguments); |
|
840 | + self::keysName($action, $arguments); |
|
841 | + self::readyFile($action, $arguments); |
|
842 | 842 | self::cleanArguments($arguments); |
843 | - self::setDefaults($action,$arguments); |
|
843 | + self::setDefaults($action, $arguments); |
|
844 | 844 | |
845 | 845 | if (isset($arguments['answer']) && $arguments['answer'] === true) { |
846 | 846 | unset($arguments['answer']); |
847 | 847 | if (!answer::isAnswered()) { |
848 | - return answer::init($action,$arguments); |
|
848 | + return answer::init($action, $arguments); |
|
849 | 849 | } |
850 | - logger::write('you can use answer mode only once for each webhook update, Others will be called like normal',loggerTypes::WARNING); |
|
850 | + logger::write('you can use answer mode only once for each webhook update, Others will be called like normal', loggerTypes::WARNING); |
|
851 | 851 | } |
852 | - $result = curl::init($action,$arguments); |
|
852 | + $result = curl::init($action, $arguments); |
|
853 | 853 | if (!is_object($result)) { |
854 | - logger::write("Telegram $action method failed : " . $result, loggerTypes::WARNING); |
|
854 | + logger::write("Telegram $action method failed : ".$result, loggerTypes::WARNING); |
|
855 | 855 | return false; |
856 | 856 | } |
857 | - return self::processResponse($action,$result); |
|
857 | + return self::processResponse($action, $result); |
|
858 | 858 | } |
859 | 859 | |
860 | 860 | private static function checkArguments(array &$arguments): void { |
@@ -863,7 +863,7 @@ discard block |
||
863 | 863 | } |
864 | 864 | } |
865 | 865 | |
866 | - private static function keysName (string $name, array &$arguments): void { |
|
866 | + private static function keysName(string $name, array &$arguments): void { |
|
867 | 867 | foreach ($arguments as $key => $argument) { |
868 | 868 | if (is_numeric($key) && isset(self::METHODS_KEYS[$name][$key])) { |
869 | 869 | $arguments[self::METHODS_KEYS[$name][$key]] = $argument; |
@@ -872,7 +872,7 @@ discard block |
||
872 | 872 | } |
873 | 873 | } |
874 | 874 | |
875 | - private static function methodAction(string $name): string|false { |
|
875 | + private static function methodAction(string $name): string | false { |
|
876 | 876 | return self::METHODS_ACTION[str_replace('_', '', strtolower($name))] ?? false; |
877 | 877 | } |
878 | 878 | |
@@ -908,11 +908,11 @@ discard block |
||
908 | 908 | } |
909 | 909 | } |
910 | 910 | |
911 | - private static function methodFile(string $name): array|false { |
|
911 | + private static function methodFile(string $name): array | false { |
|
912 | 912 | return self::METHODS_WITH_FILE[$name] ?? false; |
913 | 913 | } |
914 | 914 | |
915 | - private static function methodReturn(string $name,stdClass $response) { |
|
915 | + private static function methodReturn(string $name, stdClass $response) { |
|
916 | 916 | if (!settings::$use_types_classes) { |
917 | 917 | return $response; |
918 | 918 | } |
@@ -934,13 +934,13 @@ discard block |
||
934 | 934 | $defaults = self::METHODS_EXTRA_DEFAULTS[$name] ?? []; |
935 | 935 | foreach ($defaults as $key => $default) { |
936 | 936 | if (is_numeric($key)) { |
937 | - if (!isset($arguments[$default])){ |
|
937 | + if (!isset($arguments[$default])) { |
|
938 | 938 | $arguments[$default] = self::catchFields($default); |
939 | 939 | } |
940 | 940 | } |
941 | 941 | elseif (isset(BPT::$update->{$key}) || $key === 'other') { |
942 | 942 | foreach ($default as $def) { |
943 | - if (!isset($arguments[$def])){ |
|
943 | + if (!isset($arguments[$def])) { |
|
944 | 944 | $arguments[$def] = self::catchFields($def); |
945 | 945 | } |
946 | 946 | } |
@@ -959,14 +959,14 @@ discard block |
||
959 | 959 | self::$status = $response->ok; |
960 | 960 | self::$pure_response = $response; |
961 | 961 | if (!$response->ok) { |
962 | - logger::write("Telegram $name method failed : " . json_encode($response), loggerTypes::WARNING); |
|
962 | + logger::write("Telegram $name method failed : ".json_encode($response), loggerTypes::WARNING); |
|
963 | 963 | unset($response->ok); |
964 | 964 | return new responseError($response); |
965 | 965 | } |
966 | - return self::methodReturn($name,$response); |
|
966 | + return self::methodReturn($name, $response); |
|
967 | 967 | } |
968 | 968 | |
969 | - private static function cleanArguments (array &$arguments): void { |
|
969 | + private static function cleanArguments(array &$arguments): void { |
|
970 | 970 | foreach ($arguments as $key => $argument) { |
971 | 971 | if ($argument == [] || $argument === null) { |
972 | 972 | unset($arguments[$key]); |
@@ -981,7 +981,7 @@ discard block |
||
981 | 981 | * |
982 | 982 | * @return int|string|bool |
983 | 983 | */ |
984 | - public static function catchFields (string $field): int|string|bool { |
|
984 | + public static function catchFields(string $field): int | string | bool { |
|
985 | 985 | switch ($field) { |
986 | 986 | case fields::CHAT_ID : |
987 | 987 | case fields::FROM_CHAT_ID : |
@@ -1128,13 +1128,13 @@ discard block |
||
1128 | 1128 | default => false |
1129 | 1129 | }; |
1130 | 1130 | case fields::URL : |
1131 | - return 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; |
|
1131 | + return 'https://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; |
|
1132 | 1132 | default: |
1133 | 1133 | return false; |
1134 | 1134 | } |
1135 | 1135 | } |
1136 | 1136 | |
1137 | - public static function fileLink (string|null $file_id = null): bool|string { |
|
1137 | + public static function fileLink(string | null $file_id = null): bool | string { |
|
1138 | 1138 | $file = request::getFile($file_id); |
1139 | 1139 | if (!isset($file->file_path)) { |
1140 | 1140 | return false; |
@@ -1156,7 +1156,7 @@ discard block |
||
1156 | 1156 | * |
1157 | 1157 | * @return bool |
1158 | 1158 | */ |
1159 | - public static function downloadFile (string $destination, string|null $file_id = null): bool { |
|
1159 | + public static function downloadFile(string $destination, string | null $file_id = null): bool { |
|
1160 | 1160 | return tools::downloadFile(self::fileLink($file_id), $destination); |
1161 | 1161 | } |
1162 | 1162 | |
@@ -1174,10 +1174,10 @@ discard block |
||
1174 | 1174 | * |
1175 | 1175 | * @return message|bool|responseError |
1176 | 1176 | */ |
1177 | - public static function sendFile (string $file_id, int|string $chat_id = null, int $message_thread_id = null, string $caption = null, string $parse_mode = null, array $caption_entities = null, bool $disable_notification = null, bool $protect_content = null, int $reply_to_message_id = null, bool $allow_sending_without_reply = null, inlineKeyboardMarkup|replyKeyboardMarkup|replyKeyboardRemove|forceReply|stdClass|array $reply_markup = null, string $token = null, bool $forgot = null, bool $answer = null): message|bool|responseError { |
|
1177 | + public static function sendFile(string $file_id, int | string $chat_id = null, int $message_thread_id = null, string $caption = null, string $parse_mode = null, array $caption_entities = null, bool $disable_notification = null, bool $protect_content = null, int $reply_to_message_id = null, bool $allow_sending_without_reply = null, inlineKeyboardMarkup | replyKeyboardMarkup | replyKeyboardRemove | forceReply | stdClass | array $reply_markup = null, string $token = null, bool $forgot = null, bool $answer = null): message | bool | responseError { |
|
1178 | 1178 | $type = tools::fileType($file_id); |
1179 | 1179 | return match ($type) { |
1180 | - fileTypes::VIDEO => request::sendVideo($file_id, $chat_id, $message_thread_id, null, null, null, null, $caption, $parse_mode, $caption_entities, false,null, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer), |
|
1180 | + fileTypes::VIDEO => request::sendVideo($file_id, $chat_id, $message_thread_id, null, null, null, null, $caption, $parse_mode, $caption_entities, false, null, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer), |
|
1181 | 1181 | fileTypes::VIDEO_NOTE => request::sendVideoNote($file_id, $chat_id, $message_thread_id, null, null, null, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer), |
1182 | 1182 | fileTypes::ANIMATION => request::sendAnimation($file_id, $chat_id, $message_thread_id, null, null, null, null, $caption, $parse_mode, $caption_entities, false, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer), |
1183 | 1183 | fileTypes::AUDIO => request::sendAudio($file_id, $chat_id, $message_thread_id, $caption, $parse_mode, $caption_entities, null, null, null, null, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer), |
@@ -881,20 +881,17 @@ discard block |
||
881 | 881 | foreach ($arguments['media'] as $key => $media) { |
882 | 882 | if ($media['media'] instanceof CURLFile) { |
883 | 883 | $remove_answer = true; |
884 | - } |
|
885 | - elseif (is_string($media['media']) && file_exists(realpath($media['media']))) { |
|
884 | + } elseif (is_string($media['media']) && file_exists(realpath($media['media']))) { |
|
886 | 885 | $arguments['media'][$key]['media'] = new CURLFile($media['media']); |
887 | 886 | $remove_answer = true; |
888 | 887 | } |
889 | 888 | } |
890 | - } |
|
891 | - elseif ($file_params = self::methodFile($name)) { |
|
889 | + } elseif ($file_params = self::methodFile($name)) { |
|
892 | 890 | foreach ($file_params as $param) { |
893 | 891 | if (isset($arguments[$param])) { |
894 | 892 | if ($arguments[$param] instanceof CURLFile) { |
895 | 893 | $remove_answer = true; |
896 | - } |
|
897 | - elseif (is_string($arguments[$param]) && file_exists(realpath($arguments[$param]))) { |
|
894 | + } elseif (is_string($arguments[$param]) && file_exists(realpath($arguments[$param]))) { |
|
898 | 895 | $arguments[$param] = new CURLFile($arguments[$param]); |
899 | 896 | $remove_answer = true; |
900 | 897 | } |
@@ -937,8 +934,7 @@ discard block |
||
937 | 934 | if (!isset($arguments[$default])){ |
938 | 935 | $arguments[$default] = self::catchFields($default); |
939 | 936 | } |
940 | - } |
|
941 | - elseif (isset(BPT::$update->{$key}) || $key === 'other') { |
|
937 | + } elseif (isset(BPT::$update->{$key}) || $key === 'other') { |
|
942 | 938 | foreach ($default as $def) { |
943 | 939 | if (!isset($arguments[$def])){ |
944 | 940 | $arguments[$def] = self::catchFields($def); |
@@ -1010,9 +1006,13 @@ discard block |
||
1010 | 1006 | default => false |
1011 | 1007 | }; |
1012 | 1008 | case fields::FILE_ID : |
1013 | - if (isset(BPT::$update->message)) $type = 'message'; |
|
1014 | - elseif (isset(BPT::$update->edited_message)) $type = 'edited_message'; |
|
1015 | - else return false; |
|
1009 | + if (isset(BPT::$update->message)) { |
|
1010 | + $type = 'message'; |
|
1011 | + } elseif (isset(BPT::$update->edited_message)) { |
|
1012 | + $type = 'edited_message'; |
|
1013 | + } else { |
|
1014 | + return false; |
|
1015 | + } |
|
1016 | 1016 | |
1017 | 1017 | return match(true) { |
1018 | 1018 | isset(BPT::$update->{$type}->animation) => BPT::$update->{$type}->animation->file_id, |
@@ -16,14 +16,14 @@ discard block |
||
16 | 16 | /** |
17 | 17 | * @internal Only for BPT self usage , Don't use it in your source! |
18 | 18 | */ |
19 | - public static function init(): string|null { |
|
19 | + public static function init(): string | null { |
|
20 | 20 | return self::getUpdate(); |
21 | 21 | } |
22 | 22 | |
23 | - private static function getUpdate (): string|null { |
|
23 | + private static function getUpdate(): string | null { |
|
24 | 24 | $up = glob('*.update'); |
25 | 25 | if (!isset($up[0])) { |
26 | - logger::write('not authorized access denied. IP : '. $_SERVER['REMOTE_ADDR'] ?? 'unknown',loggerTypes::WARNING); |
|
26 | + logger::write('not authorized access denied. IP : '.$_SERVER['REMOTE_ADDR'] ?? 'unknown', loggerTypes::WARNING); |
|
27 | 27 | BPT::exit(); |
28 | 28 | } |
29 | 29 | $up = end($up); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | } |
54 | 54 | |
55 | 55 | private static function create($file) { |
56 | - 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 &");'); |
|
56 | + 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 &");'); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | #[ArrayShape(['url' => 'array|string|string[]', 'file' => 'string'])] |