-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasic_bot.php
65 lines (51 loc) · 2.13 KB
/
basic_bot.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
ini_set('error_reporting', E_ALL);
$botToken = "TOKEN";
$website = "https://api.telegram.org/bot".$botToken;
$update = file_get_contents('php://input');
//$update = file_get_contents($website."/getupdates");
$update = json_decode($update, TRUE);
$chatId = $update["message"]["chat"]["id"];
print_r("$chatId\n");
$message = $update["message"]["text"];
$last_name = $update["message"]["chat"]["last_name"];
$osname= php_uname();
$host = gethostname();
switch($message) {
case "/start":
sendMessage($chatId,"Sr(a): $last_name. Bienvenido");
break;
case "/evento":
sendMessage($chatId,"Proximo evento progamado para el dia DD/MM/YYYY");
break;
case "/info":
sendMessage($chatId,"Sr(a): $last_name. Gracias por contactarnos.\nPuede ubicarnos por https://webpage");
break;
case "/osinfo":
sendMessage($chatId,"Sr(a): $last_name. Se esta comunicando con un bot que interactua con $osname");
break;
case "/host":
sendMessage($chatId,"Sr(a): $last_name. Se esta comunicando con el servidor $host");
break;
case "/creditos":
sendMessage($chatId,"Desarrollado por Ender Mujica - @emujicad");
break;
case "/ayuda":
sendMessage($chatId,"Comandos soportados: \n
\t/evento - Indica si hay algún evento de la comunidad\n
\t/info - Indica como contactar en la web\n
\t/osinfo - Indica con que sistema operativo esta interactuando\n
\t/host - Indica con que servidor esta interactuando\n
\t/creditos - Equipo Desarrollador\n
\t/ayuda - Muestra los comandos disponibles");
break;
default:
sendMessage($chatId,"Comando no reconocido. Intente con:\n\t /ayuda");
}
function sendMessage ($chatId, $message) {
$url = $GLOBALS[website]."/sendMessage?chat_id=".$chatId."&text=".urlencode($message);
file_get_contents($url);
}
// https://api.telegram.org/botTOKEN/setwebhook?url=https://FQDN:PUERTO/basic_bot.php
// curl -F "url=https://FQDN:PUERTO/basic_bot.php" -F "certificate=@/ruta/certificado.crt" https://api.telegram.org/TOKEN/setWebhook
?>