DmitrMakeev
commited on
Commit
•
d60a5e8
1
Parent(s):
6c1489a
Create del_user_gp
Browse files- del_user_gp +154 -0
del_user_gp
ADDED
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/toastify-js/src/toastify.min.css">
|
7 |
+
<title>Remove Participants from Group</title>
|
8 |
+
<style>
|
9 |
+
body {
|
10 |
+
font-family: Arial, sans-serif;
|
11 |
+
text-align: center;
|
12 |
+
background-color: #f0f0f0;
|
13 |
+
margin: 0;
|
14 |
+
padding: 0;
|
15 |
+
}
|
16 |
+
h1 {
|
17 |
+
background-color: #4CAF50;
|
18 |
+
color: white;
|
19 |
+
padding: 20px;
|
20 |
+
margin: 0;
|
21 |
+
border-bottom: 2px solid #388E3C;
|
22 |
+
}
|
23 |
+
.input-row {
|
24 |
+
display: flex;
|
25 |
+
justify-content: center;
|
26 |
+
gap: 10px;
|
27 |
+
margin-top: 20px;
|
28 |
+
}
|
29 |
+
.input-row input {
|
30 |
+
padding: 10px;
|
31 |
+
font-size: 16px;
|
32 |
+
border: 1px solid #ccc;
|
33 |
+
border-radius: 5px;
|
34 |
+
}
|
35 |
+
#progressBarContainer {
|
36 |
+
width: 80%;
|
37 |
+
margin: 20px auto;
|
38 |
+
}
|
39 |
+
#progressBar {
|
40 |
+
width: 100%;
|
41 |
+
background-color: #ddd;
|
42 |
+
}
|
43 |
+
#progress {
|
44 |
+
width: 0%;
|
45 |
+
height: 30px;
|
46 |
+
background-color: #4CAF50;
|
47 |
+
text-align: center;
|
48 |
+
line-height: 30px;
|
49 |
+
color: white;
|
50 |
+
}
|
51 |
+
#removeButton {
|
52 |
+
color: white;
|
53 |
+
background-color: #4CAF50;
|
54 |
+
border: none;
|
55 |
+
cursor: pointer;
|
56 |
+
padding: 10px 20px;
|
57 |
+
font-size: 16px;
|
58 |
+
border-radius: 5px;
|
59 |
+
margin-top: 20px;
|
60 |
+
}
|
61 |
+
#removeButton:hover {
|
62 |
+
background-color: #388E3C;
|
63 |
+
}
|
64 |
+
</style>
|
65 |
+
</head>
|
66 |
+
<body>
|
67 |
+
<h1>Удаление пользователей из группы</h1>
|
68 |
+
<div class="input-row">
|
69 |
+
<input type="text" id="apiKeyInput" placeholder="Введите API ключ">
|
70 |
+
<input type="text" id="groupIdInput" placeholder="Введите ID группы">
|
71 |
+
<input type="number" id="minDelayInput" placeholder="Min Delay (ms)" value="500">
|
72 |
+
<input type="number" id="maxDelayInput" placeholder="Max Delay (ms)" value="1000">
|
73 |
+
</div>
|
74 |
+
<div id="progressBarContainer">
|
75 |
+
<div id="progressBar">
|
76 |
+
<div id="progress">0%</div>
|
77 |
+
</div>
|
78 |
+
</div>
|
79 |
+
<input type="file" id="fileInput" accept=".txt">
|
80 |
+
<button id="removeButton">Запустить цикл удаления</button>
|
81 |
+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/toastify-js"></script>
|
82 |
+
<script>
|
83 |
+
document.getElementById('removeButton').addEventListener('click', function() {
|
84 |
+
const apiKey = document.getElementById('apiKeyInput').value;
|
85 |
+
const groupId = document.getElementById('groupIdInput').value;
|
86 |
+
const minDelay = parseInt(document.getElementById('minDelayInput').value) || 500;
|
87 |
+
const maxDelay = parseInt(document.getElementById('maxDelayInput').value) || 1000;
|
88 |
+
if (!apiKey || !groupId) {
|
89 |
+
Toastify({
|
90 |
+
text: "Проверьте правильность API ключа или ID группы",
|
91 |
+
duration: 3000,
|
92 |
+
gravity: "top",
|
93 |
+
position: "center",
|
94 |
+
backgroundColor: "#fc0303",
|
95 |
+
}).showToast();
|
96 |
+
return;
|
97 |
+
}
|
98 |
+
const fileInput = document.getElementById('fileInput');
|
99 |
+
const file = fileInput.files[0];
|
100 |
+
if (!file) {
|
101 |
+
Toastify({
|
102 |
+
text: "Добавьте файл с подписчиками",
|
103 |
+
duration: 3000,
|
104 |
+
gravity: "top",
|
105 |
+
position: "center",
|
106 |
+
backgroundColor: "#fc0303",
|
107 |
+
}).showToast();
|
108 |
+
return;
|
109 |
+
}
|
110 |
+
const reader = new FileReader();
|
111 |
+
reader.onload = function(event) {
|
112 |
+
const text = event.target.result;
|
113 |
+
const participants = text.split('\n').map(line => line.trim()).filter(line => line);
|
114 |
+
removeParticipants(participants, apiKey, groupId, minDelay, maxDelay);
|
115 |
+
};
|
116 |
+
reader.readAsText(file);
|
117 |
+
});
|
118 |
+
|
119 |
+
async function removeParticipants(participants, apiKey, groupId, minDelay, maxDelay) {
|
120 |
+
const totalParticipants = participants.length;
|
121 |
+
const progressBar = document.getElementById('progress');
|
122 |
+
for (let i = 0; i < totalParticipants; i++) {
|
123 |
+
const participant = participants[i];
|
124 |
+
try {
|
125 |
+
const response = await fetch(`https://api.green-api.com/waInstance1101952913/removeGroupParticipant/${apiKey}`, {
|
126 |
+
method: 'POST',
|
127 |
+
headers: {
|
128 |
+
'Content-Type': 'application/json'
|
129 |
+
},
|
130 |
+
body: JSON.stringify({
|
131 |
+
groupId: groupId,
|
132 |
+
participantChatId: `${participant}@c.us`
|
133 |
+
})
|
134 |
+
});
|
135 |
+
if (!response.ok) {
|
136 |
+
throw new Error(`HTTP error! status: ${response.status}`);
|
137 |
+
}
|
138 |
+
const data = await response.json();
|
139 |
+
console.log(`Participant ${participant} removed from group:`, data);
|
140 |
+
} catch (error) {
|
141 |
+
console.error(`Error removing participant ${participant} from group:`, error);
|
142 |
+
}
|
143 |
+
const progress = ((i + 1) / totalParticipants) * 100;
|
144 |
+
progressBar.style.width = `${progress}%`;
|
145 |
+
progressBar.textContent = `${progress.toFixed(2)}%`;
|
146 |
+
if (i < totalParticipants - 1) {
|
147 |
+
const randomDelay = Math.floor(Math.random() * (maxDelay - minDelay + 1)) + minDelay;
|
148 |
+
await new Promise(resolve => setTimeout(resolve, randomDelay));
|
149 |
+
}
|
150 |
+
}
|
151 |
+
}
|
152 |
+
</script>
|
153 |
+
</body>
|
154 |
+
</html>
|