Skip to content
This repository has been archived by the owner on Oct 25, 2019. It is now read-only.

Commit

Permalink
Fix urbandict data['result_type']
Browse files Browse the repository at this point in the history
  • Loading branch information
Androbin committed Jul 31, 2018
1 parent 44084c8 commit 462e7ba
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions modules/urbandict.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@ def urbandict(phenny, input):
phenny.say(urbandict.__doc__.strip())
return

# create opener
#opener = urllib.request.build_opener()
#opener.addheaders = [
# ('User-agent', web.Grab().version),
# ('Referer', "http://m.urbandictionary.com"),
#]

try:
data = web.get(
"http://api.urbandictionary.com/v0/define?term={0}".format(
Expand All @@ -33,11 +26,13 @@ def urbandict(phenny, input):
raise GrumbleError(
"Urban Dictionary slemped out on me. Try again in a minute.")

if data['result_type'] == 'no_results':
results = data['list']

if not results:
phenny.say("No results found for {0}".format(word))
return

result = data['list'][0]
result = results[0]
url = 'http://www.urbandictionary.com/define.php?term={0}'.format(
web.quote(word))

Expand Down

0 comments on commit 462e7ba

Please sign in to comment.