diff --git a/modules/Weather.py b/modules/Weather.py index c884f32..a29f26c 100644 --- a/modules/Weather.py +++ b/modules/Weather.py @@ -111,9 +111,22 @@ class Weather(Module): # just see if we have current_observation data current = condition_data['current_observation'] except KeyError as e: - self.log.error("error or bad query in conditions lookup") - self.log.exception(e) - return "No results." + # ok, try to see if the ambiguous results stuff will help + self.log.debug("potentially ambiguous results, checking") + try: + results = condition_data['response']['results'] + reply = "Multiple results, try one of the following zmw codes:" + for res in results[:-1]: + q = res['l'].strip('/q/') + reply += " {0:s} ({1:s}),".format(q, res['name']) + q = results[-1]['l'].strip('/q/') + reply += " or {0:s} ({1:s}).".format(q, results[-1]['name']) + return reply + except KeyError as e: + # now we really know something is wrong + self.log.error("error or bad query in conditions lookup") + self.log.exception(e) + return "No results." else: try: location = current['display_location']['full']