diff --git a/locationHelper.py b/locationHelper.py index ab1f73a..d3c0306 100644 --- a/locationHelper.py +++ b/locationHelper.py @@ -21,11 +21,11 @@ def getCountry(ip): try: # Try to get country from Pikolo Aul's Go-Sanic ip API - country = json.loads(urllib.request.urlopen("{}/{}".format(URL, ip), timeout=3).read().decode())["country"] + result = json.loads(urllib.request.urlopen("{}/{}".format(URL, ip), timeout=3).read().decode())["country"] + return result.upper() except: consoleHelper.printColored("[!] Error in get country", bcolors.RED) - - return country.upper() + return "XX" def getLocation(ip): @@ -41,8 +41,8 @@ def getLocation(ip): try: # Try to get position from Pikolo Aul's Go-Sanic ip API - data = json.loads(urllib.request.urlopen("{}/{}".format(URL, ip), timeout=3).read().decode())["loc"].split(",") + result = json.loads(urllib.request.urlopen("{}/{}".format(URL, ip), timeout=3).read().decode())["loc"].split(",") + return [float(result[0]), float(result[1])] except: consoleHelper.printColored("[!] Error in get position", bcolors.RED) - - return [float(data[0]), float(data[1])] + return [0,0] diff --git a/loginEvent.py b/loginEvent.py index 74b14f5..15855a4 100644 --- a/loginEvent.py +++ b/loginEvent.py @@ -123,14 +123,7 @@ def handle(flaskRequest): responseToken.enqueue(serverPackets.onlineUsers()) # Get location and country from ip.zxq.co or database - if generalFunctions.stringToBool(glob.conf.config["server"]["localizeusers"]): - # Make sure this user has not disabled his country flag - #if userHelper.getShowCountry(userID) == False: - # location = [0,0] - # countryLetters = "XX" - # country = 0 - #else: - + if generalFunctions.stringToBool(glob.conf.config["server"]["localizeusers"]): # Get location and country from IP location = locationHelper.getLocation(requestIP) countryLetters = locationHelper.getCountry(requestIP)