· 6 years ago · Mar 06, 2020, 02:04 PM
1<?php
2
3
4function sr($method, $args){
5 global $token;
6 $args = http_build_query($args);
7 $request = curl_init("https://api.telegram.org/$token/$method");
8 curl_setopt_array($request, array(
9 CURLOPT_CONNECTTIMEOUT => 1,
10 CURLOPT_RETURNTRANSFER => 1,
11 CURLOPT_USERAGENT => 'cURL request',
12 CURLOPT_POST => 1,
13 CURLOPT_POSTFIELDS => $args,
14 ));
15 $result = curl_exec($request);
16 curl_close($request);
17 return $result;
18}
19function action($chatID, $action) {
20 $args = array(
21 "chat_id" => $chatID,
22 "action" => $action,
23 );
24 return sr("sendChatAction", $args);
25}
26function sm($chatID, $msg, $menu= false, $keyboardtype = false, $parse_mode=false, $reply_to_message=false, $disablewebpreview = false) {
27 global $token;
28 global $config;
29 if (!$keyboardtype && $menu) {
30 $keyboardtype = $config['tastiera'];
31 }
32 if ($keyboardtype == "reply") {
33 $rm = array('keyboard' => $menu,
34 'resize_keyboard' => true
35 );
36 } elseif ($keyboardtype == "inline") {
37 $rm = array('inline_keyboard' => $menu);
38 } elseif ($keyboardtype == "nascondi") {
39 $rm = array('hide_keyboard' => true);
40 }
41 $rm = json_encode($rm);
42
43 if (!$parse_mode) {
44 $parse_mode = $config['parse_mode'];
45 }
46 if (!$disablewebpreview) {
47 $disablewebpreview = $config['disabilitapreview'];
48 }
49 $args = array(
50 "chat_id" => $chatID,
51 "text" => $msg,
52 "parse_mode" => $parse_mode,
53 "reply_to_message_id" => $reply_to_message,
54 "disable_web_page_preview" => true,
55 );
56 if($menu) $args['reply_markup'] = $rm;
57 if ($config['action']) {
58 action($chatID, "typing");
59 }
60 sr("sendMessage", $args);
61 }
62function sendMessage() {
63 return call_user_func_array("sm", func_get_args());
64}
65function em($chatID, $msg, $msgid, $menu= false, $keyboardtype = false, $parse_mode=false, $reply_to_message=false, $disablewebpreview = false) {
66 global $token;
67 global $config;
68 if (!$keyboardtype && $menu) {
69 $keyboardtype = $config['tastiera'];
70 }
71 if ($keyboardtype == "reply") {
72 $rm = array('keyboard' => $menu,
73 'resize_keyboard' => true);
74 } elseif ($keyboardtype == "inline") {
75 $rm = array('inline_keyboard' => $menu);
76 } elseif ($keyboardtype == "nascondi") {
77 $rm = array('hide_keyboard' => true);
78 }
79 $rm = json_encode($rm);
80
81 if (!$parse_mode) {
82 $parse_mode = $config['parse_mode'];
83 }
84 if (!$disablewebpreview) {
85 $disablewebpreview = $config['disabilitapreview'];
86 }
87 $args = array(
88 "chat_id" => $chatID,
89 "text" => $msg,
90 "parse_mode" => $parse_mode,
91 "reply_to_message_id" => $reply_to_message,
92 "disable_web_page_preview" => true,
93 "message_id" => $msgid,
94 );
95 return sr("sendMessage", $args);
96}
97function cb_reply($id, $text, $alert = false, $cbmid = false, $ntext = false, $nmenu = false, $npm = "pred")
98{
99 global $api;
100 global $chatID;
101 global $config;
102 if($npm == 'pred') $npm = $config['parse_mode'];
103 $args = array(
104 'callback_query_id' => $id,
105 'text' => $text,
106 'show_alert' => $alert,
107 'disable_web_page_preview' => true,
108 );
109 $r = sr("answerCallbackQuery", $args);
110 if($cbmid){
111 if($nmenu){
112 $rm = array('inline_keyboard' => $nmenu);
113 $rm = json_encode($rm);
114 }
115 $args = array(
116 'chat_id' => $chatID,
117 'message_id' => $cbmid,
118 'text' => $ntext,
119 'parse_mode' => $npm,
120 'disable_web_page_preview' => true,
121
122 );
123 if($nmenu) $args["reply_markup"] = $rm;
124 $r = sr("editMessageText", $args);
125 }
126 return $r;
127}
128function editMessageText() {
129 return call_user_func_array("em", func_get_args());
130}
131//ForwardMessage
132function fw($chatID, $from ,$msgid) {
133 $args = array(
134 "chat_id" => $chatID,
135 "from_chat_id" => $from,
136 "message_id" => $msgid,
137 );
138 return sr("forwardMessage", $args);
139}
140function forwardMessage() {
141 return call_user_func_array("fw", func_get_args());
142}
143//sendPhoto
144function si($chatID, $image, $caption = true,$menu= true, $keyboardtype = false, $parse_mode=false, $reply_to_message=false) {
145 global $token;
146 global $config;
147 if (!$keyboardtype && $menu) {
148 $keyboardtype = $config['tastiera'];
149 }
150 if ($keyboardtype == "reply") {
151 $rm = array('keyboard' => $menu,
152 'resize_keyboard' => true
153 );
154 } elseif ($keyboardtype == "inline") {
155 $rm = array('inline_keyboard' => $menu,
156 );
157 } elseif ($keyboardtype == "nascondi") {
158 $rm = array('hide_keyboard' => true
159 );
160 }
161 $rm = json_encode($rm);
162 if (!$parse_mode) {
163 $parse_mode = $config['parse_mode'];
164 }
165 $args = array(
166 "chat_id" => $chatID,
167 "photo" => $image,
168 "parse_mode" => $parse_mode,
169 "reply_to_message_id" => $reply_to_message,
170 "caption" => $caption,
171 );
172 if($menu) $args['reply_markup'] = $rm;
173 if ($config['action']) {
174 action($chatID, "upload_photo");
175 }
176 return sr("sendPhoto", $args);
177 }
178function sendPhoto() {
179 return call_user_func_array("si", func_get_args());
180}
181//sendAudio
182function sa($chatID, $audio, $caption = false,$menu= false, $keyboardtype = false, $parse_mode=false, $reply_to_message=false, $autore = "false", $titolo = "false") {
183 global $token;
184 global $config;
185 if (!$keyboardtype && $menu) {
186 $keyboardtype = $config['tastiera'];
187 }
188 if ($keyboardtype == "reply") {
189 $rm = array('keyboard' => $menu,
190 'resize_keyboard' => true);
191 } elseif ($keyboardtype == "inline") {
192 $rm = array('inline_keyboard' => $menu);
193 } elseif ($keyboardtype == "nascondi") {
194 $rm = array('hide_keyboard' => true);
195 }
196 $rm = json_encode($rm);
197
198 if (!$parse_mode) {
199 $parse_mode = $config['parse_mode'];
200 }
201 $args = array(
202 "chat_id" => $chatID,
203 "audio" => $audio,
204 "parse_mode" => $parse_mode,
205 "reply_to_message_id" => $reply_to_message,
206 "caption" => $caption,
207 "title" => $titolo,
208 "performer" => $autore,
209 );
210 if($menu) $args['reply_markup'] = $rm;
211 if ($config['action']) {
212 action($chatID, "upload_audio");
213 }
214 return sr("sendAudio", $args);
215 }
216function sendAudio() {
217 return call_user_func_array("sa", func_get_args());
218}
219function sd($chatID, $document, $caption = false,$menu= false, $keyboardtype = false, $parse_mode=false, $reply_to_message=false) {
220 global $token;
221 global $config;
222 if (!$keyboardtype && $menu) {
223 $keyboardtype = $config['tastiera'];
224 }
225 if ($keyboardtype == "reply") {
226 $rm = array('keyboard' => $menu,
227 'resize_keyboard' => true);
228 } elseif ($keyboardtype == "inline") {
229 $rm = array('inline_keyboard' => $menu,);
230 } elseif ($keyboardtype == "nascondi") {
231 $rm = array('hide_keyboard' => true);
232 }
233 $rm = json_encode($rm);
234
235 if (!$parse_mode) {
236 $parse_mode = $config['parse_mode'];
237 }
238 $args = array(
239 "chat_id" => $chatID,
240 "document" => $document,
241 "parse_mode" => $parse_mode,
242 "reply_to_message_id" => $reply_to_message,
243 "caption" => $caption,
244 );
245 if($menu) $args['reply_markup'] = $rm;
246 if ($config['action']) {
247 action($chatID, "upload_document");
248 }
249 return sr("sendDocument", $args);
250 }
251function sendDocument() {
252 return call_user_func_array("sd", func_get_args());
253}
254 //sendVideo
255function sv($chatID, $video, $caption = false,$menu= false, $keyboardtype = false, $parse_mode=false, $reply_to_message=false) {
256 global $token;
257 global $config;
258 if (!$keyboardtype && $menu) {
259 $keyboardtype = $config['tastiera'];
260 }
261 if ($keyboardtype == "reply") {
262 $rm = array('keyboard' => $menu,
263 'resize_keyboard' => true);
264 } elseif ($keyboardtype == "inline") {
265 $rm = array('inline_keyboard' => $menu,);
266 } elseif ($keyboardtype == "nascondi") {
267 $rm = array('hide_keyboard' => true);
268 }
269 $rm = json_encode($rm);
270
271 if (!$parse_mode) {
272 $parse_mode = $config['parse_mode'];
273 }
274 $args = array(
275 "chat_id" => $chatID,
276 "video" => $video,
277 "parse_mode" => $parse_mode,
278 "reply_to_message_id" => $reply_to_message,
279 "caption" => $caption,
280 );
281 if($menu) $args['reply_markup'] = $rm;
282 if ($config['action']) {
283 action($chatID, "upload_video");
284 }
285 return sr("sendVideo", $args);
286 }
287function sendVideo() {
288 return call_user_func_array("sm", func_get_args());
289}
290function sendAnimation($chatID, $animation,$menu= false, $keyboardtype = false, $parse_mode=false, $reply_to_message=false) {
291 global $token;
292 global $config;
293 if (!$keyboardtype && $menu) {
294 $keyboardtype = $config['tastiera'];
295 }
296 if ($keyboardtype == "reply") {
297 $rm = array('keyboard' => $menu,
298 'resize_keyboard' => true
299 );
300 } elseif ($keyboardtype == "inline") {
301 $rm = array('inline_keyboard' => $menu,);
302 } elseif ($keyboardtype == "nascondi") {
303
304 $rm = array('hide_keyboard' => true);
305 }
306 $rm = json_encode($rm);
307
308 if (!$parse_mode) {
309 $parse_mode = $config['parse_mode'];
310 }
311 $args = array(
312 "chat_id" => $chatID,
313 "animation" => $animation,
314 "parse_mode" => $parse_mode,
315 "reply_to_message_id" => $reply_to_message,
316 );
317 if($menu) $args['reply_markup'] = $rm;
318 if ($config['action']) {
319 action($chatID, "upload_video");
320 }
321 return sr("sendAnimation", $args);
322 }
323//sendVoice
324function svc($chatID, $voice, $caption = false,$menu= false, $keyboardtype = false, $parse_mode=false, $reply_to_message=false) {
325 global $token;
326 global $config;
327 if (!$keyboardtype && $menu) {
328 $keyboardtype = $config['tastiera'];
329 }
330 if ($keyboardtype == "reply") {
331 $rm = array('keyboard' => $menu,
332 'resize_keyboard' => true);
333 } elseif ($keyboardtype == "inline") {
334 $rm = array('inline_keyboard' => $menu);
335 } elseif ($keyboardtype == "nascondi") {
336 $rm = array('hide_keyboard' => true);
337 }
338 $rm = json_encode($rm);
339
340 if (!$parse_mode) {
341 $parse_mode = $config['parse_mode'];
342 }
343 $args = array(
344 "chat_id" => $chatID,
345 "voice" => $voice,
346 "parse_mode" => $parse_mode,
347 "reply_to_message_id" => $reply_to_message,
348 "caption" => $caption,
349 );
350 if($menu) $args['reply_markup'] = $rm;
351 if ($config['action']) {
352 action($chatID, "record_audio");
353 }
354 return sr("sendVoice", $args);
355 }
356function sendVoice() {
357 return call_user_func_array("svc", func_get_args());
358}
359//sendSticker
360function ss($chatID, $sticker,$menu= false, $keyboardtype = false, $reply_to_message=false) {
361 global $token;
362 global $config;
363 if (!$keyboardtype && $menu) {
364 $keyboardtype = $config['tastiera'];
365 }
366 if ($keyboardtype == "reply") {
367 $rm = array('keyboard' => $menu,
368 'resize_keyboard' => true
369 );
370 } elseif ($keyboardtype == "inline") {
371 $rm = array('inline_keyboard' => $menu,
372 );
373 } elseif ($keyboardtype == "nascondi") {
374
375 $rm = array('hide_keyboard' => true
376 );
377 }
378 $rm = json_encode($rm);
379
380 $args = array(
381 "chat_id" => $chatID,
382 "sticker" => $sticker,
383 "reply_to_message_id" => $reply_to_message,
384 );
385 if($menu) $args['reply_markup'] = $rm;
386 return sr("sendSticker", $args);
387 }
388function sendSticker() {
389 return call_user_func_array("ss", func_get_args());
390}
391//sendVideoNote
392function svn($chatID, $video_note ,$menu= false, $keyboardtype = false, $parse_mode=false, $reply_to_message=false) {
393 global $token;
394 global $config;
395 if (!$keyboardtype && $menu) {
396 $keyboardtype = $config['tastiera'];
397 }
398 if ($keyboardtype == "reply") {
399 $rm = array('keyboard' => $menu,
400 'resize_keyboard' => true
401 );
402 } elseif ($keyboardtype == "inline") {
403 $rm = array('inline_keyboard' => $menu);
404 } elseif ($keyboardtype == "nascondi") {
405
406 $rm = array('hide_keyboard' => true);
407 }
408 $rm = json_encode($rm);
409
410 if (!$parse_mode) {
411 $parse_mode = $config['parse_mode'];
412 }
413 $args = array(
414 "chat_id" => $chatID,
415 "video_note" => $video_note,
416 "parse_mode" => $parse_mode,
417 "reply_to_message_id" => $reply_to_message,
418 );
419 if($menu) $args['reply_markup'] = $rm;
420 if ($config['action']) {
421 action($chatID, "upload_video_note");
422 }
423 return sr("sendVideoNote", $args);
424 }
425function sendVideoNote() {
426 return call_user_func_array("svn", func_get_args());
427}
428//deleteMessage
429function dm($chatID, $msgid){
430 global $token;
431 $args = array(
432 "chat_id" => $chatID,
433 "message_id" => $msgid,
434 );
435 return sr("deleteMessage", $args);
436}
437function deleteMessage() {
438 return call_user_func_array("dm", func_get_args());
439}
440//sendLocation
441function sl($chatID, $latitude,$longitude,$menu= false, $keyboardtype = false, $parse_mode=false, $reply_to_message=false, $live_period = false) {
442 global $token;
443 global $config;
444 if (!$keyboardtype && $menu) {
445 $keyboardtype = $config['tastiera'];
446 }
447 if ($keyboardtype == "reply") {
448 $rm = array('keyboard' => $menu,
449 'resize_keyboard' => true
450 );
451 } elseif ($keyboardtype == "inline") {
452 $rm = array('inline_keyboard' => $menu,);
453 } elseif ($keyboardtype == "nascondi") {
454 $rm = array('hide_keyboard' => true);
455 }
456 $rm = json_encode($rm);
457
458 if (!$parse_mode) {
459 $parse_mode = $config['parse_mode'];
460 }
461 $args = array(
462 "chat_id" => $chatID,
463 "latitude" => $latitude,
464 "parse_mode" => $parse_mode,
465 "reply_to_message_id" => $reply_to_message,
466 "longitude" => $lungitude,
467 "live_period" => $live_period,
468 );
469 if($menu) $args['reply_markup'] = $rm;
470 if ($config['action']) {
471 action($chatID, "find_location");
472 }
473 return sr("sendLocation", $args);
474 }
475function sendLocation() {
476 return call_user_func_array("sl", func_get_args());
477}
478function sc($chatID, $phone_number, $first_name, $last_name=false,$menu= false, $keyboardtype = false, $parse_mode=false, $reply_to_message=false) {
479 global $token;
480 global $config;
481 if (!$keyboardtype && $menu) {
482 $keyboardtype = $config['tastiera'];
483 }
484 if ($keyboardtype == "reply") {
485 $rm = array('keyboard' => $menu,
486 'resize_keyboard' => true
487 );
488 } elseif ($keyboardtype == "inline") {
489 $rm = array('inline_keyboard' => $menu);
490 } elseif ($keyboardtype == "nascondi") {
491
492 $rm = array('hide_keyboard' => true);
493 }
494 $rm = json_encode($rm);
495
496 if (!$parse_mode) {
497 $parse_mode = $config['parse_mode'];
498 }
499 $args = array(
500 "chat_id" => $chatID,
501 "phone_number" => $phone_number,
502 "first_name" => $first_name,
503 "last_name" => $last_name,
504 "parse_mode" => $parse_mode,
505 "reply_to_message_id" => $reply_to_message,
506 );
507 if($menu) $args['reply_markup'] = $rm;
508 if ($config['action']) {
509 action($chatID, "typing");
510 }
511 return sr("sendContact", $args);
512}
513function sendContact() {
514 return call_user_func_array("sc", func_get_args());
515}
516function sendMediaGroup($chatID, $media, $reply=false) {
517 $media = json_encode($media);
518 $args = array(
519 "chat_id"=> $chatID,
520 "media" => $media,
521 "reply_to_message_id" => $reply,
522 );
523 return sr("sendMediaGroup", $args);
524}
525
526//GRUPPI
527function deleteChatPhoto($chatID){
528 global $token;
529 $args = array(
530 "chat_id" => $chatID,
531 );
532 return sr("deleteChatPhoto", $args);
533}
534function setChatPhoto($chatID, $photo) {
535 global $token;
536 $args = array(
537 "chat_id" => $chatID,
538 "photo" => $photo
539 );
540 return sr("setChatPhoto", $args);
541}
542function ban($chatID, $userID, $time=0)
543{
544 global $api;
545 $args = array(
546 'chat_id' => $chatID,
547 'user_id' => $userID,
548 'until_date' => $time,
549 );
550 return sr("kickChatMember", $args);
551}
552function kickChatMember() {
553 return call_user_func_array("ban", func_get_args());
554}
555function unban($chatID, $userID){
556 global $api;
557 $args = array(
558 'chat_id' => $chatID,
559 'user_id' => $userID
560 );
561 return sr("unbanChatMember", $args);
562}
563function unbanChatMember() {
564 return call_user_func_array("unban", func_get_args());
565}
566//fissa
567function fissa($chatID, $msgid){
568 global $api;
569 $args = array(
570 'chat_id' => $chatID,
571 'message_id' => $msgid,
572 );
573 return sr("pinChatMessage", $args);
574}
575function pinChatMessage() {
576 return call_user_func_array("fissa", func_get_args());
577}
578function unpinChatMessage($chatID){
579 global $token;
580 $args = array(
581 "chat_id" => $chatID,
582 );
583 return sr("unpinChatMessage", $args);
584}
585function limita($chatID, $userID, $dateRelase, $sendMsg, $sendMedia, $sendOther, $WPPreview){
586 global $token;
587 $args = array(
588 "chat_id" => $chatID,
589 "user_id" => $userID,
590 "until_date" => $dateRelase,
591 "can_send_messages" => $sendMsg,
592 "can_send_media_messages" => $sendMedia,
593 "can_send_other_messages" => $sendOther,
594 "can_add_web_page_previews" => $WPPreview
595 );
596 return sr("restrictChatMember", $args);
597}
598function restrictChatMember() {
599 return call_user_func_array("limita", func_get_args());
600}
601function promoteChatMember($chatID, $userID, $changeInfo, $postMsg, $modifyMsg, $deleteMsg, $inviteUsers, $restrictUsers, $pinMsg, $promoteUsers ){
602 global $token;
603 $args = array(
604 "chat_id" => $chatID,
605 "user_id" => $userID,
606 "can_change_info" => $changeInfo,
607 "can_post_messages" => $postMsg,
608 "can_edit_messages" => $modifyMsg,
609 "can_delete_messages" => $deleteMsg,
610 "can_invite_users" => $inviteUsers,
611 "can_restrict_members" => $restrictUsers,
612 "can_pin_messages" => $pinMsg,
613 "can_promote_members" => $promoteUsers
614 );
615 return sr("promoteChatMember", $args);
616}
617function getlink($chatID){
618 global $token;
619 $args = array(
620 "chat_id" => $chatID,
621 );
622 $j = json_decode( sr("exportChatInviteLink", $args),true);
623 return $j["result"];
624}
625function exportChatInviteLink() {
626 return call_user_func_array("getlink", func_get_args());
627}
628function getChatMembersCount($chatID){
629 global $token;
630 $args = array(
631 "chat_id" => $chatID,
632 );
633 $j = json_decode( sr("getChatMembersCount", $args),true);
634 return $j["result"];
635}
636function setChatTitle($chatID, $title) {
637 $args = array(
638 "chat_id" => $chatID,
639 "title" => $title,
640 );
641 return sr("setChatTitle", $args);
642}
643function setChatDescription($chatID, $description) {
644 $args = array(
645 "chat_id" => $chatID,
646 "title" => $description,
647 );
648 return sr("setChatDescription", $args);
649}
650function leaveChat($chatID) {
651 $args = array(
652 "chat_id" => $chatID,
653 );
654 return sr("leaveChat", $args);
655}
656function getChatMember($chatID, $userID) {
657 $args = array(
658 "chat_id" => $chatID,
659 "user_id" => $userID,
660 );
661 return sr("getChatMember", $args);
662}
663if ($config['db']){
664if ($config['tipo_db'] == "json") {
665function username($id) {
666 global $dbcontent;
667return $dbcontent[$id]['username'];
668}
669function id($username) {
670 global $dbcontent;
671 $username = str_replace("@", "", $username);
672 $key= array_search($username, array_column($dbcontent, "username","chat_id"));
673return $key;
674}
675function jsonsave() {
676global $dbcontent;
677file_put_contents("database.json", json_encode($dbcontent));
678}
679 } elseif ($config['tipo_db'] == "mysql") {
680function id($username) {
681 global $userbot;
682 global $db;
683$username = str_replace("@", "", $username);
684$q = $db->query("select * from `$userbot` where username = '" . $username ."'");
685$u = $q->fetch(PDO::FETCH_ASSOC);
686return $u['chat_id'];
687}
688function username($id) {
689 global $userbot;
690 global $db;
691$q = $db->query("select * from `$userbot` where chat_id = $id");
692$u = $q->fetch(PDO::FETCH_ASSOC);
693return $u['username'];
694}
695}
696}
697
698<?php
699
700
701function sr($method, $args){
702 global $token;
703 $args = http_build_query($args);
704 $request = curl_init("https://api.telegram.org/$token/$method");
705 curl_setopt_array($request, array(
706 CURLOPT_CONNECTTIMEOUT => 1,
707 CURLOPT_RETURNTRANSFER => 1,
708 CURLOPT_USERAGENT => 'cURL request',
709 CURLOPT_POST => 1,
710 CURLOPT_POSTFIELDS => $args,
711 ));
712 $result = curl_exec($request);
713 curl_close($request);
714 return $result;
715}
716function action($chatID, $action) {
717 $args = array(
718 "chat_id" => $chatID,
719 "action" => $action,
720 );
721 return sr("sendChatAction", $args);
722}
723function sm($chatID, $msg, $menu= false, $keyboardtype = false, $parse_mode=false, $reply_to_message=false, $disablewebpreview = false) {
724 global $token;
725 global $config;
726 if (!$keyboardtype && $menu) {
727 $keyboardtype = $config['tastiera'];
728 }
729 if ($keyboardtype == "reply") {
730 $rm = array('keyboard' => $menu,
731 'resize_keyboard' => true
732 );
733 } elseif ($keyboardtype == "inline") {
734 $rm = array('inline_keyboard' => $menu);
735 } elseif ($keyboardtype == "nascondi") {
736 $rm = array('hide_keyboard' => true);
737 }
738 $rm = json_encode($rm);
739
740 if (!$parse_mode) {
741 $parse_mode = $config['parse_mode'];
742 }
743 if (!$disablewebpreview) {
744 $disablewebpreview = $config['disabilitapreview'];
745 }
746 $args = array(
747 "chat_id" => $chatID,
748 "text" => $msg,
749 "parse_mode" => $parse_mode,
750 "reply_to_message_id" => $reply_to_message,
751 "disable_web_page_preview" => true,
752 );
753 if($menu) $args['reply_markup'] = $rm;
754 if ($config['action']) {
755 action($chatID, "typing");
756 }
757 sr("sendMessage", $args);
758 }
759function sendMessage() {
760 return call_user_func_array("sm", func_get_args());
761}
762function em($chatID, $msg, $msgid, $menu= false, $keyboardtype = false, $parse_mode=false, $reply_to_message=false, $disablewebpreview = false) {
763 global $token;
764 global $config;
765 if (!$keyboardtype && $menu) {
766 $keyboardtype = $config['tastiera'];
767 }
768 if ($keyboardtype == "reply") {
769 $rm = array('keyboard' => $menu,
770 'resize_keyboard' => true);
771 } elseif ($keyboardtype == "inline") {
772 $rm = array('inline_keyboard' => $menu);
773 } elseif ($keyboardtype == "nascondi") {
774 $rm = array('hide_keyboard' => true);
775 }
776 $rm = json_encode($rm);
777
778 if (!$parse_mode) {
779 $parse_mode = $config['parse_mode'];
780 }
781 if (!$disablewebpreview) {
782 $disablewebpreview = $config['disabilitapreview'];
783 }
784 $args = array(
785 "chat_id" => $chatID,
786 "text" => $msg,
787 "parse_mode" => $parse_mode,
788 "reply_to_message_id" => $reply_to_message,
789 "disable_web_page_preview" => true,
790 "message_id" => $msgid,
791 );
792 return sr("sendMessage", $args);
793}
794function cb_reply($id, $text, $alert = false, $cbmid = false, $ntext = false, $nmenu = false, $npm = "pred")
795{
796 global $api;
797 global $chatID;
798 global $config;
799 if($npm == 'pred') $npm = $config['parse_mode'];
800 $args = array(
801 'callback_query_id' => $id,
802 'text' => $text,
803 'show_alert' => $alert,
804 'disable_web_page_preview' => true,
805 );
806 $r = sr("answerCallbackQuery", $args);
807 if($cbmid){
808 if($nmenu){
809 $rm = array('inline_keyboard' => $nmenu);
810 $rm = json_encode($rm);
811 }
812 $args = array(
813 'chat_id' => $chatID,
814 'message_id' => $cbmid,
815 'text' => $ntext,
816 'parse_mode' => $npm,
817 'disable_web_page_preview' => true,
818
819 );
820 if($nmenu) $args["reply_markup"] = $rm;
821 $r = sr("editMessageText", $args);
822 }
823 return $r;
824}
825function editMessageText() {
826 return call_user_func_array("em", func_get_args());
827}
828//ForwardMessage
829function fw($chatID, $from ,$msgid) {
830 $args = array(
831 "chat_id" => $chatID,
832 "from_chat_id" => $from,
833 "message_id" => $msgid,
834 );
835 return sr("forwardMessage", $args);
836}
837function forwardMessage() {
838 return call_user_func_array("fw", func_get_args());
839}
840//sendPhoto
841function si($chatID, $image, $caption = true,$menu= true, $keyboardtype = false, $parse_mode=false, $reply_to_message=false) {
842 global $token;
843 global $config;
844 if (!$keyboardtype && $menu) {
845 $keyboardtype = $config['tastiera'];
846 }
847 if ($keyboardtype == "reply") {
848 $rm = array('keyboard' => $menu,
849 'resize_keyboard' => true
850 );
851 } elseif ($keyboardtype == "inline") {
852 $rm = array('inline_keyboard' => $menu,
853 );
854 } elseif ($keyboardtype == "nascondi") {
855 $rm = array('hide_keyboard' => true
856 );
857 }
858 $rm = json_encode($rm);
859 if (!$parse_mode) {
860 $parse_mode = $config['parse_mode'];
861 }
862 $args = array(
863 "chat_id" => $chatID,
864 "photo" => $image,
865 "parse_mode" => $parse_mode,
866 "reply_to_message_id" => $reply_to_message,
867 "caption" => $caption,
868 );
869 if($menu) $args['reply_markup'] = $rm;
870 if ($config['action']) {
871 action($chatID, "upload_photo");
872 }
873 return sr("sendPhoto", $args);
874 }
875function sendPhoto() {
876 return call_user_func_array("si", func_get_args());
877}
878//sendAudio
879function sa($chatID, $audio, $caption = false,$menu= false, $keyboardtype = false, $parse_mode=false, $reply_to_message=false, $autore = "false", $titolo = "false") {
880 global $token;
881 global $config;
882 if (!$keyboardtype && $menu) {
883 $keyboardtype = $config['tastiera'];
884 }
885 if ($keyboardtype == "reply") {
886 $rm = array('keyboard' => $menu,
887 'resize_keyboard' => true);
888 } elseif ($keyboardtype == "inline") {
889 $rm = array('inline_keyboard' => $menu);
890 } elseif ($keyboardtype == "nascondi") {
891 $rm = array('hide_keyboard' => true);
892 }
893 $rm = json_encode($rm);
894
895 if (!$parse_mode) {
896 $parse_mode = $config['parse_mode'];
897 }
898 $args = array(
899 "chat_id" => $chatID,
900 "audio" => $audio,
901 "parse_mode" => $parse_mode,
902 "reply_to_message_id" => $reply_to_message,
903 "caption" => $caption,
904 "title" => $titolo,
905 "performer" => $autore,
906 );
907 if($menu) $args['reply_markup'] = $rm;
908 if ($config['action']) {
909 action($chatID, "upload_audio");
910 }
911 return sr("sendAudio", $args);
912 }
913function sendAudio() {
914 return call_user_func_array("sa", func_get_args());
915}
916function sd($chatID, $document, $caption = false,$menu= false, $keyboardtype = false, $parse_mode=false, $reply_to_message=false) {
917 global $token;
918 global $config;
919 if (!$keyboardtype && $menu) {
920 $keyboardtype = $config['tastiera'];
921 }
922 if ($keyboardtype == "reply") {
923 $rm = array('keyboard' => $menu,
924 'resize_keyboard' => true);
925 } elseif ($keyboardtype == "inline") {
926 $rm = array('inline_keyboard' => $menu,);
927 } elseif ($keyboardtype == "nascondi") {
928 $rm = array('hide_keyboard' => true);
929 }
930 $rm = json_encode($rm);
931
932 if (!$parse_mode) {
933 $parse_mode = $config['parse_mode'];
934 }
935 $args = array(
936 "chat_id" => $chatID,
937 "document" => $document,
938 "parse_mode" => $parse_mode,
939 "reply_to_message_id" => $reply_to_message,
940 "caption" => $caption,
941 );
942 if($menu) $args['reply_markup'] = $rm;
943 if ($config['action']) {
944 action($chatID, "upload_document");
945 }
946 return sr("sendDocument", $args);
947 }
948function sendDocument() {
949 return call_user_func_array("sd", func_get_args());
950}
951 //sendVideo
952function sv($chatID, $video, $caption = false,$menu= false, $keyboardtype = false, $parse_mode=false, $reply_to_message=false) {
953 global $token;
954 global $config;
955 if (!$keyboardtype && $menu) {
956 $keyboardtype = $config['tastiera'];
957 }
958 if ($keyboardtype == "reply") {
959 $rm = array('keyboard' => $menu,
960 'resize_keyboard' => true);
961 } elseif ($keyboardtype == "inline") {
962 $rm = array('inline_keyboard' => $menu,);
963 } elseif ($keyboardtype == "nascondi") {
964 $rm = array('hide_keyboard' => true);
965 }
966 $rm = json_encode($rm);
967
968 if (!$parse_mode) {
969 $parse_mode = $config['parse_mode'];
970 }
971 $args = array(
972 "chat_id" => $chatID,
973 "video" => $video,
974 "parse_mode" => $parse_mode,
975 "reply_to_message_id" => $reply_to_message,
976 "caption" => $caption,
977 );
978 if($menu) $args['reply_markup'] = $rm;
979 if ($config['action']) {
980 action($chatID, "upload_video");
981 }
982 return sr("sendVideo", $args);
983 }
984function sendVideo() {
985 return call_user_func_array("sm", func_get_args());
986}
987function sendAnimation($chatID, $animation,$menu= false, $keyboardtype = false, $parse_mode=false, $reply_to_message=false) {
988 global $token;
989 global $config;
990 if (!$keyboardtype && $menu) {
991 $keyboardtype = $config['tastiera'];
992 }
993 if ($keyboardtype == "reply") {
994 $rm = array('keyboard' => $menu,
995 'resize_keyboard' => true
996 );
997 } elseif ($keyboardtype == "inline") {
998 $rm = array('inline_keyboard' => $menu,);
999 } elseif ($keyboardtype == "nascondi") {
1000
1001 $rm = array('hide_keyboard' => true);
1002 }
1003 $rm = json_encode($rm);
1004
1005 if (!$parse_mode) {
1006 $parse_mode = $config['parse_mode'];
1007 }
1008 $args = array(
1009 "chat_id" => $chatID,
1010 "animation" => $animation,
1011 "parse_mode" => $parse_mode,
1012 "reply_to_message_id" => $reply_to_message,
1013 );
1014 if($menu) $args['reply_markup'] = $rm;
1015 if ($config['action']) {
1016 action($chatID, "upload_video");
1017 }
1018 return sr("sendAnimation", $args);
1019 }
1020//sendVoice
1021function svc($chatID, $voice, $caption = false,$menu= false, $keyboardtype = false, $parse_mode=false, $reply_to_message=false) {
1022 global $token;
1023 global $config;
1024 if (!$keyboardtype && $menu) {
1025 $keyboardtype = $config['tastiera'];
1026 }
1027 if ($keyboardtype == "reply") {
1028 $rm = array('keyboard' => $menu,
1029 'resize_keyboard' => true);
1030 } elseif ($keyboardtype == "inline") {
1031 $rm = array('inline_keyboard' => $menu);
1032 } elseif ($keyboardtype == "nascondi") {
1033 $rm = array('hide_keyboard' => true);
1034 }
1035 $rm = json_encode($rm);
1036
1037 if (!$parse_mode) {
1038 $parse_mode = $config['parse_mode'];
1039 }
1040 $args = array(
1041 "chat_id" => $chatID,
1042 "voice" => $voice,
1043 "parse_mode" => $parse_mode,
1044 "reply_to_message_id" => $reply_to_message,
1045 "caption" => $caption,
1046 );
1047 if($menu) $args['reply_markup'] = $rm;
1048 if ($config['action']) {
1049 action($chatID, "record_audio");
1050 }
1051 return sr("sendVoice", $args);
1052 }
1053function sendVoice() {
1054 return call_user_func_array("svc", func_get_args());
1055}
1056//sendSticker
1057function ss($chatID, $sticker,$menu= false, $keyboardtype = false, $reply_to_message=false) {
1058 global $token;
1059 global $config;
1060 if (!$keyboardtype && $menu) {
1061 $keyboardtype = $config['tastiera'];
1062 }
1063 if ($keyboardtype == "reply") {
1064 $rm = array('keyboard' => $menu,
1065 'resize_keyboard' => true
1066 );
1067 } elseif ($keyboardtype == "inline") {
1068 $rm = array('inline_keyboard' => $menu,
1069 );
1070 } elseif ($keyboardtype == "nascondi") {
1071
1072 $rm = array('hide_keyboard' => true
1073 );
1074 }
1075 $rm = json_encode($rm);
1076
1077 $args = array(
1078 "chat_id" => $chatID,
1079 "sticker" => $sticker,
1080 "reply_to_message_id" => $reply_to_message,
1081 );
1082 if($menu) $args['reply_markup'] = $rm;
1083 return sr("sendSticker", $args);
1084 }
1085function sendSticker() {
1086 return call_user_func_array("ss", func_get_args());
1087}
1088//sendVideoNote
1089function svn($chatID, $video_note ,$menu= false, $keyboardtype = false, $parse_mode=false, $reply_to_message=false) {
1090 global $token;
1091 global $config;
1092 if (!$keyboardtype && $menu) {
1093 $keyboardtype = $config['tastiera'];
1094 }
1095 if ($keyboardtype == "reply") {
1096 $rm = array('keyboard' => $menu,
1097 'resize_keyboard' => true
1098 );
1099 } elseif ($keyboardtype == "inline") {
1100 $rm = array('inline_keyboard' => $menu);
1101 } elseif ($keyboardtype == "nascondi") {
1102
1103 $rm = array('hide_keyboard' => true);
1104 }
1105 $rm = json_encode($rm);
1106
1107 if (!$parse_mode) {
1108 $parse_mode = $config['parse_mode'];
1109 }
1110 $args = array(
1111 "chat_id" => $chatID,
1112 "video_note" => $video_note,
1113 "parse_mode" => $parse_mode,
1114 "reply_to_message_id" => $reply_to_message,
1115 );
1116 if($menu) $args['reply_markup'] = $rm;
1117 if ($config['action']) {
1118 action($chatID, "upload_video_note");
1119 }
1120 return sr("sendVideoNote", $args);
1121 }
1122function sendVideoNote() {
1123 return call_user_func_array("svn", func_get_args());
1124}
1125//deleteMessage
1126function dm($chatID, $msgid){
1127 global $token;
1128 $args = array(
1129 "chat_id" => $chatID,
1130 "message_id" => $msgid,
1131 );
1132 return sr("deleteMessage", $args);
1133}
1134function deleteMessage() {
1135 return call_user_func_array("dm", func_get_args());
1136}
1137//sendLocation
1138function sl($chatID, $latitude,$longitude,$menu= false, $keyboardtype = false, $parse_mode=false, $reply_to_message=false, $live_period = false) {
1139 global $token;
1140 global $config;
1141 if (!$keyboardtype && $menu) {
1142 $keyboardtype = $config['tastiera'];
1143 }
1144 if ($keyboardtype == "reply") {
1145 $rm = array('keyboard' => $menu,
1146 'resize_keyboard' => true
1147 );
1148 } elseif ($keyboardtype == "inline") {
1149 $rm = array('inline_keyboard' => $menu,);
1150 } elseif ($keyboardtype == "nascondi") {
1151 $rm = array('hide_keyboard' => true);
1152 }
1153 $rm = json_encode($rm);
1154
1155 if (!$parse_mode) {
1156 $parse_mode = $config['parse_mode'];
1157 }
1158 $args = array(
1159 "chat_id" => $chatID,
1160 "latitude" => $latitude,
1161 "parse_mode" => $parse_mode,
1162 "reply_to_message_id" => $reply_to_message,
1163 "longitude" => $lungitude,
1164 "live_period" => $live_period,
1165 );
1166 if($menu) $args['reply_markup'] = $rm;
1167 if ($config['action']) {
1168 action($chatID, "find_location");
1169 }
1170 return sr("sendLocation", $args);
1171 }
1172function sendLocation() {
1173 return call_user_func_array("sl", func_get_args());
1174}
1175function sc($chatID, $phone_number, $first_name, $last_name=false,$menu= false, $keyboardtype = false, $parse_mode=false, $reply_to_message=false) {
1176 global $token;
1177 global $config;
1178 if (!$keyboardtype && $menu) {
1179 $keyboardtype = $config['tastiera'];
1180 }
1181 if ($keyboardtype == "reply") {
1182 $rm = array('keyboard' => $menu,
1183 'resize_keyboard' => true
1184 );
1185 } elseif ($keyboardtype == "inline") {
1186 $rm = array('inline_keyboard' => $menu);
1187 } elseif ($keyboardtype == "nascondi") {
1188
1189 $rm = array('hide_keyboard' => true);
1190 }
1191 $rm = json_encode($rm);
1192
1193 if (!$parse_mode) {
1194 $parse_mode = $config['parse_mode'];
1195 }
1196 $args = array(
1197 "chat_id" => $chatID,
1198 "phone_number" => $phone_number,
1199 "first_name" => $first_name,
1200 "last_name" => $last_name,
1201 "parse_mode" => $parse_mode,
1202 "reply_to_message_id" => $reply_to_message,
1203 );
1204 if($menu) $args['reply_markup'] = $rm;
1205 if ($config['action']) {
1206 action($chatID, "typing");
1207 }
1208 return sr("sendContact", $args);
1209}
1210function sendContact() {
1211 return call_user_func_array("sc", func_get_args());
1212}
1213function sendMediaGroup($chatID, $media, $reply=false) {
1214 $media = json_encode($media);
1215 $args = array(
1216 "chat_id"=> $chatID,
1217 "media" => $media,
1218 "reply_to_message_id" => $reply,
1219 );
1220 return sr("sendMediaGroup", $args);
1221}
1222
1223//GRUPPI
1224function deleteChatPhoto($chatID){
1225 global $token;
1226 $args = array(
1227 "chat_id" => $chatID,
1228 );
1229 return sr("deleteChatPhoto", $args);
1230}
1231function setChatPhoto($chatID, $photo) {
1232 global $token;
1233 $args = array(
1234 "chat_id" => $chatID,
1235 "photo" => $photo
1236 );
1237 return sr("setChatPhoto", $args);
1238}
1239function ban($chatID, $userID, $time=0)
1240{
1241 global $api;
1242 $args = array(
1243 'chat_id' => $chatID,
1244 'user_id' => $userID,
1245 'until_date' => $time,
1246 );
1247 return sr("kickChatMember", $args);
1248}
1249function kickChatMember() {
1250 return call_user_func_array("ban", func_get_args());
1251}
1252function unban($chatID, $userID){
1253 global $api;
1254 $args = array(
1255 'chat_id' => $chatID,
1256 'user_id' => $userID
1257 );
1258 return sr("unbanChatMember", $args);
1259}
1260function unbanChatMember() {
1261 return call_user_func_array("unban", func_get_args());
1262}
1263//fissa
1264function fissa($chatID, $msgid){
1265 global $api;
1266 $args = array(
1267 'chat_id' => $chatID,
1268 'message_id' => $msgid,
1269 );
1270 return sr("pinChatMessage", $args);
1271}
1272function pinChatMessage() {
1273 return call_user_func_array("fissa", func_get_args());
1274}
1275function unpinChatMessage($chatID){
1276 global $token;
1277 $args = array(
1278 "chat_id" => $chatID,
1279 );
1280 return sr("unpinChatMessage", $args);
1281}
1282function limita($chatID, $userID, $dateRelase, $sendMsg, $sendMedia, $sendOther, $WPPreview){
1283 global $token;
1284 $args = array(
1285 "chat_id" => $chatID,
1286 "user_id" => $userID,
1287 "until_date" => $dateRelase,
1288 "can_send_messages" => $sendMsg,
1289 "can_send_media_messages" => $sendMedia,
1290 "can_send_other_messages" => $sendOther,
1291 "can_add_web_page_previews" => $WPPreview
1292 );
1293 return sr("restrictChatMember", $args);
1294}
1295function restrictChatMember() {
1296 return call_user_func_array("limita", func_get_args());
1297}
1298function promoteChatMember($chatID, $userID, $changeInfo, $postMsg, $modifyMsg, $deleteMsg, $inviteUsers, $restrictUsers, $pinMsg, $promoteUsers ){
1299 global $token;
1300 $args = array(
1301 "chat_id" => $chatID,
1302 "user_id" => $userID,
1303 "can_change_info" => $changeInfo,
1304 "can_post_messages" => $postMsg,
1305 "can_edit_messages" => $modifyMsg,
1306 "can_delete_messages" => $deleteMsg,
1307 "can_invite_users" => $inviteUsers,
1308 "can_restrict_members" => $restrictUsers,
1309 "can_pin_messages" => $pinMsg,
1310 "can_promote_members" => $promoteUsers
1311 );
1312 return sr("promoteChatMember", $args);
1313}
1314function getlink($chatID){
1315 global $token;
1316 $args = array(
1317 "chat_id" => $chatID,
1318 );
1319 $j = json_decode( sr("exportChatInviteLink", $args),true);
1320 return $j["result"];
1321}
1322function exportChatInviteLink() {
1323 return call_user_func_array("getlink", func_get_args());
1324}
1325function getChatMembersCount($chatID){
1326 global $token;
1327 $args = array(
1328 "chat_id" => $chatID,
1329 );
1330 $j = json_decode( sr("getChatMembersCount", $args),true);
1331 return $j["result"];
1332}
1333function setChatTitle($chatID, $title) {
1334 $args = array(
1335 "chat_id" => $chatID,
1336 "title" => $title,
1337 );
1338 return sr("setChatTitle", $args);
1339}
1340function setChatDescription($chatID, $description) {
1341 $args = array(
1342 "chat_id" => $chatID,
1343 "title" => $description,
1344 );
1345 return sr("setChatDescription", $args);
1346}
1347function leaveChat($chatID) {
1348 $args = array(
1349 "chat_id" => $chatID,
1350 );
1351 return sr("leaveChat", $args);
1352}
1353function getChatMember($chatID, $userID) {
1354 $args = array(
1355 "chat_id" => $chatID,
1356 "user_id" => $userID,
1357 );
1358 return sr("getChatMember", $args);
1359}
1360if ($config['db']){
1361if ($config['tipo_db'] == "json") {
1362function username($id) {
1363 global $dbcontent;
1364return $dbcontent[$id]['username'];
1365}
1366function id($username) {
1367 global $dbcontent;
1368 $username = str_replace("@", "", $username);
1369 $key= array_search($username, array_column($dbcontent, "username","chat_id"));
1370return $key;
1371}
1372function jsonsave() {
1373global $dbcontent;
1374file_put_contents("database.json", json_encode($dbcontent));
1375}
1376 } elseif ($config['tipo_db'] == "mysql") {
1377function id($username) {
1378 global $userbot;
1379 global $db;
1380$username = str_replace("@", "", $username);
1381$q = $db->query("select * from `$userbot` where username = '" . $username ."'");
1382$u = $q->fetch(PDO::FETCH_ASSOC);
1383return $u['chat_id'];
1384}
1385function username($id) {
1386 global $userbot;
1387 global $db;
1388$q = $db->query("select * from `$userbot` where chat_id = $id");
1389$u = $q->fetch(PDO::FETCH_ASSOC);
1390return $u['username'];
1391}
1392}
1393}