@@ -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 | } |
@@ -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 | } |
@@ -17,40 +17,40 @@ |
||
17 | 17 | /** |
18 | 18 | * @internal Only for BPT self usage , Don't use it in your source! |
19 | 19 | */ |
20 | - public static function init(string $method,array $data): bool { |
|
20 | + public static function init(string $method, array $data): bool { |
|
21 | 21 | self::checkWebhook(); |
22 | 22 | self::sieveData($data); |
23 | 23 | self::$is_answered = true; |
24 | 24 | $data['method'] = $method; |
25 | 25 | $payload = json_encode($data); |
26 | - header('Content-Type: application/json;Content-Length: ' . strlen($payload)); |
|
26 | + header('Content-Type: application/json;Content-Length: '.strlen($payload)); |
|
27 | 27 | echo $payload; |
28 | 28 | return true; |
29 | 29 | } |
30 | 30 | |
31 | - public static function isAnswered (): bool { |
|
31 | + public static function isAnswered(): bool { |
|
32 | 32 | return self::$is_answered; |
33 | 33 | } |
34 | 34 | |
35 | 35 | private static function checkWebhook(): void { |
36 | - if(settings::$receiver === receiver::GETUPDATES) { |
|
37 | - logger::write('Answer mode only work when receiver is webhook',loggerTypes::ERROR); |
|
36 | + if (settings::$receiver === receiver::GETUPDATES) { |
|
37 | + logger::write('Answer mode only work when receiver is webhook', loggerTypes::ERROR); |
|
38 | 38 | throw new bptException('ANSWER_MODE_GETUPDATES'); |
39 | 39 | } |
40 | - if(settings::$multi) { |
|
41 | - logger::write('You can not use answer mode when multi setting is on',loggerTypes::ERROR); |
|
40 | + if (settings::$multi) { |
|
41 | + logger::write('You can not use answer mode when multi setting is on', loggerTypes::ERROR); |
|
42 | 42 | throw new bptException('ANSWER_MODE_MULTI'); |
43 | 43 | } |
44 | 44 | } |
45 | 45 | |
46 | 46 | private static function sieveData(array &$data): void { |
47 | - unset($data['token'],$data['forgot'],$data['return_array']); |
|
47 | + unset($data['token'], $data['forgot'], $data['return_array']); |
|
48 | 48 | |
49 | - foreach ($data as $key=>&$value){ |
|
50 | - if (!isset($value)){ |
|
49 | + foreach ($data as $key=>&$value) { |
|
50 | + if (!isset($value)) { |
|
51 | 51 | unset($data[$key]); |
52 | 52 | } |
53 | - elseif (is_array($value) || is_object($value)){ |
|
53 | + elseif (is_array($value) || is_object($value)) { |
|
54 | 54 | $value = json_encode($value); |
55 | 55 | } |
56 | 56 | } |
@@ -49,8 +49,7 @@ |
||
49 | 49 | foreach ($data as $key=>&$value){ |
50 | 50 | if (!isset($value)){ |
51 | 51 | unset($data[$key]); |
52 | - } |
|
53 | - elseif (is_array($value) || is_object($value)){ |
|
52 | + } elseif (is_array($value) || is_object($value)){ |
|
54 | 53 | $value = json_encode($value); |
55 | 54 | } |
56 | 55 | } |
@@ -811,19 +811,16 @@ discard block |
||
811 | 811 | foreach ($arguments['media'] as $key => $media) { |
812 | 812 | if ($media['media'] instanceof CURLFile) { |
813 | 813 | $remove_answer = true; |
814 | - } |
|
815 | - elseif (is_string($media['media']) && file_exists(realpath($media['media']))) { |
|
814 | + } elseif (is_string($media['media']) && file_exists(realpath($media['media']))) { |
|
816 | 815 | $arguments['media'][$key]['media'] = new CURLFile($media['media']); |
817 | 816 | $remove_answer = true; |
818 | 817 | } |
819 | 818 | } |
820 | - } |
|
821 | - elseif ($file_params = self::methodFile($name)) { |
|
819 | + } elseif ($file_params = self::methodFile($name)) { |
|
822 | 820 | foreach ($file_params as $param) { |
823 | 821 | if ($arguments[$param] instanceof CURLFile) { |
824 | 822 | $remove_answer = true; |
825 | - } |
|
826 | - elseif (isset($arguments[$param]) && is_string($arguments[$param]) && file_exists(realpath($arguments[$param]))) { |
|
823 | + } elseif (isset($arguments[$param]) && is_string($arguments[$param]) && file_exists(realpath($arguments[$param]))) { |
|
827 | 824 | $arguments[$param] = new CURLFile($arguments[$param]); |
828 | 825 | $remove_answer = true; |
829 | 826 | } |
@@ -861,8 +858,7 @@ discard block |
||
861 | 858 | if (!isset($arguments[$default])){ |
862 | 859 | $arguments[$default] = self::catchFields($default); |
863 | 860 | } |
864 | - } |
|
865 | - elseif (isset(BPT::$update->$key) || $key === 'other') { |
|
861 | + } elseif (isset(BPT::$update->$key) || $key === 'other') { |
|
866 | 862 | foreach ($default as $def) { |
867 | 863 | if (!isset($arguments[$def])){ |
868 | 864 | $arguments[$def] = self::catchFields($def); |
@@ -919,9 +915,13 @@ discard block |
||
919 | 915 | default => false |
920 | 916 | }; |
921 | 917 | case fields::FILE_ID : |
922 | - if (isset(BPT::$update->message)) $type = 'message'; |
|
923 | - elseif (isset(BPT::$update->edited_message)) $type = 'edited_message'; |
|
924 | - else return false; |
|
918 | + if (isset(BPT::$update->message)) { |
|
919 | + $type = 'message'; |
|
920 | + } elseif (isset(BPT::$update->edited_message)) { |
|
921 | + $type = 'edited_message'; |
|
922 | + } else { |
|
923 | + return false; |
|
924 | + } |
|
925 | 925 | |
926 | 926 | return match(true) { |
927 | 927 | isset(BPT::$update->$type->animation) => BPT::$update->$type->animation->file_id, |
@@ -503,95 +503,95 @@ discard block |
||
503 | 503 | ]; |
504 | 504 | |
505 | 505 | private const METHODS_KEYS = [ |
506 | - 'getUpdates' => ['offset','limit','timeout','allowed_updates','token','forgot','answer'], |
|
507 | - 'setWebhook' => ['url','certificate','ip_address','max_connections','allowed_updates','drop_pending_updates','secret_token','token','forgot','answer'], |
|
508 | - 'deleteWebhook' => ['drop_pending_updates','token','forgot','answer'], |
|
509 | - 'getWebhookInfo' => ['token','forgot','answer'], |
|
510 | - 'getMe' => ['token','forgot','answer'], |
|
511 | - 'logOut' => ['token','forgot','answer'], |
|
512 | - 'close' => ['token','forgot','answer'], |
|
513 | - 'sendMessage' => ['text','chat_id','parse_mode','entities','disable_web_page_preview','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
514 | - 'forwardMessage' => ['chat_id','from_chat_id','disable_notification','protect_content','message_id','token','forgot','answer','message_thread_id'], |
|
515 | - 'copyMessage' => ['chat_id','from_chat_id','message_id','caption','parse_mode','caption_entities','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
516 | - 'sendPhoto' => ['photo','chat_id','caption','parse_mode','caption_entities','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','has_spoiler','message_thread_id'], |
|
517 | - 'sendAudio' => ['audio','chat_id','caption','parse_mode','caption_entities','duration','performer','title','thumb','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
518 | - 'sendDocument' => ['document','chat_id','thumb','caption','parse_mode','caption_entities','disable_content_type_detection','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
519 | - 'sendVideo' => ['video','chat_id','duration','width','height','thumb','caption','parse_mode','caption_entities','supports_streaming','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','has_spoiler','message_thread_id'], |
|
520 | - 'sendAnimation' => ['animation','chat_id','duration','width','height','thumb','caption','parse_mode','caption_entities','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','has_spoiler','message_thread_id'], |
|
521 | - 'sendVoice' => ['voice','chat_id','caption','parse_mode','caption_entities','duration','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
522 | - 'sendVideoNote' => ['video_note','chat_id','duration','length','thumb','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
523 | - 'sendMediaGroup' => ['media','chat_id','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','token','forgot','answer','message_thread_id'], |
|
524 | - 'sendLocation' => ['latitude','longitude','chat_id','horizontal_accuracy','live_period','heading','proximity_alert_radius','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
525 | - 'editMessageLiveLocation' => ['latitude','longitude','chat_id','message_id','inline_message_id','horizontal_accuracy','heading','proximity_alert_radius','reply_markup','token','forgot','answer'], |
|
526 | - 'stopMessageLiveLocation' => ['chat_id','message_id','inline_message_id','reply_markup','token','forgot','answer'], |
|
527 | - 'sendVenue' => ['chat_id','latitude','longitude','title','address','foursquare_id','foursquare_type','google_place_id','google_place_type','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
528 | - 'sendContact' => ['phone_number','first_name','chat_id','last_name','vcard','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
529 | - 'sendPoll' => ['question','options','chat_id','is_anonymous','type','allows_multiple_answers','correct_option_id','explanation','explanation_parse_mode','explanation_entities','open_period','close_date','is_closed','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
530 | - 'sendDice' => ['chat_id','emoji','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
531 | - 'sendChatAction' => ['chat_id','action','token','forgot','answer','message_thread_id'], |
|
532 | - 'getUserProfilePhotos' => ['user_id','offset','limit','token','forgot','answer'], |
|
533 | - 'getFile' => ['file_id','token','forgot','answer'], |
|
534 | - 'banChatMember' => ['chat_id','user_id','until_date','revoke_messages','token','forgot','answer'], |
|
535 | - 'unbanChatMember' => ['chat_id','user_id','only_if_banned','token','forgot','answer'], |
|
536 | - 'restrictChatMember' => ['permissions','chat_id','user_id','until_date','token','forgot','answer','use_independent_chat_permissions'], |
|
537 | - 'promoteChatMember' => ['chat_id','user_id','is_anonymous','can_manage_chat','can_post_messages','can_edit_messages','can_delete_messages','can_manage_video_chats','can_restrict_members','can_promote_members','can_change_info','can_invite_users','can_pin_messages','can_manage_topics','token','forgot','answer'], |
|
538 | - 'setChatAdministratorCustomTitle' => ['custom_title','chat_id','user_id','token','forgot','answer'], |
|
539 | - 'banChatSenderChat' => ['sender_chat_id','chat_id','token','forgot','answer'], |
|
540 | - 'unbanChatSenderChat' => ['sender_chat_id','chat_id','token','forgot','answer'], |
|
541 | - 'setChatPermissions' => ['permissions','chat_id','token','forgot','answer','use_independent_chat_permissions'], |
|
542 | - 'exportChatInviteLink' => ['chat_id','token','forgot','answer'], |
|
543 | - 'createChatInviteLink' => ['chat_id','name','expire_date','member_limit','creates_join_request','token','forgot','answer'], |
|
544 | - 'editChatInviteLink' => ['invite_link','chat_id','name','expire_date','member_limit','creates_join_request','token','forgot','answer'], |
|
545 | - 'revokeChatInviteLink' => ['invite_link','chat_id','token','forgot','answer'], |
|
546 | - 'approveChatJoinRequest' => ['chat_id','user_id','token','forgot','answer'], |
|
547 | - 'declineChatJoinRequest' => ['chat_id','user_id','token','forgot','answer'], |
|
548 | - 'setChatPhoto' => ['photo','chat_id','token','forgot','answer'], |
|
549 | - 'deleteChatPhoto' => ['chat_id','token','forgot','answer'], |
|
550 | - 'setChatTitle' => ['title','chat_id','token','forgot','answer'], |
|
551 | - 'setChatDescription' => ['chat_id','description','token','forgot','answer'], |
|
552 | - 'pinChatMessage' => ['message_id','chat_id','disable_notification','token','forgot','answer'], |
|
553 | - 'unpinChatMessage' => ['chat_id','message_id','token','forgot','answer'], |
|
554 | - 'unpinAllChatMessages' => ['chat_id','token','forgot','answer'], |
|
555 | - 'leaveChat' => ['chat_id','token','forgot','answer'], |
|
556 | - 'getChat' => ['chat_id','token','forgot','answer'], |
|
557 | - 'getChatAdministrators' => ['chat_id','token','forgot','answer'], |
|
558 | - 'getChatMemberCount' => ['chat_id','token','forgot','answer'], |
|
559 | - 'getChatMember' => ['chat_id','user_id','token','forgot','answer'], |
|
560 | - 'setChatStickerSet' => ['sticker_set_name','chat_id','token','forgot','answer'], |
|
561 | - 'deleteChatStickerSet' => ['chat_id','token','forgot','answer'], |
|
562 | - 'answerCallbackQuery' => ['callback_query_id','text','show_alert','url','cache_time','token','forgot','answer'], |
|
563 | - 'setMyCommands' => ['commands','scope','language_code','token','forgot','answer'], |
|
564 | - 'deleteMyCommands' => ['scope','language_code','token','forgot','answer'], |
|
565 | - 'getMyCommands' => ['scope','language_code','token','forgot','answer'], |
|
566 | - 'setChatMenuButton' => ['chat_id','menu_button','token','forgot','answer'], |
|
567 | - 'getChatMenuButton' => ['chat_id','token','forgot','answer'], |
|
568 | - 'setMyDefaultAdministratorRights' => ['rights','for_channels','token','forgot','answer'], |
|
569 | - 'getMyDefaultAdministratorRights' => ['for_channels','token','forgot','answer'], |
|
570 | - 'editMessageText' => ['text','chat_id','message_id','inline_message_id','parse_mode','entities','disable_web_page_preview','reply_markup','token','forgot','answer'], |
|
571 | - 'editMessageCaption' => ['chat_id','message_id','inline_message_id','caption','parse_mode','caption_entities','reply_markup','token','forgot','answer'], |
|
572 | - 'editMessageMedia' => ['media','chat_id','message_id','inline_message_id','reply_markup','token','forgot','answer'], |
|
573 | - 'editMessageReplyMarkup' => ['chat_id','message_id','inline_message_id','reply_markup','token','forgot','answer'], |
|
574 | - 'stopPoll' => ['chat_id','message_id','reply_markup','token','forgot','answer'], |
|
575 | - 'deleteMessage' => ['chat_id','message_id','token','forgot','answer'], |
|
576 | - 'sendSticker' => ['sticker','chat_id','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
577 | - 'getStickerSet' => ['name','token','forgot','answer'], |
|
506 | + 'getUpdates' => ['offset', 'limit', 'timeout', 'allowed_updates', 'token', 'forgot', 'answer'], |
|
507 | + 'setWebhook' => ['url', 'certificate', 'ip_address', 'max_connections', 'allowed_updates', 'drop_pending_updates', 'secret_token', 'token', 'forgot', 'answer'], |
|
508 | + 'deleteWebhook' => ['drop_pending_updates', 'token', 'forgot', 'answer'], |
|
509 | + 'getWebhookInfo' => ['token', 'forgot', 'answer'], |
|
510 | + 'getMe' => ['token', 'forgot', 'answer'], |
|
511 | + 'logOut' => ['token', 'forgot', 'answer'], |
|
512 | + 'close' => ['token', 'forgot', 'answer'], |
|
513 | + 'sendMessage' => ['text', 'chat_id', 'parse_mode', 'entities', 'disable_web_page_preview', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
514 | + 'forwardMessage' => ['chat_id', 'from_chat_id', 'disable_notification', 'protect_content', 'message_id', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
515 | + 'copyMessage' => ['chat_id', 'from_chat_id', 'message_id', 'caption', 'parse_mode', 'caption_entities', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
516 | + 'sendPhoto' => ['photo', 'chat_id', 'caption', 'parse_mode', 'caption_entities', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'has_spoiler', 'message_thread_id'], |
|
517 | + 'sendAudio' => ['audio', 'chat_id', 'caption', 'parse_mode', 'caption_entities', 'duration', 'performer', 'title', 'thumb', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
518 | + 'sendDocument' => ['document', 'chat_id', 'thumb', 'caption', 'parse_mode', 'caption_entities', 'disable_content_type_detection', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
519 | + 'sendVideo' => ['video', 'chat_id', 'duration', 'width', 'height', 'thumb', 'caption', 'parse_mode', 'caption_entities', 'supports_streaming', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'has_spoiler', 'message_thread_id'], |
|
520 | + 'sendAnimation' => ['animation', 'chat_id', 'duration', 'width', 'height', 'thumb', 'caption', 'parse_mode', 'caption_entities', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'has_spoiler', 'message_thread_id'], |
|
521 | + 'sendVoice' => ['voice', 'chat_id', 'caption', 'parse_mode', 'caption_entities', 'duration', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
522 | + 'sendVideoNote' => ['video_note', 'chat_id', 'duration', 'length', 'thumb', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
523 | + 'sendMediaGroup' => ['media', 'chat_id', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
524 | + 'sendLocation' => ['latitude', 'longitude', 'chat_id', 'horizontal_accuracy', 'live_period', 'heading', 'proximity_alert_radius', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
525 | + 'editMessageLiveLocation' => ['latitude', 'longitude', 'chat_id', 'message_id', 'inline_message_id', 'horizontal_accuracy', 'heading', 'proximity_alert_radius', 'reply_markup', 'token', 'forgot', 'answer'], |
|
526 | + 'stopMessageLiveLocation' => ['chat_id', 'message_id', 'inline_message_id', 'reply_markup', 'token', 'forgot', 'answer'], |
|
527 | + 'sendVenue' => ['chat_id', 'latitude', 'longitude', 'title', 'address', 'foursquare_id', 'foursquare_type', 'google_place_id', 'google_place_type', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
528 | + 'sendContact' => ['phone_number', 'first_name', 'chat_id', 'last_name', 'vcard', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
529 | + 'sendPoll' => ['question', 'options', 'chat_id', 'is_anonymous', 'type', 'allows_multiple_answers', 'correct_option_id', 'explanation', 'explanation_parse_mode', 'explanation_entities', 'open_period', 'close_date', 'is_closed', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
530 | + 'sendDice' => ['chat_id', 'emoji', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
531 | + 'sendChatAction' => ['chat_id', 'action', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
532 | + 'getUserProfilePhotos' => ['user_id', 'offset', 'limit', 'token', 'forgot', 'answer'], |
|
533 | + 'getFile' => ['file_id', 'token', 'forgot', 'answer'], |
|
534 | + 'banChatMember' => ['chat_id', 'user_id', 'until_date', 'revoke_messages', 'token', 'forgot', 'answer'], |
|
535 | + 'unbanChatMember' => ['chat_id', 'user_id', 'only_if_banned', 'token', 'forgot', 'answer'], |
|
536 | + 'restrictChatMember' => ['permissions', 'chat_id', 'user_id', 'until_date', 'token', 'forgot', 'answer', 'use_independent_chat_permissions'], |
|
537 | + 'promoteChatMember' => ['chat_id', 'user_id', 'is_anonymous', 'can_manage_chat', 'can_post_messages', 'can_edit_messages', 'can_delete_messages', 'can_manage_video_chats', 'can_restrict_members', 'can_promote_members', 'can_change_info', 'can_invite_users', 'can_pin_messages', 'can_manage_topics', 'token', 'forgot', 'answer'], |
|
538 | + 'setChatAdministratorCustomTitle' => ['custom_title', 'chat_id', 'user_id', 'token', 'forgot', 'answer'], |
|
539 | + 'banChatSenderChat' => ['sender_chat_id', 'chat_id', 'token', 'forgot', 'answer'], |
|
540 | + 'unbanChatSenderChat' => ['sender_chat_id', 'chat_id', 'token', 'forgot', 'answer'], |
|
541 | + 'setChatPermissions' => ['permissions', 'chat_id', 'token', 'forgot', 'answer', 'use_independent_chat_permissions'], |
|
542 | + 'exportChatInviteLink' => ['chat_id', 'token', 'forgot', 'answer'], |
|
543 | + 'createChatInviteLink' => ['chat_id', 'name', 'expire_date', 'member_limit', 'creates_join_request', 'token', 'forgot', 'answer'], |
|
544 | + 'editChatInviteLink' => ['invite_link', 'chat_id', 'name', 'expire_date', 'member_limit', 'creates_join_request', 'token', 'forgot', 'answer'], |
|
545 | + 'revokeChatInviteLink' => ['invite_link', 'chat_id', 'token', 'forgot', 'answer'], |
|
546 | + 'approveChatJoinRequest' => ['chat_id', 'user_id', 'token', 'forgot', 'answer'], |
|
547 | + 'declineChatJoinRequest' => ['chat_id', 'user_id', 'token', 'forgot', 'answer'], |
|
548 | + 'setChatPhoto' => ['photo', 'chat_id', 'token', 'forgot', 'answer'], |
|
549 | + 'deleteChatPhoto' => ['chat_id', 'token', 'forgot', 'answer'], |
|
550 | + 'setChatTitle' => ['title', 'chat_id', 'token', 'forgot', 'answer'], |
|
551 | + 'setChatDescription' => ['chat_id', 'description', 'token', 'forgot', 'answer'], |
|
552 | + 'pinChatMessage' => ['message_id', 'chat_id', 'disable_notification', 'token', 'forgot', 'answer'], |
|
553 | + 'unpinChatMessage' => ['chat_id', 'message_id', 'token', 'forgot', 'answer'], |
|
554 | + 'unpinAllChatMessages' => ['chat_id', 'token', 'forgot', 'answer'], |
|
555 | + 'leaveChat' => ['chat_id', 'token', 'forgot', 'answer'], |
|
556 | + 'getChat' => ['chat_id', 'token', 'forgot', 'answer'], |
|
557 | + 'getChatAdministrators' => ['chat_id', 'token', 'forgot', 'answer'], |
|
558 | + 'getChatMemberCount' => ['chat_id', 'token', 'forgot', 'answer'], |
|
559 | + 'getChatMember' => ['chat_id', 'user_id', 'token', 'forgot', 'answer'], |
|
560 | + 'setChatStickerSet' => ['sticker_set_name', 'chat_id', 'token', 'forgot', 'answer'], |
|
561 | + 'deleteChatStickerSet' => ['chat_id', 'token', 'forgot', 'answer'], |
|
562 | + 'answerCallbackQuery' => ['callback_query_id', 'text', 'show_alert', 'url', 'cache_time', 'token', 'forgot', 'answer'], |
|
563 | + 'setMyCommands' => ['commands', 'scope', 'language_code', 'token', 'forgot', 'answer'], |
|
564 | + 'deleteMyCommands' => ['scope', 'language_code', 'token', 'forgot', 'answer'], |
|
565 | + 'getMyCommands' => ['scope', 'language_code', 'token', 'forgot', 'answer'], |
|
566 | + 'setChatMenuButton' => ['chat_id', 'menu_button', 'token', 'forgot', 'answer'], |
|
567 | + 'getChatMenuButton' => ['chat_id', 'token', 'forgot', 'answer'], |
|
568 | + 'setMyDefaultAdministratorRights' => ['rights', 'for_channels', 'token', 'forgot', 'answer'], |
|
569 | + 'getMyDefaultAdministratorRights' => ['for_channels', 'token', 'forgot', 'answer'], |
|
570 | + 'editMessageText' => ['text', 'chat_id', 'message_id', 'inline_message_id', 'parse_mode', 'entities', 'disable_web_page_preview', 'reply_markup', 'token', 'forgot', 'answer'], |
|
571 | + 'editMessageCaption' => ['chat_id', 'message_id', 'inline_message_id', 'caption', 'parse_mode', 'caption_entities', 'reply_markup', 'token', 'forgot', 'answer'], |
|
572 | + 'editMessageMedia' => ['media', 'chat_id', 'message_id', 'inline_message_id', 'reply_markup', 'token', 'forgot', 'answer'], |
|
573 | + 'editMessageReplyMarkup' => ['chat_id', 'message_id', 'inline_message_id', 'reply_markup', 'token', 'forgot', 'answer'], |
|
574 | + 'stopPoll' => ['chat_id', 'message_id', 'reply_markup', 'token', 'forgot', 'answer'], |
|
575 | + 'deleteMessage' => ['chat_id', 'message_id', 'token', 'forgot', 'answer'], |
|
576 | + 'sendSticker' => ['sticker', 'chat_id', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
577 | + 'getStickerSet' => ['name', 'token', 'forgot', 'answer'], |
|
578 | 578 | 'getCustomEmojiStickers' => ['custom_emoji_ids', 'token', 'return_array', 'forgot', 'answer'], |
579 | - 'uploadStickerFile' => ['png_sticker','user_id','token','forgot','answer'], |
|
580 | - 'createNewStickerSet' => ['name','title','emojis','user_id','png_sticker','tgs_sticker','webm_sticker','sticker_type','contains_masks','mask_position','token','forgot','answer'], |
|
581 | - 'addStickerToSet' => ['name','emojis','user_id','png_sticker','tgs_sticker','webm_sticker','mask_position','token','forgot','answer'], |
|
582 | - 'setStickerPositionInSet' => ['sticker','position','token','forgot','answer'], |
|
583 | - 'deleteStickerFromSet' => ['sticker','token','forgot','answer'], |
|
584 | - 'setStickerSetThumb' => ['name','user_id','thumb','token','forgot','answer'], |
|
585 | - 'answerInlineQuery' => ['results','inline_query_id','cache_time','is_personal','next_offset','switch_pm_text','switch_pm_parameter','token','forgot','answer'], |
|
586 | - 'answerWebAppQuery' => ['web_app_query_id','result','token','forgot','answer'], |
|
587 | - 'sendInvoice' => ['title','description','payload','provider_token','currency','prices','chat_id','max_tip_amount','suggested_tip_amounts','start_parameter','provider_data','photo_url','photo_size','photo_width','photo_height','need_name','need_phone_number','need_email','need_shipping_address','send_phone_number_to_provider','send_email_to_provider','is_flexible','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer','message_thread_id'], |
|
588 | - 'createInvoiceLink' => ['title','description','payload','provider_token','currency','prices','max_tip_amount','suggested_tip_amounts','provider_data','photo_url','photo_size','photo_width','photo_height','need_name','need_phone_number','need_email','need_shipping_address','send_phone_number_to_provider','send_email_to_provider','is_flexible','token','forgot','answer'], |
|
589 | - 'answerShippingQuery' => ['ok','shipping_query_id','shipping_options','error_message','token','forgot','answer'], |
|
590 | - 'answerPreCheckoutQuery' => ['ok','pre_checkout_query_id','error_message','token','forgot','answer'], |
|
591 | - 'setPassportDataErrors' => ['errors','user_id','token','forgot','answer'], |
|
592 | - 'sendGame' => ['game_short_name','chat_id','disable_notification','protect_content','reply_to_message_id','allow_sending_without_reply','reply_markup','token','forgot','answer', 'message_thread_id'], |
|
593 | - 'setGameScore' => ['score','user_id','force','disable_edit_message','chat_id','message_id','inline_message_id','token','forgot','answer'], |
|
594 | - 'getGameHighScores' => ['user_id','chat_id','message_id','inline_message_id','token','forgot','answer'], |
|
579 | + 'uploadStickerFile' => ['png_sticker', 'user_id', 'token', 'forgot', 'answer'], |
|
580 | + 'createNewStickerSet' => ['name', 'title', 'emojis', 'user_id', 'png_sticker', 'tgs_sticker', 'webm_sticker', 'sticker_type', 'contains_masks', 'mask_position', 'token', 'forgot', 'answer'], |
|
581 | + 'addStickerToSet' => ['name', 'emojis', 'user_id', 'png_sticker', 'tgs_sticker', 'webm_sticker', 'mask_position', 'token', 'forgot', 'answer'], |
|
582 | + 'setStickerPositionInSet' => ['sticker', 'position', 'token', 'forgot', 'answer'], |
|
583 | + 'deleteStickerFromSet' => ['sticker', 'token', 'forgot', 'answer'], |
|
584 | + 'setStickerSetThumb' => ['name', 'user_id', 'thumb', 'token', 'forgot', 'answer'], |
|
585 | + 'answerInlineQuery' => ['results', 'inline_query_id', 'cache_time', 'is_personal', 'next_offset', 'switch_pm_text', 'switch_pm_parameter', 'token', 'forgot', 'answer'], |
|
586 | + 'answerWebAppQuery' => ['web_app_query_id', 'result', 'token', 'forgot', 'answer'], |
|
587 | + 'sendInvoice' => ['title', 'description', 'payload', 'provider_token', 'currency', 'prices', 'chat_id', 'max_tip_amount', 'suggested_tip_amounts', 'start_parameter', 'provider_data', 'photo_url', 'photo_size', 'photo_width', 'photo_height', 'need_name', 'need_phone_number', 'need_email', 'need_shipping_address', 'send_phone_number_to_provider', 'send_email_to_provider', 'is_flexible', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
588 | + 'createInvoiceLink' => ['title', 'description', 'payload', 'provider_token', 'currency', 'prices', 'max_tip_amount', 'suggested_tip_amounts', 'provider_data', 'photo_url', 'photo_size', 'photo_width', 'photo_height', 'need_name', 'need_phone_number', 'need_email', 'need_shipping_address', 'send_phone_number_to_provider', 'send_email_to_provider', 'is_flexible', 'token', 'forgot', 'answer'], |
|
589 | + 'answerShippingQuery' => ['ok', 'shipping_query_id', 'shipping_options', 'error_message', 'token', 'forgot', 'answer'], |
|
590 | + 'answerPreCheckoutQuery' => ['ok', 'pre_checkout_query_id', 'error_message', 'token', 'forgot', 'answer'], |
|
591 | + 'setPassportDataErrors' => ['errors', 'user_id', 'token', 'forgot', 'answer'], |
|
592 | + 'sendGame' => ['game_short_name', 'chat_id', 'disable_notification', 'protect_content', 'reply_to_message_id', 'allow_sending_without_reply', 'reply_markup', 'token', 'forgot', 'answer', 'message_thread_id'], |
|
593 | + 'setGameScore' => ['score', 'user_id', 'force', 'disable_edit_message', 'chat_id', 'message_id', 'inline_message_id', 'token', 'forgot', 'answer'], |
|
594 | + 'getGameHighScores' => ['user_id', 'chat_id', 'message_id', 'inline_message_id', 'token', 'forgot', 'answer'], |
|
595 | 595 | 'getForumTopicIconStickers' => ['token', 'return_array', 'forgot', 'answer'], |
596 | 596 | 'createForumTopic' => ['chat_id', 'name', 'icon_color', 'icon_custom_emoji_id', 'token', 'return_array', 'forgot', 'answer'], |
597 | 597 | 'editForumTopic' => ['chat_id', 'name', 'icon_custom_emoji_id', 'token', 'return_array', 'forgot', 'answer', 'message_thread_id'], |
@@ -632,8 +632,8 @@ discard block |
||
632 | 632 | 'logOut' => [], |
633 | 633 | 'close' => [], |
634 | 634 | 'sendMessage' => ['chat_id'], |
635 | - 'forwardMessage' => ['from_chat_id','message_id'], |
|
636 | - 'copyMessage' => ['from_chat_id','message_id'], |
|
635 | + 'forwardMessage' => ['from_chat_id', 'message_id'], |
|
636 | + 'copyMessage' => ['from_chat_id', 'message_id'], |
|
637 | 637 | 'sendPhoto' => ['chat_id'], |
638 | 638 | 'sendAudio' => ['chat_id'], |
639 | 639 | 'sendDocument' => ['chat_id'], |
@@ -649,15 +649,15 @@ discard block |
||
649 | 649 | 'sendContact' => ['chat_id'], |
650 | 650 | 'sendPoll' => ['chat_id'], |
651 | 651 | 'sendDice' => ['chat_id'], |
652 | - 'sendChatAction' => ['chat_id','action'], |
|
652 | + 'sendChatAction' => ['chat_id', 'action'], |
|
653 | 653 | 'getUserProfilePhotos' => ['user_id'], |
654 | 654 | 'getFile' => ['file_id'], |
655 | - 'banChatMember' => ['chat_id','user_id'], |
|
656 | - 'kickChatMember' => ['chat_id','user_id'], |
|
657 | - 'unbanChatMember' => ['chat_id','user_id'], |
|
658 | - 'restrictChatMember' => ['chat_id','user_id'], |
|
659 | - 'promoteChatMember' => ['chat_id','user_id'], |
|
660 | - 'setChatAdministratorCustomTitle' => ['chat_id','user_id'], |
|
655 | + 'banChatMember' => ['chat_id', 'user_id'], |
|
656 | + 'kickChatMember' => ['chat_id', 'user_id'], |
|
657 | + 'unbanChatMember' => ['chat_id', 'user_id'], |
|
658 | + 'restrictChatMember' => ['chat_id', 'user_id'], |
|
659 | + 'promoteChatMember' => ['chat_id', 'user_id'], |
|
660 | + 'setChatAdministratorCustomTitle' => ['chat_id', 'user_id'], |
|
661 | 661 | 'banChatSenderChat' => ['chat_id'], |
662 | 662 | 'unbanChatSenderChat' => ['chat_id'], |
663 | 663 | 'setChatPermissions' => ['chat_id'], |
@@ -665,8 +665,8 @@ discard block |
||
665 | 665 | 'createChatInviteLink' => ['chat_id'], |
666 | 666 | 'editChatInviteLink' => ['chat_id'], |
667 | 667 | 'revokeChatInviteLink' => ['chat_id'], |
668 | - 'approveChatJoinRequest' => ['chat_id','user_id'], |
|
669 | - 'declineChatJoinRequest' => ['chat_id','user_id'], |
|
668 | + 'approveChatJoinRequest' => ['chat_id', 'user_id'], |
|
669 | + 'declineChatJoinRequest' => ['chat_id', 'user_id'], |
|
670 | 670 | 'setChatPhoto' => ['chat_id'], |
671 | 671 | 'deleteChatPhoto' => ['chat_id'], |
672 | 672 | 'setChatTitle' => ['chat_id'], |
@@ -678,7 +678,7 @@ discard block |
||
678 | 678 | 'getChat' => ['chat_id'], |
679 | 679 | 'getChatAdministrators' => ['chat_id'], |
680 | 680 | 'getChatMembersCount' => ['chat_id'], |
681 | - 'getChatMember' => ['chat_id','user_id'], |
|
681 | + 'getChatMember' => ['chat_id', 'user_id'], |
|
682 | 682 | 'setChatStickerSet' => ['chat_id'], |
683 | 683 | 'deleteChatStickerSet' => ['chat_id'], |
684 | 684 | 'answerCallbackQuery' => ['callback_query_id'], |
@@ -689,12 +689,12 @@ discard block |
||
689 | 689 | 'getChatMenuButton' => [], |
690 | 690 | 'setMyDefaultAdministratorRights' => [], |
691 | 691 | 'getMyDefaultAdministratorRights' => [], |
692 | - 'editMessageText' => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
693 | - 'editMessageCaption' => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
694 | - 'editMessageMedia' => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
695 | - 'editMessageReplyMarkup' => ['inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
696 | - 'stopPoll' => ['chat_id','message_id'], |
|
697 | - 'deleteMessage' => ['chat_id','message_id'], |
|
692 | + 'editMessageText' => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
693 | + 'editMessageCaption' => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
694 | + 'editMessageMedia' => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
695 | + 'editMessageReplyMarkup' => ['inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
696 | + 'stopPoll' => ['chat_id', 'message_id'], |
|
697 | + 'deleteMessage' => ['chat_id', 'message_id'], |
|
698 | 698 | 'sendSticker' => ['chat_id'], |
699 | 699 | 'getStickerSet' => [], |
700 | 700 | 'uploadStickerFile' => ['user_id'], |
@@ -710,8 +710,8 @@ discard block |
||
710 | 710 | 'answerPreCheckoutQuery' => ['pre_checkout_query_id'], |
711 | 711 | 'setPassportDataErrors' => ['user_id'], |
712 | 712 | 'sendGame' => ['chat_id'], |
713 | - 'setGameScore' => ['user_id','inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']], |
|
714 | - 'getGameHighScores' => ['user_id','inline_query'=>['inline_message_id'],'other'=>['chat_id','message_id']] |
|
713 | + 'setGameScore' => ['user_id', 'inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']], |
|
714 | + 'getGameHighScores' => ['user_id', 'inline_query'=>['inline_message_id'], 'other'=>['chat_id', 'message_id']] |
|
715 | 715 | ]; |
716 | 716 | |
717 | 717 | private const METHODS_RETURN = [ |
@@ -765,29 +765,29 @@ discard block |
||
765 | 765 | 'getGameHighScores' => ['BPT\types\gameHighScore'] |
766 | 766 | ]; |
767 | 767 | |
768 | - public static function __callStatic (string $name, array $arguments) { |
|
768 | + public static function __callStatic(string $name, array $arguments) { |
|
769 | 769 | if (!$action = self::methodAction($name)) { |
770 | - logger::write("$name method is not supported",loggerTypes::ERROR); |
|
770 | + logger::write("$name method is not supported", loggerTypes::ERROR); |
|
771 | 771 | throw new bptException('METHOD_NOT_FOUND'); |
772 | 772 | } |
773 | 773 | self::checkArguments($arguments); |
774 | - self::keysName($action,$arguments); |
|
775 | - self::readyFile($action,$arguments); |
|
776 | - self::setDefaults($action,$arguments); |
|
774 | + self::keysName($action, $arguments); |
|
775 | + self::readyFile($action, $arguments); |
|
776 | + self::setDefaults($action, $arguments); |
|
777 | 777 | self::cleanArguments($arguments); |
778 | 778 | |
779 | 779 | if (isset($arguments['answer']) && $arguments['answer'] === true) { |
780 | 780 | unset($arguments['answer']); |
781 | 781 | if (!answer::isAnswered()) { |
782 | - return answer::init($action,$arguments); |
|
782 | + return answer::init($action, $arguments); |
|
783 | 783 | } |
784 | - logger::write('you can use answer mode only once for each webhook update, Others will be called like normal',loggerTypes::WARNING); |
|
784 | + logger::write('you can use answer mode only once for each webhook update, Others will be called like normal', loggerTypes::WARNING); |
|
785 | 785 | } |
786 | - $result = curl::init($action,$arguments); |
|
786 | + $result = curl::init($action, $arguments); |
|
787 | 787 | if (!is_object($result)) { |
788 | 788 | return false; |
789 | 789 | } |
790 | - return self::processResponse($action,$result); |
|
790 | + return self::processResponse($action, $result); |
|
791 | 791 | } |
792 | 792 | |
793 | 793 | private static function checkArguments(array &$arguments): void { |
@@ -796,7 +796,7 @@ discard block |
||
796 | 796 | } |
797 | 797 | } |
798 | 798 | |
799 | - private static function keysName (string $name, array &$arguments): void { |
|
799 | + private static function keysName(string $name, array &$arguments): void { |
|
800 | 800 | foreach ($arguments as $key => $argument) { |
801 | 801 | if (is_numeric($key) && isset(self::METHODS_KEYS[$name][$key])) { |
802 | 802 | $arguments[self::METHODS_KEYS[$name][$key]] = $argument; |
@@ -805,7 +805,7 @@ discard block |
||
805 | 805 | } |
806 | 806 | } |
807 | 807 | |
808 | - private static function methodAction(string $name): string|false { |
|
808 | + private static function methodAction(string $name): string | false { |
|
809 | 809 | return self::METHODS_ACTION[str_replace('_', '', strtolower($name))] ?? false; |
810 | 810 | } |
811 | 811 | |
@@ -838,11 +838,11 @@ discard block |
||
838 | 838 | } |
839 | 839 | } |
840 | 840 | |
841 | - private static function methodFile(string $name): array|false { |
|
841 | + private static function methodFile(string $name): array | false { |
|
842 | 842 | return self::METHODS_WITH_FILE[$name] ?? false; |
843 | 843 | } |
844 | 844 | |
845 | - private static function methodReturn(string $name,stdClass $response) { |
|
845 | + private static function methodReturn(string $name, stdClass $response) { |
|
846 | 846 | if (!isset(self::METHODS_RETURN[$name])) { |
847 | 847 | return $response->result; |
848 | 848 | } |
@@ -861,13 +861,13 @@ discard block |
||
861 | 861 | $defaults = self::METHODS_EXTRA_DEFAULTS[$name]; |
862 | 862 | foreach ($defaults as $key => $default) { |
863 | 863 | if (is_numeric($key)) { |
864 | - if (!isset($arguments[$default])){ |
|
864 | + if (!isset($arguments[$default])) { |
|
865 | 865 | $arguments[$default] = self::catchFields($default); |
866 | 866 | } |
867 | 867 | } |
868 | 868 | elseif (isset(BPT::$update->$key) || $key === 'other') { |
869 | 869 | foreach ($default as $def) { |
870 | - if (!isset($arguments[$def])){ |
|
870 | + if (!isset($arguments[$def])) { |
|
871 | 871 | $arguments[$def] = self::catchFields($def); |
872 | 872 | } |
873 | 873 | } |
@@ -880,13 +880,13 @@ discard block |
||
880 | 880 | self::$status = $response->ok; |
881 | 881 | self::$pure_response = $response; |
882 | 882 | if (!$response->ok) { |
883 | - logger::write("Telegram $name method failed : " . json_encode($response), loggerTypes::WARNING); |
|
883 | + logger::write("Telegram $name method failed : ".json_encode($response), loggerTypes::WARNING); |
|
884 | 884 | return new responseError($response); |
885 | 885 | } |
886 | - return self::methodReturn($name,$response); |
|
886 | + return self::methodReturn($name, $response); |
|
887 | 887 | } |
888 | 888 | |
889 | - private static function cleanArguments (array &$arguments): void { |
|
889 | + private static function cleanArguments(array &$arguments): void { |
|
890 | 890 | foreach ($arguments as $key => $argument) { |
891 | 891 | if ($argument == [] || $argument === null) { |
892 | 892 | unset($arguments[$key]); |
@@ -900,7 +900,7 @@ discard block |
||
900 | 900 | * |
901 | 901 | * @return int|string|bool |
902 | 902 | */ |
903 | - public static function catchFields (string $field): int|string|bool { |
|
903 | + public static function catchFields(string $field): int | string | bool { |
|
904 | 904 | switch ($field) { |
905 | 905 | case fields::CHAT_ID : |
906 | 906 | case fields::FROM_CHAT_ID : |
@@ -1036,13 +1036,13 @@ discard block |
||
1036 | 1036 | default => false |
1037 | 1037 | }; |
1038 | 1038 | case fields::URL : |
1039 | - return 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; |
|
1039 | + return 'https://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; |
|
1040 | 1040 | default: |
1041 | 1041 | return false; |
1042 | 1042 | } |
1043 | 1043 | } |
1044 | 1044 | |
1045 | - public static function fileLink (string|null $file_id = null): bool|string { |
|
1045 | + public static function fileLink(string | null $file_id = null): bool | string { |
|
1046 | 1046 | $file = request::getFile($file_id); |
1047 | 1047 | if (!isset($file->file_path)) { |
1048 | 1048 | return false; |
@@ -1064,7 +1064,7 @@ discard block |
||
1064 | 1064 | * |
1065 | 1065 | * @return bool |
1066 | 1066 | */ |
1067 | - public static function downloadFile (string|null $destination = null, string|null $file_id = null): bool { |
|
1067 | + public static function downloadFile(string | null $destination = null, string | null $file_id = null): bool { |
|
1068 | 1068 | return tools::downloadFile(self::fileLink($file_id), $destination); |
1069 | 1069 | } |
1070 | 1070 | |
@@ -1082,7 +1082,7 @@ discard block |
||
1082 | 1082 | * |
1083 | 1083 | * @return message|bool|responseError |
1084 | 1084 | */ |
1085 | - 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 { |
|
1085 | + 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 { |
|
1086 | 1086 | $type = tools::fileType($file_id); |
1087 | 1087 | return match ($type) { |
1088 | 1088 | fileTypes::VIDEO => request::sendVideo($file_id, $chat_id, null, null, null, null, $caption, $parse_mode, $caption_entities, null, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer, $message_thread_id), |