-
Notifications
You must be signed in to change notification settings - Fork 0
/
a.php
52 lines (50 loc) · 1.6 KB
/
a.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
<?php
$content = file_get_contents("php://input");
$update = json_decode($content, true);
if(!$update) { exit; }
$message = isset($update['message']) ? $update['message'] : "";
$messageId = isset($message['message_id']) ? $message['message_id'] : "";
$chatId = isset($message['chat']['id']) ? $message['chat']['id'] : "";
$firstname = isset($message['chat']['first_name']) ? $message['chat']['first_name'] : "";
$lastname = isset($message['chat']['last_name']) ? $message['chat']['last_name'] : "";
$username = isset($message['chat']['username']) ? $message['chat']['username'] : "";
$date = isset($message['date']) ? $message['date'] : "";
$text = isset($message['text']) ? $message['text'] : "";
switch ($text){
case "ciao":
$text="Ciao $firstname come stai?";
break;
case "Ciao":
$text="Ciao $firstname come stai?";
break; case "Tutto bene tu?":
$text = "Benissimo grazie!";
break;
case "tutto bene tu?":
$text = "Benissimo grazie!";
break;
case "bene tu?":
$text = "Benissimo grazie!";
break;
case "Bene tu?":
$text = "Benissimo grazie!";
break; case "Che fai?":
$text = "Programmo tu?";
break;
case "che fai?":
$text = "Programmo tu?";
break;
case "Niente":
$text="Capito";
break;
case "niente":
$text="Capito";
break;
default:
$text="Non capisco";
break;
}
$text = trim($text);
$text = strtolower($text);
header("Content-Type: application/json");
$parameters = array('chat_id' => $chatId, "text" => $text); $parameters["method"] = "sendMessage"; echo json_encode($parameters);
?>