Skip to content

Commit 7af790a

Browse files
committed
GeoIP now correctly handles queries with no region, fixes #90
1 parent e9e9048 commit 7af790a

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

plugins/geoip.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,11 @@ def geoip(text, reply, loop):
9292
data = {
9393
"cc": location_data.country.iso_code or "N/A",
9494
"country": location_data.country.name or "Unknown",
95-
"city": location_data.city.name or "Unknown",
96-
"region": ", " + location_data.subdivisions.most_specific.name or ""
95+
"city": location_data.city.name or "Unknown"
9796
}
9897

99-
reply("\x02Country:\x02 {country} ({cc}), \x02City:\x02 {city}{region}".format(**data))
98+
# add a region to the city if one is listed
99+
if location_data.subdivisions.most_specific.name:
100+
data["city"] += ", " + location_data.subdivisions.most_specific.name
101+
102+
reply("\x02Country:\x02 {country} ({cc}), \x02City:\x02 {city}".format(**data))

0 commit comments

Comments
 (0)