From 7aac5d09a01c6b8a52f275e19e6cabfb9f479c76 Mon Sep 17 00:00:00 2001 From: randomuser Date: Wed, 23 Jun 2021 21:03:28 +0000 Subject: [PATCH] fix some bugs --- bot.py | 52 +++++++++++++++++++++++++++------------------------- botany.py | 3 ++- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/bot.py b/bot.py index c44ce47..33846cb 100644 --- a/bot.py +++ b/bot.py @@ -55,14 +55,14 @@ class Server(BaseServer): if line.params[-1][0] == '%': commands = line.params[-1][1:].split(' ') if commands[0] == "score": - if len(commands) == 2: - if self.isDrunk(): b = Botany(commands[1]) - else: + if len(commands) == 1: commands.append(user) + if self.isDrunk(): b = Botany(commands[1]) + else: + b = Botany(userchooser(commands[1])) + while b.getInfo() == []: 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) + 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()) @@ -70,27 +70,25 @@ class Server(BaseServer): else: await self.msg(channel, "vodka? what's vodka? *burp*", user) elif commands[0] == "desc": - if len(commands) == 2: - if self.isDrunk(): - b = Botany(commands[1]) - else: - b = Botany(userchooser(commands[1])) - await self.msg(channel, b.plantDescription(), user) + if len(commands) == 1: commands.append(user) + if self.isDrunk(): + b = Botany(commands[1]) else: - await self.msg(channel, "specify user", user) + b = Botany(userchooser(commands[1])) + await self.msg(channel, b.plantDescription(), user) elif commands[0] == "water": - if len(commands) == 2: - if self.isDrunk(): - b = Botany(commands[1]) - if b.water("{} (via IRC)".format(user)): - await self.msg(channel, b.watered(), user) - else: - await self.msg(channel, b.cantWater(), user) - else: - b = Botany(userchooser(commands[1])) - while not b.water("{} (via IRC".format(user)): - b = Botany(userchooser(commands[1])) + if len(commands) == 1: commands.append(user) + if self.isDrunk(): + b = Botany(commands[1]) + if b.water("{} (via IRC)".format(user)): await self.msg(channel, b.watered(), user) + else: + await self.msg(channel, b.cantWater(), user) + else: + b = Botany(userchooser(commands[1])) + while not b.water("{} (via IRC)".format(user)): + b = Botany(userchooser(commands[1])) + await self.msg(channel, b.watered(), user) elif commands[0] == "help": await self.msg(channel, helpmessage, user) elif commands[0] == "join": @@ -98,6 +96,10 @@ class Server(BaseServer): if user == self.admin: await self.send(build("JOIN", [commands[1]])) await self.msg(channel, "joined the channel {}".format(commands[1]), user) + else: + await self.msg(channel, "you're not an admin", user) + else: + await self.msg(channel, "specify the channel", user) elif commands[0] == "addowner": if len(commands) == 2: if user == self.admin: diff --git a/botany.py b/botany.py index 3f1d9fb..f261c78 100644 --- a/botany.py +++ b/botany.py @@ -43,7 +43,8 @@ class Botany: 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 + if len(i) > 1: return i['score'] + min(i['last_watered'] - int(time.time()), 24 * 3600) * 0.2 * (i['generation'] - 1) + 1 + return 0 class IRCBotany(Botany): def plantDescription(self):