From 07508eb31ff4e19b983c8589ea2d466389727d64 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Thu, 1 Dec 2011 00:47:45 +1300 Subject: [PATCH] Added OMGFACTS plugin --- plugins/fact.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 plugins/fact.py diff --git a/plugins/fact.py b/plugins/fact.py new file mode 100644 index 0000000..93e9021 --- /dev/null +++ b/plugins/fact.py @@ -0,0 +1,18 @@ +import re +from util import hook, http, misc +from BeautifulSoup import BeautifulSoup + +@hook.command(autohelp=False) +def fact(inp, say=False, nick=False): + ".fact -- gets a fact from OMGFACTS" + page = http.get('http://www.omg-facts.com/random') + + soup = BeautifulSoup(page) + + container = soup.find('a', {'class' : 'surprise'}) + + link = container['href'] + + fact = misc.strip_html(container.renderContents()) + + return "%s [%s]" % (fact, link)