From 6bd9a1534353a5f2832f74aef3f7324dd1a1d8db Mon Sep 17 00:00:00 2001 From: mutantmonkey Date: Mon, 6 Dec 2010 17:39:08 -0500 Subject: [PATCH] Make .tfw only work for zip codes --- modules/tfw.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/tfw.py b/modules/tfw.py index beb17a1..be31644 100755 --- a/modules/tfw.py +++ b/modules/tfw.py @@ -11,7 +11,12 @@ import lxml.html def tfw(phenny, input): 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) doc = lxml.html.parse(req) @@ -36,7 +41,7 @@ def tfw(phenny, input): response = "%s %s - %s - %s" % (temp, comment, remark, location) phenny.say(response) -tfw.rule = (['tfw'], r'(.*)') +tfw.rule = (['tfw'], r'(\d*)') if __name__ == '__main__': print __doc__.strip()