Spaces:
Sleeping
Sleeping
Create del_ad.html
Browse files- del_ad.html +125 -0
del_ad.html
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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>Manage Group Admin</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 |
+
#setAdminButton {
|
| 36 |
+
color: white;
|
| 37 |
+
background-color: #4CAF50;
|
| 38 |
+
border: none;
|
| 39 |
+
cursor: pointer;
|
| 40 |
+
padding: 10px 20px;
|
| 41 |
+
font-size: 16px;
|
| 42 |
+
border-radius: 5px;
|
| 43 |
+
margin-top: 20px;
|
| 44 |
+
}
|
| 45 |
+
#setAdminButton:hover {
|
| 46 |
+
background-color: #388E3C;
|
| 47 |
+
}
|
| 48 |
+
</style>
|
| 49 |
+
</head>
|
| 50 |
+
<body>
|
| 51 |
+
<h1>EУдаление администратора закрытой группы</h1>
|
| 52 |
+
<div class="input-row">
|
| 53 |
+
<input type="text" id="apiKeyInput" placeholder="Вставьте API ключ">
|
| 54 |
+
<input type="text" id="groupIdInput" placeholder="Вставьте ID группы">
|
| 55 |
+
<input type="text" id="participantChatIdInput" placeholder="Телефое администратора">
|
| 56 |
+
</div>
|
| 57 |
+
<button id="setAdminButton">Удалить администратора</button>
|
| 58 |
+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/toastify-js"></script>
|
| 59 |
+
<script>
|
| 60 |
+
document.getElementById('setAdminButton').addEventListener('click', function() {
|
| 61 |
+
const apiKey = document.getElementById('apiKeyInput').value;
|
| 62 |
+
const groupId = document.getElementById('groupIdInput').value;
|
| 63 |
+
let participantChatId = document.getElementById('participantChatIdInput').value;
|
| 64 |
+
if (!apiKey || !groupId || !participantChatId) {
|
| 65 |
+
|
| 66 |
+
Toastify({
|
| 67 |
+
text: "Пожалуйста заполните все поля!",
|
| 68 |
+
duration: 3000,
|
| 69 |
+
gravity: "top",
|
| 70 |
+
position: "center",
|
| 71 |
+
backgroundColor: "#fc0303",
|
| 72 |
+
}).showToast();
|
| 73 |
+
return;
|
| 74 |
+
}
|
| 75 |
+
// Add the @c.us suffix if it's not already present
|
| 76 |
+
if (!participantChatId.includes('@c.us')) {
|
| 77 |
+
participantChatId = participantChatId + '@c.us';
|
| 78 |
+
}
|
| 79 |
+
setGroupAdmin(apiKey, groupId, participantChatId);
|
| 80 |
+
});
|
| 81 |
+
async function setGroupAdmin(apiKey, groupId, participantChatId) {
|
| 82 |
+
const url = `https://api.green-api.com/waInstance1101952913/removeAdmin/${apiKey}`;
|
| 83 |
+
const payload = {
|
| 84 |
+
groupId: groupId,
|
| 85 |
+
participantChatId: participantChatId
|
| 86 |
+
};
|
| 87 |
+
const headers = {
|
| 88 |
+
'Content-Type': 'application/json'
|
| 89 |
+
};
|
| 90 |
+
try {
|
| 91 |
+
const response = await fetch(url, {
|
| 92 |
+
method: 'POST',
|
| 93 |
+
headers: headers,
|
| 94 |
+
body: JSON.stringify(payload)
|
| 95 |
+
});
|
| 96 |
+
if (!response.ok) {
|
| 97 |
+
throw new Error(`HTTP error! status: ${response.status}`);
|
| 98 |
+
}
|
| 99 |
+
const data = await response.json();
|
| 100 |
+
if (data.setGroupAdmin === false && data.error === "participant not found") {
|
| 101 |
+
alert('Добавьте пользователя в группу');
|
| 102 |
+
Toastify({
|
| 103 |
+
text: "Пользователь должен быть в группе!",
|
| 104 |
+
duration: 3000,
|
| 105 |
+
gravity: "top",
|
| 106 |
+
position: "center",
|
| 107 |
+
backgroundColor: "#fc0303",
|
| 108 |
+
}).showToast();
|
| 109 |
+
} else {
|
| 110 |
+
console.log('Admin set successfully:', data);
|
| 111 |
+
Toastify({
|
| 112 |
+
text: "Администратор добавлен!",
|
| 113 |
+
duration: 3000,
|
| 114 |
+
gravity: "top",
|
| 115 |
+
position: "center",
|
| 116 |
+
backgroundColor: "#56fcb7",
|
| 117 |
+
}).showToast();
|
| 118 |
+
}
|
| 119 |
+
} catch (error) {
|
| 120 |
+
console.error('Error setting admin:', error);
|
| 121 |
+
}
|
| 122 |
+
}
|
| 123 |
+
</script>
|
| 124 |
+
</body>
|
| 125 |
+
</html>
|