Update set_webhook.html
Browse files- set_webhook.html +12 -9
set_webhook.html
CHANGED
@@ -26,29 +26,32 @@
|
|
26 |
function activateWebhook() {
|
27 |
const token = document.getElementById("token").value;
|
28 |
const url = document.getElementById("url").value;
|
29 |
-
|
30 |
if (!token || !url) {
|
31 |
document.getElementById("result").innerText = "Введите все данные!";
|
32 |
return;
|
33 |
}
|
34 |
|
35 |
-
// Отправляем запрос на
|
36 |
-
|
|
|
|
|
37 |
method: 'POST',
|
38 |
headers: { 'Content-Type': 'application/json' },
|
39 |
-
body: JSON.stringify({
|
40 |
-
token: token,
|
41 |
-
url: url
|
42 |
-
})
|
43 |
})
|
44 |
.then(response => response.json())
|
45 |
.then(result => {
|
46 |
-
|
|
|
|
|
|
|
|
|
47 |
})
|
48 |
.catch(error => {
|
49 |
-
document.getElementById("result").innerText = "Ошибка: " + error;
|
50 |
});
|
51 |
}
|
52 |
</script>
|
53 |
</body>
|
54 |
</html>
|
|
|
|
26 |
function activateWebhook() {
|
27 |
const token = document.getElementById("token").value;
|
28 |
const url = document.getElementById("url").value;
|
|
|
29 |
if (!token || !url) {
|
30 |
document.getElementById("result").innerText = "Введите все данные!";
|
31 |
return;
|
32 |
}
|
33 |
|
34 |
+
// Отправляем запрос на Telegram API для установки webhook
|
35 |
+
const apiUrl = `https://api.telegram.org/bot${token}/setWebhook`;
|
36 |
+
|
37 |
+
fetch(apiUrl, {
|
38 |
method: 'POST',
|
39 |
headers: { 'Content-Type': 'application/json' },
|
40 |
+
body: JSON.stringify({ url: url })
|
|
|
|
|
|
|
41 |
})
|
42 |
.then(response => response.json())
|
43 |
.then(result => {
|
44 |
+
if (result.ok) {
|
45 |
+
document.getElementById("result").innerText = "Webhook активирован успешно!";
|
46 |
+
} else {
|
47 |
+
document.getElementById("result").innerText = `Ошибка: ${result.description}`;
|
48 |
+
}
|
49 |
})
|
50 |
.catch(error => {
|
51 |
+
document.getElementById("result").innerText = "Ошибка: " + error.message;
|
52 |
});
|
53 |
}
|
54 |
</script>
|
55 |
</body>
|
56 |
</html>
|
57 |
+
|