Added OMGFACTS plugin
This commit is contained in:
parent
aa45288bd9
commit
07508eb31f
18
plugins/fact.py
Normal file
18
plugins/fact.py
Normal file
|
@ -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)
|
Reference in a new issue