aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorGravatar jesopo2019-06-18 16:34:51 +0100
committerGravatar jesopo2019-06-18 16:35:51 +0100
commit2ed1cf2e4a4aa5fceb9806b3374d404b3ca0c2f5 (patch)
treea8391b7262dc9efbacb27e3c36aef6a21071ca43 /modules
parentImplement `+bitbot.dev/mulitline-concat` to concat line to previous line (diff)
signature
Only try to show !w country when it is available. closes #72
Diffstat (limited to 'modules')
-rw-r--r--modules/weather.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/modules/weather.py b/modules/weather.py
index be3bb316..202eb0fb 100644
--- a/modules/weather.py
+++ b/modules/weather.py
@@ -49,8 +49,11 @@ class Module(ModuleManager.BaseModule):
page = utils.http.request(URL_WEATHER, get_params=args, json=True)
if page:
if "weather" in page.data:
- location = "%s, %s" % (page.data["name"], page.data["sys"][
- "country"])
+ 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)
description = page.data["weather"][0]["description"].title()
@@ -59,7 +62,7 @@ class Module(ModuleManager.BaseModule):
event["stdout"].write(
"(%s) %s/%s | %s | Humidity: %s | Wind: %s" % (
- location, celsius, fahrenheit, description, humidity,
+ location_str, celsius, fahrenheit, description, humidity,
wind_speed))
else:
event["stderr"].write("No weather information for this location")