Change location.py to use lat/lon instead of continent/country/city
This commit is contained in:
parent
74ef18a418
commit
3fce209a99
2 changed files with 6 additions and 9 deletions
|
@ -16,10 +16,7 @@ class Module(ModuleManager.BaseModule):
|
||||||
if page and page.data["results"]:
|
if page and page.data["results"]:
|
||||||
result = page.data["results"][0]
|
result = page.data["results"][0]
|
||||||
timezone = result["annotations"]["timezone"]["name"]
|
timezone = result["annotations"]["timezone"]["name"]
|
||||||
continent = result["components"]["continent"]
|
lat = result["geometry"]["lat"]
|
||||||
country = result["components"]["country"]
|
lon = result["geometry"]["lng"]
|
||||||
city = result["components"]["city"]
|
|
||||||
|
|
||||||
print("yes")
|
return {"timezone": timezone, "lat": lat, "lon": lon}
|
||||||
return {"timezone": timezone, "continent": continent,
|
|
||||||
"country": country, "city": city}
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ class Module(ModuleManager.BaseModule):
|
||||||
def _user_location(self, user):
|
def _user_location(self, user):
|
||||||
user_location = user.get_setting("location", None)
|
user_location = user.get_setting("location", None)
|
||||||
if not user_location == None:
|
if not user_location == None:
|
||||||
return "%s, %s" % (user_location["city"], user_location["country"])
|
return [user_location["lat"], user_location["lon"]]
|
||||||
|
|
||||||
@utils.hook("received.command.w", alias_of="weather")
|
@utils.hook("received.command.w", alias_of="weather")
|
||||||
@utils.hook("received.command.weather")
|
@utils.hook("received.command.weather")
|
||||||
|
@ -31,9 +31,9 @@ class Module(ModuleManager.BaseModule):
|
||||||
if location == None:
|
if location == None:
|
||||||
raise utils.EventError("You don't have a location set")
|
raise utils.EventError("You don't have a location set")
|
||||||
|
|
||||||
|
lat, lon = location
|
||||||
page = utils.http.request(URL_WEATHER, get_params={
|
page = utils.http.request(URL_WEATHER, get_params={
|
||||||
"q": location, "units": "metric",
|
"units": "metric", "lat": lat, "lon": lon, "APPID": api_key},
|
||||||
"APPID": api_key},
|
|
||||||
json=True)
|
json=True)
|
||||||
if page:
|
if page:
|
||||||
if "weather" in page.data:
|
if "weather" in page.data:
|
||||||
|
|
Loading…
Reference in a new issue