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/wordoftheday.py

19 lines
662 B
Python
Raw Normal View History

2011-11-20 10:23:31 +01:00
import re
2012-02-02 14:05:11 +01:00
from util import hook, http, misc
2011-11-20 10:23:31 +01:00
from BeautifulSoup import BeautifulSoup
@hook.command(autohelp=False)
2011-11-20 11:59:51 +01:00
def word(inp, say=False, nick=False):
2012-02-28 03:03:43 +01:00
".word -- Gets the word of the day."
2011-11-20 10:23:31 +01:00
page = http.get('http://merriam-webster.com/word-of-the-day')
soup = BeautifulSoup(page)
2011-11-20 11:59:51 +01:00
word = soup.find('strong', {'class' : 'main_entry_word'}).renderContents()
function = soup.find('p', {'class' : 'word_function'}).renderContents()
2011-11-20 10:23:31 +01:00
#definitions = re.findall(r'<span class="ssens"><strong>:</strong>'
# r' *([^<]+)</span>', content)
2011-11-20 11:59:51 +01:00
say("(%s) The word of the day is: \x02%s\x02 (%s)" % (nick, word, function))