Make .tfw only work for zip codes
parent
c1a847c8a5
commit
6bd9a15343
|
@ -11,7 +11,12 @@ import lxml.html
|
||||||
|
|
||||||
def tfw(phenny, input):
|
def tfw(phenny, input):
|
||||||
zipcode = input.group(2)
|
zipcode = input.group(2)
|
||||||
zipcode = int(zipcode)
|
|
||||||
|
try:
|
||||||
|
zipcode = int(zipcode)
|
||||||
|
except ValueError:
|
||||||
|
phenny.say("Sorry, .tfw only supports zip codes")
|
||||||
|
return
|
||||||
|
|
||||||
req = urlopen("http://thefuckingweather.com/?zipcode=%d" % zipcode)
|
req = urlopen("http://thefuckingweather.com/?zipcode=%d" % zipcode)
|
||||||
doc = lxml.html.parse(req)
|
doc = lxml.html.parse(req)
|
||||||
|
@ -36,7 +41,7 @@ def tfw(phenny, input):
|
||||||
|
|
||||||
response = "%s %s - %s - %s" % (temp, comment, remark, location)
|
response = "%s %s - %s - %s" % (temp, comment, remark, location)
|
||||||
phenny.say(response)
|
phenny.say(response)
|
||||||
tfw.rule = (['tfw'], r'(.*)')
|
tfw.rule = (['tfw'], r'(\d*)')
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print __doc__.strip()
|
print __doc__.strip()
|
||||||
|
|
Loading…
Reference in New Issue