phenny-1/modules/mylife.py

110 lines
3.0 KiB
Python
Raw Normal View History

#!/usr/bin/python2
"""
mylife.py - various commentary on life
author: Ramblurr <unnamedrambler@gmail.com>
"""
import random
from urllib import quote as urlquote
from urllib2 import urlopen, HTTPError
import lxml.html
def fml(phenny, input):
2011-09-02 00:56:55 -04:00
""".fml"""
try:
req = urlopen("http://www.fmylife.com/random")
except HTTPError:
2011-09-02 00:57:40 -04:00
phenny.say("I tried to use .fml, but it was broken. FML")
2011-09-02 00:56:55 -04:00
return
2011-09-02 00:56:55 -04:00
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):
2011-09-02 00:56:55 -04:00
""".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
2011-09-02 00:56:55 -04:00
doc = lxml.html.parse(req)
quote = doc.getroot().find_class('story')[0][0].text_content()
quote = quote.strip()
phenny.say(quote)
mlia.commands = ['mlia']
2011-09-02 00:56:55 -04:00
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('entry')[0][0].text_content()
quote = quote.strip()
phenny.say(quote)
mliarab.commands = ['mliarab']
2011-09-02 01:16:19 -04:00
def mlib(phenny, input):
""".mlib - My life is bro."""
2011-09-02 00:56:55 -04:00
try:
2011-09-02 01:16:19 -04:00
req = urlopen("http://mylifeisbro.com/random")
2011-09-02 00:56:55 -04:00
except HTTPError:
2011-09-02 01:16:19 -04:00
phenny.say("MLIB is out getting a case of Natty. It's chill.")
2011-09-02 00:56:55 -04:00
return
2011-09-02 00:56:55 -04:00
doc = lxml.html.parse(req)
quote = doc.getroot().find_class('storycontent')[0][0].text_content()
phenny.say(quote)
2011-09-02 01:16:19 -04:00
mlib.commands = ['mlib']
2011-09-02 01:16:19 -04:00
def mlid(phenny, input):
""".mlib - My life is Desi."""
2011-09-02 00:56:55 -04:00
try:
2011-09-02 01:16:19 -04:00
req = urlopen("http://www.mylifeisdesi.com/random")
2011-09-02 00:56:55 -04:00
except HTTPError:
2011-09-02 01:16:19 -04:00
phenny.say("MLID is busy at the hookah lounge, be back soon.")
return
doc = lxml.html.parse(req)
quote = doc.getroot().find_class('oldlink')[0].text_content()
phenny.say(quote)
mlid.commands = ['mlid']
def mlig(phenny, input):
""".mlig - My life is ginger."""
try:
req = urlopen("http://www.mylifeisginger.org/random")
except HTTPError:
phenny.say("Busy eating your soul. Be back soon.")
return
doc = lxml.html.parse(req)
quote = doc.getroot().find_class('oldlink')[0].text_content()
phenny.say(quote)
mlig.commands = ['mlig']
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.")
2011-09-02 00:56:55 -04:00
return
2011-09-02 00:56:55 -04:00
doc = lxml.html.parse(req)
quote = doc.getroot().find_class('storycontent')[0][0].text_content()
phenny.say(quote)
2011-09-02 01:16:19 -04:00
mlih.commands = ['mlih']
if __name__ == '__main__':
2011-09-02 00:56:55 -04:00
print __doc__.strip()