Spaces:
Sleeping
Sleeping
DmitrMakeev
commited on
Commit
•
a30b9b5
1
Parent(s):
0b3a584
Update se_mes_im2.html
Browse files- se_mes_im2.html +10 -26
se_mes_im2.html
CHANGED
@@ -76,7 +76,7 @@
|
|
76 |
<textarea id="messageInput" placeholder="Введите текст сообщения с картинкой."></textarea>
|
77 |
<div id="progressBarContainer">
|
78 |
<div id="progressBar">
|
79 |
-
<div id="progress">0
|
80 |
</div>
|
81 |
</div>
|
82 |
<input type="file" id="fileInput" accept=".txt">
|
@@ -90,10 +90,6 @@
|
|
90 |
const message = document.getElementById('messageInput').value;
|
91 |
const minDelay = parseInt(document.getElementById('minDelayInput').value) || 500;
|
92 |
const maxDelay = parseInt(document.getElementById('maxDelayInput').value) || 10000;
|
93 |
-
|
94 |
-
console.log('URL файла из localStorage:', urlFile); // Added log
|
95 |
-
console.log('Имя файла из localStorage:', fileName); // Added log
|
96 |
-
|
97 |
if (!apiKey) {
|
98 |
alert('Please enter your API key.');
|
99 |
return;
|
@@ -114,17 +110,14 @@
|
|
114 |
alert('Min delay must be less than max delay.');
|
115 |
return;
|
116 |
}
|
117 |
-
|
118 |
const fileInput = document.getElementById('fileInput');
|
119 |
const file = fileInput.files[0];
|
120 |
if (!file) {
|
121 |
alert('Please select a file.');
|
122 |
return;
|
123 |
}
|
124 |
-
|
125 |
-
console.log('
|
126 |
-
console.log('Имя файла:', fileName); // Added log
|
127 |
-
|
128 |
const reader = new FileReader();
|
129 |
reader.onload = function(event) {
|
130 |
const text = event.target.result;
|
@@ -133,33 +126,24 @@
|
|
133 |
};
|
134 |
reader.readAsText(file);
|
135 |
});
|
136 |
-
|
137 |
async function sendMessages(phones, apiKey, urlFile, fileName, message, minDelay, maxDelay) {
|
138 |
const totalPhones = phones.length;
|
139 |
const progressBar = document.getElementById('progress');
|
140 |
-
|
141 |
for (let i = 0; i < totalPhones; i++) {
|
142 |
const phone = phones[i];
|
143 |
try {
|
144 |
-
const payload = JSON.stringify({
|
145 |
-
chatId: `${phone}@c.us`,
|
146 |
-
urlFile: urlFile,
|
147 |
-
fileName: fileName,
|
148 |
-
caption: message
|
149 |
-
});
|
150 |
-
|
151 |
-
console.log('Request payload:', payload); // Added log
|
152 |
-
|
153 |
const response = await fetch(`https://api.green-api.com/waInstance1101952913/sendFileByUrl/${apiKey}`, {
|
154 |
method: 'POST',
|
155 |
headers: {
|
156 |
'Content-Type': 'application/json'
|
157 |
},
|
158 |
-
body:
|
|
|
|
|
|
|
|
|
|
|
159 |
});
|
160 |
-
|
161 |
-
console.log('Response status:', response.status); // Added log
|
162 |
-
|
163 |
if (!response.ok) {
|
164 |
throw new Error(`HTTP error! status: ${response.status}`);
|
165 |
}
|
@@ -179,4 +163,4 @@
|
|
179 |
}
|
180 |
</script>
|
181 |
</body>
|
182 |
-
</html>
|
|
|
76 |
<textarea id="messageInput" placeholder="Введите текст сообщения с картинкой."></textarea>
|
77 |
<div id="progressBarContainer">
|
78 |
<div id="progressBar">
|
79 |
+
<div id="progress">0%</div>
|
80 |
</div>
|
81 |
</div>
|
82 |
<input type="file" id="fileInput" accept=".txt">
|
|
|
90 |
const message = document.getElementById('messageInput').value;
|
91 |
const minDelay = parseInt(document.getElementById('minDelayInput').value) || 500;
|
92 |
const maxDelay = parseInt(document.getElementById('maxDelayInput').value) || 10000;
|
|
|
|
|
|
|
|
|
93 |
if (!apiKey) {
|
94 |
alert('Please enter your API key.');
|
95 |
return;
|
|
|
110 |
alert('Min delay must be less than max delay.');
|
111 |
return;
|
112 |
}
|
|
|
113 |
const fileInput = document.getElementById('fileInput');
|
114 |
const file = fileInput.files[0];
|
115 |
if (!file) {
|
116 |
alert('Please select a file.');
|
117 |
return;
|
118 |
}
|
119 |
+
console.log('URL файла:', urlFile);
|
120 |
+
console.log('Имя файла:', fileName);
|
|
|
|
|
121 |
const reader = new FileReader();
|
122 |
reader.onload = function(event) {
|
123 |
const text = event.target.result;
|
|
|
126 |
};
|
127 |
reader.readAsText(file);
|
128 |
});
|
|
|
129 |
async function sendMessages(phones, apiKey, urlFile, fileName, message, minDelay, maxDelay) {
|
130 |
const totalPhones = phones.length;
|
131 |
const progressBar = document.getElementById('progress');
|
|
|
132 |
for (let i = 0; i < totalPhones; i++) {
|
133 |
const phone = phones[i];
|
134 |
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
const response = await fetch(`https://api.green-api.com/waInstance1101952913/sendFileByUrl/${apiKey}`, {
|
136 |
method: 'POST',
|
137 |
headers: {
|
138 |
'Content-Type': 'application/json'
|
139 |
},
|
140 |
+
body: JSON.stringify({
|
141 |
+
chatId: `${phone}@c.us`,
|
142 |
+
urlFile: urlFile,
|
143 |
+
fileName: fileName,
|
144 |
+
caption: message
|
145 |
+
})
|
146 |
});
|
|
|
|
|
|
|
147 |
if (!response.ok) {
|
148 |
throw new Error(`HTTP error! status: ${response.status}`);
|
149 |
}
|
|
|
163 |
}
|
164 |
</script>
|
165 |
</body>
|
166 |
+
</html>
|