tfw: handle unknown locations properly
parent
cd9f5ac8e2
commit
76c0feddb5
|
@ -30,12 +30,11 @@ def tfw(phenny, input, fahrenheit=False, celsius=False):
|
||||||
|
|
||||||
doc = lxml.html.fromstring(req)
|
doc = lxml.html.fromstring(req)
|
||||||
|
|
||||||
location = doc.find_class('small')[0].text_content()
|
try:
|
||||||
|
location = doc.find_class('small')[0].text_content()
|
||||||
try:
|
|
||||||
weather = doc.get_element_by_id('content')
|
weather = doc.get_element_by_id('content')
|
||||||
except KeyError:
|
except (IndexError, KeyError):
|
||||||
phenny.say("Unknown location")
|
phenny.say("UNKNOWN FUCKING LOCATION. Try another?")
|
||||||
return
|
return
|
||||||
|
|
||||||
main = weather.find_class('large')
|
main = weather.find_class('large')
|
||||||
|
|
Loading…
Reference in New Issue