add percentage warning and sanity checking

This commit is contained in:
randomuser 2021-07-11 17:49:47 +00:00
parent 6297b790df
commit 735d07fb77
1 changed files with 2 additions and 1 deletions

3
bot.py
View File

@ -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)