Weather: give hints when results are ambiguous
This commit is contained in:
parent
b17de69a93
commit
41c1a46bb2
@ -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']
|
||||
|
Loading…
Reference in New Issue
Block a user