DmitrMakeev commited on
Commit
ac5e872
1 Parent(s): 21416a0

Create se_mes_im.html

Browse files
Files changed (1) hide show
  1. se_mes_im.html +181 -0
se_mes_im.html ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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, #urlFileInput, #fileNameInput {
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 {
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 {
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="text" id="urlFileInput" placeholder="Введите URL файла">
77
+ <input type="text" id="fileNameInput" placeholder="Введите название файла">
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="fileInput" accept=".txt">
85
+ <button id="sendButton">Запустить рассылку</button>
86
+
87
+ <script>
88
+ document.getElementById('sendButton').addEventListener('click', function() {
89
+ const apiKey = document.getElementById('apiKeyInput').value;
90
+ const urlFile = document.getElementById('urlFileInput').value;
91
+ const fileName = document.getElementById('fileNameInput').value;
92
+ const message = document.getElementById('messageInput').value;
93
+ const minDelay = parseInt(document.getElementById('minDelayInput').value) || 500;
94
+ const maxDelay = parseInt(document.getElementById('maxDelayInput').value) || 10000;
95
+
96
+ if (!apiKey) {
97
+ alert('Please enter your API key.');
98
+ return;
99
+ }
100
+ if (!urlFile) {
101
+ alert('Please enter the URL of the file.');
102
+ return;
103
+ }
104
+ if (!fileName) {
105
+ alert('Please enter the file name.');
106
+ return;
107
+ }
108
+ if (!message) {
109
+ alert('Please enter a message.');
110
+ return;
111
+ }
112
+ if (minDelay >= maxDelay) {
113
+ alert('Min delay must be less than max delay.');
114
+ return;
115
+ }
116
+
117
+ const fileInput = document.getElementById('fileInput');
118
+ const file = fileInput.files[0];
119
+
120
+ if (!file) {
121
+ alert('Please select a file.');
122
+ return;
123
+ }
124
+
125
+ const reader = new FileReader();
126
+
127
+ reader.onload = function(event) {
128
+ const text = event.target.result;
129
+ const phones = text.split('\n').map(phone => phone.trim()).filter(phone => phone);
130
+
131
+ sendMessages(phones, apiKey, urlFile, fileName, message, minDelay, maxDelay);
132
+ };
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
+
144
+ try {
145
+ const response = await fetch(`https://api.green-api.com/waInstance1101952913/sendFileByUrl/${apiKey}`, {
146
+ method: 'POST',
147
+ headers: {
148
+ 'Content-Type': 'application/json'
149
+ },
150
+ body: JSON.stringify({
151
+ chatId: `${phone}@c.us`,
152
+ urlFile: urlFile,
153
+ fileName: fileName,
154
+ caption: message
155
+ })
156
+ });
157
+
158
+ if (!response.ok) {
159
+ throw new Error(`HTTP error! status: ${response.status}`);
160
+ }
161
+
162
+ const data = await response.json();
163
+ console.log(`Message sent to ${phone}:`, data);
164
+
165
+ } catch (error) {
166
+ console.error(`Error sending message to ${phone}:`, error);
167
+ }
168
+
169
+ const progress = ((i + 1) / totalPhones) * 100;
170
+ progressBar.style.width = `${progress}%`;
171
+ progressBar.textContent = `${progress.toFixed(2)}%`;
172
+
173
+ if (i < totalPhones - 1) {
174
+ const randomDelay = Math.floor(Math.random() * (maxDelay - minDelay + 1)) + minDelay;
175
+ await new Promise(resolve => setTimeout(resolve, randomDelay));
176
+ }
177
+ }
178
+ }
179
+ </script>
180
+ </body>
181
+ </html>