From 8d54baa90127a719fcd3ba5e3b2f389e25a490b9 Mon Sep 17 00:00:00 2001 From: mutantmonkey Date: Fri, 2 Sep 2011 00:56:55 -0400 Subject: [PATCH] add another mylife module --- modules/mylife.py | 94 +++++++++++++++++++++++++++-------------------- 1 file changed, 55 insertions(+), 39 deletions(-) diff --git a/modules/mylife.py b/modules/mylife.py index ca0ffbc..b9d1a36 100644 --- a/modules/mylife.py +++ b/modules/mylife.py @@ -11,58 +11,74 @@ 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 + """.fml""" + try: + req = urlopen("http://www.fmylife.com/random") + except HTTPError: + phenny.say("I tried to use .fml, but it was broken. FML" + return - doc = lxml.html.parse(req) - quote = doc.getroot().find_class('article')[0][0].text_content() - phenny.say(quote) + doc = lxml.html.parse(req) + quote = doc.getroot().find_class('article')[0][0].text_content() + phenny.say(quote) fml.commands = ['fml'] def mlia(phenny, input): - """.mlia""" - try: - req = urlopen("http://mylifeisaverage.com/") - except HTTPError: - phenny.say("THE INTERNET IS FUCKING BROKEN. Please try again later.") - return + """.mlia - My life is average.""" + try: + req = urlopen("http://mylifeisaverage.com/") + except HTTPError: + phenny.say("I tried to use .mlia, but it wasn't loading. MLIA") + return - doc = lxml.html.parse(req) - quote = doc.getroot().find_class('story')[0][0].text_content() - quote = quote.strip() - phenny.say(quote) + doc = lxml.html.parse(req) + quote = doc.getroot().find_class('story')[0][0].text_content() + quote = quote.strip() + phenny.say(quote) mlia.commands = ['mlia'] -def mlih(phenny, input): - """.mlih""" - try: - req = urlopen("http://mylifeisho.com/random") - except HTTPError: - phenny.say("THE INTERNET IS FUCKING BROKEN. Please try again later.") - return +def mliarab(phenny, input): + """.mliarab - My life is Arabic.""" + try: + req = urlopen("http://mylifeisarabic.com/random/") + except HTTPError: + phenny.say("The site you requested, mylifeisarabic.com, has been banned \ + in the UAE. You will be reported to appropriate authorities") + return - doc = lxml.html.parse(req) - quote = doc.getroot().find_class('storycontent')[0][0].text_content() - phenny.say(quote) + doc = lxml.html.parse(req) + quote = doc.getroot().find_class('entry')[0][0].text_content() + quote = quote.strip() + phenny.say(quote) +mliarab.commands = ['mliarab'] + + +def mlih(phenny, input): + """.mlih - My life is ho.""" + try: + req = urlopen("http://mylifeisho.com/random") + except HTTPError: + phenny.say("MLIH is giving some dome to some lax bros.") + return + + doc = lxml.html.parse(req) + quote = doc.getroot().find_class('storycontent')[0][0].text_content() + phenny.say(quote) mlih.commands = ['mlih'] def mlib(phenny, input): - """.mlib""" - try: - req = urlopen("http://mylifeisbro.com/random") - except HTTPError: - phenny.say("MLIB is out getting a case of Natty. It's chill.") - return + """.mlib""" + try: + req = urlopen("http://mylifeisbro.com/random") + except HTTPError: + phenny.say("MLIB is out getting a case of Natty. It's chill.") + return - doc = lxml.html.parse(req) - quote = doc.getroot().find_class('storycontent')[0][0].text_content() - phenny.say(quote) + doc = lxml.html.parse(req) + quote = doc.getroot().find_class('storycontent')[0][0].text_content() + phenny.say(quote) mlib.commands = ['mlib'] if __name__ == '__main__': - print __doc__.strip() + print __doc__.strip()