X-Git-Url: https://jfr.im/git/erebus.git/blobdiff_plain/4d8427458a6c049d50fd1cb49f258856a9cd1486..79519d5abd251267436256b6cc41f36872f39dbe:/modules/weatherstack_weather.py?ds=sidebyside diff --git a/modules/weatherstack_weather.py b/modules/weatherstack_weather.py index a79ff78..d6140d1 100644 --- a/modules/weatherstack_weather.py +++ b/modules/weatherstack_weather.py @@ -1,6 +1,6 @@ # Erebus IRC bot - Author: Erebus Team # vim: fileencoding=utf-8 -# weather module +# weather module (from WeatherStack, boo) # This file is released into the public domain; see http://unlicense.org/ # module info @@ -53,7 +53,10 @@ def _weather(place): return "Weather is not enabled - please set the API key in the config file" if place is not None: - weather = json.load(urlopen(('http://api.weatherstack.com/current?access_key=%s&query=%s' % (lib.parent.cfg.get('weatherstack_weather', 'key'), quote_plus(place))).encode('utf8'))) + url = 'http://api.weatherstack.com/current?access_key=%s&query=%s' % (lib.parent.cfg.get('weatherstack_weather', 'key'), quote_plus(place)) + if sys.version_info.major < 3: + url = url.encode('utf8') + weather = json.load(urlopen(url)) if lib.parent.cfg.getboolean('debug', 'weather'): lib.parent.log('*', "?", repr(weather)) if 'error' in weather: