phenny-1/modules/mylife.py

81 lines
2.1 KiB
Python
Raw Normal View History

#!/usr/bin/python3
"""
mylife.py - various commentary on life
author: Ramblurr <unnamedrambler@gmail.com>
2011-09-02 17:11:12 -04:00
author: mutantmonkey <mutantmonkey@mutantmonkey.in>
"""
from tools import GrumbleError
import web
import lxml.html
def fml(phenny, input):
2013-10-05 19:20:37 -04:00
""".fml - Grab something from fmylife.com."""
2011-09-02 00:56:55 -04:00
try:
req = web.get("http://www.fmylife.com/random")
2013-06-09 01:27:24 -04:00
except:
raise GrumbleError("I tried to use .fml, but it was broken. FML")
doc = lxml.html.fromstring(req)
quote = doc.find_class('article')[0][0].text_content()
2011-09-02 00:56:55 -04:00
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 = web.get("http://mylifeisaverage.com/")
2013-06-09 01:27:24 -04:00
except:
raise GrumbleError("I tried to use .mlia, but it wasn't loading. MLIA")
doc = lxml.html.fromstring(req)
quote = doc.find_class('story')[0][0].text_content()
2011-09-02 00:56:55 -04:00
quote = quote.strip()
phenny.say(quote)
mlia.commands = ['mlia']
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:
req = web.get("http://mylifeisbro.com/random")
2013-06-09 01:27:24 -04:00
except:
raise GrumbleError("MLIB is out getting a case of Natty. It's chill.")
doc = lxml.html.fromstring(req)
quote = doc.find_class('storycontent')[0][0].text_content()
2011-09-02 00:56:55 -04:00
phenny.say(quote)
2011-09-02 01:16:19 -04:00
mlib.commands = ['mlib']
2011-09-02 01:16:19 -04:00
def mlig(phenny, input):
""".mlig - My life is ginger."""
try:
req = web.get("http://www.mylifeisginger.org/random")
2013-06-09 01:27:24 -04:00
except:
raise GrumbleError("Busy eating your soul. Be back soon.")
2011-09-02 01:16:19 -04:00
doc = lxml.html.fromstring(req)
quote = doc.find_class('oldlink')[0].text_content()
2011-09-02 01:16:19 -04:00
phenny.say(quote)
mlig.commands = ['mlig']
2011-09-17 21:35:08 -04:00
def mlihp(phenny, input):
""".mlihp - My life is Harry Potter."""
try:
req = web.get("http://www.mylifeishp.com/random")
2013-06-09 01:27:24 -04:00
except:
raise GrumbleError("This service is not available to Muggles.")
2011-09-17 21:35:08 -04:00
doc = lxml.html.fromstring(req)
quote = doc.find_class('oldlink')[0].text_content()
2011-09-17 21:35:08 -04:00
phenny.say(quote)
mlihp.commands = ['mlihp']
if __name__ == '__main__':
2011-09-22 14:17:27 -04:00
print(__doc__.strip())