From 735d07fb775b6a1a2fb74028faa61079105fe9d3 Mon Sep 17 00:00:00 2001 From: randomuser Date: Sun, 11 Jul 2021 17:49:47 +0000 Subject: [PATCH] add percentage warning and sanity checking --- bot.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bot.py b/bot.py index 8710ff5..949d181 100644 --- a/bot.py +++ b/bot.py @@ -67,8 +67,9 @@ class Server(BaseServer): if len(commands) == 1: commands.append(user) b = Botany(commands[1]) i = b.getInfo() + await self.msg(channel, "warning: the %pct command is experimental and could possibly not work. you have been warned.", user) if len(i) > 1: - pct = (1 - ((time.time() - i['last_watered'])/86400)) * 100 + pct = max((1 - ((time.time() - i['last_watered'])/86400)) * 100, 0) await self.msg(channel, "plant percentage for {}: {}%".format(b.user, int(pct)), user) else: await self.msg(channel, "couldn't find plant for {}".format(commands[1]), user)