-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.php
More file actions
89 lines (63 loc) · 2.51 KB
/
bot.php
File metadata and controls
89 lines (63 loc) · 2.51 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
include 'Telegram.php';
require_once realpath(__DIR__ . "/vendor/autoload.php");
use Dotenv\Dotenv;
$dotenv = Dotenv::createImmutable(__DIR__);
$dotenv->load();
$bot_token = $_ENV['BOT_TOKEN'];
$telegram = new Telegram($bot_token);
// user's info
$result = $telegram->getData();
$text = $result['message'] ['text'];
$chat_id = $result['message'] ['chat']['id'];
$first_name = $result['message']['chat']['first_name'];
$username = $result['message']['chat']['username'];
$date = date('Y-m-d', $result['message']['date']);
include 'database.php';
// start command
if ($text == '/start') {
$db_insert = $db->query("SELECT chat_id FROM users WHERE chat_id = '$chat_id'")->fetch_assoc();
if (!$db_insert){
$db->query("insert into users (name,username,chat_id,joined_at) values ('$first_name','$username','$chat_id','$date')");
}
$reply = "Assalomu alaykum va rohmatullohi va barokatuh!
😊 Botimizga xush kelibsiz!
⏳ Vaqtlar <b>Polvonko'l jome</b> masjidida belgilangan va har <b>Juma</b> kuni yangilanadi
❗️ Namoz vaqtlarini bilish uchun <b>Namoz vaqtlari</b> tugmasini bosing.
";
$option = array(array($telegram->buildKeyboardButton("Namoz vaqtlari")));
$keyb = $telegram->buildKeyBoard($option, $onetime=false,$resize=true);
$content = array('chat_id' => $chat_id, 'reply_markup' => $keyb, 'text' => $reply,'parse_mode' => 'HTML');
$telegram->sendMessage($content);
}
// about command
if ($text == '/about') {
$sql = "SELECT COUNT(*) FROM users";
$count = $db->query($sql);
$row = $count->fetch_assoc();
$num = $row["COUNT(*)"];
$reply = "
📊 Statistika:
👤 Foydalanuvchilar: " . $num . "
📨 Bog'lanish uchun: @dastur_muhandisi_bot
";
$content = array('chat_id' => $chat_id, 'text' => $reply,'parse_mode' => 'HTML');
$telegram->sendMessage($content);
}
// Namoz vaqtlari button
if ($text == 'Namoz vaqtlari') {
$vaqtlar = $db->query("SELECT * FROM vaqtlar")->fetch_assoc();
$a = explode('-',$vaqtlar['vaqt_oraliq']);
$b = $a[0];
$c = $a[1];
$reply = "🕋 Namoz vaqtlari
🗓 " . $b ." dan"." $c"." gacha". "
🕔 Bomdod: <b>".$vaqtlar['bomdod']."</b>
🕐 Peshin: <b>".$vaqtlar['peshin']."</b>
🕓 Asr: <b>".$vaqtlar['asr']."</b>
🕧 Shom: <b>".$vaqtlar['shom'].' (+1)'."</b>
🕗 Xufton: <b>".$vaqtlar['xufton']."</b>
❗️ Albatta, namoz mo'minlarga vaqtida farz qilingandir (Niso surasi,103-oyat).";
$content = array('chat_id' => $chat_id, 'text' => $reply,'parse_mode' => 'HTML');
$telegram->sendMessage($content);
}