diff options
| author | 2018-08-31 10:51:47 +0100 | |
|---|---|---|
| committer | 2018-08-31 10:51:47 +0100 | |
| commit | 90ce92dc39395444862edfc7946ef7a1195f2464 (patch) | |
| tree | 6832c146a15879df292d265083bfe5795cbdfa69 /modules/weather.py | |
| parent | Reformat (diff) | |
Revert "Reformat"
This reverts commit abed9cf
Diffstat (limited to 'modules/weather.py')
| -rw-r--r-- | modules/weather.py | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/modules/weather.py b/modules/weather.py index ee3c79b9..53fce200 100644 --- a/modules/weather.py +++ b/modules/weather.py @@ -1,10 +1,9 @@ -# --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 @@ -18,23 +17,22 @@ 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") |
