This repository has been archived on 2023-04-13. You can view files and clone it, but cannot push or open issues or pull requests.
CloudBot/plugins/fact.py
2011-12-02 02:38:34 +13:00

19 lines
462 B
Python

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)