add @doseslogged command

This commit is contained in:
Pratyush Desai 2021-06-30 08:08:49 +05:30
parent 0dc06a87a5
commit bdc110598c

View File

@ -281,6 +281,24 @@ class Tripsit(callbacks.Plugin):
else:
irc.error(f'No doses saved for {nick}')
@wrap()
def doseslogged(self, irc, msg, args, history):
"""
This command takes no arguments.
Retrieves the number of doses logged for a given nick
"""
nick = msg.nick
if nick in self.db:
try:
nick_dose_log_count = len(self.db[nick]['doses'])
irc.reply(f"{nick} has logged {nick_dose_log_count} doses")
except IndexError:
irc.error(f"Can't seem to do math, check logs")
else:
irc.error(f"No doses saved for {nick}")
@wrap([optional('positiveInt')])
def lastdose(self, irc, msg, args, history):
"""<n>