From f3c80c2ba74349c860f4e1a5287d526f4a5bc76e Mon Sep 17 00:00:00 2001 From: mutantmonkey Date: Wed, 8 Dec 2010 22:00:54 -0500 Subject: [PATCH] Added documentation and Celsius support to .tfw --- modules/tfw.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/tfw.py b/modules/tfw.py index 687db7d..0c956e2 100755 --- a/modules/tfw.py +++ b/modules/tfw.py @@ -10,14 +10,21 @@ from urllib import quote as urlquote from urllib2 import urlopen, HTTPError import lxml.html -def tfw(phenny, input): +def tfw(phenny, input, celsius=False): + """.tfw - Show the fucking weather at the specified location.""" + zipcode = input.group(2) if not zipcode: # default to Blacksburg, VA zipcode = "24060" + if celsius: + celsius_param = "&CELSIUS=yes" + else: + celsius_param = "" + try: - req = urlopen("http://thefuckingweather.com/?zipcode=%s" % urlquote(zipcode)) + req = urlopen("http://thefuckingweather.com/?zipcode=%s%s" % (urlquote(zipcode), celsius_param)) except HTTPError: phenny.say("THE INTERNET IS FUCKING BROKEN. Please try again later.") return @@ -51,6 +58,11 @@ def tfw(phenny, input): phenny.say(response) tfw.rule = (['tfw'], r'(.*)') +def tfwc(phenny, input): + """.tfwc - The fucking weather, in fucking celsius.""" + return tfw(phenny, input, True) +tfwc.rule = (['tfwc'], r'(.*)') + if __name__ == '__main__': print __doc__.strip()