diff options
| author | 2019-10-16 15:53:34 +0100 | |
|---|---|---|
| committer | 2019-10-16 15:53:34 +0100 | |
| commit | 4a4a0ac45b8e151b8a873dc41e408b8e29c654ad (patch) | |
| tree | f7e719464b0278a599dbdcddfc3e4df0b589557e /modules | |
| parent | also catch m.youtube.com urls (diff) | |
| signature | ||
dont fail !weather when we decide a nickname is a location
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/weather.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/modules/weather.py b/modules/weather.py index df246690..a11891cc 100644 --- a/modules/weather.py +++ b/modules/weather.py @@ -25,15 +25,15 @@ class Module(ModuleManager.BaseModule): api_key = self.bot.config["openweathermap-api-key"] location = None + query = None nickname = None if event["args"]: + query = event["args"] if len(event["args_split"]) == 1 and event["server"].has_user_id( event["args_split"][0]): target_user = event["server"].get_user(event["args_split"][0]) location = self._user_location(target_user) - if location == None: - location = event["args_split"][0] - else: + if not location == None: nickname = target_user.nickname else: location = self._user_location(event["user"]) @@ -44,12 +44,13 @@ class Module(ModuleManager.BaseModule): args = {"units": "metric", "APPID": api_key} + if location == None and query: + location_info = self.exports.get_one("get-location")(query) + if not location_info == None: + location = [location_info["lat"], location_info["lon"], + location_info.get("name", None)] if location == None: - location_info = self.exports.get_one("get-location")(event["args"]) - if location_info == None: - raise utils.EventError("Unknown location") - location = [location_info["lat"], location_info["lon"], - location_info.get("name", None)] + raise utils.EventError("Unknown location") lat, lon, location_name = location args["lat"] = lat |
