.BANCHO. .FIX. More location api checks, this _should_ fix clients stuck at 'singing in'

This commit is contained in:
Nyo 2016-05-17 21:18:03 +02:00
parent 363e272d3f
commit afa6fa8563
2 changed files with 7 additions and 14 deletions

View File

@ -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]

View File

@ -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)