Update index.html
Browse files- index.html +55 -18
index.html
CHANGED
@@ -1,19 +1,56 @@
|
|
1 |
-
<!
|
2 |
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
<html>
|
3 |
+
<head>
|
4 |
+
<title>Telegram Bot</title>
|
5 |
+
</head>
|
6 |
+
<body>
|
7 |
+
<h1>BOT TELE RUN</h1>
|
8 |
+
|
9 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.21.1/axios.min.js"></script>
|
10 |
+
<script>
|
11 |
+
// Replace 'YOUR_BOT_TOKEN' with your actual bot token
|
12 |
+
const botToken = '7405960993:AAH1YTmoam4-Afk_QHsAcAObrdXwAlzfsaQ';
|
13 |
+
function sendMessage(chatId, text) {
|
14 |
+
const url = `https://api.telegram.org/bot${botToken}/sendMessage`;
|
15 |
+
const params = { chat_id: chatId, text: text };
|
16 |
+
axios.get(url, { params })
|
17 |
+
.then(response => {
|
18 |
+
console.log(response.data);
|
19 |
+
})
|
20 |
+
.catch(error => {
|
21 |
+
console.error(error);
|
22 |
+
});
|
23 |
+
}
|
24 |
+
function handleMessage(message) {
|
25 |
+
const chatId = message.chat.id;
|
26 |
+
const text = message.text;
|
27 |
+
if (text === '/start') {
|
28 |
+
sendMessage(chatId, 'Hi');
|
29 |
+
}
|
30 |
+
}
|
31 |
+
function main() {
|
32 |
+
let offset = null;
|
33 |
+
setInterval(() => {
|
34 |
+
const url = `https://api.telegram.org/bot${botToken}/getUpdates`;
|
35 |
+
const params = { offset };
|
36 |
+
axios.get(url, { params })
|
37 |
+
.then(response => {
|
38 |
+
const data = response.data;
|
39 |
+
if (data.ok) {
|
40 |
+
for (const update of data.result) {
|
41 |
+
offset = update.update_id + 1;
|
42 |
+
if (update.message) {
|
43 |
+
handleMessage(update.message);
|
44 |
+
}
|
45 |
+
}
|
46 |
+
}
|
47 |
+
})
|
48 |
+
.catch(error => {
|
49 |
+
console.error(error);
|
50 |
+
});
|
51 |
+
}, 1000);
|
52 |
+
}
|
53 |
+
main();
|
54 |
+
</script>
|
55 |
+
</body>
|
56 |
+
</html>
|