Delete se_mes_im2.html
Browse files- se_mes_im2.html +0 -202
se_mes_im2.html
DELETED
@@ -1,202 +0,0 @@
|
|
1 |
-
<!DOCTYPE html>
|
2 |
-
<html lang="en">
|
3 |
-
<head>
|
4 |
-
<meta charset="UTF-8">
|
5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
-
<title>Send Messages with Image</title>
|
7 |
-
<style>
|
8 |
-
body {
|
9 |
-
font-family: Arial, sans-serif;
|
10 |
-
text-align: center;
|
11 |
-
background-color: #f0f0f0;
|
12 |
-
margin: 0;
|
13 |
-
padding: 0;
|
14 |
-
}
|
15 |
-
h1 {
|
16 |
-
background-color: #4CAF50;
|
17 |
-
color: white;
|
18 |
-
padding: 20px;
|
19 |
-
margin: 0;
|
20 |
-
border-bottom: 2px solid #388E3C;
|
21 |
-
}
|
22 |
-
.input-row {
|
23 |
-
display: flex;
|
24 |
-
justify-content: center;
|
25 |
-
gap: 10px;
|
26 |
-
margin-top: 20px;
|
27 |
-
}
|
28 |
-
.input-row input, .input-row textarea {
|
29 |
-
padding: 10px;
|
30 |
-
font-size: 16px;
|
31 |
-
border: 1px solid #ccc;
|
32 |
-
border-radius: 5px;
|
33 |
-
}
|
34 |
-
#messageInput {
|
35 |
-
width: 80%;
|
36 |
-
margin-top: 20px;
|
37 |
-
}
|
38 |
-
#progressBarContainer {
|
39 |
-
width: 80%;
|
40 |
-
margin: 20px auto;
|
41 |
-
}
|
42 |
-
#progressBar {
|
43 |
-
width: 100%;
|
44 |
-
background-color: #ddd;
|
45 |
-
}
|
46 |
-
#progress {
|
47 |
-
width: 0%;
|
48 |
-
height: 30px;
|
49 |
-
background-color: #4CAF50;
|
50 |
-
text-align: center;
|
51 |
-
line-height: 30px;
|
52 |
-
color: white;
|
53 |
-
}
|
54 |
-
#sendButton, #uploadButton {
|
55 |
-
color: white;
|
56 |
-
background-color: #4CAF50;
|
57 |
-
border: none;
|
58 |
-
cursor: pointer;
|
59 |
-
padding: 10px 20px;
|
60 |
-
font-size: 16px;
|
61 |
-
border-radius: 5px;
|
62 |
-
margin-top: 20px;
|
63 |
-
}
|
64 |
-
#sendButton:hover, #uploadButton:hover {
|
65 |
-
background-color: #388E3C;
|
66 |
-
}
|
67 |
-
</style>
|
68 |
-
</head>
|
69 |
-
<body>
|
70 |
-
<h1>Отправка сообщения с картинкой</h1>
|
71 |
-
<div class="input-row">
|
72 |
-
<input type="text" id="apiKeyInput" placeholder="Введите API ключ">
|
73 |
-
<input type="number" id="minDelayInput" placeholder="Min Delay (ms)" value="500">
|
74 |
-
<input type="number" id="maxDelayInput" placeholder="Max Delay (ms)" value="1000">
|
75 |
-
</div>
|
76 |
-
<input type="file" id="fileInput" accept="image/*">
|
77 |
-
<button id="uploadButton">Загрузить картинку</button>
|
78 |
-
<textarea id="messageInput" placeholder="Введите текст сообщения с картинкой."></textarea>
|
79 |
-
<div id="progressBarContainer">
|
80 |
-
<div id="progressBar">
|
81 |
-
<div id="progress">0%</div>
|
82 |
-
</div>
|
83 |
-
</div>
|
84 |
-
<input type="file" id="phoneFileInput" accept=".txt">
|
85 |
-
<button id="sendButton">Запустить рассылку</button>
|
86 |
-
|
87 |
-
<script>
|
88 |
-
let uploadedImageUrl = '';
|
89 |
-
|
90 |
-
document.getElementById('uploadButton').addEventListener('click', function() {
|
91 |
-
const fileInput = document.getElementById('fileInput');
|
92 |
-
const file = fileInput.files[0];
|
93 |
-
if (!file) {
|
94 |
-
alert('Please select a file.');
|
95 |
-
return;
|
96 |
-
}
|
97 |
-
const formData = new FormData();
|
98 |
-
formData.append('photo', file);
|
99 |
-
|
100 |
-
fetch('/upload', {
|
101 |
-
method: 'POST',
|
102 |
-
body: formData
|
103 |
-
})
|
104 |
-
.then(response => response.text())
|
105 |
-
.then(data => {
|
106 |
-
uploadedImageUrl = data; // Use the returned URL as the image URL
|
107 |
-
alert('Image uploaded successfully!');
|
108 |
-
})
|
109 |
-
.catch(error => {
|
110 |
-
console.error('Error uploading image:', error);
|
111 |
-
alert('Error uploading image');
|
112 |
-
});
|
113 |
-
});
|
114 |
-
|
115 |
-
document.getElementById('sendButton').addEventListener('click', function() {
|
116 |
-
const apiKey = document.getElementById('apiKeyInput').value;
|
117 |
-
const message = document.getElementById('messageInput').value;
|
118 |
-
const minDelay = parseInt(document.getElementById('minDelayInput').value) || 500;
|
119 |
-
const maxDelay = parseInt(document.getElementById('maxDelayInput').value) || 10000;
|
120 |
-
|
121 |
-
if (!apiKey) {
|
122 |
-
alert('Please enter your API key.');
|
123 |
-
return;
|
124 |
-
}
|
125 |
-
if (!uploadedImageUrl) {
|
126 |
-
alert('Please upload an image.');
|
127 |
-
return;
|
128 |
-
}
|
129 |
-
if (!message) {
|
130 |
-
alert('Please enter a message.');
|
131 |
-
return;
|
132 |
-
}
|
133 |
-
if (minDelay >= maxDelay) {
|
134 |
-
alert('Min delay must be less than max delay.');
|
135 |
-
return;
|
136 |
-
}
|
137 |
-
|
138 |
-
const phoneFileInput = document.getElementById('phoneFileInput');
|
139 |
-
const file = phoneFileInput.files[0];
|
140 |
-
|
141 |
-
if (!file) {
|
142 |
-
alert('Please select a file.');
|
143 |
-
return;
|
144 |
-
}
|
145 |
-
|
146 |
-
const reader = new FileReader();
|
147 |
-
|
148 |
-
reader.onload = function(event) {
|
149 |
-
const text = event.target.result;
|
150 |
-
const phones = text.split('\n').map(phone => phone.trim()).filter(phone => phone);
|
151 |
-
|
152 |
-
sendMessages(phones, apiKey, uploadedImageUrl, message, minDelay, maxDelay);
|
153 |
-
};
|
154 |
-
|
155 |
-
reader.readAsText(file);
|
156 |
-
});
|
157 |
-
|
158 |
-
async function sendMessages(phones, apiKey, urlFile, message, minDelay, maxDelay) {
|
159 |
-
const totalPhones = phones.length;
|
160 |
-
const progressBar = document.getElementById('progress');
|
161 |
-
|
162 |
-
for (let i = 0; i < totalPhones; i++) {
|
163 |
-
const phone = phones[i];
|
164 |
-
|
165 |
-
try {
|
166 |
-
const response = await fetch(`https://api.green-api.com/waInstance1101952913/sendFileByUrl/${apiKey}`, {
|
167 |
-
method: 'POST',
|
168 |
-
headers: {
|
169 |
-
'Content-Type': 'application/json'
|
170 |
-
},
|
171 |
-
body: JSON.stringify({
|
172 |
-
chatId: `${phone}@c.us`,
|
173 |
-
urlFile: urlFile,
|
174 |
-
fileName: 'image.jpg',
|
175 |
-
caption: message
|
176 |
-
})
|
177 |
-
});
|
178 |
-
|
179 |
-
if (!response.ok) {
|
180 |
-
throw new Error(`HTTP error! status: ${response.status}`);
|
181 |
-
}
|
182 |
-
|
183 |
-
const data = await response.json();
|
184 |
-
console.log(`Message sent to ${phone}:`, data);
|
185 |
-
|
186 |
-
} catch (error) {
|
187 |
-
console.error(`Error sending message to ${phone}:`, error);
|
188 |
-
}
|
189 |
-
|
190 |
-
const progress = ((i + 1) / totalPhones) * 100;
|
191 |
-
progressBar.style.width = `${progress}%`;
|
192 |
-
progressBar.textContent = `${progress.toFixed(2)}%`;
|
193 |
-
|
194 |
-
if (i < totalPhones - 1) {
|
195 |
-
const randomDelay = Math.floor(Math.random() * (maxDelay - minDelay + 1)) + minDelay;
|
196 |
-
await new Promise(resolve => setTimeout(resolve, randomDelay));
|
197 |
-
}
|
198 |
-
}
|
199 |
-
}
|
200 |
-
</script>
|
201 |
-
</body>
|
202 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|