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

21 lines
672 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
2012-02-29 06:58:38 +01:00
2011-11-20 10:23:31 +01:00
@hook.command(autohelp=False)
2011-11-20 11:59:51 +01:00
def word(inp, say=False, nick=False):
2012-05-16 05:07:27 +02: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)
2012-04-02 18:17:55 +02: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)
2012-02-29 06:58:38 +01:00
say("(%s) The word of the day is:"\
" \x02%s\x02 (%s)" % (nick, word, function))