From d43cef654340783fda49bc7eea5f772ac6d80080 Mon Sep 17 00:00:00 2001 From: jesopo Date: Tue, 18 Jun 2019 16:36:22 +0100 Subject: Save location name from geocoding, use it for !w when available closes #71 --- modules/weather.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'modules/weather.py') diff --git a/modules/weather.py b/modules/weather.py index 202eb0fb..aa93d7f4 100644 --- a/modules/weather.py +++ b/modules/weather.py @@ -49,10 +49,13 @@ class Module(ModuleManager.BaseModule): page = utils.http.request(URL_WEATHER, get_params=args, json=True) if page: if "weather" in page.data: - location_parts = [page.data["name"]] - if "country" in page.data["sys"]: - location_parts.append(page.data["sys"]["country"]) - location_str = ", ".join(location_parts) + if "name" in location: + location_str = location["name"] + else: + location_parts = [page.data["name"]] + if "country" in page.data["sys"]: + location_parts.append(page.data["sys"]["country"]) + location_str = ", ".join(location_parts) celsius = "%dC" % page.data["main"]["temp"] fahrenheit = "%dF" % ((page.data["main"]["temp"]*(9/5))+32) -- cgit v1.3.1-10-gc9f91