From b4480bb7709cd1bd8df9ff498a32f3a75f0a0b71 Mon Sep 17 00:00:00 2001 From: mogad0n Date: Sun, 3 Jan 2021 18:23:12 +0530 Subject: [PATCH] FixIndexError --- plugin.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/plugin.py b/plugin.py index cd98bb2..9ae5419 100644 --- a/plugin.py +++ b/plugin.py @@ -169,9 +169,9 @@ class Tripsit(callbacks.Plugin): irc.error(_('Unknown timezone'), Raise=True) set = wrap(set, ["something"]) - @wrap(["private", "something", "something", optional("something"), getopts({'ago': 'something'})]) - def idose(self, irc, msg, args, dose, name, method, opts): - """ [] [--ago ] + @wrap(["private", getopts({'ago': 'something'}), "something", "something", optional("something")]) + def idose(self, irc, msg, args, opts, dose, name, method): + """[--ago ] [] logs a dose for you, can only be used in private. """ @@ -264,6 +264,7 @@ class Tripsit(callbacks.Plugin): lastdose = self.db[nick]['doses'][-int(history)] except IndexError: irc.error("You haven't logged that many doses") + return else: lastdose = self.db[nick]['doses'][-1] dose = lastdose['dose'] @@ -276,9 +277,9 @@ class Tripsit(callbacks.Plugin): since_dose = time - dose_time since_dose_seconds = since_dose.total_seconds() if history: - if history == '2': + if history == 2: re = utils.str.format("Your %i'nd last dose was %s of %s via %s at %s %s, %T ago", history, dose, drug, method, str(dose_time), timezone, since_dose_seconds) - if history == '3': + elif history == 3: re = utils.str.format("Your %i'rd last dose was %s of %s via %s at %s %s, %T ago", history, dose, drug, method, str(dose_time), timezone, since_dose_seconds) else: re = utils.str.format("Your %i'th last dose was %s of %s via %s at %s %s, %T ago", history, dose, drug, method, str(dose_time), timezone, since_dose_seconds) @@ -287,8 +288,8 @@ class Tripsit(callbacks.Plugin): irc.reply(re) else: irc.error(f'No doses saved for {nick}') - + Class = Tripsit -# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: +# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: \ No newline at end of file