aboutsummaryrefslogtreecommitdiff
path: root/modules/weather.py
diff options
context:
space:
mode:
authorGravatar dngfx2018-08-31 10:50:37 +0100
committerGravatar dngfx2018-08-31 10:50:37 +0100
commitabed9cf4ea71dcbad2dd2c049683b8d14b942e09 (patch)
tree3e40caf63fa7e1500469f4ad9a0c45c51808aad4 /modules/weather.py
parentFix a copy paste fail in IRCLineHandler that caused PARTs to be handled as QUITs (diff)
signature
Reformat
Diffstat (limited to 'modules/weather.py')
-rw-r--r--modules/weather.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/modules/weather.py b/modules/weather.py
index 53fce200..ee3c79b9 100644
--- a/modules/weather.py
+++ b/modules/weather.py
@@ -1,9 +1,10 @@
-#--require-config openweathermap-api-key
+# --require-config openweathermap-api-key
import Utils
URL_WEATHER = "http://api.openweathermap.org/data/2.5/weather"
+
class Module(object):
def __init__(self, bot):
self.bot = bot
@@ -17,22 +18,23 @@ class Module(object):
page = Utils.get_url(URL_WEATHER, get_params={
"q": event["args"], "units": "metric",
"APPID": api_key},
- json=True)
+ json=True)
if page:
if "weather" in page:
location = "%s, %s" % (page["name"], page["sys"][
"country"])
celsius = "%dC" % page["main"]["temp"]
- fahrenheit = "%dF" % ((page["main"]["temp"]*(9/5))+32)
+ fahrenheit = "%dF" % ((page["main"]["temp"] * (9 / 5)) + 32)
description = page["weather"][0]["description"].title()
humidity = "%s%%" % page["main"]["humidity"]
wind_speed = "%sKM/h" % page["wind"]["speed"]
event["stdout"].write(
"(%s) %s/%s | %s | Humidity: %s | Wind: %s" % (
- location, celsius, fahrenheit, description, humidity,
- wind_speed))
+ location, celsius, fahrenheit, description, humidity,
+ wind_speed))
else:
- event["stderr"].write("No weather information for this location")
+ event["stderr"].write(
+ "No weather information for this location")
else:
event["stderr"].write("Failed to load results")