Fix current/total

This commit is contained in:
Pedro de Oliveira 2020-02-19 23:09:39 +00:00
parent 536f50152d
commit 42bc7d0085
1 changed files with 9 additions and 6 deletions

View File

@ -55,7 +55,7 @@ class Metal(callbacks.Plugin):
return "{} [{}/{}] {} | {} | {} | {}".format(
self.prepend,
position,
total - 1,
total,
item['band'],
item['genre'],
item['country'],
@ -85,18 +85,21 @@ class Metal(callbacks.Plugin):
)
result = json.loads(response.content.decode('utf-8'))
if result['iTotalRecords'] == 0:
irc.reply('NOT METAL', prefixNick=False)
position = position - 1
total = result['iTotalRecords']
if total == 0:
irc.error('NOT METAL', prefixNick=False)
return
try:
item = self.__parse_item(result['aaData'][position])
except IndexError:
irc.reply('NO HACKZ', prefixNick=False)
irc.error('NO HACKZ', prefixNick=False)
return
irc.reply(self.__format_message(item, position, result['iTotalRecords']), prefixNick=False)
find = wrap(find, ['anything', optional('int', default=0)])
irc.reply(self.__format_message(item, position + 1, total), prefixNick=False)
find = wrap(find, ['anything', optional('int', default=1)])
Class = Metal