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()