uouiouy / index.html
Dooratre's picture
Update index.html
805a9de verified
<!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>