From: Dwarf Date: Sat, 21 Jul 2018 21:35:05 +0000 (+0200) Subject: Fix urbandictionary API handling X-Git-Url: https://jfr.im/git/irc/rizon/acid.git/commitdiff_plain/f63777025bd97034c14d189a9afa61c0c91a1982 Fix urbandictionary API handling --- diff --git a/pyva/pyva/src/main/python/internets/cmd_user.py b/pyva/pyva/src/main/python/internets/cmd_user.py index 6aac8e9..85a9069 100644 --- a/pyva/pyva/src/main/python/internets/cmd_user.py +++ b/pyva/pyva/src/main/python/internets/cmd_user.py @@ -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)