File size: 1,897 Bytes
da35a53 d8673bf da35a53 805a9de da35a53 361b655 da35a53 361b655 da35a53 |
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 |
<!DOCTYPE html>
<html>
<head>
<title>Telegram Bot</title>
</head>
<body>
<h1>BOT TELE RUN</h1>
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script>
// Replace 'YOUR_BOT_TOKEN' with your actual bot token
const botToken = '';
function sendMessage(chatId, text) {
const url = `https://api.telegram.org/bot${botToken}/sendMessage`;
const params = { chat_id: chatId, text: text };
axios.get(url, { params })
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error(error);
});
}
function handleMessage(message) {
const chatId = message.chat.id;
const text = message.text;
if (text === '/start') {
sendMessage(chatId, 'Hi');
}
}
function main() {
let offset = null;
setInterval(() => {
const url = `https://api.telegram.org/bot${botToken}/getUpdates`;
const params = { offset };
axios.get(url, { params })
.then(response => {
const data = response.data;
if (data.ok) {
for (const update of data.result) {
offset = update.update_id + 1;
if (update.message) {
handleMessage(update.message);
}
}
}
})
.catch(error => {
console.error(error);
});
}, 1000);
}
main();
</script>
</body>
</html> |