├── README.md
├── commands.php
├── config.php
├── functions
├── botapi.php
├── database.php
├── objects.php
└── update.php
├── index.php
└── plugins
├── end
└── example.php
└── start
└── inline.php
/README.md:
--------------------------------------------------------------------------------
1 | # SilBot 1.5
2 |
3 | A new version based on OOP programming in PHP 7 with MySQL integration.
4 | - - -
5 | # Documentation
6 |
7 | You can read the full documentation for this framework on https://github.com/SilverOS/Silbot-Webhook/wiki.
8 | To easly install this framework you can use the [installer](https://github.com/SilverOS/silbot-installer).
9 | - - -
10 | # Webhook
11 |
12 | To set the bot's webhook you have to do a setWebhook request to the botAPI using this format:
13 | https://api.telegram.org/botTOKEN/setWebhook?url=https://your.server.com/path/index.php?token=TOKEN
14 |
15 | You can also use @DevToolsForBot using Set Webhook and writing first the token and next the url to your server in format https://your.server.com/path/index.php?token=TOKEN
16 | - - -
17 | # How it works
18 |
19 | In the file functions/botapi.php
there is the botApi class, where there are the functions to make requests to the botapi. In index.php is defined in $bot
, so to send a message you can use $bot->sendMessage('Chat_ID','Text');
.
20 |
21 | Then, there is the file functions/update.php
whose purpose is to set variables, sort the update and, if set, save users in the database. The variables are set dinamically, the objects which do this are in functions/objects.php
.
22 |
23 | In conclusion, index.php make same important variables easier tu write and execute commands.php, where the bot's code should be written.
24 |
25 | You can include config.php in an external file to use the framework's functions and objects without elaborating an update
26 | - - -
27 | # Config
28 |
29 | In the config.php
file you will find an array, $config, where you can set pre-defined values for some botapi variables if not included in the function, such as disable_notification
. You can also set if you want a MySQL database.
30 | - - -
31 | # MySQL
32 |
33 | To use this you have to set database->active on true and insert your credentials in the config. After that are asked the names of two tables:
34 | - universal_table => Created to work with more than one bot, there will be saved all the users and chats the bot see with Telegram information, even with forwarded messages or reply. The table contains 4 coloumns: chat_id,username,lang,type
35 | - bot_table => Where the bot's users are saved, by default it only contains two coloumns: chat_id, state
. This is made to do stuff with the code.
36 |
37 | To install the database you need to do a GET request to the webhook url with the parameter install
38 | - - -
39 | # Plugins
40 |
41 | There are two plugins folders:
42 | - Plugins in plugins/start
will be loaded before commands.php
43 | - Plugins in plugins/end
will be loaded after commands.php
44 | To add a plugin just drop it in the needed folder
45 | - - -
46 |
47 | # TO-DO List
48 | - [ ] Finish adding all the botapi methods
49 | - [ ] Add more functions to objects
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/commands.php:
--------------------------------------------------------------------------------
1 | text == '/start') {
4 | $keyboard = [
5 | [['text' => 'Callback Test','callback_data' => '/test']],
6 | [['text' => 'URL Example','url' => 'https://github.com/SilverOS/Silbot-Webhook'],['text' => 'Switch Inline','switch_inline_query' => 'Example Text']],
7 | ];
8 | $bot->sendMessage($chat,'Hello ' . $user->htmlmention . '!',$keyboard,'inline','html');
9 | } elseif (isset($callback->data) && $callback->data == '/test') {
10 | $bot->editMessageText($chat,$message,'Message edited!');
11 | $callback->answer('Callback Answered',true);
12 | } elseif ($message->text == '/delete') {
13 | $message->deleteMessage();
14 | /*
15 | * You can also do
16 | * $bot->deleteMessage($chat,$message);
17 | * or
18 | * $bot->deleteMessage($chat->id,$message->id);
19 | */
20 | } elseif ($message->text == '/photo') {
21 | $bot->sendPhoto($chat,'https://www.silveros.it/img/silbot.png');
22 | } elseif (isset($photo)) {
23 | $photo->send($chat,'Here is your photo!');
24 | } elseif (isset($sticker)) {
25 | $r = $sticker->send($chat);
26 | }
27 | }
--------------------------------------------------------------------------------
/config.php:
--------------------------------------------------------------------------------
1 | [ //Avoid receiving fake requests or not allowed cloned bots
6 | 'tokens' => ['botTOKEN'],
7 | 'enabled' => false
8 | ],
9 | 'plugins' => [
10 | 'active' => true, // Choose if you want plugins loaded
11 | 'start_disabled' => [''], // Array of files to not load in plugins/start folder
12 | 'end_disabled' => [''], // Array of files to not load in plugins/end folder
13 | ],
14 | 'database' => [ //MySQL Credentials
15 | 'active' => true,
16 | 'ip' => 'localhost',
17 | 'user' => '',
18 | 'password' => '',
19 | 'db_name' => '',
20 | 'universal_table' => 'users', // Where are stored Telegram User Information
21 | 'bot_table' => 'silbot', // Where are stored Bot - Related User information
22 | ],
23 | 'connection_close' => false, //This option will close the connection with the bot API, not making it wait for the update
24 | 'parse_mode' => 'HTML',
25 | 'keyboard_type' => 'inline', // Can be 'inline' or 'reply' or 'hide'
26 | 'disable_notification' => false,
27 | 'object_response' => false, // If enabled it will automatically return a response object after botApi requests
28 | 'disable_web_page_preview' => false,
29 | ];
30 | if ($config['token_whitelist']['enabled']) {
31 | if (!in_array($token,$config['token_whitelist']['tokens'])) {
32 | exit;
33 | }
34 | }
35 |
36 | if ($config['database']['active']) {
37 | require 'functions/database.php';
38 | }
39 |
40 | require 'functions/botapi.php';
41 | require 'functions/objects.php';
42 |
--------------------------------------------------------------------------------
/functions/botapi.php:
--------------------------------------------------------------------------------
1 | $parse_mode,
13 | 'keyboard_type' => $keyboard_type, // Can be 'inline' or 'reply' or 'hide'
14 | 'disable_notification' => $disable_notification,
15 | 'object_response' => $object_response, // If enabled it will automatically return a response object after botApi requests
16 | 'disable_web_page_preview' => $disable_web_page_preview,
17 | ];
18 | }
19 | $this->token = $token;
20 | $this->config = $config;
21 | }
22 |
23 | function sendRequest($method, $args = [], $response_type = false)
24 | {
25 | $args = http_build_query($args);
26 | $request = curl_init('https://api.telegram.org/' . $this->token . '/' . $method);
27 | curl_setopt_array($request, array(
28 | CURLOPT_CONNECTTIMEOUT => 1,
29 | CURLOPT_RETURNTRANSFER => 1,
30 | CURLOPT_USERAGENT => 'cURL request',
31 | CURLOPT_POST => 1,
32 | CURLOPT_POSTFIELDS => $args
33 | ));
34 | curl_setopt($request, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
35 | $result = curl_exec($request);
36 | curl_close($request);
37 | if (($this->config['object_response'] && !$response_type) || $response_type == "object") {
38 | return new response(json_decode($result, true));
39 | } else {
40 | return $result;
41 | }
42 | }
43 |
44 | /*
45 | * SEND FUNCTIONS
46 | */
47 | function sendMessage($chat, $text, $keyboard = false, $keyboard_type = false, $parse_mode = false, $reply_to_message_id = false, $disable_notification = 0, $disable_web_page_preview = 0)
48 | {
49 | if (is_a($chat, 'chat') || is_a($chat, 'user')) {
50 | $chat_id = $chat->id;
51 | } else {
52 | $chat_id = $chat;
53 | }
54 | if (!$parse_mode) $parse_mode = $this->config['parse_mode'];
55 | if ($disable_notification === 0) $disable_notification = $this->config['disable_notification'];
56 | if ($disable_web_page_preview === 0) $disable_web_page_preview = $this->config['disable_web_page_preview'];
57 | if ($keyboard) {
58 | if (!$keyboard_type) $keyboard_type = $this->config['keyboard_type'];
59 | if ($keyboard_type === 'inline') {
60 | $reply_markup = ['inline_keyboard' => $keyboard];
61 | } elseif ($keyboard_type === 'reply') {
62 | $reply_markup = ['keyboard' => $keyboard, 'resize_keyboard' => true];
63 | } elseif ($keyboard_type === 'hide') {
64 | $reply_markup = ['hide_keyboard' => true];
65 | }
66 | }
67 | $args = [
68 | 'chat_id' => $chat_id,
69 | 'text' => $text,
70 | 'parse_mode' => $parse_mode,
71 | 'reply_to_message_id' => $reply_to_message_id,
72 | 'disable_notification' => $disable_notification,
73 | 'disable_web_page_preview' => $disable_web_page_preview,];
74 | if (isset($reply_markup)) $args['reply_markup'] = json_encode($reply_markup);
75 | return $this->sendRequest('sendMessage', $args);
76 | }
77 | function sendMediaGroup($chat,$media,$reply_to_message_id = false,$disable_notification = 0) {
78 | if ($disable_notification === 0) $disable_notification = $this->config['disable_notification'];
79 | if (is_a($chat, 'chat') || is_a($chat, 'user')) {
80 | $chat_id = $chat->id;
81 | } else {
82 | $chat_id = $chat;
83 | }
84 | $args = [
85 | 'chat_id' => $chat_id,
86 | 'media' => $media,
87 | 'reply_to_message_id' => $reply_to_message_id,
88 | 'disable_notigication' => $disable_notification,
89 | ];
90 | return $this->sendRequest('sendMediaGroup',$args);
91 | }
92 | function sendPhoto($chat, $photo, $caption = '', $keyboard = false, $keyboard_type = false, $parse_mode = false, $reply_to_message_id = false, $disable_notification = 0)
93 | {
94 | if (is_a($chat, 'chat') || is_a($chat, 'user')) {
95 | $chat_id = $chat->id;
96 | } else {
97 | $chat_id = $chat;
98 | }
99 | if (!$parse_mode) $parse_mode = $this->config['parse_mode'];
100 | if ($disable_notification === 0) $disable_notification = $this->config['disable_notification'];
101 | if ($keyboard) {
102 | if (!$keyboard_type) $keyboard_type = $this->config['keyboard_type'];
103 | if ($keyboard_type === 'inline') {
104 | $reply_markup = ['inline_keyboard' => $keyboard];
105 | } elseif ($keyboard_type === 'reply') {
106 | $reply_markup = ['keyboard' => $keyboard, 'resize_keyboard' => true];
107 | } elseif ($keyboard_type === 'hide') {
108 | $reply_markup = ['hide_keyboard' => true];
109 | }
110 | }
111 | $args = [
112 | 'chat_id' => $chat_id,
113 | 'caption' => $caption,
114 | 'photo' => $photo,
115 | 'parse_mode' => $parse_mode,
116 | 'reply_to_message_id' => $reply_to_message_id,
117 | 'disable_notification' => $disable_notification,
118 | ];
119 | if (isset($reply_markup)) $args['reply_markup'] = json_encode($reply_markup);
120 | return $this->sendRequest('sendPhoto', $args);
121 | }
122 |
123 | function sendAudio($chat, $audio, $caption = '', $keyboard = false, $keyboard_type = false, $duration = false, $performer = false, $title = false, $thumb = false, $parse_mode = false, $reply_to_message_id = false, $disable_notification = 0)
124 | {
125 | if (is_a($chat, 'chat') || is_a($chat, 'user')) {
126 | $chat_id = $chat->id;
127 | } else {
128 | $chat_id = $chat;
129 | }
130 | if (!$parse_mode) $parse_mode = $this->config['parse_mode'];
131 | if ($disable_notification === 0) $disable_notification = $this->config['disable_notification'];
132 | if ($keyboard) {
133 | if (!$keyboard_type) $keyboard_type = $this->config['keyboard_type'];
134 | if ($keyboard_type === 'inline') {
135 | $reply_markup = ['inline_keyboard' => $keyboard];
136 | } elseif ($keyboard_type === 'reply') {
137 | $reply_markup = ['keyboard' => $keyboard, 'resize_keyboard' => true];
138 | } elseif ($keyboard_type === 'hide') {
139 | $reply_markup = ['hide_keyboard' => true];
140 | }
141 | }
142 | $args = [
143 | 'chat_id' => $chat_id,
144 | 'caption' => $caption,
145 | 'audio' => $audio,
146 | 'duration' => $duration,
147 | 'performer' => $performer,
148 | 'title' => $title,
149 | 'thumb' => $thumb,
150 | 'parse_mode' => $parse_mode,
151 | 'reply_to_message_id' => $reply_to_message_id,
152 | 'disable_notification' => $disable_notification,
153 | ];
154 | if (isset($reply_markup)) $args['reply_markup'] = json_encode($reply_markup);
155 | return $this->sendRequest('sendAudio', $args);
156 | }
157 |
158 | function sendDocument($chat, $document, $caption = '', $keyboard = false, $keyboard_type = false, $thumb = false, $parse_mode = false, $reply_to_message_id = false, $disable_notification = 0)
159 | {
160 | if (is_a($chat, 'chat') || is_a($chat, 'user')) {
161 | $chat_id = $chat->id;
162 | } else {
163 | $chat_id = $chat;
164 | }
165 | if (!$parse_mode) $parse_mode = $this->config['parse_mode'];
166 | if ($disable_notification === 0) $disable_notification = $this->config['disable_notification'];
167 | if ($keyboard) {
168 | if (!$keyboard_type) $keyboard_type = $this->config['keyboard_type'];
169 | if ($keyboard_type === 'inline') {
170 | $reply_markup = ['inline_keyboard' => $keyboard];
171 | } elseif ($keyboard_type === 'reply') {
172 | $reply_markup = ['keyboard' => $keyboard, 'resize_keyboard' => true];
173 | } elseif ($keyboard_type === 'hide') {
174 | $reply_markup = ['hide_keyboard' => true];
175 | }
176 | }
177 | $args = [
178 | 'chat_id' => $chat_id,
179 | 'caption' => $caption,
180 | 'document' => $document,
181 | 'thumb' => $thumb,
182 | 'parse_mode' => $parse_mode,
183 | 'reply_to_message_id' => $reply_to_message_id,
184 | 'disable_notification' => $disable_notification,
185 | ];
186 | if (isset($reply_markup)) $args['reply_markup'] = json_encode($reply_markup);
187 | return $this->sendRequest('sendDocument', $args);
188 | }
189 |
190 | function sendVideo($chat, $video, $caption = '', $keyboard = false, $keyboard_type = false, $thumb = false, $height = false, $width = false, $duration = false, $supports_streaming = false, $parse_mode = false, $reply_to_message_id = false, $disable_notification = 0)
191 | {
192 | if (is_a($chat, 'chat') || is_a($chat, 'user')) {
193 | $chat_id = $chat->id;
194 | } else {
195 | $chat_id = $chat;
196 | }
197 | if (!$parse_mode) $parse_mode = $this->config['parse_mode'];
198 | if ($disable_notification === 0) $disable_notification = $this->config['disable_notification'];
199 | if ($keyboard) {
200 | if (!$keyboard_type) $keyboard_type = $this->config['keyboard_type'];
201 | if ($keyboard_type === 'inline') {
202 | $reply_markup = ['inline_keyboard' => $keyboard];
203 | } elseif ($keyboard_type === 'reply') {
204 | $reply_markup = ['keyboard' => $keyboard, 'resize_keyboard' => true];
205 | } elseif ($keyboard_type === 'hide') {
206 | $reply_markup = ['hide_keyboard' => true];
207 | }
208 | }
209 | $args = [
210 | 'chat_id' => $chat_id,
211 | 'caption' => $caption,
212 | 'video' => $video,
213 | 'thumb' => $thumb,
214 | 'height' => $height,
215 | 'width' => $width,
216 | 'duration' => $duration,
217 | 'supports_streaming' => $supports_streaming,
218 | 'parse_mode' => $parse_mode,
219 | 'reply_to_message_id' => $reply_to_message_id,
220 | 'disable_notification' => $disable_notification,
221 | ];
222 | if (isset($reply_markup)) $args['reply_markup'] = json_encode($reply_markup);
223 | return $this->sendRequest('sendVideo', $args);
224 | }
225 |
226 | function sendAnimation($chat, $animation, $caption = '', $keyboard = false, $keyboard_type = false, $thumb = false, $height = false, $width = false, $duration = false, $parse_mode = false, $reply_to_message_id = false, $disable_notification = 0)
227 | {
228 | if (is_a($chat, 'chat') || is_a($chat, 'user')) {
229 | $chat_id = $chat->id;
230 | } else {
231 | $chat_id = $chat;
232 | }
233 | if (!$parse_mode) $parse_mode = $this->config['parse_mode'];
234 | if ($disable_notification === 0) $disable_notification = $this->config['disable_notification'];
235 | if ($keyboard) {
236 | if (!$keyboard_type) $keyboard_type = $this->config['keyboard_type'];
237 | if ($keyboard_type === 'inline') {
238 | $reply_markup = ['inline_keyboard' => $keyboard];
239 | } elseif ($keyboard_type === 'reply') {
240 | $reply_markup = ['keyboard' => $keyboard, 'resize_keyboard' => true];
241 | } elseif ($keyboard_type === 'hide') {
242 | $reply_markup = ['hide_keyboard' => true];
243 | }
244 | }
245 | $args = [
246 | 'chat_id' => $chat_id,
247 | 'caption' => $caption,
248 | 'animation' => $animation,
249 | 'thumb' => $thumb,
250 | 'height' => $height,
251 | 'width' => $width,
252 | 'duration' => $duration,
253 | 'parse_mode' => $parse_mode,
254 | 'reply_to_message_id' => $reply_to_message_id,
255 | 'disable_notification' => $disable_notification,
256 | ];
257 | if (isset($reply_markup)) $args['reply_markup'] = json_encode($reply_markup);
258 | return $this->sendRequest('sendAnimation', $args);
259 | }
260 |
261 | function sendVoice($chat, $voice, $caption = '', $keyboard = false, $keyboard_type = false, $duration = false, $parse_mode = false, $reply_to_message_id = false, $disable_notification = 0)
262 | {
263 | if (is_a($chat, 'chat') || is_a($chat, 'user')) {
264 | $chat_id = $chat->id;
265 | } else {
266 | $chat_id = $chat;
267 | }
268 | if (!$parse_mode) $parse_mode = $this->config['parse_mode'];
269 | if ($disable_notification === 0) $disable_notification = $this->config['disable_notification'];
270 | if ($keyboard) {
271 | if (!$keyboard_type) $keyboard_type = $this->config['keyboard_type'];
272 | if ($keyboard_type === 'inline') {
273 | $reply_markup = ['inline_keyboard' => $keyboard];
274 | } elseif ($keyboard_type === 'reply') {
275 | $reply_markup = ['keyboard' => $keyboard, 'resize_keyboard' => true];
276 | } elseif ($keyboard_type === 'hide') {
277 | $reply_markup = ['hide_keyboard' => true];
278 | }
279 | }
280 | $args = [
281 | 'chat_id' => $chat_id,
282 | 'caption' => $caption,
283 | 'voice' => $voice,
284 | 'duration' => $duration,
285 | 'parse_mode' => $parse_mode,
286 | 'reply_to_message_id' => $reply_to_message_id,
287 | 'disable_notification' => $disable_notification,
288 | ];
289 | if (isset($reply_markup)) $args['reply_markup'] = json_encode($reply_markup);
290 | return $this->sendRequest('sendVoice', $args);
291 | }
292 |
293 | function sendVideoNote($chat, $video_note, $caption = '', $keyboard = false, $keyboard_type = false, $thumb = false, $length = false, $duration = false, $parse_mode = false, $reply_to_message_id = false, $disable_notification = 0)
294 | {
295 | if (is_a($chat, 'chat') || is_a($chat, 'user')) {
296 | $chat_id = $chat->id;
297 | } else {
298 | $chat_id = $chat;
299 | }
300 | if (!$parse_mode) $parse_mode = $this->config['parse_mode'];
301 | if ($disable_notification === 0) $disable_notification = $this->config['disable_notification'];
302 | if ($keyboard) {
303 | if (!$keyboard_type) $keyboard_type = $this->config['keyboard_type'];
304 | if ($keyboard_type === 'inline') {
305 | $reply_markup = ['inline_keyboard' => $keyboard];
306 | } elseif ($keyboard_type === 'reply') {
307 | $reply_markup = ['keyboard' => $keyboard, 'resize_keyboard' => true];
308 | } elseif ($keyboard_type === 'hide') {
309 | $reply_markup = ['hide_keyboard' => true];
310 | }
311 | }
312 | $args = [
313 | 'chat_id' => $chat_id,
314 | 'caption' => $caption,
315 | 'video_note' => $video_note,
316 | 'thumb' => $thumb,
317 | 'lenght' => $length,
318 | 'duration' => $duration,
319 | 'parse_mode' => $parse_mode,
320 | 'reply_to_message_id' => $reply_to_message_id,
321 | 'disable_notification' => $disable_notification,
322 | ];
323 | if (isset($reply_markup)) $args['reply_markup'] = json_encode($reply_markup);
324 | return $this->sendRequest('sendVideoNote', $args);
325 | }
326 |
327 | function sendSticker($chat, $sticker, $keyboard = false, $keyboard_type = false, $reply_to_message_id = false, $disable_notification = 0)
328 | {
329 | if (is_a($chat, 'chat') || is_a($chat, 'user')) {
330 | $chat_id = $chat->id;
331 | } else {
332 | $chat_id = $chat;
333 | }
334 | if ($disable_notification === 0) $disable_notification = $this->config['disable_notification'];
335 | if ($keyboard) {
336 | if (!$keyboard_type) $keyboard_type = $this->config['keyboard_type'];
337 | if ($keyboard_type === 'inline') {
338 | $reply_markup = ['inline_keyboard' => $keyboard];
339 | } elseif ($keyboard_type === 'reply') {
340 | $reply_markup = ['keyboard' => $keyboard, 'resize_keyboard' => true];
341 | } elseif ($keyboard_type === 'hide') {
342 | $reply_markup = ['hide_keyboard' => true];
343 | }
344 | }
345 | $args = [
346 | 'chat_id' => $chat_id,
347 | 'sticker' => $sticker,
348 | 'reply_to_message_id' => $reply_to_message_id,
349 | 'disable_notification' => $disable_notification,
350 | ];
351 | if (isset($reply_markup)) $args['reply_markup'] = json_encode($reply_markup);
352 | return $this->sendRequest('sendSticker', $args);
353 | }
354 | function sendVenue($chat, $longitude, $latitude,$title,$address,$foursquare_id=false,$foursquare_type=false, $keyboard = false, $keyboard_type = false, $reply_to_message_id = false, $disable_notification = 0)
355 | {
356 | if (is_a($chat, 'chat') || is_a($chat, 'user')) {
357 | $chat_id = $chat->id;
358 | } else {
359 | $chat_id = $chat;
360 | }
361 | if ($disable_notification === 0) $disable_notification = $this->config['disable_notification'];
362 | if ($keyboard) {
363 | if (!$keyboard_type) $keyboard_type = $this->config['keyboard_type'];
364 | if ($keyboard_type === 'inline') {
365 | $reply_markup = ['inline_keyboard' => $keyboard];
366 | } elseif ($keyboard_type === 'reply') {
367 | $reply_markup = ['keyboard' => $keyboard, 'resize_keyboard' => true];
368 | } elseif ($keyboard_type === 'hide') {
369 | $reply_markup = ['hide_keyboard' => true];
370 | }
371 | }
372 | $args = [
373 | 'chat_id' => $chat_id,
374 | 'longitude' => $longitude,
375 | 'latitude' => $latitude,
376 | 'title' => $title,
377 | 'address' => $address,
378 | 'foursquare_id' => $foursquare_id,
379 | 'foursquare_type' => $foursquare_type,
380 | 'reply_to_message_id' => $reply_to_message_id,
381 | 'disable_notification' => $disable_notification,
382 | ];
383 | if (isset($reply_markup)) $args['reply_markup'] = json_encode($reply_markup);
384 | return $this->sendRequest('sendVenue', $args);
385 | }
386 | function sendLocation($chat, $longitude, $latitude, $keyboard = false, $live_period = false, $keyboard_type = false, $parse_mode = false, $reply_to_message_id = false, $disable_notification = 0)
387 | {
388 | if (is_a($chat, 'chat') || is_a($chat, 'user')) {
389 | $chat_id = $chat->id;
390 | } else {
391 | $chat_id = $chat;
392 | }
393 | if (!$parse_mode) $parse_mode = $this->config['parse_mode'];
394 | if ($disable_notification === 0) $disable_notification = $this->config['disable_notification'];
395 | if ($keyboard) {
396 | if (!$keyboard_type) $keyboard_type = $this->config['keyboard_type'];
397 | if ($keyboard_type === 'inline') {
398 | $reply_markup = ['inline_keyboard' => $keyboard];
399 | } elseif ($keyboard_type === 'reply') {
400 | $reply_markup = ['keyboard' => $keyboard, 'resize_keyboard' => true];
401 | } elseif ($keyboard_type === 'hide') {
402 | $reply_markup = ['hide_keyboard' => true];
403 | }
404 | }
405 | $args = [
406 | 'chat_id' => $chat_id,
407 | 'longitude' => $longitude,
408 | 'latitude' => $latitude,
409 | 'live_period' => $live_period,
410 | 'parse_mode' => $parse_mode,
411 | 'reply_to_message_id' => $reply_to_message_id,
412 | 'disable_notification' => $disable_notification,
413 | ];
414 | if (isset($reply_markup)) $args['reply_markup'] = json_encode($reply_markup);
415 | return $this->sendRequest('sendLocation', $args);
416 | }
417 | function sendContact($chat, $phone_number, $first_name, $last_name = false, $vcard = false, $keyboard = false, $keyboard_type = false, $reply_to_message_id = false, $disable_notification = 0)
418 | {
419 | if (is_a($chat, 'chat') || is_a($chat, 'user')) {
420 | $chat_id = $chat->id;
421 | } else {
422 | $chat_id = $chat;
423 | }
424 | if ($disable_notification === 0) $disable_notification = $this->config['disable_notification'];
425 | if ($keyboard) {
426 | if (!$keyboard_type) $keyboard_type = $this->config['keyboard_type'];
427 | if ($keyboard_type === 'inline') {
428 | $reply_markup = ['inline_keyboard' => $keyboard];
429 | } elseif ($keyboard_type === 'reply') {
430 | $reply_markup = ['keyboard' => $keyboard, 'resize_keyboard' => true];
431 | } elseif ($keyboard_type === 'hide') {
432 | $reply_markup = ['hide_keyboard' => true];
433 | }
434 | }
435 | $args = [
436 | 'chat_id' => $chat_id,
437 | 'phone_number' => $phone_number,
438 | 'first_name' => $first_name,
439 | 'vcard' => $vcard,
440 | 'last_name' => $last_name,
441 | 'reply_to_message_id' => $reply_to_message_id,
442 | 'disable_notification' => $disable_notification,
443 | ];
444 | if (isset($reply_markup)) $args['reply_markup'] = json_encode($reply_markup);
445 | return $this->sendRequest('sendContact', $args);
446 | }
447 |
448 | function sendPoll($chat, $question, $options, $keyboard = false, $keyboard_type = false, $reply_to_message_id = false, $disable_notification = 0)
449 | {
450 | if (is_a($chat, 'chat') || is_a($chat, 'user')) {
451 | $chat_id = $chat->id;
452 | } else {
453 | $chat_id = $chat;
454 | }
455 | if ($disable_notification === 0) $disable_notification = $this->config['disable_notification'];
456 | if ($keyboard) {
457 | if (!$keyboard_type) $keyboard_type = $this->config['keyboard_type'];
458 | if ($keyboard_type === 'inline') {
459 | $reply_markup = ['inline_keyboard' => $keyboard];
460 | } elseif ($keyboard_type === 'reply') {
461 | $reply_markup = ['keyboard' => $keyboard, 'resize_keyboard' => true];
462 | } elseif ($keyboard_type === 'hide') {
463 | $reply_markup = ['hide_keyboard' => true];
464 | }
465 | }
466 | if (is_array($options)) $options = json_encode($options);
467 | $args = [
468 | 'chat_id' => $chat_id,
469 | 'question' => $question,
470 | 'options' => $options,
471 | 'reply_to_message_id' => $reply_to_message_id,
472 | 'disable_notification' => $disable_notification,
473 | ];
474 | if (isset($reply_markup)) $args['reply_markup'] = json_encode($reply_markup);
475 | return $this->sendRequest('sendPoll', $args);
476 | }
477 |
478 | function sendChatAction($chat, $action)
479 | {
480 | if (is_a($chat, 'chat') || is_a($chat, 'user')) {
481 | $chat_id = $chat->id;
482 | } else {
483 | $chat_id = $chat;
484 | }
485 | $args = [
486 | 'chat_id' => $chat_id,
487 | 'action' => $action,
488 | ];
489 | return $this->sendRequest('sendAction', $args);
490 | }
491 | function sendDice($chat, $emoji, $keyboard = false, $keyboard_type = false, $reply_to_message_id = false, $disable_notification = 0)
492 | {
493 | if (is_a($chat, 'chat') || is_a($chat, 'user')) {
494 | $chat_id = $chat->id;
495 | } else {
496 | $chat_id = $chat;
497 | }
498 | if ($disable_notification === 0) $disable_notification = $this->config['disable_notification'];
499 | if ($keyboard) {
500 | if (!$keyboard_type) $keyboard_type = $this->config['keyboard_type'];
501 | if ($keyboard_type === 'inline') {
502 | $reply_markup = ['inline_keyboard' => $keyboard];
503 | } elseif ($keyboard_type === 'reply') {
504 | $reply_markup = ['keyboard' => $keyboard, 'resize_keyboard' => true];
505 | } elseif ($keyboard_type === 'hide') {
506 | $reply_markup = ['hide_keyboard' => true];
507 | }
508 | }
509 | $args = [
510 | 'chat_id' => $chat_id,
511 | 'emoji' => $emoji,
512 | 'reply_to_message_id' => $reply_to_message_id,
513 | 'disable_notification' => $disable_notification,
514 | ];
515 | if (isset($reply_markup)) $args['reply_markup'] = json_encode($reply_markup);
516 | return $this->sendRequest('sendDice', $args);
517 | }
518 |
519 | /*
520 | * OTHER FUNCTIONS
521 | */
522 |
523 | function answerCallbackQuery($callback, $text = '', $show_alert = false, $url = false, $cache_time = false)
524 | {
525 | if (is_a($callback, 'callback')) {
526 | $callback_query_id = $callback->id;
527 | } else {
528 | $callback_query_id = $callback;
529 | }
530 | $args = [
531 | 'callback_query_id' => $callback_query_id,
532 | 'text' => $text,
533 | 'show_alert' => $show_alert,
534 | 'cache_time' => $cache_time
535 | ];
536 | if ($url) $args['url'] = $url;
537 | return $this->sendRequest('answerCallbackQuery', $args);
538 | }
539 |
540 | function answerInlineQuery($inline, $results, $switch_pm_text = false, $switch_pm_parameter = false, $cache_time = 300, $is_personal = true, $next_offset = false)
541 | {
542 | if (is_a($inline, 'inline')) {
543 | $inline_query_id = $inline->id;
544 | } else {
545 | $inline_query_id = $inline;
546 | }
547 | $args = [
548 | 'inline_query_id' => $inline_query_id,
549 | 'results' => json_encode($results),
550 | 'cache_time' => $cache_time,
551 | 'is_personal' => $is_personal,
552 | ];
553 | if ($switch_pm_text) $args['switch_pm_text'] = $switch_pm_text;
554 | if ($switch_pm_parameter) $args['switch_pm_parameter'] = $switch_pm_parameter;
555 | if ($next_offset) $args['next_offset'] = $next_offset;
556 | return $this->sendRequest('answerInlineQuery', $args);
557 | }
558 |
559 | function forwardMessage($chat, $from, $message, $disable_notification = 0)
560 | {
561 | if (is_a($chat, 'chat') || is_a($chat, 'user')) {
562 | $chat_id = $chat->id;
563 | } else {
564 | $chat_id = $chat;
565 | }
566 | if (is_a($from, 'chat') || is_a($from, 'user')) {
567 | $from_chat_id = $from->id;
568 | } else {
569 | $from_chat_id = $from;
570 | }
571 | if (is_a($message, 'message')) {
572 | $message_id = $message->message_id;
573 | } else {
574 | $message_id = $message;
575 | }
576 | if ($disable_notification === 0) $disable_notification = $this->config['disable_notification'];
577 | $args = [
578 | 'chat_id' => $chat_id,
579 | 'from_chat_id' => $from_chat_id,
580 | 'message_id' => $message_id,
581 | 'disable_notification' => $disable_notification,
582 | ];
583 | return $this->sendRequest('forwardMessage', $args);
584 | }
585 | function createNewStickerSet($user,$name,$title,$emojis,$png_sticker=false,$tgs_sticker=false,$contains_masks=false,$mask_position =false) {
586 | if (is_a($user, 'chat') || is_a($user, 'user')) {
587 | $user_id = $user->id;
588 | } else {
589 | $user_id = $user;
590 | }
591 | $args = [
592 | 'user_id' => $user_id,
593 | 'name' => $name,
594 | 'title' => $title,
595 | 'emojis' => $emojis,
596 | 'png_sticker' => $png_sticker,
597 | 'tgs_sticker' => $tgs_sticker,
598 | 'contains_masks' => $contains_masks,
599 | 'mask_position' => $mask_position,
600 | ];
601 | return $this->sendRequest('createNewStickerSet', $args);
602 | }
603 | function addStickerToSet($user,$name,$emojis,$png_sticker=false,$tgs_sticker=false,$mask_position =false) {
604 | if (is_a($user, 'chat') || is_a($user, 'user')) {
605 | $user_id = $user->id;
606 | } else {
607 | $user_id = $user;
608 | }
609 | $args = [
610 | 'user_id' => $user_id,
611 | 'name' => $name,
612 | 'emojis' => $emojis,
613 | 'png_sticker' => $png_sticker,
614 | 'tgs_sticker' => $tgs_sticker,
615 | 'mask_position' => $mask_position,
616 | ];
617 | return $this->sendRequest('addStickerToSet', $args);
618 | }
619 | function setStickerPositionInSet($sticker,$position) {
620 | $args = [
621 | 'sticker' => $sticker,
622 | 'position' => $position,
623 | ];
624 | return $this->sendRequest('setStickerPositionInSet', $args);
625 | }
626 | function setStickerSetThumb($name,$user,$thumb=false) {
627 | if (is_a($user, 'chat') || is_a($user, 'user')) {
628 | $user_id = $user->id;
629 | } else {
630 | $user_id = $user;
631 | }
632 | $args = [
633 | 'user' => $user_id,
634 | 'name' => $name,
635 | 'thumb' => $thumb,
636 | ];
637 | return $this->sendRequest('setStickerPositionInSet', $args);
638 | }
639 | function deleteStickerFromSet($sticker) {
640 | $args = [
641 | 'sticker' => $sticker,
642 | ];
643 | return $this->sendRequest('deleteStickerFromSet', $args);
644 | }
645 | /*
646 | * UPDATING MESSAGES
647 | */
648 |
649 | function editMessageText($chat, $message, $text, $keyboard = false, $keyboard_type = false, $parse_mode = false, $disable_web_page_preview = 0)
650 | {
651 | if (is_a($chat, 'chat') || is_a($chat, 'user')) {
652 | $chat_id = $chat->id;
653 | } else {
654 | $chat_id = $chat;
655 | }
656 | if (is_a($message, 'message')) {
657 | $message_id = $message->message_id;
658 | } else {
659 | $message_id = $message;
660 | }
661 | if (!$parse_mode) $parse_mode = $this->config['parse_mode'];
662 | if ($disable_web_page_preview === 0) $disable_web_page_preview = $this->config['disable_web_page_preview'];
663 | if ($keyboard) {
664 | if (!$keyboard_type) $keyboard_type = $this->config['keyboard_type'];
665 | if ($keyboard_type === 'inline') {
666 | $reply_markup = ['inline_keyboard' => $keyboard];
667 | } elseif ($keyboard_type === 'reply') {
668 | $reply_markup = ['keyboard' => $keyboard, 'resize_keyboard' => true];
669 | } elseif ($keyboard_type === 'hide') {
670 | $reply_markup = ['hide_keyboard' => true];
671 | }
672 | }
673 | $args = [
674 | 'chat_id' => $chat_id,
675 | 'text' => $text,
676 | 'message_id' => $message_id,
677 | 'parse_mode' => $parse_mode,
678 | 'disable_web_page_preview' => $disable_web_page_preview,];
679 | if (isset($reply_markup)) $args['reply_markup'] = json_encode($reply_markup);
680 | return $this->sendRequest('editMessageText', $args);
681 | }
682 | function editInlineMessageText($inline_message_id, $text, $keyboard = false, $keyboard_type = false, $parse_mode = false, $disable_web_page_preview = 0)
683 | {
684 | if (!$parse_mode) $parse_mode = $this->config['parse_mode'];
685 | if ($disable_web_page_preview === 0) $disable_web_page_preview = $this->config['disable_web_page_preview'];
686 | if ($keyboard) {
687 | if (!$keyboard_type) $keyboard_type = $this->config['keyboard_type'];
688 | if ($keyboard_type === 'inline') {
689 | $reply_markup = ['inline_keyboard' => $keyboard];
690 | } elseif ($keyboard_type === 'reply') {
691 | $reply_markup = ['keyboard' => $keyboard, 'resize_keyboard' => true];
692 | } elseif ($keyboard_type === 'hide') {
693 | $reply_markup = ['hide_keyboard' => true];
694 | }
695 | }
696 | $args = [
697 | 'text' => $text,
698 | 'inline_message_id' => $inline_message_id,
699 | 'parse_mode' => $parse_mode,
700 | 'disable_web_page_preview' => $disable_web_page_preview,];
701 | if (isset($reply_markup)) $args['reply_markup'] = json_encode($reply_markup);
702 | return $this->sendRequest('editMessageText', $args);
703 | }
704 | function editMessageCaption($chat, $message, $caption, $keyboard = false, $keyboard_type = false, $parse_mode = false)
705 | {
706 | if (is_a($chat, 'chat') || is_a($chat, 'user')) {
707 | $chat_id = $chat->id;
708 | } else {
709 | $chat_id = $chat;
710 | }
711 | if (is_a($message, 'message')) {
712 | $message_id = $message->message_id;
713 | } else {
714 | $message_id = $message;
715 | }
716 | if (!$parse_mode) $parse_mode = $this->config['parse_mode'];
717 | if ($keyboard) {
718 | if (!$keyboard_type) $keyboard_type = $this->config['keyboard_type'];
719 | if ($keyboard_type === 'inline') {
720 | $reply_markup = ['inline_keyboard' => $keyboard];
721 | } elseif ($keyboard_type === 'reply') {
722 | $reply_markup = ['keyboard' => $keyboard, 'resize_keyboard' => true];
723 | } elseif ($keyboard_type === 'hide') {
724 | $reply_markup = ['hide_keyboard' => true];
725 | }
726 | }
727 | $args = [
728 | 'chat_id' => $chat_id,
729 | 'caption' => $caption,
730 | 'message_id' => $message_id,
731 | 'parse_mode' => $parse_mode,
732 | ];
733 | if (isset($reply_markup)) $args['reply_markup'] = json_encode($reply_markup);
734 | return $this->sendRequest('editMessageCaption', $args);
735 | }
736 | function editInlineMessageCaption($inline_message_id, $caption, $keyboard = false, $keyboard_type = false, $parse_mode = false)
737 | {
738 | if (!$parse_mode) $parse_mode = $this->config['parse_mode'];
739 | if ($keyboard) {
740 | if (!$keyboard_type) $keyboard_type = $this->config['keyboard_type'];
741 | if ($keyboard_type === 'inline') {
742 | $reply_markup = ['inline_keyboard' => $keyboard];
743 | } elseif ($keyboard_type === 'reply') {
744 | $reply_markup = ['keyboard' => $keyboard, 'resize_keyboard' => true];
745 | } elseif ($keyboard_type === 'hide') {
746 | $reply_markup = ['hide_keyboard' => true];
747 | }
748 | }
749 | $args = [
750 | 'caption' => $caption,
751 | 'message_id' => $inline_message_id,
752 | 'parse_mode' => $parse_mode,
753 | ];
754 | if (isset($reply_markup)) $args['reply_markup'] = json_encode($reply_markup);
755 | return $this->sendRequest('editMessageCaption', $args);
756 | }
757 |
758 | function editMessageMedia($chat, $message, $media, $keyboard = false, $keyboard_type = false)
759 | {
760 | if (is_a($chat, 'chat') || is_a($chat, 'user')) {
761 | $chat_id = $chat->id;
762 | } else {
763 | $chat_id = $chat;
764 | }
765 | if (is_a($message, 'message')) {
766 | $message_id = $message->message_id;
767 | } else {
768 | $message_id = $message;
769 | }
770 | if ($keyboard) {
771 | if (!$keyboard_type) $keyboard_type = $this->config['keyboard_type'];
772 | if ($keyboard_type === 'inline') {
773 | $reply_markup = ['inline_keyboard' => $keyboard];
774 | } elseif ($keyboard_type === 'reply') {
775 | $reply_markup = ['keyboard' => $keyboard, 'resize_keyboard' => true];
776 | } elseif ($keyboard_type === 'hide') {
777 | $reply_markup = ['hide_keyboard' => true];
778 | }
779 | }
780 | $args = [
781 | 'chat_id' => $chat_id,
782 | 'media' => $media,
783 | 'message_id' => $message_id,
784 | ];
785 | if (isset($reply_markup)) $args['reply_markup'] = json_encode($reply_markup);
786 | return $this->sendRequest('editMessageMedia', $args);
787 | }
788 | function editInlineMessageMedia($inline_message_id, $media, $keyboard = false, $keyboard_type = false)
789 | {
790 | if ($keyboard) {
791 | if (!$keyboard_type) $keyboard_type = $this->config['keyboard_type'];
792 | if ($keyboard_type === 'inline') {
793 | $reply_markup = ['inline_keyboard' => $keyboard];
794 | } elseif ($keyboard_type === 'reply') {
795 | $reply_markup = ['keyboard' => $keyboard, 'resize_keyboard' => true];
796 | } elseif ($keyboard_type === 'hide') {
797 | $reply_markup = ['hide_keyboard' => true];
798 | }
799 | }
800 | $args = [
801 | 'inline_message_id' => $inline_message_id,
802 | 'media' => $media,
803 | ];
804 | if (isset($reply_markup)) $args['reply_markup'] = json_encode($reply_markup);
805 | return $this->sendRequest('editMessageMedia', $args);
806 | }
807 |
808 |
809 | function editMessageReplyMarkup($chat, $message, $keyboard = false, $keyboard_type = false)
810 | {
811 | if (is_a($chat, 'chat') || is_a($chat, 'user')) {
812 | $chat_id = $chat->id;
813 | } else {
814 | $chat_id = $chat;
815 | }
816 | if (is_a($message, 'message')) {
817 | $message_id = $message->message_id;
818 | } else {
819 | $message_id = $message;
820 | }
821 | if ($keyboard) {
822 | if (!$keyboard_type) $keyboard_type = $this->config['keyboard_type'];
823 | if ($keyboard_type === 'inline') {
824 | $reply_markup = ['inline_keyboard' => $keyboard];
825 | } elseif ($keyboard_type === 'reply') {
826 | $reply_markup = ['keyboard' => $keyboard, 'resize_keyboard' => true];
827 | } elseif ($keyboard_type === 'hide') {
828 | $reply_markup = ['hide_keyboard' => true];
829 | }
830 | }
831 | $args = [
832 | 'chat_id' => $chat_id,
833 | 'message_id' => $message_id,
834 | ];
835 | if (isset($reply_markup)) $args['reply_markup'] = json_encode($reply_markup);
836 | return $this->sendRequest('editMessageReplyMarkup', $args);
837 | }
838 | function editInlineMessageReplyMarkup($inline_message_id, $keyboard = false, $keyboard_type = false)
839 | {
840 | if ($keyboard) {
841 | if (!$keyboard_type) $keyboard_type = $this->config['keyboard_type'];
842 | if ($keyboard_type === 'inline') {
843 | $reply_markup = ['inline_keyboard' => $keyboard];
844 | } elseif ($keyboard_type === 'reply') {
845 | $reply_markup = ['keyboard' => $keyboard, 'resize_keyboard' => true];
846 | } elseif ($keyboard_type === 'hide') {
847 | $reply_markup = ['hide_keyboard' => true];
848 | }
849 | }
850 | $args = [
851 | 'inline_message_id' => $inline_message_id,
852 | ];
853 | if (isset($reply_markup)) $args['reply_markup'] = json_encode($reply_markup);
854 | return $this->sendRequest('editMessageReplyMarkup', $args);
855 | }
856 |
857 |
858 | function editMessageLiveLocation($chat,$message, $latitude,$longitude,$keyboard = false)
859 | {
860 | if (is_a($chat, 'chat') || is_a($chat, 'user')) {
861 | $chat_id = $chat->id;
862 | } else {
863 | $chat_id = $chat;
864 | }
865 | if (is_a($message, 'message')) {
866 | $message_id = $message->message_id;
867 | } else {
868 | $message_id = $message;
869 | }
870 | if ($keyboard) {
871 | $reply_markup = ['inline_keyboard' => $keyboard];
872 | }
873 | $args = [
874 | 'chat_id' => $chat_id,
875 | 'message_id' => $message_id,
876 | 'latitude' => $latitude,
877 | 'logitude' => $longitude,
878 | ];
879 | if (isset($reply_markup)) $args['reply_markup'] = json_encode($reply_markup);
880 | return $this->sendRequest('editMessageLiveLocation', $args);
881 | }
882 | function editInlineMessageLiveLocation($inline_message_id, $latitude,$longitude,$keyboard = false)
883 | {
884 | if ($keyboard) {
885 | $reply_markup = ['inline_keyboard' => $keyboard];
886 | }
887 | $args = [
888 | 'inline_message_id' => $inline_message_id,
889 | 'latitude' => $latitude,
890 | 'logitude' => $longitude,
891 | ];
892 | if (isset($reply_markup)) $args['reply_markup'] = json_encode($reply_markup);
893 | return $this->sendRequest('editMessageLiveLocation', $args);
894 | }
895 | function stopMessageLiveLocation($chat,$message,$keyboard = false)
896 | {
897 | if (is_a($chat, 'chat') || is_a($chat, 'user')) {
898 | $chat_id = $chat->id;
899 | } else {
900 | $chat_id = $chat;
901 | }
902 | if (is_a($message, 'message')) {
903 | $message_id = $message->message_id;
904 | } else {
905 | $message_id = $message;
906 | }
907 | if ($keyboard) {
908 | $reply_markup = ['inline_keyboard' => $keyboard];
909 | }
910 | $args = [
911 | 'chat_id' => $chat_id,
912 | 'message_id' => $message_id,
913 | ];
914 | if (isset($reply_markup)) $args['reply_markup'] = json_encode($reply_markup);
915 | return $this->sendRequest('stopMessageLiveLocation', $args);
916 | }
917 | function stopInlineMessageLiveLocation($inline_message_id,$keyboard = false)
918 | {
919 | if ($keyboard) {
920 | $reply_markup = ['inline_keyboard' => $keyboard];
921 | }
922 | $args = [
923 | 'inline_message_id' => $inline_message_id,
924 | ];
925 | if (isset($reply_markup)) $args['reply_markup'] = json_encode($reply_markup);
926 | return $this->sendRequest('stopMessageLiveLocation', $args);
927 | }
928 |
929 |
930 | function deleteMessage($chat, $message)
931 | {
932 | if (is_a($chat, 'chat') || is_a($chat, 'user')) {
933 | $chat_id = $chat->id;
934 | } else {
935 | $chat_id = $chat;
936 | }
937 | if (is_a($message, 'message')) {
938 | $message_id = $message->message_id;
939 | } else {
940 | $message_id = $message;
941 | }
942 | $args = [
943 | 'chat_id' => $chat_id,
944 | 'message_id' => $message_id,
945 | ];
946 | return $this->sendRequest('deleteMessage', $args);
947 | }
948 |
949 |
950 |
951 | /*
952 | * GET METHODS
953 | */
954 |
955 | function getFile($file_id, $response_type = false)
956 | {
957 | $args = [
958 | 'file_id' => $file_id,
959 | ];
960 | return $this->sendRequest('getFile', $args, $response_type);
961 | }
962 |
963 | function getUserProfilePhotos($user, $offset = false,$limit=100)
964 | {
965 | if (is_a($user, 'chat') || is_a($user, 'user')) {
966 | $user_id = $user->id;
967 | } else {
968 | $user_id = $user;
969 | }
970 | $args = [
971 | 'file_id' => $user_id,
972 | 'offset' => $offset,
973 | 'limit' => $limit,
974 | ];
975 | return $this->sendRequest('getUserProfilePhotos', $args);
976 | }
977 |
978 | function getChat($chat, $response_type = false)
979 | {
980 | if (is_a($chat, 'chat')) {
981 | $chat_id = $chat->id;
982 | } else {
983 | $chat_id = $chat;
984 | }
985 | $args = [
986 | 'chat_id' => $chat_id,
987 | ];
988 | return $this->sendRequest('getChat', $args, $response_type);
989 | }
990 |
991 | function getChatAdministrators($chat, $response_type = false)
992 | {
993 | if (is_a($chat, 'chat')) {
994 | $chat_id = $chat->id;
995 | } else {
996 | $chat_id = $chat;
997 | }
998 | $args = [
999 | 'chat_id' => $chat_id,
1000 | ];
1001 | return $this->sendRequest('getChatAdministrators', $args, $response_type);
1002 | }
1003 | function getChatMembersCount($chat)
1004 | {
1005 | if (is_a($chat, 'chat')) {
1006 | $chat_id = $chat->id;
1007 | } else {
1008 | $chat_id = $chat;
1009 | }
1010 | $args = [
1011 | 'chat_id' => $chat_id,
1012 | ];
1013 | return json_decode($this->sendRequest('getChatMembersCount', $args, 'raw'), true)['result'];
1014 | }
1015 | function getChatMember($chat, $user, $response_type = false)
1016 | {
1017 | if (is_a($chat, 'chat')) {
1018 | $chat_id = $chat->id;
1019 | } else {
1020 | $chat_id = $chat;
1021 | }
1022 | if (is_a($user, 'user')) {
1023 | $user_id = $user->id;
1024 | } else {
1025 | $user_id = $user;
1026 | }
1027 | $args = [
1028 | 'chat_id' => $chat_id,
1029 | 'user_id' => $user_id,
1030 | ];
1031 | return $this->sendRequest('getChatMember', $args, $response_type);
1032 | }
1033 | function getStickerSet($name) {
1034 | $args = [
1035 | 'name' => $name,
1036 | ];
1037 | return $this->sendRequest('getStickerSet',$args);
1038 | }
1039 |
1040 | /*
1041 | * GROUP MANAGEMENT FUNCTIONS
1042 | */
1043 | function exportChatInviteLink($chat)
1044 | {
1045 | if (is_a($chat, 'chat')) {
1046 | $chat_id = $chat->id;
1047 | } else {
1048 | $chat_id = $chat;
1049 | }
1050 | $args = [
1051 | 'chat_id' => $chat_id,
1052 | ];
1053 | return json_decode($this->sendRequest('exportChatInviteLink', $args, 'raw'), true)['result'];
1054 | }
1055 |
1056 | function kickChatMember($chat, $user, $until_date = false)
1057 | {
1058 | if (is_a($chat, 'chat')) {
1059 | $chat_id = $chat->id;
1060 | } else {
1061 | $chat_id = $chat;
1062 | }
1063 | if (is_a($user, 'user')) {
1064 | $user_id = $user->id;
1065 | } else {
1066 | $user_id = $user;
1067 | }
1068 | $args = [
1069 | 'chat_id' => $chat_id,
1070 | 'user_id' => $user_id,
1071 | 'until_date' => $until_date,
1072 | ];
1073 | return $this->sendRequest('kickChatMember', $args);
1074 | }
1075 |
1076 | function unbanChatMember($chat, $user)
1077 | {
1078 | if (is_a($chat, 'chat')) {
1079 | $chat_id = $chat->id;
1080 | } else {
1081 | $chat_id = $chat;
1082 | }
1083 | if (is_a($user, 'user')) {
1084 | $user_id = $user->id;
1085 | } else {
1086 | $user_id = $user;
1087 | }
1088 | $args = [
1089 | 'chat_id' => $chat_id,
1090 | 'user_id' => $user_id,
1091 | ];
1092 | return $this->sendRequest('unbanChatMember', $args);
1093 | }
1094 |
1095 | function restrictChatMember($chat, $user, $permissions, $until_date = false)
1096 | {
1097 | if (is_a($chat, 'chat')) {
1098 | $chat_id = $chat->id;
1099 | } else {
1100 | $chat_id = $chat;
1101 | }
1102 | if (is_a($user, 'user')) {
1103 | $user_id = $user->id;
1104 | } else {
1105 | $user_id = $user;
1106 | }
1107 | $args = [
1108 | 'chat_id' => $chat_id,
1109 | 'user_id' => $user_id,
1110 | 'permissions' => $permissions,
1111 | 'until_date' => $until_date,
1112 | ];
1113 | return $this->sendRequest('restrictChatMember', $args);
1114 | }
1115 |
1116 | function promoteChatMember($chat, $user, $can_change_info = false, $can_post_messages = false, $can_edit_messages = false, $can_delete_messages = false, $can_invite_users = false, $can_restrict_members = false, $can_pin_messages = false, $can_promote_members = false)
1117 | {
1118 | if (is_a($chat, 'chat')) {
1119 | $chat_id = $chat->id;
1120 | } else {
1121 | $chat_id = $chat;
1122 | }
1123 | if (is_a($user, 'user')) {
1124 | $user_id = $user->id;
1125 | } else {
1126 | $user_id = $user;
1127 | }
1128 | $args = [
1129 | 'chat_id' => $chat_id,
1130 | 'user_id' => $user_id,
1131 | 'can_change_info' => $can_change_info,
1132 | 'can_post_messages' => $can_post_messages,
1133 | 'can_edit_messages' => $can_edit_messages,
1134 | 'can_delete_messages' => $can_delete_messages,
1135 | 'can_invite_users' => $can_invite_users,
1136 | 'can_restrict_members' => $can_restrict_members,
1137 | 'can_pin_messages' => $can_pin_messages,
1138 | 'can_promote_members' => $can_promote_members,
1139 | ];
1140 | return $this->sendRequest('promoteChatMember', $args);
1141 | }
1142 |
1143 | function setChatPermissions($chat, $permissions)
1144 | {
1145 | if (is_a($chat,'chat')) {
1146 | $chat_id = $chat->id;
1147 | } else {
1148 | $chat_id = $chat;
1149 | }
1150 | $args = [
1151 | 'chat_id' => $chat_id,
1152 | 'permissions' => $permissions,
1153 | ];
1154 | return $this->sendRequest('setChatPermissions', $args);
1155 | }
1156 |
1157 | function setChatPhoto($chat, $photo)
1158 | {
1159 | if (is_a($chat,'chat')) {
1160 | $chat_id = $chat->id;
1161 | } else {
1162 | $chat_id = $chat;
1163 | }
1164 | $args = [
1165 | 'chat_id' => $chat_id,
1166 | 'photo' => $photo,
1167 | ];
1168 | return $this->sendRequest('setChatPhoto', $args);
1169 | }
1170 |
1171 | function setChatTitle($chat, $title)
1172 | {
1173 | if (is_a($chat,'chat')) {
1174 | $chat_id = $chat->id;
1175 | } else {
1176 | $chat_id = $chat;
1177 | }
1178 |
1179 | $args = [
1180 | 'chat_id' => $chat_id,
1181 | 'title' => $title,
1182 | ];
1183 | return $this->sendRequest('setChatTitle', $args);
1184 | }
1185 |
1186 | function setChatDescription($chat, $description)
1187 | {
1188 | if (is_a($chat,'chat')) {
1189 | $chat_id = $chat->id;
1190 | } else {
1191 | $chat_id = $chat;
1192 | }
1193 | $args = [
1194 | 'chat_id' => $chat_id,
1195 | 'description' => $description,
1196 | ];
1197 | return $this->sendRequest('setChatDescription', $args);
1198 | }
1199 | function setChatStickerSet($chat, $sticker_set_name)
1200 | {
1201 | if (is_a($chat,'chat')) {
1202 | $chat_id = $chat->id;
1203 | } else {
1204 | $chat_id = $chat;
1205 | }
1206 | $args = [
1207 | 'chat_id' => $chat_id,
1208 | 'sticker_set_name' => $sticker_set_name,
1209 | ];
1210 | return $this->sendRequest('setChatStickerSet', $args);
1211 | }
1212 |
1213 | function deleteChatStickerSet($chat)
1214 | {
1215 | if (is_a($chat,'chat')) {
1216 | $chat_id = $chat->id;
1217 | } else {
1218 | $chat_id = $chat;
1219 | }
1220 | $args = [
1221 | 'chat_id' => $chat_id,
1222 | ];
1223 | return $this->sendRequest('deleteChatStickerSet', $args);
1224 | }
1225 | function deleteChatPhoto($chat)
1226 | {
1227 | if (is_a($chat,'chat')) {
1228 | $chat_id = $chat->id;
1229 | } else {
1230 | $chat_id = $chat;
1231 | }
1232 | $args = [
1233 | 'chat_id' => $chat_id,
1234 | ];
1235 | return $this->sendRequest('deleteChatPhoto', $args);
1236 | }
1237 |
1238 | function pinChatMessage($chat, $message, $disable_notification = 0)
1239 | {
1240 | if (is_a($chat, 'chat') ) {
1241 | $chat_id = $chat->id;
1242 | } else {
1243 | $chat_id = $chat;
1244 | }
1245 | if (is_a($message, 'message')) {
1246 | $message_id = $message;
1247 | } else {
1248 | $message_id = $message;
1249 | }
1250 | if ($disable_notification === 0) $disable_notification = $this->config['disable_notification'];
1251 | $args = [
1252 | 'chat_id' => $chat_id,
1253 | 'message_id' => $message_id,
1254 | 'disable_notification' => $disable_notification,
1255 | ];
1256 | return $this->sendRequest('pinCharMessage', $args);
1257 | }
1258 |
1259 | function unpinChatMessage($chat)
1260 | {
1261 | if (is_a($chat, 'chat')) {
1262 | $chat_id = $chat->id;
1263 | } else {
1264 | $chat_id = $chat;
1265 | }
1266 |
1267 | $args = [
1268 | 'chat_id' => $chat_id,
1269 | ];
1270 | return $this->sendRequest('unpinCharMessage', $args);
1271 | }
1272 |
1273 | function leaveChat($chat)
1274 | {
1275 | if (is_a($chat, 'chat')) {
1276 | $chat_id = $chat->id;
1277 | } else {
1278 | $chat_id = $chat;
1279 | }
1280 | $args = [
1281 | 'chat_id' => $chat_id,
1282 | ];
1283 | return $this->sendRequest('leaveChat', $args);
1284 | }
1285 |
1286 | /*
1287 | * BOT FUNCTIONS
1288 | */
1289 | function getMe() {
1290 | return $this->sendRequest('getMe');
1291 | }
1292 | function getMyCommands() {
1293 | return $this->sendRequest('getMyCommands');
1294 | }
1295 | function setMyCommands($commands) {
1296 | $args = [
1297 | 'commands' => $commands,
1298 | ];
1299 | return $this->sendRequest('setMyCommands',$args);
1300 | }
1301 | function getWebhookInfo() {
1302 | return $this->sendRequest('getWebhookInfo');
1303 | }
1304 | function deleteWebhook() {
1305 | return $this->sendRequest('deleteWebhook');
1306 | }
1307 | function setWebhook ($url,$certificate=false,$max_connections=40,$allowed_updates= false) {
1308 | $args = [
1309 | 'url' => $url,
1310 | 'certificate' => $certificate,
1311 | 'max_connections' => $max_connections,
1312 | 'allowed_updates' => $allowed_updates,
1313 | ];
1314 | return $this->sendRequest('setWebhook',$args);
1315 | }
1316 | }
1317 |
--------------------------------------------------------------------------------
/functions/database.php:
--------------------------------------------------------------------------------
1 | prepare('CREATE TABLE IF NOT EXISTS ' . $config['database']['universal_table'] . ' (
9 | chat_id bigint(0),
10 | name varchar(200) CHARACTER SET utf8mb4,
11 | username varchar(50),
12 | lang varchar(10),
13 | type varchar(10),
14 | PRIMARY KEY (chat_id))');
15 | $install->execute();
16 | $install = $db->prepare('CREATE TABLE IF NOT EXISTS ' . $config['database']['bot_table'] . ' (
17 | chat_id bigint(0),
18 | state varchar(50),
19 | PRIMARY KEY (chat_id))');
20 | $install->execute();
21 | die('Database Installed');
22 | }
--------------------------------------------------------------------------------
/functions/objects.php:
--------------------------------------------------------------------------------
1 | $value) {
12 | $this->$key = $value;
13 | }
14 | isset($this->last_name) ? $this->name = $this->first_name . ' ' . $this->last_name : $this->name = $this->first_name;
15 | $this->htmlmention = ''.$this->name.'';
16 | $this->markdownmention = '[' . $this->name .'](tg://user?id='.$this->id.')';
17 | if (isset($config) && $config['database']['active'] && (!(isset($this->unsave_db) && $this->unsave_db))) {
18 | $q = $db->prepare('SELECT * FROM ' . $config['database']['universal_table'] . ' WHERE chat_id = ?');
19 | $q->execute([$this->id]);
20 | if(!isset($this->username)) $this->username = '';
21 | if (!$q->rowCount()) {
22 | $db->prepare('INSERT INTO ' . $config['database']['universal_table'] . ' (chat_id,username,name,lang,type) VALUES (?,?,?,?,?)')->execute([$this->id,$this->username,$this->name,$this->language_code,'user']);
23 | } else {
24 | $this->dbinfo = $q->fetch(PDO::FETCH_ASSOC);
25 | if ($this->dbinfo['username'] != $this->username) {
26 | $db->prepare('UPDATE '. $config['database']['universal_table'] . ' SET username = ? WHERE chat_id = ?')->execute([$this->username,$this->id]);
27 | }
28 | if ($this->dbinfo['name'] != $this->name) {
29 | $db->prepare('UPDATE '. $config['database']['universal_table'] . ' SET name = ? WHERE chat_id = ?')->execute([$this->name,$this->id]);
30 | }
31 | }
32 | }
33 | }
34 | function db_save($state = '') {
35 | global $config;
36 | global $db;
37 | if (isset($config) && $config['database']['active']) {
38 | $q = $db->prepare('SELECT * FROM ' . $config['database']['bot_table'] . ' WHERE chat_id = ?');
39 | $q->execute([$this->id]);
40 | if (!$q->rowCount()) {
41 | $db->prepare('INSERT INTO ' . $config['database']['bot_table'] . ' (chat_id,state) VALUES (?,?)')->execute([$this->id,$state]);
42 | return true;
43 | } else {
44 | $this->db = new DBUser($this->id);
45 | if ($this->db->state == 'group' && $state == '') {
46 | $db->prepare('UPDATE '. $config['database']['bot_table'] . ' SET state = ? WHERE chat_id = ?')->execute(['',$this->id]);
47 | }
48 | return false;
49 | }
50 | }
51 | }
52 | function getChatMember($chat,$botObject = false) {
53 | if (is_a($chat, 'chat')) {
54 | $chat_id = $chat->id;
55 | } else {
56 | $chat_id = $chat;
57 | }
58 | global $bot;
59 | if (!$botObject && isset($bot)) {
60 | $botObject = $bot;
61 | } else {
62 | return false;
63 | }
64 | return $botObject->getChatMember($chat_id,$this->id);
65 | }
66 | function isAdmin($chat,$botObject = false) {
67 | global $bot;
68 | if (!$botObject && isset($bot)) {
69 | $botObject = $bot;
70 | } else {
71 | return false;
72 | }
73 | if (is_a($chat, 'chat')) {
74 | $chat_id = $chat->id;
75 | } else {
76 | $chat_id = $chat;
77 | }
78 | $admins = json_decode($botObject->getChatAdministrators($chat_id,'raw'),true)['result'];
79 | foreach ($admins as $admin) {
80 | if ($admin['user']['id'] == $this->id) {
81 | return true;
82 | }
83 | }
84 | return false;
85 | }
86 | function isMember($chat,$botObject = false) {
87 | global $bot;
88 | if (!$botObject && isset($bot)) {
89 | $botObject = $bot;
90 | } else {
91 | return false;
92 | }
93 | if (is_a($chat, 'chat')) {
94 | $chat_id = $chat->id;
95 | } else {
96 | $chat_id = $chat;
97 | }
98 | $result = $botObject->getChatMember($chat_id,$this->id,'object');
99 | if (!$result->ok || !isset($result->status)) {
100 | return false;
101 | } else {
102 | if ($result->status == 'left' || $result->status == 'kicked') {
103 | return false;
104 | } else {
105 | return true;
106 | }
107 | }
108 | }
109 | }
110 | class DBUser {
111 | function __construct($id)
112 | {
113 | global $config;
114 | global $db;
115 | if (isset($config) && $config['database']['active']) {
116 | $q = $db->prepare('SELECT * FROM ' . $config['database']['bot_table'] . ' WHERE chat_id = ?');
117 | $q->execute([$id]);
118 | if (!$q->rowCount()) {
119 | return false;
120 | } else {
121 | $dbinfo = $q->fetch(PDO::FETCH_ASSOC);
122 | foreach ($dbinfo as $column => $value) {
123 | $this->$column = $value;
124 | }
125 | $this->tgdb = new TGDBUser($id);
126 | return false;
127 | }
128 | }
129 | }
130 | function setColumn ($column,$value) {
131 | global $db;
132 | global $config;
133 | $q = $db->prepare('UPDATE ' . $config['database']['bot_table'] . ' SET ' . $column .' = ? WHERE chat_id = ?');
134 | $q->execute([$value,$this->chat_id]);
135 | }
136 | }
137 | class TGDBUser {
138 | function __construct($id)
139 | {
140 | global $config;
141 | global $db;
142 | if (isset($config) && $config['database']['active']) {
143 | if (is_numeric($id)) {
144 | $q = $db->prepare('SELECT * FROM ' . $config['database']['universal_table'] . ' WHERE chat_id = ? LIMIT 1');
145 | } elseif (is_string($id)) {
146 | $q = $db->prepare('SELECT * FROM ' . $config['database']['universal_table'] . ' WHERE username LIKE ? LIMIT 1');
147 | }
148 | $q->execute([$id]);
149 | $this->htmlmention = ''.$this->name.'';
150 | $this->markdownmention = '[' . $this->name .'](tg://user?id='.$this->chat_id.')';
151 | if (!$q->rowCount()) {
152 | return false;
153 | } else {
154 | $dbinfo = $q->fetch(PDO::FETCH_ASSOC);
155 | foreach ($dbinfo as $column => $value) {
156 | $this->$column = $value;
157 | }
158 | }
159 | }
160 | }
161 | function getDBUserObject() {
162 | return new DBUser($this->chat_id);
163 | }
164 | function getUserObject () {
165 | if ($this->type == 'user') {
166 | return new user(['id' => $this->id,'username' => $this->username,'first_name' => $this->name,'language_code' => $this->lang,'type' => $this->type,'unsave_db' => true]);
167 | }
168 | }
169 | function getChatObject() {
170 | if ($this->type == 'user') {
171 | return new chat(['id' => $this->id,'username' => $this->username,'first_name' => $this->name,'language_code' => $this->lang,'type' => $this->type,'unsave_db' => true]);
172 | } else {
173 | return new chat(['id' => $this->id,'username' => $this->username,'title' => $this->name,'language_code' => $this->lang,'type' => $this->type,'unsave_db' => true]);
174 | }
175 | }
176 | function setColumn ($column,$value) {
177 | global $db;
178 | global $config;
179 | $q = $db->prepare('UPDATE ' . $config['database']['universal_table'] . ' SET ' . $column .' = ? WHERE chat_id = ? LIMIT 1');
180 | $q->execute([$value,$this->chat_id]);
181 | }
182 | }
183 | class chat
184 | {
185 | var $array;
186 |
187 | function __construct($array)
188 | {
189 | global $config;
190 | global $db;
191 | foreach ($array as $key => $value) {
192 | $this->$key = $value;
193 | }
194 | if (isset($this->title)) {
195 | $this->name = $this->title;
196 | } else {
197 | isset($this->last_name) ? $this->name = $this->first_name . ' ' . $this->last_name : $this->name = $this->first_name;
198 | }
199 | if (isset($config) && $config['database']['active'] && (!(isset($this->unsave_db) && $this->unsave_db))) {
200 | $q = $db->prepare('SELECT * FROM ' . $config['database']['universal_table'] . ' WHERE chat_id = ?');
201 | $q->execute([$this->id]);
202 | if(!isset($this->username)) $this->username = '';
203 | if (!$q->rowCount()) {
204 | $db->prepare('INSERT INTO ' . $config['database']['universal_table'] . ' (chat_id,username,name,lang,type) VALUES (?,?,?,?,?)')->execute([$this->id,$this->username,$this->name,'',$this->type]);
205 | } else {
206 | $this->dbinfo = $q->fetch(PDO::FETCH_ASSOC);
207 | if ($this->dbinfo['username'] != $this->username) {
208 | $db->prepare('UPDATE '. $config['database']['universal_table'] . ' SET username = ? WHERE chat_id = ?')->execute([$this->username,$this->id]);
209 | }
210 | }
211 | }
212 | }
213 | function db_save($state = '') {
214 | global $config;
215 | global $db;
216 | if (isset($config) && $config['database']['active']) {
217 | $q = $db->prepare('SELECT * FROM ' . $config['database']['bot_table'] . ' WHERE chat_id = ?');
218 | $q->execute([$this->id]);
219 | if (!$q->rowCount()) {
220 | $db->prepare('INSERT INTO ' . $config['database']['bot_table'] . ' (chat_id,state) VALUES (?,?)')->execute([$this->id,$state]);
221 | return true;
222 | } else {
223 | $this->db = new DBUser($this->id);
224 | return false;
225 | }
226 | }
227 | }
228 | function getChat($botObject = false) {
229 | global $bot;
230 | if (!$botObject && isset($bot)) {
231 | $botObject = $bot;
232 | } else {
233 | return false;
234 | }
235 | return $botObject->getChat($this->id);
236 | }
237 | function getChatMembersCount($botObject = false) {
238 | global $bot;
239 | if (!$botObject && isset($bot)) {
240 | $botObject = $bot;
241 | } else {
242 | return false;
243 | }
244 | return $botObject->getChatMembersCount($this->id);
245 | }
246 | function getChatMember($user,$botObject = false) {
247 | if (is_a($user, 'user')) {
248 | $user_id = $user->id;
249 | } else {
250 | $user_id = $user;
251 | }
252 | global $bot;
253 | if (!$botObject && isset($bot)) {
254 | $botObject = $bot;
255 | } else {
256 | return false;
257 | }
258 | return $botObject->getChatMember($this->id,$user_id);
259 | }
260 | function getChatAdministrators($botObject = false) {
261 | global $bot;
262 | if (!$botObject && isset($bot)) {
263 | $botObject = $bot;
264 | } else {
265 | return false;
266 | }
267 | return $botObject->getChatAdministrators($this->id);
268 | }
269 | function exportChatInviteLink($botObject = false) {
270 | global $bot;
271 | if (!$botObject && isset($bot)) {
272 | $botObject = $bot;
273 | } else {
274 | return false;
275 | }
276 | return $botObject->exportChatInviteLink($this->id);
277 | }
278 | }
279 |
280 | class message
281 | {
282 | var $array;
283 |
284 | function __construct($array)
285 | {
286 | foreach ($array as $key => $value) {
287 | if ($key === 'from') {
288 | $this->user = new user($value);
289 | $this->from = $this->user;
290 | } elseif ($key === 'chat') {
291 | $this->chat = new chat($value);
292 | } elseif ($key === 'forward_from_chat') {
293 | $this->forward_from_chat = new chat($value);
294 | $this->fwchat = $this->forward_from_chat;
295 | } elseif ($key === 'forward_from') {
296 | $this->forward_from = new user($value);
297 | $this->fwuser = $this->forward_from;
298 | } elseif ($key === 'reply_to_message') {
299 | $this->reply_to_message = new message($value);
300 | $this->reply = $this->reply_to_message;
301 | } elseif ($key === 'photo') {
302 | $this->photo = new photo($value[count($value) - 1]);
303 | } elseif ($key === 'audio') {
304 | $this->audio = new audio($value);
305 | } elseif ($key === 'voice') {
306 | $this->voice = new voice($value);
307 | } elseif ($key === 'animation') {
308 | $this->animation = new animation($value);
309 | } elseif ($key === 'document' && !isset($this->animation)) {
310 | $this->document = new document($value);
311 | } elseif ($key === 'video') {
312 | $this->video = new video($value);
313 | } elseif ($key === 'video_note') {
314 | $this->video_note = new video_note($value);
315 | } elseif ($key === 'contact') {
316 | $this->contact = new contact($value);
317 | } elseif ($key === 'location') {
318 | $this->location = new location($value);
319 | } elseif ($key === 'venue') {
320 | $this->venue = new venue($value);
321 | } elseif ($key === 'sticker') {
322 | $this->sticker = new sticker($value);
323 | } elseif ($key === 'dice') {
324 | $this->sticker = new dice($value);
325 | } elseif ($key === 'poll') {
326 | $this->poll = new poll($value);
327 | } else {
328 | $this->$key = $value;
329 | }
330 | }
331 | }
332 | function forwardMessage ($chat,$botObject = false) {
333 | global $bot;
334 | if (!$botObject && isset($bot)) {
335 | $botObject = $bot;
336 | } else {
337 | return false;
338 | }
339 | if (is_a($chat, 'chat') || is_a($chat, 'user')) {
340 | $chat_id = $chat->id;
341 | } else {
342 | $chat_id = $chat;
343 | }
344 | return $botObject->forwardMessage($chat_id,$this->chat->id,$this->message_id);
345 | }
346 | function deleteMessage ($botObject = false) {
347 | global $bot;
348 | if (!$botObject && isset($bot)) {
349 | $botObject = $bot;
350 | } else {
351 | return false;
352 | }
353 | return $botObject->deleteMessage($this->chat->id,$this->message_id);
354 | }
355 | function toHTML () {
356 | if (isset($this->text)) {
357 | $text = $this->text;
358 | } elseif (isset($this->caption)) {
359 | $text = $this->caption;
360 | } else {
361 | return false;
362 | }
363 | if (!isset($this->entities)) {
364 | return $text;
365 | }
366 | $entityParser = new entityParser();
367 | return $entityParser->entitiesToHtml($text,$this->entities);
368 | }
369 | }
370 | class callback_query
371 | {
372 | var $array;
373 |
374 | function __construct($array)
375 | {
376 | foreach ($array as $key => $value) {
377 | if ($key === 'from') {
378 | $this->user = new user($value);
379 | $this->from = $this->user;
380 | } elseif ($key === 'message') {
381 | $this->message = new message($value);
382 | } else {
383 | $this->$key = $value;
384 | }
385 | }
386 | }
387 | function answer ($text='',$show_alert = false,$url = false,$cache_time = false,$botObject=false) {
388 | global $bot;
389 | if (!$botObject && isset($bot)) {
390 | $botObject = $bot;
391 | } else {
392 | return false;
393 | }
394 | return $botObject->answerCallbackQuery($this->id,$text,$show_alert,$url,$cache_time);
395 | }
396 | }
397 | class response {
398 | var $array;
399 | function __construct($array)
400 | {
401 | if (!is_array($array) && is_string($array)) {
402 | $this->raw = $array;
403 | $array = json_decode($array,true);
404 | }
405 | if ($array['ok']) {
406 | $this->ok = true;
407 | $this->raw = json_encode($array);
408 | $array = $array['result'];
409 | foreach ($array as $key => $value) {
410 | if ($key === 'from') {
411 | $this->user = new user($value);
412 | } elseif ($key === 'message') {
413 | $this->message = new message($value);
414 | } else {
415 | $this->$key = $value;
416 | }
417 | }
418 | } else {
419 | $this->ok = false;
420 | foreach ($array as $key => $value) {
421 | if ($key === 'from') {
422 | $this->$key = $value;
423 | }
424 | }
425 | return false;
426 | }
427 | }
428 | }
429 | class inline_query
430 | {
431 | function __construct($array)
432 | {
433 | foreach ($array as $key => $value) {
434 | if ($key === 'from') {
435 | $this->user = new user($value);
436 | } else {
437 | $this->$key = $value;
438 | }
439 | }
440 | }
441 | }
442 |
443 | /*
444 | * MEDIA
445 | */
446 |
447 | class photo
448 | {
449 | var $array;
450 | function __construct($array)
451 | {
452 | foreach ($array as $key => $value) {
453 | $this->$key = $value;
454 | }
455 | return $this;
456 | }
457 | function download ($path = false,$botObject = false) {
458 | global $bot;
459 | if (!$botObject && isset($bot)) {
460 | $botObject = $bot;
461 | } elseif (!$botObject) {
462 | return false;
463 | }
464 | $file = new file($this->file_id,$botObject);
465 | if ($file) {
466 | return $file->download($path);
467 | }
468 | }
469 | function send($chat,$caption='',$keyboard=false,$keyboard_type=false, $parse_mode = false, $reply_to_message_id = false, $disable_notification = 0,$botObject = false) {
470 | global $bot;
471 | if (!$botObject && isset($bot)) {
472 | $botObject = $bot;
473 | } elseif (!$botObject) {
474 | return false;
475 | }
476 | return $botObject->sendPhoto($chat,$this->file_id,$caption,$keyboard,$keyboard_type,$parse_mode,$reply_to_message_id,$disable_notification);
477 | }
478 |
479 | }
480 | class sticker
481 | {
482 | var $array;
483 | function __construct($array)
484 | {
485 | foreach ($array as $key => $value) {
486 | if ($key === 'thumb') {
487 | $this->$key = new photo ($value);
488 | } else {
489 | $this->$key = $value;
490 | }
491 | }
492 | return $this;
493 | }
494 | function download ($path = false,$botObject = false) {
495 | global $bot;
496 | if (!$botObject && isset($bot)) {
497 | $botObject = $bot;
498 | } elseif (!$botObject) {
499 | return false;
500 | }
501 | $file = new file($this->file_id,$botObject);
502 | if ($file) {
503 | return $file->download($path);
504 | }
505 | }
506 | function send($chat,$keyboard=false,$keyboard_type=false, $reply_to_message_id = false, $disable_notification = 0,$botObject = false) {
507 | global $bot;
508 | if (!$botObject && isset($bot)) {
509 | $botObject = $bot;
510 | } elseif (!$botObject) {
511 | return false;
512 | }
513 | return $botObject->sendSticker($chat, $this->file_id, $keyboard, $keyboard_type, $reply_to_message_id, $disable_notification);
514 | }
515 |
516 | }
517 | class audio
518 | {
519 | var $array;
520 | function __construct($array)
521 | {
522 | foreach ($array as $key => $value) {
523 | if ($key === 'thumb') {
524 | $this->$key = new photo ($value);
525 | } else {
526 | $this->$key = $value;
527 | }
528 | }
529 | return $this;
530 | }
531 | function download ($path = false,$botObject = false) {
532 | global $bot;
533 | if (!$botObject && isset($bot)) {
534 | $botObject = $bot;
535 | } elseif (!$botObject) {
536 | return false;
537 | }
538 | $file = new file($this->file_id,$botObject);
539 | if ($file) {
540 | return $file->download($path);
541 | }
542 | }
543 | function send($chat, $caption = '', $keyboard = false, $keyboard_type = false,$thumb=false, $parse_mode = false, $reply_to_message_id = false, $disable_notification = 0,$botObject = false) {
544 | global $bot;
545 | if (!$botObject && isset($bot)) {
546 | $botObject = $bot;
547 | } elseif (!$botObject) {
548 | return false;
549 | }
550 | return $botObject->sendAudio($chat, $this->file_id,$caption,$keyboard,$keyboard_type,$this->duration,$this->performer,$this->title,$thumb,$parse_mode,$reply_to_message_id,$disable_notification);
551 | }
552 |
553 | }
554 |
555 | class voice
556 | {
557 | var $array;
558 | function __construct($array)
559 | {
560 | foreach ($array as $key => $value) {
561 | $this->$key = $value;
562 | }
563 | return $this;
564 | }
565 | function download ($path = false,$botObject = false) {
566 | global $bot;
567 | if (!$botObject && isset($bot)) {
568 | $botObject = $bot;
569 | } elseif (!$botObject) {
570 | return false;
571 | }
572 | $file = new file($this->file_id,$botObject);
573 | if ($file) {
574 | return $file->download($path);
575 | }
576 | }
577 | function send($chat, $caption = '', $keyboard = false, $keyboard_type = false, $parse_mode = false, $reply_to_message_id = false, $disable_notification = 0,$botObject=false) {
578 | global $bot;
579 | if (!$botObject && isset($bot)) {
580 | $botObject = $bot;
581 | } elseif (!$botObject) {
582 | return false;
583 | }
584 | return $botObject->sendVoice($chat,$this->file_id,$caption,$keyboard,$keyboard_type,$this->duration,$parse_mode,$reply_to_message_id,$disable_notification);
585 | }
586 | }
587 |
588 | class document
589 | {
590 | var $array;
591 | function __construct($array)
592 | {
593 | foreach ($array as $key => $value) {
594 | if ($key === 'thumb') {
595 | $this->$key = new photo ($value);
596 | } else {
597 | $this->$key = $value;
598 | }
599 | }
600 | return $this;
601 | }
602 | function download ($path = false,$botObject = false) {
603 | global $bot;
604 | if (!$botObject && isset($bot)) {
605 | $botObject = $bot;
606 | } elseif (!$botObject) {
607 | return false;
608 | }
609 | $file = new file($this->file_id,$botObject);
610 | if ($file) {
611 | return $file->download($path);
612 | }
613 | }
614 | function send($chat, $caption = '', $keyboard = false, $keyboard_type = false,$thumb=false, $parse_mode = false, $reply_to_message_id = false, $disable_notification = 0,$botObject = false) {
615 | global $bot;
616 | if (!$botObject && isset($bot)) {
617 | $botObject = $bot;
618 | } elseif (!$botObject) {
619 | return false;
620 | }
621 | return $botObject->sendDocument($chat,$this->file_id,$caption,$keyboard,$keyboard_type,$thumb,$parse_mode,$reply_to_message_id,$disable_notification);
622 | }
623 | }
624 | class video
625 | {
626 | var $array;
627 | function __construct($array)
628 | {
629 | foreach ($array as $key => $value) {
630 | if ($key === 'thumb') {
631 | $this->$key = new photo ($value);
632 | } else {
633 | $this->$key = $value;
634 | }
635 | }
636 | return $this;
637 | }
638 | function download ($path = false,$botObject = false) {
639 | global $bot;
640 | if (!$botObject && isset($bot)) {
641 | $botObject = $bot;
642 | } elseif (!$botObject) {
643 | return false;
644 | }
645 | $file = new file($this->file_id,$botObject);
646 | if ($file) {
647 | return $file->download($path);
648 | }
649 | }
650 | function send($chat, $caption = '', $keyboard = false, $keyboard_type = false, $thumb = false, $supports_streaming = false, $parse_mode = false, $reply_to_message_id = false, $disable_notification = 0,$botObject=false) {
651 | global $bot;
652 | if (!$botObject && isset($bot)) {
653 | $botObject = $bot;
654 | } elseif (!$botObject) {
655 | return false;
656 | }
657 | return $bot->sendVideo($chat,$this->file_id,$caption,$keyboard,$keyboard_type,$thumb,$this->height,$this->width,$this->duration,$supports_streaming,$parse_mode,$reply_to_message_id,$disable_notification);
658 | }
659 | }
660 |
661 | class animation
662 | {
663 | var $array;
664 | function __construct($array)
665 | {
666 | foreach ($array as $key => $value) {
667 | if ($key === 'thumb') {
668 | $this->$key = new photo ($value);
669 | } else {
670 | $this->$key = $value;
671 | }
672 | }
673 | return $this;
674 | }
675 | function download ($path = false,$botObject = false) {
676 | global $bot;
677 | if (!$botObject && isset($bot)) {
678 | $botObject = $bot;
679 | } elseif (!$botObject) {
680 | return false;
681 | }
682 | $file = new file($this->file_id,$botObject);
683 | if ($file) {
684 | return $file->download($path);
685 | }
686 | }
687 | function send($chat, $caption = '', $keyboard = false, $keyboard_type = false, $thumb = false, $parse_mode = false, $reply_to_message_id = false, $disable_notification = 0,$botObject=false) {
688 | global $bot;
689 | if (!$botObject && isset($bot)) {
690 | $botObject = $bot;
691 | } elseif (!$botObject) {
692 | return false;
693 | }
694 | return $botObject->sendAnimation($chat,$this->file_id,$caption,$keyboard,$keyboard_type,$thumb,$this->height,$this->width,$this->duration,$parse_mode,$reply_to_message_id,$disable_notification);
695 | }
696 | }
697 |
698 | class video_note
699 | {
700 | var $array;
701 | function __construct($array)
702 | {
703 | foreach ($array as $key => $value) {
704 | if ($key === 'thumb') {
705 | $this->$key = new photo ($value);
706 | } else {
707 | $this->$key = $value;
708 | }
709 | }
710 | return $this;
711 | }
712 | function download ($path = false,$botObject = false) {
713 | global $bot;
714 | if (!$botObject && isset($bot)) {
715 | $botObject = $bot;
716 | } elseif (!$botObject) {
717 | return false;
718 | }
719 | $file = new file($this->file_id,$botObject);
720 | if ($file) {
721 | return $file->download($path);
722 | }
723 | }
724 | function send($chat, $caption = '', $keyboard = false, $keyboard_type = false, $thumb = false, $parse_mode = false, $reply_to_message_id = false, $disable_notification = 0,$botObject=false) {
725 | global $bot;
726 | if (!$botObject && isset($bot)) {
727 | $botObject = $bot;
728 | } elseif (!$botObject) {
729 | return false;
730 | }
731 | return $botObject->sendVideoNote($chat,$this->file_id,$caption,$keyboard,$keyboard_type,$thumb,$this->lenght,$this->duration,$parse_mode,$reply_to_message_id,$disable_notification);
732 | }
733 | }
734 |
735 | class contact
736 | {
737 | var $array;
738 | function __construct($array)
739 | {
740 | foreach ($array as $key => $value) {
741 | $this->$key = $value;
742 | }
743 | return $this;
744 | }
745 | }
746 | class dice
747 | {
748 | var $array;
749 | function __construct($array)
750 | {
751 | foreach ($array as $key => $value) {
752 | $this->$key = $value;
753 | }
754 | return $this;
755 | }
756 | }
757 |
758 | class location
759 | {
760 | var $array;
761 | function __construct($array)
762 | {
763 | foreach ($array as $key => $value) {
764 | $this->$key = $value;
765 | }
766 | return $this;
767 | }
768 |
769 | }
770 |
771 | class venue
772 | {
773 | var $array;
774 | function __construct($array)
775 | {
776 | foreach ($array as $key => $value) {
777 | if ($key === 'venue') {
778 | $this->$key = new location ($value);
779 | } else {
780 | $this->$key = $value;
781 | }
782 | }
783 | return $this;
784 | }
785 |
786 | }
787 |
788 | class poll
789 | {
790 | var $array;
791 | function __construct($array)
792 | {
793 | foreach ($array as $key => $value) {
794 | if ($key === 'options') {
795 | foreach ($value as $option => $val) {
796 | $this->$key[$option]= new pollOption ($val);
797 | }
798 | } else {
799 | $this->$key = $value;
800 | }
801 | }
802 | return $this;
803 | }
804 | function getOptions() {
805 | $options = [];
806 | foreach ($this->options as $option) {
807 | $options[] = $option->text;
808 | }
809 | return $options;
810 | }
811 | }
812 |
813 | class pollOption
814 | {
815 | function __construct($array)
816 | {
817 | foreach ($array as $key => $value) {
818 | $this->$key = $value;
819 | }
820 | return $this;
821 | }
822 |
823 | }
824 | class file
825 | {
826 | var $array;
827 | var $bot;
828 | function __construct($array,$botObject = false)
829 | {
830 | global $bot;
831 | if (!$botObject && isset($bot)) {
832 | $botObject = $bot;
833 | } elseif (!$botObject) {
834 | return false;
835 | }
836 | if (!is_array($array) && $botObject) {
837 | $array = json_decode($botObject->getFile($array),true);
838 | $this->bot = $botObject;
839 | } elseif (!$bot) {
840 | return false;
841 | }
842 | foreach ($array['result'] as $key => $value) {
843 | $this->$key = $value;
844 | }
845 | return $this;
846 | }
847 |
848 | function download ($path = false,$botObject = false)
849 | {
850 | global $bot;
851 | if (!$botObject && isset($bot)) {
852 | $botObject = $bot;
853 | } elseif (!$botObject) {
854 | return false;
855 | }
856 | $content = file_get_contents('https://api.telegram.org/file/'. $botObject->token .'/' . $this->file_path);
857 | if (!$content) {
858 | return false;
859 | }
860 | if ($path) {
861 | return file_put_contents($path,$content);
862 | } else {
863 | return $content;
864 | }
865 | }
866 | }
867 | class generic_json {
868 | function __construct($array)
869 | {
870 | if (is_string($array)) {
871 | $json = json_decode($array,true);
872 | } elseif (is_array($array)) {
873 | $json = $array;
874 | }
875 | foreach ($json as $key => $value) {
876 | if (is_array($value)) {
877 | $this->$key = new generic_json($value);
878 | } else {
879 | $this->$key = $value;
880 | }
881 | }
882 | }
883 | }
884 |
885 | /*
886 | *
887 | * Note: entityParser class has been programmed by davtur19
888 | * Here is original code: https://github.com/davtur19/TelegramEntityParser
889 | *
890 | */
891 | class entityParser {
892 | function mbStringToArray($string, $encoding = 'UTF-8')
893 | {
894 | $array = [];
895 | $strlen = mb_strlen($string, $encoding);
896 | while ($strlen) {
897 | $array[] = mb_substr($string, 0, 1, $encoding);
898 | $string = mb_substr($string, 1, $strlen, $encoding);
899 | $strlen = mb_strlen($string, $encoding);
900 | }
901 | return $array;
902 | }
903 |
904 | function parseTagOpen($textToParse, $entity, $oTag)
905 | {
906 | $i = 0;
907 | $textParsed = '';
908 | $nullControl = false;
909 | $string = $this->mbStringToArray($textToParse, 'UTF-16LE');
910 | foreach ($string as $s) {
911 | if ($s === "\0\0") {
912 | $nullControl = !$nullControl;
913 | } elseif (!$nullControl) {
914 | if ($i == $entity['offset']) {
915 | $textParsed = $textParsed . $oTag;
916 | }
917 | $i++;
918 | }
919 | $textParsed = $textParsed . $s;
920 | }
921 | return $textParsed;
922 | }
923 |
924 | function parseTagClose($textToParse, $entity, $cTag)
925 | {
926 | $i = 0;
927 | $textParsed = '';
928 | $nullControl = false;
929 | $string = $this->mbStringToArray($textToParse, 'UTF-16LE');
930 | foreach ($string as $s) {
931 | $textParsed = $textParsed . $s;
932 | if ($s === "\0\0") {
933 | $nullControl = !$nullControl;
934 | } elseif (!$nullControl) {
935 | $i++;
936 | if ($i == ($entity['offset'] + $entity['length'])) {
937 | $textParsed = $textParsed . $cTag;
938 | }
939 | }
940 | }
941 | return $textParsed;
942 | }
943 |
944 | function htmlEscape($textToParse)
945 | {
946 | $i = 0;
947 | $textParsed = '';
948 | $nullControl = false;
949 | $string = $this->mbStringToArray($textToParse, 'UTF-8');
950 | foreach ($string as $s) {
951 | if ($s === "\0") {
952 | $nullControl = !$nullControl;
953 | } elseif (!$nullControl) {
954 | $i++;
955 | $textParsed = $textParsed . str_replace(['&', '"', '<', '>'], ["&", """, "<", ">"], $s);
956 | } else {
957 | $textParsed = $textParsed . $s;
958 | }
959 | }
960 | return $textParsed;
961 | }
962 |
963 |
964 | function entitiesToHtml($text, $entities)
965 | {
966 | $textToParse = mb_convert_encoding($text, 'UTF-16BE', 'UTF-8');
967 |
968 | foreach ($entities as $entity) {
969 | $href = false;
970 | switch ($entity['type']) {
971 | case 'bold':
972 | $tag = 'b';
973 | break;
974 | case 'italic':
975 | $tag = 'i';
976 | break;
977 | case 'underline':
978 | $tag = 'ins';
979 | break;
980 | case 'strikethrough':
981 | $tag = 'strike';
982 | break;
983 | case 'code':
984 | $tag = 'code';
985 | break;
986 | case 'pre':
987 | $tag = 'pre';
988 | break;
989 | case 'text_link':
990 | $tag = '';
991 | $href = true;
992 | break;
993 | case 'text_mention':
994 | $tag = '';
995 | $href = true;
996 | break;
997 | default:
998 | continue 2;
999 | }
1000 |
1001 | if ($href) {
1002 | $oTag = "\0{$tag}\0";
1003 | $cTag = "\0\0";
1004 | } else {
1005 | $oTag = "\0<{$tag}>\0";
1006 | $cTag = "\0{$tag}>\0";
1007 | }
1008 | $oTag = mb_convert_encoding($oTag, 'UTF-16BE', 'UTF-8');
1009 | $cTag = mb_convert_encoding($cTag, 'UTF-16BE', 'UTF-8');
1010 |
1011 | $textToParse = $this->parseTagOpen($textToParse, $entity, $oTag);
1012 | $textToParse = $this->parseTagClose($textToParse, $entity, $cTag);
1013 | }
1014 |
1015 | if (isset($entity)) {
1016 | $textToParse = mb_convert_encoding($textToParse, 'UTF-8', 'UTF-16BE');
1017 | $textToParse = $this->htmlEscape($textToParse);
1018 | return str_replace("\0", '', $textToParse);
1019 | }
1020 |
1021 | return htmlspecialchars($text);
1022 | }
1023 | }
1024 |
--------------------------------------------------------------------------------
/functions/update.php:
--------------------------------------------------------------------------------
1 | update = json_decode($update, true);
12 | if (isset($this->update['message'])) {
13 | $this->type = 'message';
14 | $this->message = new message($this->update['message']);
15 | if (isset($this->message->chat)) $this->chat = $this->message->chat;
16 | if (isset($this->message->user)) $this->user = $this->message->user;
17 | if (isset($this->chat)) $this->chat->db_save();
18 | if ((isset($this->user) && isset($this->chat)) && ($this->chat->id == $this->user->id)) {
19 | $this->user->db_save();
20 | } else {
21 | $this->user->db_save('group');
22 | }
23 | } elseif (isset($this->update['edited_message'])) {
24 | $this->type = 'edited_message';
25 | $this->message = new message($this->update['edited_message']);
26 | if (isset($this->message->chat)) $this->chat = $this->message->chat;
27 | if (isset($this->message->user)) $this->user = $this->message->user;
28 | if (isset($this->chat)) $this->chat->db_save();
29 | if ((isset($this->user) && isset($this->chat)) && ($this->chat->id == $this->user->id)) {
30 | $this->user->db_save();
31 | } else {
32 | $this->user->db_save('group');
33 | }
34 | } elseif (isset($this->update['channel_post'])) {
35 | $this->type = 'channel_post';
36 | $this->message = new message($this->update['channel_post']);
37 | if (isset($this->message->chat)) $this->chat = $this->message->chat;
38 | $this->chat->db_save();
39 | } elseif (isset($this->update['edited_channel_post'])) {
40 | $this->type = 'edited_channel_post';
41 | $this->message = new message($this->update['edited_channel_post']);
42 | if (isset($this->message->chat)) $this->chat = $this->message->chat;
43 | $this->chat->db_save();
44 | } elseif (isset($this->update['inline_query'])) {
45 | $this->type = 'inline_query';
46 | $this->inline_query = new inline_query($this->update['inline_query']);
47 | if (isset($this->inline_query->user)) $this->user = $this->inline_query->user;
48 | } elseif (isset($this->update['callback_query'])) {
49 | $this->type = 'callback_query';
50 | $this->callback = new callback_query($this->update['callback_query']);
51 | if (isset($this->callback->user)) $this->user = $this->callback->user;
52 | if (isset($this->callback->message)) $this->message = $this->callback->message;
53 | if (isset($this->callback->message->chat)) $this->chat = $this->callback->message->chat;
54 | if (isset($this->chat)) $this->chat->db_save();
55 | if (isset($this->user)) $this->user->db_save();
56 | }
57 | return $this;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/index.php:
--------------------------------------------------------------------------------
1 | message)) {
28 | $message = $update->message;
29 | if (isset($message->photo)) $photo = $message->photo;
30 | if (isset($message->audio)) $audio = $message->audio;
31 | if (isset($message->voice)) $voice = $message->voice;
32 | if (isset($message->animation)) $animation = $message->animation;
33 | if (isset($message->document)) $document = $message->document;
34 | if (isset($message->video)) $video = $message->video;
35 | if (isset($message->sticker)) $sticker = $message->sticker;
36 | if (isset($message->video_note)) $video_note = $message->video_note;
37 | if (isset($message->contact)) $contact = $message->contact;
38 | if (isset($message->location)) $location = $message->location;
39 | if (isset($message->venue)) $venue = $message->venue;
40 | if (isset($message->poll)) $poll = $message->poll;
41 | }
42 | if (isset($update->chat)) $chat = $update->chat;
43 | if (isset($update->user)) $user = $update->user;
44 | if (isset($update->callback)) $callback = $update->callback;
45 | if (isset($update->inline_query)) $inline = $update->inline_query;
46 | if (isset($update->callback)) $callback = $update->callback;
47 |
48 | //Plugins
49 | if ($config['plugins']['active']) {
50 | $startpls = array_diff(scandir('plugins/start'),['.', '..']);
51 | foreach ($startpls as $pl) {
52 | if (!in_array($pl,$config['plugins']['start_disabled'])) {
53 | include('plugins/start/' . $pl);
54 | }
55 | }
56 | }
57 |
58 | include 'commands.php';
59 |
60 | if ($config['plugins']['active']) {
61 | $endpls = array_diff(scandir('plugins/end'),['.', '..']);
62 | foreach ($endpls as $pl) {
63 | if (!in_array($pl,$config['plugins']['end_disabled'])) {
64 | include('plugins/end/' . $pl);
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/plugins/end/example.php:
--------------------------------------------------------------------------------
1 | type == 'inline_query' && isset($inline)) {
6 | $results = [
7 | [
8 | 'type' => 'article',
9 | 'id' => 1,
10 | 'title' => 'Send HTML formatted text',
11 | 'description' => "Write an html text and I will parse it",
12 | 'message_text' => $inline->query,
13 | 'parse_mode' => 'html'
14 | ],
15 |
16 | ];
17 | $bot->answerInlineQuery($inline->id,$results);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------