Spaces:
Runtime error
Runtime error
DmitrMakeev
commited on
Commit
•
ad59067
1
Parent(s):
cec61c0
Create up_user_gp.html
Browse files- up_user_gp.html +141 -0
up_user_gp.html
ADDED
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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>Add Participants to Group</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 {
|
29 |
+
padding: 10px;
|
30 |
+
font-size: 16px;
|
31 |
+
border: 1px solid #ccc;
|
32 |
+
border-radius: 5px;
|
33 |
+
}
|
34 |
+
#progressBarContainer {
|
35 |
+
width: 80%;
|
36 |
+
margin: 20px auto;
|
37 |
+
}
|
38 |
+
#progressBar {
|
39 |
+
width: 100%;
|
40 |
+
background-color: #ddd;
|
41 |
+
}
|
42 |
+
#progress {
|
43 |
+
width: 0%;
|
44 |
+
height: 30px;
|
45 |
+
background-color: #4CAF50;
|
46 |
+
text-align: center;
|
47 |
+
line-height: 30px;
|
48 |
+
color: white;
|
49 |
+
}
|
50 |
+
#addButton {
|
51 |
+
color: white;
|
52 |
+
background-color: #4CAF50;
|
53 |
+
border: none;
|
54 |
+
cursor: pointer;
|
55 |
+
padding: 10px 20px;
|
56 |
+
font-size: 16px;
|
57 |
+
border-radius: 5px;
|
58 |
+
margin-top: 20px;
|
59 |
+
}
|
60 |
+
#addButton:hover {
|
61 |
+
background-color: #388E3C;
|
62 |
+
}
|
63 |
+
</style>
|
64 |
+
</head>
|
65 |
+
<body>
|
66 |
+
<h1>Add Participants to Group</h1>
|
67 |
+
<div class="input-row">
|
68 |
+
<input type="text" id="apiKeyInput" placeholder="Enter API key">
|
69 |
+
<input type="text" id="groupIdInput" placeholder="Enter group ID">
|
70 |
+
<input type="number" id="minDelayInput" placeholder="Min Delay (ms)" value="500">
|
71 |
+
<input type="number" id="maxDelayInput" placeholder="Max Delay (ms)" value="1000">
|
72 |
+
</div>
|
73 |
+
<div id="progressBarContainer">
|
74 |
+
<div id="progressBar">
|
75 |
+
<div id="progress">0%</div>
|
76 |
+
</div>
|
77 |
+
</div>
|
78 |
+
<input type="file" id="fileInput" accept=".txt">
|
79 |
+
<button id="addButton">Add Participants</button>
|
80 |
+
|
81 |
+
<script>
|
82 |
+
document.getElementById('addButton').addEventListener('click', function() {
|
83 |
+
const apiKey = document.getElementById('apiKeyInput').value;
|
84 |
+
const groupId = document.getElementById('groupIdInput').value;
|
85 |
+
const minDelay = parseInt(document.getElementById('minDelayInput').value) || 500;
|
86 |
+
const maxDelay = parseInt(document.getElementById('maxDelayInput').value) || 1000;
|
87 |
+
if (!apiKey || !groupId) {
|
88 |
+
alert('Please enter an API key and group ID.');
|
89 |
+
return;
|
90 |
+
}
|
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 reader = new FileReader();
|
98 |
+
reader.onload = function(event) {
|
99 |
+
const text = event.target.result;
|
100 |
+
const participants = text.split('\n').map(line => line.trim()).filter(line => line);
|
101 |
+
addParticipants(participants, apiKey, groupId, minDelay, maxDelay);
|
102 |
+
};
|
103 |
+
reader.readAsText(file);
|
104 |
+
});
|
105 |
+
|
106 |
+
async function addParticipants(participants, apiKey, groupId, minDelay, maxDelay) {
|
107 |
+
const totalParticipants = participants.length;
|
108 |
+
const progressBar = document.getElementById('progress');
|
109 |
+
for (let i = 0; i < totalParticipants; i++) {
|
110 |
+
const participant = participants[i];
|
111 |
+
try {
|
112 |
+
const response = await fetch(`https://api.green-api.com/waInstance1101952913/addGroupParticipant/${apiKey}`, {
|
113 |
+
method: 'POST',
|
114 |
+
headers: {
|
115 |
+
'Content-Type': 'application/json'
|
116 |
+
},
|
117 |
+
body: JSON.stringify({
|
118 |
+
groupId: groupId,
|
119 |
+
participantChatId: `${participant}@c.us`
|
120 |
+
})
|
121 |
+
});
|
122 |
+
if (!response.ok) {
|
123 |
+
throw new Error(`HTTP error! status: ${response.status}`);
|
124 |
+
}
|
125 |
+
const data = await response.json();
|
126 |
+
console.log(`Participant ${participant} added to group:`, data);
|
127 |
+
} catch (error) {
|
128 |
+
console.error(`Error adding participant ${participant} to group:`, error);
|
129 |
+
}
|
130 |
+
const progress = ((i + 1) / totalParticipants) * 100;
|
131 |
+
progressBar.style.width = `${progress}%`;
|
132 |
+
progressBar.textContent = `${progress.toFixed(2)}%`;
|
133 |
+
if (i < totalParticipants - 1) {
|
134 |
+
const randomDelay = Math.floor(Math.random() * (maxDelay - minDelay + 1)) + minDelay;
|
135 |
+
await new Promise(resolve => setTimeout(resolve, randomDelay));
|
136 |
+
}
|
137 |
+
}
|
138 |
+
}
|
139 |
+
</script>
|
140 |
+
</body>
|
141 |
+
</html>
|