Massive code dump :o
This commit is contained in:
parent
185c1d5ae3
commit
9bc8901972
60 changed files with 5781 additions and 125 deletions
|
@ -5,14 +5,27 @@ from BeautifulSoup import BeautifulSoup
|
|||
@hook.command(autohelp=False)
|
||||
def fact(inp, say=False, nick=False):
|
||||
".fact -- gets a fact from OMGFACTS"
|
||||
|
||||
fact = None
|
||||
while fact is None:
|
||||
try:
|
||||
fact, link = get_fact()
|
||||
except:
|
||||
pass
|
||||
|
||||
return "%s [ %s ]" % (fact, link)
|
||||
|
||||
|
||||
|
||||
def get_fact():
|
||||
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)
|
||||
if fact:
|
||||
return (fact, link)
|
||||
else:
|
||||
raise nofact
|
||||
|
|
Reference in a new issue