Compare commits

...

2 Commits

Author SHA1 Message Date
randomuser 4b9c7eba7b add support for !botlist 2021-07-11 18:01:23 +00:00
randomuser 735d07fb77 add percentage warning and sanity checking 2021-07-11 17:49:47 +00:00
1 changed files with 4 additions and 1 deletions

5
bot.py
View File

@ -52,6 +52,8 @@ class Server(BaseServer):
channel = line.params[0]
if line.params[-1] == "!rollcall":
await self.msg(channel, helpmessage, user)
if line.params[-1] == "!botlist":
await self.msg(channel, helpmessage, user)
if line.params[-1][0] == '%':
commands = line.params[-1][1:].split(' ')
if commands[0] == "score":
@ -67,8 +69,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)