]> jfr.im git - irc/rizon/acid.git/commitdiff
Fix urbandictionary API handling
authorDwarf <redacted>
Sat, 21 Jul 2018 21:35:05 +0000 (23:35 +0200)
committerDwarf <redacted>
Sat, 21 Jul 2018 21:35:05 +0000 (23:35 +0200)
pyva/pyva/src/main/python/internets/cmd_user.py

index 6aac8e97f895b6f8f8bf893ef993cfbb8aebc2c5..85a906953a0797bb2e8fdfb66c47cabbf20089f1 100644 (file)
@@ -479,9 +479,9 @@ def command_urbandictionary(self, manager, opts, arg, channel, sender, userinfo)
                self.elog.warning('feed error in .urbandictionary: %s' % e)
                return
        
-       if res['result_type'] == 'no_results' or res['result_type'] == 'fulltext':
+       if 'list' not in res or len(res['list']) < 1:
                self.errormsg(channel, 'no results found')
-       elif res['result_type'] == 'exact':
+       else:
                if def_id:
                        try:
                                def_id = int(def_id)
@@ -503,7 +503,7 @@ def command_urbandictionary(self, manager, opts, arg, channel, sender, userinfo)
                                self.errormsg(channel, 'invalid definition number')
                        except IndexError:
                                self.errormsg(channel, 'definition id out of range: only %d definitions available' % len(res['list']))
-               else:   
+               else:
                        for num, entry in enumerate(res['list'], 1):
                                if num == 4:
                                        self.notice(sender, u'To view a single definition with a related example, type: @b.u %s /def_number@b. For more definitions, visit: %s' % (expr, res['list'][0]['permalink']))
@@ -516,10 +516,7 @@ def command_urbandictionary(self, manager, opts, arg, channel, sender, userinfo)
                                                res = res,
                                                definition = definition if len(definition) < 200 else definition[:200] + '...',
                                                entry = entry))
-       else:
-               self.msg(channel, 'An exception occurred and has been reported to the developers. If this error persists please do not use the faulty command until it has been fixed.')
-               self.elog.warning('unrecognized result type: %s' % res['result_type'])
-       
+
 def command_imdb(self, manager, opts, arg, channel, sender, userinfo):
        try:
                reply = self.imdb.get(arg)