From 569862a227b4c44818fc4efa23ef9733530b024c Mon Sep 17 00:00:00 2001 From: Casey Link Date: Sat, 30 Jul 2011 01:51:10 -0400 Subject: [PATCH] Add fml module --- modules/fml.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 modules/fml.py diff --git a/modules/fml.py b/modules/fml.py new file mode 100755 index 0000000..c0d1c92 --- /dev/null +++ b/modules/fml.py @@ -0,0 +1,30 @@ +#!/usr/bin/python2 +""" +fml.py - fuck my life retrieval +author: Ramblurr +""" + +import random + +from urllib import quote as urlquote +from urllib2 import urlopen, HTTPError +import lxml.html + +def fml(phenny, input): + """.fml""" + try: + req = urlopen("http://www.fmylife.com/random") + except HTTPError: + phenny.say("THE INTERNET IS FUCKING BROKEN. Please try again later.") + return + + doc = lxml.html.parse(req) + + quote = doc.getroot().find_class('article')[0][0].text_content() + + phenny.say(quote) +fml.commands = ['fml'] + +if __name__ == '__main__': + print __doc__.strip() +