Spaces:
Runtime error
Runtime error
DmitrMakeev
commited on
Commit
•
4e50c71
1
Parent(s):
324e9d8
Update up_gr.html
Browse files- up_gr.html +49 -44
up_gr.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>
|
7 |
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/toastify-js/src/toastify.min.css">
|
8 |
<style>
|
9 |
body {
|
@@ -26,7 +26,7 @@
|
|
26 |
gap: 10px;
|
27 |
margin-top: 20px;
|
28 |
}
|
29 |
-
.input-row input
|
30 |
padding: 10px;
|
31 |
font-size: 16px;
|
32 |
border: 1px solid #ccc;
|
@@ -61,14 +61,12 @@
|
|
61 |
</style>
|
62 |
</head>
|
63 |
<body>
|
64 |
-
<h1>Создание группы
|
65 |
<div class="input-row">
|
66 |
<input type="text" id="apiKeyInput" placeholder="Введите API ключ">
|
67 |
<input type="text" id="groupNameInput" placeholder="Введите название группы">
|
68 |
</div>
|
69 |
-
<
|
70 |
-
<input type="text" id="chatIdsInput" placeholder="Введите chatIds через запятую">
|
71 |
-
</div>
|
72 |
<button id="createGroupButton">Создать группу</button>
|
73 |
<input type="text" id="groupIdOutput" placeholder="ID созданной группы" readonly>
|
74 |
<button id="copyGroupIdButton">Скопировать ID группы</button>
|
@@ -78,10 +76,11 @@
|
|
78 |
document.getElementById('createGroupButton').addEventListener('click', async function() {
|
79 |
const apiKey = document.getElementById('apiKeyInput').value;
|
80 |
const groupName = document.getElementById('groupNameInput').value;
|
81 |
-
const
|
82 |
-
|
|
|
83 |
Toastify({
|
84 |
-
text: "Пожалуйста, заполните все
|
85 |
duration: 3000,
|
86 |
gravity: "top",
|
87 |
position: "right",
|
@@ -90,42 +89,48 @@
|
|
90 |
}).showToast();
|
91 |
return;
|
92 |
}
|
93 |
-
const
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
}
|
108 |
-
|
109 |
-
|
110 |
-
Toastify({
|
111 |
-
text: "Группа успешно создана.",
|
112 |
-
duration: 3000,
|
113 |
-
gravity: "top",
|
114 |
-
position: "right",
|
115 |
-
backgroundColor: "yellow",
|
116 |
-
stopOnFocus: true
|
117 |
-
}).showToast();
|
118 |
-
} catch (error) {
|
119 |
-
console.error('Error creating group:', error);
|
120 |
-
Toastify({
|
121 |
-
text: "Ошибка при создании группы.",
|
122 |
-
duration: 3000,
|
123 |
-
gravity: "top",
|
124 |
-
position: "right",
|
125 |
-
backgroundColor: "yellow",
|
126 |
-
stopOnFocus: true
|
127 |
-
}).showToast();
|
128 |
-
}
|
129 |
});
|
130 |
|
131 |
document.getElementById('copyGroupIdButton').addEventListener('click', function() {
|
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>Create Group with Users</title>
|
7 |
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/toastify-js/src/toastify.min.css">
|
8 |
<style>
|
9 |
body {
|
|
|
26 |
gap: 10px;
|
27 |
margin-top: 20px;
|
28 |
}
|
29 |
+
.input-row input {
|
30 |
padding: 10px;
|
31 |
font-size: 16px;
|
32 |
border: 1px solid #ccc;
|
|
|
61 |
</style>
|
62 |
</head>
|
63 |
<body>
|
64 |
+
<h1>Создание группы с пользователями</h1>
|
65 |
<div class="input-row">
|
66 |
<input type="text" id="apiKeyInput" placeholder="Введите API ключ">
|
67 |
<input type="text" id="groupNameInput" placeholder="Введите название группы">
|
68 |
</div>
|
69 |
+
<input type="file" id="fileInput" accept=".txt">
|
|
|
|
|
70 |
<button id="createGroupButton">Создать группу</button>
|
71 |
<input type="text" id="groupIdOutput" placeholder="ID созданной группы" readonly>
|
72 |
<button id="copyGroupIdButton">Скопировать ID группы</button>
|
|
|
76 |
document.getElementById('createGroupButton').addEventListener('click', async function() {
|
77 |
const apiKey = document.getElementById('apiKeyInput').value;
|
78 |
const groupName = document.getElementById('groupNameInput').value;
|
79 |
+
const fileInput = document.getElementById('fileInput');
|
80 |
+
const file = fileInput.files[0];
|
81 |
+
if (!apiKey || !groupName || !file) {
|
82 |
Toastify({
|
83 |
+
text: "Пожалуйста, заполните все поля и выберите файл.",
|
84 |
duration: 3000,
|
85 |
gravity: "top",
|
86 |
position: "right",
|
|
|
89 |
}).showToast();
|
90 |
return;
|
91 |
}
|
92 |
+
const reader = new FileReader();
|
93 |
+
reader.onload = async function(event) {
|
94 |
+
const text = event.target.result;
|
95 |
+
const chatIds = text.split(',').map(id => id.trim()).filter(id => id);
|
96 |
+
const payload = {
|
97 |
+
groupName: groupName,
|
98 |
+
chatIds: chatIds
|
99 |
+
};
|
100 |
+
try {
|
101 |
+
const response = await fetch("https://api.green-api.com/waInstance1101952913/createGroup/fb4986a9d9cb40ef9be6c7b08cb9c98b7a3b1dc8c6834b0b92", {
|
102 |
+
method: 'POST',
|
103 |
+
headers: {
|
104 |
+
'Content-Type': 'application/json'
|
105 |
+
},
|
106 |
+
body: JSON.stringify(payload)
|
107 |
+
});
|
108 |
+
if (!response.ok) {
|
109 |
+
throw new Error(`HTTP error! status: ${response.status}`);
|
110 |
+
}
|
111 |
+
const data = await response.json();
|
112 |
+
document.getElementById('groupIdOutput').value = data.chatId;
|
113 |
+
Toastify({
|
114 |
+
text: "Группа успешно создана.",
|
115 |
+
duration: 3000,
|
116 |
+
gravity: "top",
|
117 |
+
position: "right",
|
118 |
+
backgroundColor: "yellow",
|
119 |
+
stopOnFocus: true
|
120 |
+
}).showToast();
|
121 |
+
} catch (error) {
|
122 |
+
console.error('Error creating group:', error);
|
123 |
+
Toastify({
|
124 |
+
text: "Ошибка при создании группы.",
|
125 |
+
duration: 3000,
|
126 |
+
gravity: "top",
|
127 |
+
position: "right",
|
128 |
+
backgroundColor: "yellow",
|
129 |
+
stopOnFocus: true
|
130 |
+
}).showToast();
|
131 |
}
|
132 |
+
};
|
133 |
+
reader.readAsText(file);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
});
|
135 |
|
136 |
document.getElementById('copyGroupIdButton').addEventListener('click', function() {
|