From bde1c4378061ca01e2b08fd799538cf9285170bd Mon Sep 17 00:00:00 2001 From: mutantmonkey Date: Thu, 1 Sep 2011 00:50:14 -0400 Subject: [PATCH] add my life is bro module --- modules/mlib.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 modules/mlib.py diff --git a/modules/mlib.py b/modules/mlib.py new file mode 100755 index 0000000..a74f854 --- /dev/null +++ b/modules/mlib.py @@ -0,0 +1,31 @@ +#!/usr/bin/python2 +""" +mlib.py - my life is bro retrieval +author: Ramblurr +author: mutantmonkey +""" + +import random + +from urllib import quote as urlquote +from urllib2 import urlopen, HTTPError +import lxml.html + +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 + + 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() +