@hook.command('word', 'wordoftheday', autohelp=False)
def wordoftheday(text):
 if (not api_key):
  return 'This command requires an API key from wordnik.com.'
 match = re.search('(\\d\\d\\d\\d-\\d\\d-\\d\\d)', text)
 date = ''
 if match:
  date = match.group(1)
 url = (API_URL + 'words.json/wordOfTheDay')
 if date:
  params = {'api_key': api_key, 'date': date}
  day = date
 else:
  params = {'api_key': api_key}
  day = 'today'
 json = requests.get(url, params=params).json()
 if json:
  word = json['word']
  note = json['note']
  pos = json['definitions'][0]['partOfSpeech']
  definition = json['definitions'][0]['text']
  out = 'The word for \x02{}\x02 is \x02{}\x02: '.format(day, word)
  out += '\x0305({})\x0305 '.format(pos)
  out += '\x0310{}\x0310 '.format(note)
  out += '\x02Definition:\x02 \x0303{}\x0303'.format(definition)
  return ' '.join(out.split())
 else:
  return "Sorry I couldn't find the word of the day, check out this awesome otter instead {}".format('http://i.imgur.com/pkuWlWx.gif')

@ hook . command ( 'word' , 'wordoftheday' , autohelp = False ) def wordoftheday ( text ) : if ( not api_key ) : return 'This command requires an API key from wordnik.com.' match = re . search ( '(\\d\\d\\d\\d-\\d\\d-\\d\\d)' , text ) date = '' if match : date = match . group ( 1 ) url = ( API_URL + 'words.json/wordOfTheDay' ) if date : params = { 'api_key' : api_key , 'date' : date } day = date else : params = { 'api_key' : api_key } day = 'today' json = requests . get ( url , params = params ) . json ( ) if json : word = json [ 'word' ] note = json [ 'note' ] pos = json [ 'definitions' ] [ 0 ] [ 'partOfSpeech' ] definition = json [ 'definitions' ] [ 0 ] [ 'text' ] out = 'The word for \x02{}\x02 is \x02{}\x02: ' . format ( day , word ) out += '\x0305({})\x0305 ' . format ( pos ) out += '\x0310{}\x0310 ' . format ( note ) out += '\x02Definition:\x02 \x0303{}\x0303' . format ( definition ) return ' ' . join ( out . split ( ) ) else : return "Sorry I couldn't find the word of the day, check out this awesome otter instead {}" . format ( 'http://i.imgur.com/pkuWlWx.gif' )
returns the word of the day .