-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex_local.php
57 lines (52 loc) · 3.19 KB
/
index_local.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
<?php
echo 'working';
include(__DIR__ . '/vendor/autoload.php');
$telegram = new Telegram('1489990155:AAGb7YFsVA-G2Vs28R6fQQZ8uxMm3ouCFDg');
$koneksi = @mysqli_connect('localhost', 'root', 'root', 'ai_data');
date_default_timezone_set('Asia/Jakarta');
$text = strtolower(mysqli_real_escape_string($koneksi, $telegram->Text()));
$chat_id = $telegram->ChatID();
//$q = mysqli_query($koneksi, "SELECT * FROM `data_ai` WHERE `data_key_ai` LIKE _utf8 '%".$text."' ");
$q = mysqli_query($koneksi, "SELECT * FROM `data_ai` WHERE `data_key_ai` LIKE _utf8 '$text' ");
$tes_jumlah_row = @mysqli_affected_rows($koneksi);
if ($text == '/start') {
$reply = 'Hai, ada apa .... hihi';
$content = array('chat_id' => $chat_id, 'text' => $reply);
$telegram->sendMessage($content);
} elseif ($text === 'ini jam berapa?' || $text === '/waktu' || $text === 'ini jam berapa ya?' || $text === 'jam sekarang!' || $text === 'lihat jam' || $text === 'waktu' || $text === 'sekarang jam berapa?' || $text === 'sekarang jam berapa' || $text === '/waktu@Fadhil_riyanto_bot') {
$reply = 'Sekarang jam ' . date('h:i:s a') . ', dihape kamu apa tidak cocok jamnya?' . PHP_EOL;
$content = array('chat_id' => $chat_id, 'text' => $reply);
$telegram->sendMessage($content);
} elseif ($text === '/info') {
$reply = 'Hi....' . PHP_EOL . PHP_EOL . 'Saya bot Fadhil Riyanto. Hobi saya bermain komputer dan membuat program'. PHP_EOL . PHP_EOL . 'Teknologi yang saya gunakan ialah. '. PHP_EOL . 'Server: nginx' . PHP_EOL . 'Database: Mysql'. PHP_EOL . 'Forward: ngrok' .PHP_EOL . 'PHP: 8.0 ts' .PHP_EOL . 'Versi: 8.3.3' .PHP_EOL . PHP_EOL . ' Dibuat dengan Cinta oleh @fadhil_riyanto'. PHP_EOL .PHP_EOL . 'Semoga bot ini mebantu';
$content = array('chat_id' => $chat_id, 'text' => $reply);
$telegram->sendMessage($content);
} elseif ($text === '/corona') {
$file_korona = @file_get_contents('https://api.kawalcorona.com/indonesia/');
$file_korona_jsonParse = json_decode($file_korona, true);
if ($file_korona_jsonParse != NULL) {
foreach ($file_korona_jsonParse as $corona_jadi) {
$reply = 'positif ' . $corona_jadi['positif'] . PHP_EOL . 'sembuh ' . $corona_jadi['sembuh'] . PHP_EOL . 'meninggal ' . $corona_jadi['meninggal'] . PHP_EOL . 'dirawat ' . $corona_jadi['dirawat'] . PHP_EOL;
$content = array('chat_id' => $chat_id, 'text' => $reply);
$telegram->sendMessage($content);
}
} else {
$reply = 'server mati sepertinya, coba lagi nanti' . PHP_EOL;
$content = array('chat_id' => $chat_id, 'text' => $reply);
$telegram->sendMessage($content);
}
} elseif ($tes_jumlah_row > 0) {
foreach ($q as $respon) {
$reply = $respon['data_res_ai'] . PHP_EOL;
$content = array('chat_id' => $chat_id, 'text' => $reply);
$telegram->sendMessage($content);
}
} elseif ($tes_jumlah_row === 0) {
$reply = '... Percakapan ini saya simpan untuk pembendaharaan kata kata agar bot lebih pintar lagi '.PHP_EOL.'Balas oke';
mysqli_query($koneksi, "INSERT INTO `data_ai` (`data_key_ai`, `data_res_ai`) VALUES ('$text', 'null')");
$content = array('chat_id' => $chat_id, 'text' => $reply);
$telegram->sendMessage($content);
//$reply_1 = 'Ga jelas skip?!!!';
//$konten = array('chat_id' => $chat_id, 'text' => $reply_1);
//$telegram->sendMessage($konten);
}