use reverse geocoding to turn location to latlon for weather

This commit is contained in:
jesopo 2019-07-16 16:42:32 +01:00
parent 759324bb65
commit 69bab50335

View file

@ -44,13 +44,17 @@ class Module(ModuleManager.BaseModule):
args = {"units": "metric", "APPID": api_key}
location_name = None
if location:
lat, lon, location_name = location
args["lat"] = lat
args["lon"] = lon
else:
args["q"] = event["args"]
if location == None:
location_info = self.exports.get_one("get-location")(event["args"])
if location_info == None:
raise utils.EventError("Unknown location")
location = [location_info["lat"], location_info["lon"],
location_info.get("name", None)]
lat, lon, location_name = location
args["lat"] = lat
args["lon"] = lon
page = utils.http.request(URL_WEATHER, get_params=args, json=True)
if page: