19 lines
536 B
Python
19 lines
536 B
Python
import requests
|
|
import help_methods
|
|
|
|
def get_definition(content):
|
|
|
|
if len(content.split()) > 1:
|
|
word = content.split()[1:]
|
|
try:
|
|
definition = requests.get(
|
|
"https://api.urbandictionary.com/v0/define?term={}".format('%20'.join(word))
|
|
).json()['list'][0]['definition']
|
|
|
|
except IndexError:
|
|
definition = 'No definition found'
|
|
|
|
return "`{}`\n```{}```".format(' '.join(word), definition)
|
|
else:
|
|
return help_methods.get_help_message('define')
|