Rework geoip to include ccode, lat, long for cache purposes

This commit is contained in:
Gregory Danielson 2020-11-15 10:57:53 -06:00
parent 88cd84b5d2
commit e8cc9adc7f
No known key found for this signature in database
GPG key ID: 88D4EF22F6C14CA7

View file

@ -165,10 +165,11 @@ def ipinfo(ip_addr):
def geoip(ip_addr):
try:
response = GEOIP_READER.city(ip_addr)
city, region, country = response.city.name, response.subdivisions.name, response.country.name
city, region, country, ccode, lat, long = response.city.name, response.subdivisions.name, response.country.name, response.country.iso_code, response.location.latitude, response.location.longitude
except geoip2.errors.AddressNotFoundError:
return None, None, None
return city, region, country
return None
return city, region, country, ccode, lat, long
def workaround(country):
# workaround for strange bug with the country name