DmitrMakeev commited on
Commit
13d777e
1 Parent(s): 7fc9e2c

Update se_mes_im.html

Browse files
Files changed (1) hide show
  1. se_mes_im.html +111 -161
se_mes_im.html CHANGED
@@ -3,7 +3,7 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Комменты Бизон 365</title>
7
  <style>
8
  body {
9
  font-family: Arial, sans-serif;
@@ -21,22 +21,37 @@
21
  }
22
  .input-row {
23
  display: flex;
24
- flex-direction: column;
25
- align-items: center;
26
  gap: 10px;
27
  margin-top: 20px;
28
  }
29
- .input-row label, .input-row input, .input-row select, .input-row textarea {
30
- width: 80%;
31
  padding: 10px;
32
  font-size: 16px;
33
  border: 1px solid #ccc;
34
  border-radius: 5px;
35
  }
36
- .input-row input[type="number"] {
37
- max-width: 100px;
 
 
 
 
 
 
 
 
 
38
  }
39
- #sendRequestButton, #sendGetRequestButton {
 
 
 
 
 
 
 
 
40
  color: white;
41
  background-color: #4CAF50;
42
  border: none;
@@ -44,173 +59,108 @@
44
  padding: 10px 20px;
45
  font-size: 16px;
46
  border-radius: 5px;
47
- margin-top: 10px;
48
- }
49
- #sendRequestButton:hover, #sendGetRequestButton:hover {
50
- background-color: #388E3C;
51
- }
52
- .dropdown-container {
53
  margin-top: 20px;
54
- width: 80%;
55
- display: flex;
56
- justify-content: center;
57
- }
58
- select {
59
- background-color: #e8f5e9; /* Зеленый фон для выпадающего списка */
60
- }
61
- input[type="datetime-local"], input[type="date"] {
62
- background-color: #e8f5e9; /* Зеленый фон для выбора даты и времени */
63
- border: 1px solid #4CAF50; /* Зеленая рамка */
64
- color: #4CAF50; /* Зеленый текст */
65
  }
66
- input[type="datetime-local"]::-webkit-datetime-edit,
67
- input[type="date"]::-webkit-datetime-edit {
68
- color: #4CAF50; /* Зеленый текст внутри поля */
69
- }
70
- input[type="datetime-local"]::-webkit-calendar-picker-indicator,
71
- input[type="date"]::-webkit-calendar-picker-indicator {
72
- filter: invert(45%) sepia(20%) saturate(3500%) hue-rotate(90deg) brightness(95%) contrast(90%);
73
  }
74
  </style>
75
  </head>
76
  <body>
77
- <h1>Комменты Бизон 365</h1>
78
-
79
  <div class="input-row">
80
- <label for="tokenInput">Enter Token:</label>
81
- <input type="text" id="tokenInput" placeholder="Your Token">
 
82
  </div>
83
-
84
- <div class="input-row">
85
- <label for="dateSelect">Select Date:</label>
86
- <select id="dateSelect">
87
- <!-- Даты от 1 января 2000 года до 31 декабря 2020 года -->
88
- <option value="2000-01-01">2000-01-01</option>
89
- <option value="2001-01-01">2001-01-01</option>
90
- <option value="2002-01-01">2002-01-01</option>
91
- <option value="2003-01-01">2003-01-01</option>
92
- <option value="2004-01-01">2004-01-01</option>
93
- <option value="2005-01-01">2005-01-01</option>
94
- <option value="2006-01-01">2006-01-01</option>
95
- <option value="2007-01-01">2007-01-01</option>
96
- <option value="2008-01-01">2008-01-01</option>
97
- <option value="2009-01-01">2009-01-01</option>
98
- <option value="2010-01-01">2010-01-01</option>
99
- <option value="2011-01-01">2011-01-01</option>
100
- <option value="2012-01-01">2012-01-01</option>
101
- <option value="2013-01-01">2013-01-01</option>
102
- <option value="2014-01-01">2014-01-01</option>
103
- <option value="2015-01-01">2015-01-01</option>
104
- <option value="2016-01-01">2016-01-01</option>
105
- <option value="2017-01-01">2017-01-01</option>
106
- <option value="2018-01-01">2018-01-01</option>
107
- <option value="2019-01-01">2019-01-01</option>
108
- <option value="2020-01-01">2020-01-01</option>
109
- </select>
110
- </div>
111
-
112
- <div class="input-row">
113
- <label for="limitInput">Limit:</label>
114
- <input type="number" id="limitInput" value="20" min="1" max="100">
115
- </div>
116
-
117
- <div class="input-row">
118
- <label for="typeSelect">Type:</label>
119
- <select id="typeSelect">
120
- <option value="LiveWebinars">Live Webinars</option>
121
- <option value="AutoWebinars">Auto Webinars</option>
122
- </select>
123
- </div>
124
-
125
- <div class="input-row">
126
- <button id="sendRequestButton">Send Request</button>
127
- </div>
128
-
129
- <div class="input-row">
130
- <textarea id="responseArea" rows="10" cols="50" readonly></textarea>
131
- </div>
132
-
133
- <div class="dropdown-container" id="dropdown-container"></div>
134
-
135
- <div class="input-row">
136
- <button id="sendGetRequestButton">Send GET Request</button>
137
- </div>
138
-
139
- <div class="input-row">
140
- <textarea id="secondResponseArea" rows="10" cols="50" readonly></textarea>
141
  </div>
 
 
142
 
143
  <script>
144
- document.getElementById('sendRequestButton').addEventListener('click', function() {
145
- const token = document.getElementById('tokenInput').value;
146
- const selectedDate = document.getElementById('dateSelect').value;
147
- const limit = document.getElementById('limitInput').value;
148
- const type = document.getElementById('typeSelect').value;
149
-
150
- const url = '/send_request';
151
- const params = new URLSearchParams();
152
- params.append('token', token);
153
- params.append('minDate', selectedDate); // Используем выбранную дату как минимальную
154
- params.append('limit', limit);
155
- params.append('type', type);
156
-
157
- fetch(url, {
158
- method: 'POST',
159
- headers: {
160
- 'Content-Type': 'application/x-www-form-urlencoded'
161
- },
162
- body: params.toString()
163
- })
164
- .then(response => response.json())
165
- .then(data => {
166
- console.log('JSON Response:', data);
167
- document.getElementById('responseArea').value = JSON.stringify(data, null, 2);
168
- createDropdown(data);
169
- })
170
- .catch(error => {
171
- console.error('Error:', error);
172
- document.getElementById('responseArea').value = 'Error: ' + error.message;
173
- });
174
- });
175
-
176
- function createDropdown(data) {
177
- const container = document.getElementById('dropdown-container');
178
- container.innerHTML = ''; // Очистить контейнер перед добавлением нового списка
179
- const select = document.createElement('select');
180
- select.id = 'dropdown';
181
- select.style.backgroundColor = '#e8f5e9'; // Зеленый фон для выпадающего списка
182
- data.forEach(item => {
183
- const option = document.createElement('option');
184
- option.value = item;
185
- option.text = item;
186
- select.appendChild(option);
187
- });
188
- container.appendChild(select);
189
- }
190
-
191
- document.getElementById('sendGetRequestButton').addEventListener('click', function() {
192
- const selectedValue = document.getElementById('dropdown')?.value;
193
- if (!selectedValue) {
194
- alert('Please select a webinar from the dropdown.');
195
  return;
196
  }
197
- const token = document.getElementById('tokenInput').value;
198
- const getUrl = `/send_get_request?token=${encodeURIComponent(token)}&webinarId=${encodeURIComponent(selectedValue)}`;
199
-
200
- fetch(getUrl, {
201
- method: 'GET'
202
- })
203
- .then(response => response.json())
204
- .then(data => {
205
- console.log('GET Response:', data);
206
- document.getElementById('secondResponseArea').value = JSON.stringify(data, null, 2);
207
- })
208
- .catch(error => {
209
- console.error('Error:', error);
210
- document.getElementById('secondResponseArea').value = 'Error: ' + error.message;
211
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
212
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
213
  </script>
214
  </body>
215
  </html>
216
-
 
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;
 
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;
 
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
+ if (!apiKey) {
96
+ alert('Please enter your API key.');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  return;
98
  }
99
+ if (!urlFile) {
100
+ alert('Please enter the URL of the file.');
101
+ return;
102
+ }
103
+ if (!fileName) {
104
+ alert('Please enter the file name.');
105
+ return;
106
+ }
107
+ if (!message) {
108
+ alert('Please enter a message.');
109
+ return;
110
+ }
111
+ if (minDelay >= maxDelay) {
112
+ alert('Min delay must be less than max delay.');
113
+ return;
114
+ }
115
+ const fileInput = document.getElementById('fileInput');
116
+ const file = fileInput.files[0];
117
+ if (!file) {
118
+ alert('Please select a file.');
119
+ return;
120
+ }
121
+ const reader = new FileReader();
122
+ reader.onload = function(event) {
123
+ const text = event.target.result;
124
+ const phones = text.split('\n').map(phone => phone.trim()).filter(phone => phone);
125
+ sendMessages(phones, apiKey, urlFile, fileName, message, minDelay, maxDelay);
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
+ }
150
+ const data = await response.json();
151
+ console.log(`Message sent to ${phone}:`, data);
152
+ } catch (error) {
153
+ console.error(`Error sending message to ${phone}:`, error);
154
+ }
155
+ const progress = ((i + 1) / totalPhones) * 100;
156
+ progressBar.style.width = `${progress}%`;
157
+ progressBar.textContent = `${progress.toFixed(2)}%`;
158
+ if (i < totalPhones - 1) {
159
+ const randomDelay = Math.floor(Math.random() * (maxDelay - minDelay + 1)) + minDelay;
160
+ await new Promise(resolve => setTimeout(resolve, randomDelay));
161
+ }
162
+ }
163
+ }
164
  </script>
165
  </body>
166
  </html>