dickserv

- irc bot with many useful commands
git clone git://git.acid.vegas/dickserv.git
Log | Files | Refs | Archive | README | LICENSE

dictionary.py (669B)

      1 #!/usr/bin/env python
      2 # DickServ IRC Bot - Developed by acidvegas in Python (https://acid.vegas/dickserv)
      3 # dictionary.py
      4 
      5 import httplib
      6 import functions
      7 
      8 def define(word):
      9 	source  = httplib.get_source('http://www.merriam-webster.com/dictionary/' + word.replace(' ', '%20'))
     10 	results = functions.between(source, f'<meta name="description" content="Define {word}: ', '">')
     11 	if results:
     12 		return results
     13 	else:
     14 		return False
     15 
     16 def urban(word):
     17 	api = httplib.get_json('http://api.urbandictionary.com/v0/define?term=' + word.replace(' ', '+'))
     18 	if api['result_type'] != 'no_results':
     19 		definition = api['list'][0]['definition']
     20 		return definition
     21 	else:
     22 		return False