summaryrefslogtreecommitdiffstats
path: root/plugin.py
diff options
context:
space:
mode:
authormogad0n2021-01-03 18:23:12 +0530
committermogad0n2021-01-03 18:23:12 +0530
commitb4480bb7709cd1bd8df9ff498a32f3a75f0a0b71 (patch)
tree3947eca8cafe84c6e770dbcc3de4ee5eddf0d7e9 /plugin.py
parent6d5cb7cbecf2a2bbcf5bb493a540475c8f939dcb (diff)
downloadtripsit-b4480bb7709cd1bd8df9ff498a32f3a75f0a0b71.tar.gz
tripsit-b4480bb7709cd1bd8df9ff498a32f3a75f0a0b71.tar.bz2
tripsit-b4480bb7709cd1bd8df9ff498a32f3a75f0a0b71.zip
FixIndexError
Diffstat (limited to 'plugin.py')
-rw-r--r--plugin.py15
1 files 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):
- """<amount> <drug> [<method>] [--ago <HHMM>]
+ @wrap(["private", getopts({'ago': 'something'}), "something", "something", optional("something")])
+ def idose(self, irc, msg, args, opts, dose, name, method):
+ """[--ago <HHMM>] <amount> <drug> [<method/ROA>]
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