From f26efff91fcb412c18e85896d1e6bd43f184d4b5 Mon Sep 17 00:00:00 2001 From: randomuser Date: Wed, 23 Jun 2021 03:57:08 +0000 Subject: [PATCH] add scoring function --- bot.py | 17 +++++++++++++---- botany.py | 3 +++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/bot.py b/bot.py index 37f418a..589fdd4 100644 --- a/bot.py +++ b/bot.py @@ -13,8 +13,8 @@ from botany import IRCBotany as Botany from secrets import PASSWORD channels = [ -# "#bots", - "#club", + "#bots", +# "#club", "###", ] helpmessage = "hey, i'm botanybot. i water plants on ~club. my prefix is % and i was made by randomuser. check out https://ttm.sh/FoF.txt for more information." @@ -45,13 +45,22 @@ class Server(BaseServer): await self.msg(channel, helpmessage, user) if line.params[-1][0] == '%': commands = line.params[-1][1:].split(' ') - if commands[0] == "vodka": + if commands[0] == "score": + if len(commands) == 2: + if self.isDrunk(): b = Botany(commands[1]) + else: + b = Botany(userchooser(commands[1])) + while b.getInfo() == []: + b = Botany(userchooser(commands[1])) + i = b.getInfo() + await self.msg(channel, "{}'s score: {}".format(b.user, str(int(b.score()))), user) + elif commands[0] == "vodka": if self.isDrunk(): self.drunkentime = int(time.time()) await self.msg(channel, "glug glug glug", user) else: await self.msg(channel, "vodka? what's vodka? *burp*", user) - if commands[0] == "desc": + elif commands[0] == "desc": if len(commands) == 2: if self.isDrunk(): b = Botany(commands[1]) diff --git a/botany.py b/botany.py index 2f2f2ab..6accb16 100644 --- a/botany.py +++ b/botany.py @@ -40,6 +40,9 @@ class Botany: except: print("error in getInfo()") return [] + def score(self): + i = self.getInfo() + return i['score'] + min(i['last_watered'] - int(time.time()), 24 * 3600) * 0.2 * (i['generation'] - 1) + 1 class IRCBotany(Botany): def plantDescription(self):