Update up_gr.html
Browse files33 unmodified lines343536373839403 unmodified lines444546474849505152535455565758596061626364652 unmodified lines686970717273746 unmodified lines818283848586878889909192939495969798991001011021031041051064 unmodified lines1111121131141151161171181191201211221231241251261271281291301311321331341351361376 unmodified lines14414514614714814915015115215315415515633 unmodified lines#fileInput {margin-top: 20px;}.create-button {color: white;background-color: #4CAF50;border: none;3 unmodified linesborder-radius: 5px;margin-top: 20px;}.create-button:hover {background-color: #388E3C;}.group-id-container {margin-top: 20px;}.group-id {color: #4CAF50;cursor: pointer;font-size: 16px;}.group-id:hover {text-decoration: underline;}</style><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/toastify-js"></script></head><body><h1>Create Group with Members</h1>2 unmodified lines<input type="text" id="groupNameInput" placeholder="Enter group name"></div><input type="file" id="fileInput" accept=".txt"><button class="create-button" id="createGroupButton">Create Group</button><div class="group-id-container"><span class="group-id" id="groupIdToCopy" onclick="copyToClipboard(this)">Click here to copy the group ID</span></div>6 unmodified linesconst file = fileInput.files[0];if (!apiKey || !groupName || !file) {Toastify({text: "Please enter an API key, group name, and select a file.",duration: 3000,gravity: "top",position: "right",backgroundColor: "red",}).showToast();return;}const reader = new FileReader();reader.onload = async function(event) {const text = event.target.result;const chatIds = text.split('\n').map(line => line.trim() + '@c.us').filter(line => line);const payload = {groupName: groupName,chatIds: chatIds};try {const url = `https://api.green-api.com/waInstance1101952913/createGroup/${apiKey}`;const response = await fetch(url, {4 unmodified linesbody: JSON.stringify(payload)});if (!response.ok) {throw new Error(`HTTP error! status: ${response.status}`);}const data = await response.json();document.getElementById('groupIdToCopy').innerText = data.chatId;Toastify({text: "Group created successfully!",duration: 3000,gravity: "top",position: "right",backgroundColor: "green",}).showToast();} catch (error) {Toastify({text: "Error creating group.",duration: 3000,gravity: "top",position: "right",backgroundColor: "red",}).showToast();}};reader.readAsText(file);6 unmodified linestempInput.select();document.execCommand('copy');document.body.removeChild(tempInput);Toastify({text: "Group ID copied to clipboard!",duration: 3000,gravity: "top",position: "right",backgroundColor: "green",}).showToast();}</script></body>33 unmodified lines343536373839403 unmodified lines4445464748495051525354555657585960616263642 unmodified lines676869707172736 unmodified lines80818283848586878889909192939495969798991001011021031041051061071081094 unmodified lines1141151161171181191201211221231241251261271281291301311321331346 unmodified lines14114214314414514614733 unmodified lines#fileInput {margin-top: 20px;}#createGroupButton {color: white;background-color: #4CAF50;border: none;3 unmodified linesborder-radius: 5px;margin-top: 20px;}#createGroupButton:hover {background-color: #388E3C;}.group-id-container {margin-top: 20px;}.group-id {display: inline-block;padding: 10px;background-color: #fff;border: 1px solid #ccc;border-radius: 5px;cursor: pointer;}</style></head><body><h1>Create Group with Members</h1>2 unmodified lines<input type="text" id="groupNameInput" placeholder="Enter group name"></div><input type="file" id="fileInput" accept=".txt"><button id="createGroupButton">Create Group</button><div class="group-id-container"><span class="group-id" id="groupIdToCopy" onclick="copyToClipboard(this)">Click here to copy the group ID</span></div>6 unmodified linesconst file = fileInput.files[0];if (!apiKey || !groupName || !file) {alert('Please enter an API key, group name, and select a file.');return;}const reader = new FileReader();reader.onload = async function(event) {const text = event.target.result;const chatIds = text.split('\n').map(line => line.trim()).filter(line => line && /^\d+$/.test(line)).map(line => line + '@c.us');if (chatIds.length === 0) {alert('The file must contain valid phone numbers.');return;}const payload = {groupName: groupName,chatIds: chatIds};console.log('Payload:', payload);try {const url = `https://api.green-api.com/waInstance1101952913/createGroup/${apiKey}`;const response = await fetch(url, {4 unmodified linesbody: JSON.stringify(payload)});console.log('Response status:', response.status);if (!response.ok) {const errorText = await response.text();console.error('Error response:', errorText);throw new Error(`HTTP error! status: ${response.status} - ${errorText}`);}const data = await response.json();document.getElementById('groupIdToCopy').innerText = data.chatId;alert('Group created successfully!');console.log('Response JSON:', data);} catch (error) {console.error('Error creating group:', error);alert('Error creating group.');}};reader.readAsText(file);6 unmodified linestempInput.select();document.execCommand('copy');document.body.removeChild(tempInput);alert('Group ID copied to clipboard!');}</script></body>
up_gr.html+30-39