@@ -5,7 +5,7 @@ |
||
5 | 5 | use BPT\settings; |
6 | 6 | |
7 | 7 | class pay { |
8 | - public static function init (): void { |
|
8 | + public static function init(): void { |
|
9 | 9 | if (!isset(settings::$pay['crypto'])) { |
10 | 10 | return; |
11 | 11 | } |
@@ -17,7 +17,7 @@ |
||
17 | 17 | /** |
18 | 18 | * @internal Only for BPT self usage , Don't use it in your source! |
19 | 19 | */ |
20 | - public static function init (): void { |
|
20 | + public static function init(): void { |
|
21 | 21 | if (!isset(settings::$db['type'])) { |
22 | 22 | settings::$db['type'] = dbTypes::JSON; |
23 | 23 | } |
@@ -268,13 +268,13 @@ discard block |
||
268 | 268 | * @method bool|responseError unhideGeneralForumTopic (int|string|array $chat_id, string|null $token = null, bool|null $forgot = null, bool|null $answer = null) Use this method to unhide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success. |
269 | 269 | * @method bool|responseError unhideGeneralTopic (int|string|array $chat_id, string|null $token = null, bool|null $forgot = null, bool|null $answer = null) Use this method to unhide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success. |
270 | 270 | */ |
271 | -class BPT extends telegram{ |
|
271 | +class BPT extends telegram { |
|
272 | 272 | public static update $update; |
273 | 273 | |
274 | 274 | public static BPT $handler; |
275 | 275 | |
276 | 276 | |
277 | - public function __construct (array|stdClass $settings) { |
|
277 | + public function __construct(array | stdClass $settings) { |
|
278 | 278 | static::$handler = &$this; |
279 | 279 | settings::init($settings); |
280 | 280 | } |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | } |
285 | 285 | |
286 | 286 | #[NoReturn] |
287 | - public static function exit (string|null $message = null) { |
|
287 | + public static function exit (string | null $message = null) { |
|
288 | 288 | die($message ?? "<div style='width:98vw;height:98vh;display:flex;justify-content:center;align-items:center;font-size:25vw'>BPT</div>"); |
289 | 289 | } |
290 | 290 | } |
@@ -15,10 +15,10 @@ |
||
15 | 15 | public string $name; |
16 | 16 | |
17 | 17 | /** Optional. New identifier of the custom emoji shown as the topic icon, if it was edited; an empty string if the icon was removed */ |
18 | - public null|string $icon_custom_emoji_id = null; |
|
18 | + public null | string $icon_custom_emoji_id = null; |
|
19 | 19 | |
20 | 20 | |
21 | - public function __construct(stdClass|null $object = null) { |
|
21 | + public function __construct(stdClass | null $object = null) { |
|
22 | 22 | if ($object != null) { |
23 | 23 | parent::__construct($object, self::subs); |
24 | 24 | } |
@@ -11,7 +11,7 @@ |
||
11 | 11 | /** Keep all of 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 | } |
@@ -30,97 +30,97 @@ discard block |
||
30 | 30 | public string $type; |
31 | 31 | |
32 | 32 | /** Optional. Title, for supergroups, channels and group chats */ |
33 | - public null|string $title = null; |
|
33 | + public null | string $title = null; |
|
34 | 34 | |
35 | 35 | /** Optional. Username, for private chats, supergroups and channels if available */ |
36 | - public null|string $username = null; |
|
36 | + public null | string $username = null; |
|
37 | 37 | |
38 | 38 | /** Optional. First name of the other party in a private chat */ |
39 | - public null|string $first_name = null; |
|
39 | + public null | string $first_name = null; |
|
40 | 40 | |
41 | 41 | /** Optional. Last name of the other party in a private chat */ |
42 | - public null|string $last_name = null; |
|
42 | + public null | string $last_name = null; |
|
43 | 43 | |
44 | 44 | /** Optional. True, if the supergroup chat is a forum (has topics enabled) */ |
45 | - public null|bool $is_forum = null; |
|
45 | + public null | bool $is_forum = null; |
|
46 | 46 | |
47 | 47 | /** Optional. Chat photo. Returned only in getChat. */ |
48 | - public null|chatPhoto $photo = null; |
|
48 | + public null | chatPhoto $photo = null; |
|
49 | 49 | |
50 | 50 | /** Optional. If non-empty, the list of all active chat usernames; for private chats, supergroups and channels. Returned only in getChat. */ |
51 | - public null|array $active_usernames = null; |
|
51 | + public null | array $active_usernames = null; |
|
52 | 52 | |
53 | 53 | /** Optional. Custom emoji identifier of emoji status of the other party in a private chat. Returned only in getChat. */ |
54 | - public null|string $emoji_status_custom_emoji_id = null; |
|
54 | + public null | string $emoji_status_custom_emoji_id = null; |
|
55 | 55 | |
56 | 56 | /** Optional. Bio of the other party in a private chat. Returned only in getChat. */ |
57 | - public null|string $bio = null; |
|
57 | + public null | string $bio = null; |
|
58 | 58 | |
59 | 59 | /** |
60 | 60 | * Optional. True, if privacy settings of the other party in the private chat allows to use |
61 | 61 | * tg://user?id=<user_id> links only in chats with the user. Returned only in getChat. |
62 | 62 | */ |
63 | - public null|bool $has_private_forwards = null; |
|
63 | + public null | bool $has_private_forwards = null; |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * Optional. True, if the privacy settings of the other party restrict sending voice and video note messages in |
67 | 67 | * the private chat. Returned only in getChat. |
68 | 68 | */ |
69 | - public null|bool $has_restricted_voice_and_video_messages = null; |
|
69 | + public null | bool $has_restricted_voice_and_video_messages = null; |
|
70 | 70 | |
71 | 71 | /** Optional. True, if users need to join the supergroup before they can send messages. Returned only in getChat. */ |
72 | - public null|bool $join_to_send_messages = null; |
|
72 | + public null | bool $join_to_send_messages = null; |
|
73 | 73 | |
74 | 74 | /** |
75 | 75 | * Optional. True, if all users directly joining the supergroup need to be approved by supergroup administrators. |
76 | 76 | * Returned only in getChat. |
77 | 77 | */ |
78 | - public null|bool $join_by_request = null; |
|
78 | + public null | bool $join_by_request = null; |
|
79 | 79 | |
80 | 80 | /** Optional. Description, for groups, supergroups and channel chats. Returned only in getChat. */ |
81 | - public null|string $description = null; |
|
81 | + public null | string $description = null; |
|
82 | 82 | |
83 | 83 | /** Optional. Primary invite link, for groups, supergroups and channel chats. Returned only in getChat. */ |
84 | - public null|string $invite_link = null; |
|
84 | + public null | string $invite_link = null; |
|
85 | 85 | |
86 | 86 | /** Optional. The most recent pinned message (by sending date). Returned only in getChat. */ |
87 | - public null|message $pinned_message = null; |
|
87 | + public null | message $pinned_message = null; |
|
88 | 88 | |
89 | 89 | /** Optional. Default chat member permissions, for groups and supergroups. Returned only in getChat. */ |
90 | - public null|chatPermissions $permissions = null; |
|
90 | + public null | chatPermissions $permissions = null; |
|
91 | 91 | |
92 | 92 | /** |
93 | 93 | * Optional. For supergroups, the minimum allowed delay between consecutive messages sent by each unpriviledged |
94 | 94 | * user; in seconds. Returned only in getChat. |
95 | 95 | */ |
96 | - public null|int $slow_mode_delay = null; |
|
96 | + public null | int $slow_mode_delay = null; |
|
97 | 97 | |
98 | 98 | /** |
99 | 99 | * Optional. The time after which all messages sent to the chat will be automatically deleted; in seconds. |
100 | 100 | * Returned only in getChat. |
101 | 101 | */ |
102 | - public null|int $message_auto_delete_time = null; |
|
102 | + public null | int $message_auto_delete_time = null; |
|
103 | 103 | |
104 | 104 | /** |
105 | 105 | * Optional. True, if aggressive anti-spam checks are enabled in the supergroup. |
106 | 106 | * The field is only available to chat administrators. Returned only in getChat. |
107 | 107 | */ |
108 | - public null|bool $has_aggressive_anti_spam_enabled = null; |
|
108 | + public null | bool $has_aggressive_anti_spam_enabled = null; |
|
109 | 109 | |
110 | 110 | /** |
111 | 111 | * Optional. True, if non-administrators can only get the list of bots and administrators in the chat. |
112 | 112 | * Returned only in getChat. |
113 | 113 | */ |
114 | - public null|bool $has_hidden_members = null; |
|
114 | + public null | bool $has_hidden_members = null; |
|
115 | 115 | |
116 | 116 | /** Optional. True, if messages from the chat can't be forwarded to other chats. Returned only in getChat. */ |
117 | - public null|bool $has_protected_content = null; |
|
117 | + public null | bool $has_protected_content = null; |
|
118 | 118 | |
119 | 119 | /** Optional. For supergroups, name of group sticker set. Returned only in getChat. */ |
120 | - public null|string $sticker_set_name = null; |
|
120 | + public null | string $sticker_set_name = null; |
|
121 | 121 | |
122 | 122 | /** Optional. True, if the bot can change the group sticker set. Returned only in getChat. */ |
123 | - public null|bool $can_set_sticker_set = null; |
|
123 | + public null | bool $can_set_sticker_set = null; |
|
124 | 124 | |
125 | 125 | /** |
126 | 126 | * Optional. Unique identifier for the linked chat, i.e. the discussion group identifier for a channel and vice |
@@ -128,87 +128,87 @@ discard block |
||
128 | 128 | * languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed |
129 | 129 | * 64 bit integer or double-precision float type are safe for storing this identifier. Returned only in getChat. |
130 | 130 | */ |
131 | - public null|int $linked_chat_id = null; |
|
131 | + public null | int $linked_chat_id = null; |
|
132 | 132 | |
133 | 133 | /** Optional. For supergroups, the location to which the supergroup is connected. Returned only in getChat. */ |
134 | - public null|chatLocation $location = null; |
|
134 | + public null | chatLocation $location = null; |
|
135 | 135 | |
136 | 136 | |
137 | - public function __construct(stdClass|null $object = null) { |
|
137 | + public function __construct(stdClass | null $object = null) { |
|
138 | 138 | if ($object != null) { |
139 | 139 | parent::__construct($object, self::subs); |
140 | 140 | } |
141 | 141 | } |
142 | 142 | |
143 | - public function isPrivate (): bool { |
|
143 | + public function isPrivate(): bool { |
|
144 | 144 | return $this->type === chatType::PRIVATE; |
145 | 145 | } |
146 | 146 | |
147 | - public function isGroup (): bool { |
|
147 | + public function isGroup(): bool { |
|
148 | 148 | return $this->type === chatType::GROUP; |
149 | 149 | } |
150 | 150 | |
151 | - public function isSuperGroup (): bool { |
|
151 | + public function isSuperGroup(): bool { |
|
152 | 152 | return $this->type === chatType::SUPERGROUP; |
153 | 153 | } |
154 | 154 | |
155 | - public function isChannel (): bool { |
|
155 | + public function isChannel(): bool { |
|
156 | 156 | return $this->type === chatType::CHANNEL; |
157 | 157 | } |
158 | 158 | |
159 | - public function leave(): responseError|bool { |
|
159 | + public function leave(): responseError | bool { |
|
160 | 160 | if ($this->isPrivate()) { |
161 | 161 | return false; |
162 | 162 | } |
163 | 163 | return telegram::leave($this->id); |
164 | 164 | } |
165 | 165 | |
166 | - public function setPhoto(CURLFile|array $photo): responseError|bool { |
|
166 | + public function setPhoto(CURLFile | array $photo): responseError | bool { |
|
167 | 167 | if ($this->isPrivate()) { |
168 | 168 | return false; |
169 | 169 | } |
170 | - return telegram::setChatPhoto($photo,$this->id); |
|
170 | + return telegram::setChatPhoto($photo, $this->id); |
|
171 | 171 | } |
172 | 172 | |
173 | - public function delPhoto(): responseError|bool { |
|
173 | + public function delPhoto(): responseError | bool { |
|
174 | 174 | if ($this->isPrivate()) { |
175 | 175 | return false; |
176 | 176 | } |
177 | 177 | return telegram::deleteChatPhoto($this->id); |
178 | 178 | } |
179 | 179 | |
180 | - public function setTitle(string|array $title): responseError|bool { |
|
180 | + public function setTitle(string | array $title): responseError | bool { |
|
181 | 181 | if ($this->isPrivate()) { |
182 | 182 | return false; |
183 | 183 | } |
184 | - return telegram::setChatTitle($title,$this->id); |
|
184 | + return telegram::setChatTitle($title, $this->id); |
|
185 | 185 | } |
186 | 186 | |
187 | - public function setDescription(string|null $description = null): responseError|bool { |
|
187 | + public function setDescription(string | null $description = null): responseError | bool { |
|
188 | 188 | if ($this->isPrivate()) { |
189 | 189 | return false; |
190 | 190 | } |
191 | - return telegram::setChatDescription($this->id,$description); |
|
191 | + return telegram::setChatDescription($this->id, $description); |
|
192 | 192 | } |
193 | 193 | |
194 | - public function getAdmins(): bool|responseError|array { |
|
194 | + public function getAdmins(): bool | responseError | array { |
|
195 | 195 | if ($this->isPrivate()) { |
196 | 196 | return false; |
197 | 197 | } |
198 | 198 | return telegram::getChatAdministrators($this->id); |
199 | 199 | } |
200 | 200 | |
201 | - public function getMembersCount(): bool|responseError|int { |
|
201 | + public function getMembersCount(): bool | responseError | int { |
|
202 | 202 | if ($this->isPrivate()) { |
203 | 203 | return false; |
204 | 204 | } |
205 | 205 | return telegram::getChatMemberCount($this->id); |
206 | 206 | } |
207 | 207 | |
208 | - public function getMember(int|null $user_id = null): chatMember|bool|responseError { |
|
208 | + public function getMember(int | null $user_id = null): chatMember | bool | responseError { |
|
209 | 209 | if ($this->isPrivate()) { |
210 | 210 | return false; |
211 | 211 | } |
212 | - return telegram::getChatMember($this->id,$user_id); |
|
212 | + return telegram::getChatMember($this->id, $user_id); |
|
213 | 213 | } |
214 | 214 | } |
@@ -11,7 +11,7 @@ |
||
11 | 11 | /** Keep all of 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 | } |
@@ -11,7 +11,7 @@ |
||
11 | 11 | /** Keep all of 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 | } |
@@ -32,13 +32,13 @@ discard block |
||
32 | 32 | if (settings::$telegram_verify) { |
33 | 33 | $ip = $ip ?? tools::remoteIP(); |
34 | 34 | if (!tools::isTelegram($ip)) { |
35 | - logger::write('not authorized access denied. IP : '. $ip ?? 'unknown',loggerTypes::WARNING); |
|
35 | + logger::write('not authorized access denied. IP : '.$ip ?? 'unknown', loggerTypes::WARNING); |
|
36 | 36 | BPT::exit(); |
37 | 37 | } |
38 | 38 | } |
39 | 39 | } |
40 | 40 | |
41 | - protected static function processUpdate(string|stdClass|update $update = null): void { |
|
41 | + protected static function processUpdate(string | stdClass | update $update = null): void { |
|
42 | 42 | if (!is_object($update)) { |
43 | 43 | $update = json_decode($update ?? file_get_contents("php://input")); |
44 | 44 | if (!$update) { |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | } |
47 | 47 | } |
48 | 48 | |
49 | - if (!is_a($update,'update')) { |
|
49 | + if (!is_a($update, 'update')) { |
|
50 | 50 | $update = new update($update); |
51 | 51 | } |
52 | 52 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | db::save(); |
58 | 58 | } |
59 | 59 | |
60 | - protected static function setMessageExtra (update &$update): void { |
|
60 | + protected static function setMessageExtra(update & $update): void { |
|
61 | 61 | if ((isset($update->message) && isset($update->message->text)) || (isset($update->edited_message) && isset($update->edited_message->text))) { |
62 | 62 | $type = isset($update->message) ? 'message' : 'edited_message'; |
63 | 63 | $text = &$update->$type->text; |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | BPT::$handler->something_else(BPT::$update); |
131 | 131 | } |
132 | 132 | else { |
133 | - logger::write('Update received but handlers are not set',loggerTypes::WARNING); |
|
133 | + logger::write('Update received but handlers are not set', loggerTypes::WARNING); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | } |
@@ -85,51 +85,41 @@ |
||
85 | 85 | if (self::handlerExist('message')) { |
86 | 86 | BPT::$handler->message(BPT::$update->message); |
87 | 87 | } |
88 | - } |
|
89 | - elseif (isset(BPT::$update->edited_message)) { |
|
88 | + } elseif (isset(BPT::$update->edited_message)) { |
|
90 | 89 | if (self::handlerExist('edited_message')) { |
91 | 90 | BPT::$handler->edited_message(BPT::$update->edited_message); |
92 | 91 | } |
93 | - } |
|
94 | - elseif (isset(BPT::$update->channel_post)) { |
|
92 | + } elseif (isset(BPT::$update->channel_post)) { |
|
95 | 93 | if (self::handlerExist('channel_post')) { |
96 | 94 | BPT::$handler->channel_post(BPT::$update->channel_post); |
97 | 95 | } |
98 | - } |
|
99 | - elseif (isset(BPT::$update->edited_channel_post)) { |
|
96 | + } elseif (isset(BPT::$update->edited_channel_post)) { |
|
100 | 97 | if (self::handlerExist('edited_channel_post')) { |
101 | 98 | BPT::$handler->edited_channel_post(BPT::$update->edited_channel_post); |
102 | 99 | } |
103 | - } |
|
104 | - elseif (isset(BPT::$update->inline_query)) { |
|
100 | + } elseif (isset(BPT::$update->inline_query)) { |
|
105 | 101 | if (self::handlerExist('inline_query')) { |
106 | 102 | BPT::$handler->inline_query(BPT::$update->inline_query); |
107 | 103 | } |
108 | - } |
|
109 | - elseif (isset(BPT::$update->callback_query)) { |
|
104 | + } elseif (isset(BPT::$update->callback_query)) { |
|
110 | 105 | if (self::handlerExist('callback_query')) { |
111 | 106 | BPT::$handler->callback_query(BPT::$update->callback_query); |
112 | 107 | } |
113 | - } |
|
114 | - elseif (isset(BPT::$update->my_chat_member)) { |
|
108 | + } elseif (isset(BPT::$update->my_chat_member)) { |
|
115 | 109 | if (self::handlerExist('my_chat_member')) { |
116 | 110 | BPT::$handler->my_chat_member(BPT::$update->my_chat_member); |
117 | 111 | } |
118 | - } |
|
119 | - elseif (isset(BPT::$update->chat_member)) { |
|
112 | + } elseif (isset(BPT::$update->chat_member)) { |
|
120 | 113 | if (self::handlerExist('chat_member')) { |
121 | 114 | BPT::$handler->chat_member(BPT::$update->chat_member); |
122 | 115 | } |
123 | - } |
|
124 | - elseif (isset(BPT::$update->chat_join_request)) { |
|
116 | + } elseif (isset(BPT::$update->chat_join_request)) { |
|
125 | 117 | if (self::handlerExist('chat_join_request')) { |
126 | 118 | BPT::$handler->chat_join_request(BPT::$update->chat_join_request); |
127 | 119 | } |
128 | - } |
|
129 | - elseif (self::handlerExist('something_else')) { |
|
120 | + } elseif (self::handlerExist('something_else')) { |
|
130 | 121 | BPT::$handler->something_else(BPT::$update); |
131 | - } |
|
132 | - else { |
|
122 | + } else { |
|
133 | 123 | logger::write('Update received but handlers are not set',loggerTypes::WARNING); |
134 | 124 | } |
135 | 125 | } |