Skip to content

Instantly share code, notes, and snippets.

@ZribeDev
Last active April 4, 2024 08:27
Show Gist options
  • Save ZribeDev/de3cd654c4a61be18b0243a6e6ee92b5 to your computer and use it in GitHub Desktop.
Save ZribeDev/de3cd654c4a61be18b0243a6e6ee92b5 to your computer and use it in GitHub Desktop.
Pterodactyl Panel - Remove all servers on a node
# MIT License
#
# Copyright (c) 2024 ZribeDev
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import requests
import json
import time
nodenum = input("Node ID: ")
url = input("URL: ")
apikey = input("API Key (Application): ")
url = f'{url}/api/application/servers'
headers = {
"Authorization": f"Bearer {apikey}",
"Accept": "application/json",
"Content-Type": "application/json"
}
servers_on_node = []
page = 1
while True:
params = {'page': page}
response = requests.get(url, headers=headers, params=params)
data = response.json()
if 'data' in data and len(data['data']) > 0:
servers_on_node.extend([server for server in data['data'] if server['attributes']['node'] == nodenum])
page += 1
else:
break
server_count = len(servers_on_node)
identifiers = [server['attributes']['id'] for server in servers_on_node]
with open('server_identifiers.json', 'w') as file:
json.dump(identifiers, file)
print("Server count on node:", server_count)
time.sleep(1)
print("Deleting servers.")
time.sleep(1)
url2 = f'{url}/api/application/servers/{id}'
headers = {
"Authorization": f"Bearer {apikey}",
"Accept": "application/json",
"Content-Type": "application/json"
}
with open('server_identifiers.json', 'r') as file:
identifiers = json.load(file)
for identifier in identifiers:
request_url = url2.replace('{id}', str(identifier))
response = requests.delete(request_url, headers=headers)
print(f"Deleted identifier {identifier}: {response.text}")
@IkdanYT
Copy link

IkdanYT commented Mar 31, 2024

You can't even tell the difference between two codes that are completely different?

they are the same just a diff language. its even the same file for servers ids server_identifiers

Just because it's convenient) And there are no more similarities, right?)
For example, the fact that my servers are being deleted using the /force method, as well as an improved page search method, which is more optimized.
Also, my code has huge differences with yours. because according to your logic, the one who first wrote the discord bot with the command /ping (example) can throw a report on someone else's repositories with the same command, lol

@ZribeDev
Copy link
Author

ZribeDev commented Mar 31, 2024 via email

@IkdanYT
Copy link

IkdanYT commented Apr 3, 2024

There is a diffrence. You used my project, it is the same code just modified. That's still not allowed.

On Sun, Mar 31, 2024, 22:36 IkdanYT @.> wrote: @.* commented on this gist. ------------------------------ You can't even tell the difference between two codes that are completely different? they are the same just a diff language. its even the same file for servers ids server_identifiers Just because it's convenient) And there are no more similarities, right?) For example, the fact that my servers are being deleted using the /force method, as well as an improved page search method, which is more optimized. Also, my code has huge differences with yours. because according to your logic, the one who first wrote the discord bot with the command /ping (example) can throw a report on someone else's repositories with the same command, lol — Reply to this email directly, view it on GitHub https://gist.github.com/ZribeDev/de3cd654c4a61be18b0243a6e6ee92b5#gistcomment-5007378 or unsubscribe https://github.com/notifications/unsubscribe-auth/APZEYETYUBLGKFJA3ZRSASLY3BQVJBFKMF2HI4TJMJ2XIZLTSKBKK5TBNR2WLJDUOJ2WLJDOMFWWLO3UNBZGKYLEL5YGC4TUNFRWS4DBNZ2F6YLDORUXM2LUPGBKK5TBNR2WLJDHNFZXJJDOMFWWLK3UNBZGKYLEL52HS4DFVRZXKYTKMVRXIX3UPFYGLK2HNFZXIQ3PNVWWK3TUUZ2G64DJMNZZDAVEOR4XAZNEM5UXG5FFOZQWY5LFVEYTEMZVG44DKMBSU52HE2LHM5SXFJTDOJSWC5DF . You are receiving this email because you authored the thread. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub .

I'm waiting for the repository to be blocked or deleted if you're such a little crybaby)
Prove that you are not a windbag

@ZribeDev
Copy link
Author

ZribeDev commented Apr 4, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment