· 5 years ago · Jun 17, 2020, 04:08 AM
1# -*- coding: UTF-8 -*-
2import requests
3import time
4import json
5
6# Go to Hypixel and type /api for your API key.
7# Enter Your Api in The " " below (It's only for Hypixel to know who is sending requests to their API site)
8key = ""
9apifg = "https://api.hypixel.net/findGuild"
10apigl = "https://api.hypixel.net/guild"
11apifl = "https://api.hypixel.net/friends"
12
13# Put your Guild's UUID Key Here
14# Will Put Link in the Forum Post on how to get the Guild's UUID
15uuid_mm = ""
16
17def name2uuid(name):
18 getReq = requests.get(url="https://playerdb.co/api/player/minecraft/" + name)
19 if getReq.content == "":
20 print("[ERROR] Empty Response.")
21 return ""
22 getJson = json.loads(getReq.content.decode('utf-8'))
23 if getJson["success"] != True:
24 print("[ERROR] Name->UUID API Failed.")
25 print('Attempted Name: ', name)
26 print(getJson)
27 return ""
28 ret = getJson["data"]["player"]["raw_id"]
29 return ret
30
31
32def uuid2name(uuid):
33 getReq = requests.get(url="https://playerdb.co/api/player/minecraft/" + uuid)
34 if getReq.content == "":
35 print("[ERROR] Empty Response.")
36 return ""
37 getJson = json.loads(getReq.content.decode('utf-8'))
38 if getJson["success"] != True:
39 print("[ERROR] API Failed. Response:")
40 print(getJson)
41 print("Attempted uuid: ", uuid)
42 return ""
43 ret = getJson["data"]["player"]["username"]
44 return ret
45
46
47def getGuildMember(uuid) :
48 AcReq = requests.get(url = apigl, params = {"key": key, "id": uuid_mm})
49 AcJson = json.loads(AcReq.content.decode('utf-8'))
50 mbjson = AcJson["guild"]["members"]
51 ret = []
52 for i in range(0, len(mbjson)) :
53 ret.append(mbjson[i]["uuid"])
54 return ret
55
56mm_memb = getGuildMember(uuid_mm)
57print("Retrieved Guild Member Data.")
58
59
60def isPlayerInGuild(uuid):
61 if mm_memb.count(uuid) == 0:
62 return 0
63 else:
64 return 1
65
66
67def pullFriendData(uuid):
68 AcReq = requests.get(url=apifl, params={"key": key, "uuid": uuid})
69 AcJson = json.loads(AcReq.content.decode('utf-8'))
70 recordsJson = AcJson["records"]
71 ret = []
72 target = ""
73 for i in range(0, len(recordsJson)):
74 if recordsJson[i]["uuidSender"] == uuid:
75 target = recordsJson[i]["uuidReceiver"]
76 else:
77 target = recordsJson[i]["uuidSender"]
78 ret.append(target)
79 return ret
80
81
82tabList = []
83leecherList = []
84# Whitelisted Player APIs go here
85whiteList = [""]
86
87
88def getSuspect(uuid):
89 print("Leecher: ", uuid2name(uuid))
90 suspectList = pullFriendData(uuid)
91 for i in range(0, len(suspectList)):
92 if isPlayerInGuild(suspectList[i]):
93 if tabList.count(suspectList[i]):
94 print(" Suspect:", uuid2name(suspectList[i]), "(MM)")
95 else:
96 print(" Suspect:", uuid2name(suspectList[i]), "(MM)")
97 elif tabList.count(suspectList[i]):
98 print(" Related Leecher:", uuid2name(suspectList[i]))
99
100
101print("Converting All Names -> UUID...")
102# Make Notepad File Named list.txt and save it in the same file as this program. This allows the program to function without it getting too complicated.
103f = open("list.txt", "r")
104lines = f.readlines()
105for line in lines:
106 line = line.strip('\n')
107 puuid = name2uuid(line)
108 if puuid == "":
109 continue
110 if whiteList.count(puuid):
111 print("Ignoring whitelisted player: ", line)
112 continue
113 tabList.append(puuid)
114print("UUIDs retrieved, start checking...")
115
116for i in tabList:
117 if isPlayerInGuild(i) == 0:
118 leecherList.append(i)
119
120print("Total Leecher Count:", len(leecherList))
121
122for i in leecherList:
123 getSuspect(i)
124
125f.close()