diff --git a/.gitignore b/.gitignore
index 30b6453..e06fe89 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,3 @@
sochisto.zip
-.env
-/node_modules
/.vscode
-package-lock.json
-package.json
\ No newline at end of file
+consts.txt
\ No newline at end of file
diff --git a/consts.txt.example b/consts.txt.example
new file mode 100644
index 0000000..0dcec70
--- /dev/null
+++ b/consts.txt.example
@@ -0,0 +1,3 @@
+your_telegram_token_from_bot_father
+your_telegram_id
+developer_telegram_id
\ No newline at end of file
diff --git a/index.html b/index.html
index e91bb27..80cd8b2 100644
--- a/index.html
+++ b/index.html
@@ -6,7 +6,7 @@
-
+
Сочисто! | Уборка квартир в Сочи
@@ -87,22 +87,7 @@ Оставьте заявку
Вы сможете узнать всю необходимую информацию и забронировать время уборки.
-
-
-
-
-
-
diff --git a/scripts/script.js b/scripts/script.js
index 1e85cce..2e9ac23 100644
--- a/scripts/script.js
+++ b/scripts/script.js
@@ -53,31 +53,24 @@ document.querySelectorAll('.clientForm').forEach( (e) => {
const phone = document.getElementById('phone').value;
if (name.trim() === '') {
- //Please fill out NAME!
document.getElementById('name').style.border = '2px solid red'
return;
}
if (phone.trim() === '') {
- //Please fill out PHONE!
document.getElementById('phone').style.border = '2px solid red'
return;
}
else {
-
const dataToSend = {
name: name,
phone: phone
}
- sendEmail(dataToSend)
- // sendDataToNode(dataToSend);
-
-
+ send(dataToSend)
};
})
})
document.getElementById('again').addEventListener('click', function() {
- console.log('again click');
document.getElementById('name').disabled = false;
document.getElementById('phone').disabled = false;
document.getElementById('hide-after-success').style.display = 'block';
@@ -95,8 +88,8 @@ function showSuccess(){
document.getElementById('success').style.display = 'block';
}
-function sendEmail(dataToSend){
- const mailPath = '../mail.php'
+function send(dataToSend){
+ const mailPath = '../sender.php'
let request = new XMLHttpRequest();
var params = JSON.stringify(dataToSend);
@@ -108,21 +101,4 @@ function sendEmail(dataToSend){
showSuccess();
}
}
-}
-
-// function sendDataToNode(data) {
-// // fetch('https://sochisto-bot-lizatravel.amvera.io:80/sendData', {
-// fetch('95.26.169.129:80/sendData', {
-// method: 'POST',
-// headers: {
-// 'Content-Type': 'application/json'
-// },
-// body: JSON.stringify(data)
-// })
-// .then(response => {
-// console.log('Data sent to Node.js');
-// })
-// .catch(error => {
-// console.error('Error sending data:', error);
-// });
-// };
+}
\ No newline at end of file
diff --git a/mail.php b/sender.php
similarity index 66%
rename from mail.php
rename to sender.php
index f5d569d..76c1d7c 100644
--- a/mail.php
+++ b/sender.php
@@ -38,5 +38,25 @@
echo "Email успешно отправлен 📧";
} else {
echo "Что-то пошло не так при отправке письма 🙁";
-}
+};
+
+$conststxt = file_get_contents('consts.txt');
+$consts = explode("\n", $conststxt);
+
+$apiToken = substr($consts[0], 0, -1);
+$owner = $consts[1];
+$dev = $consts[2];
+
+function sendTelegram($chat_id, $message, $apiToken) {
+ $data = [
+ 'chat_id' => $chat_id,
+ 'text' => $message,
+ 'parse_mode' => 'HTML'
+ ];
+ $response = file_get_contents("https://api.telegram.org/bot$apiToken/sendMessage?".http_build_query($data));
+};
+
+sendTelegram($owner, $message, $apiToken);
+sendTelegram($dev, $message, $apiToken);
+
?>
\ No newline at end of file