diff options
| author | 2018-12-11 22:26:38 +0000 | |
|---|---|---|
| committer | 2018-12-11 22:26:38 +0000 | |
| commit | 793d234a0b924c0330e88f07f68b13559b42e4ac (patch) | |
| tree | 90ecd3746a77e17da915f90ec057cb16ead82c05 /modules/weather.py | |
| parent | Actually use `action_desc` in github.py.issues, so that we can see what things (diff) | |
'utils.http.get_url' -> 'utils.http.request', return a Response object from
utils.http.request
Diffstat (limited to 'modules/weather.py')
| -rw-r--r-- | modules/weather.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/modules/weather.py b/modules/weather.py index b5d79a8a..ddf7a1a6 100644 --- a/modules/weather.py +++ b/modules/weather.py @@ -12,19 +12,19 @@ class Module(ModuleManager.BaseModule): :usage: <location> """ api_key = self.bot.config["openweathermap-api-key"] - page = utils.http.get_url(URL_WEATHER, get_params={ + page = utils.http.request(URL_WEATHER, get_params={ "q": event["args"], "units": "metric", "APPID": api_key}, json=True) if page: - if "weather" in page: - location = "%s, %s" % (page["name"], page["sys"][ + if "weather" in page.data: + location = "%s, %s" % (page.data["name"], page.data["sys"][ "country"]) - celsius = "%dC" % page["main"]["temp"] - 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"] + celsius = "%dC" % page.data["main"]["temp"] + fahrenheit = "%dF" % ((page.data["main"]["temp"]*(9/5))+32) + description = page.data["weather"][0]["description"].title() + humidity = "%s%%" % page.data["main"]["humidity"] + wind_speed = "%sKM/h" % page.data["wind"]["speed"] event["stdout"].write( "(%s) %s/%s | %s | Humidity: %s | Wind: %s" % ( |
