fix some bugs

This commit is contained in:
randomuser 2021-06-23 21:03:28 +00:00
parent 48096c3c6b
commit 7aac5d09a0
2 changed files with 29 additions and 26 deletions

52
bot.py
View File

@ -55,14 +55,14 @@ class Server(BaseServer):
if line.params[-1][0] == '%': if line.params[-1][0] == '%':
commands = line.params[-1][1:].split(' ') commands = line.params[-1][1:].split(' ')
if commands[0] == "score": if commands[0] == "score":
if len(commands) == 2: if len(commands) == 1: commands.append(user)
if self.isDrunk(): b = Botany(commands[1]) if self.isDrunk(): b = Botany(commands[1])
else: else:
b = Botany(userchooser(commands[1]))
while b.getInfo() == []:
b = Botany(userchooser(commands[1])) b = Botany(userchooser(commands[1]))
while b.getInfo() == []: i = b.getInfo()
b = Botany(userchooser(commands[1])) 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": elif commands[0] == "vodka":
if self.isDrunk(): if self.isDrunk():
self.drunkentime = int(time.time()) self.drunkentime = int(time.time())
@ -70,27 +70,25 @@ class Server(BaseServer):
else: else:
await self.msg(channel, "vodka? what's vodka? *burp*", user) await self.msg(channel, "vodka? what's vodka? *burp*", user)
elif commands[0] == "desc": elif commands[0] == "desc":
if len(commands) == 2: if len(commands) == 1: commands.append(user)
if self.isDrunk(): if self.isDrunk():
b = Botany(commands[1]) b = Botany(commands[1])
else:
b = Botany(userchooser(commands[1]))
await self.msg(channel, b.plantDescription(), user)
else: else:
await self.msg(channel, "specify user", user) b = Botany(userchooser(commands[1]))
await self.msg(channel, b.plantDescription(), user)
elif commands[0] == "water": elif commands[0] == "water":
if len(commands) == 2: if len(commands) == 1: commands.append(user)
if self.isDrunk(): if self.isDrunk():
b = Botany(commands[1]) b = Botany(commands[1])
if b.water("{} (via IRC)".format(user)): 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) 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": elif commands[0] == "help":
await self.msg(channel, helpmessage, user) await self.msg(channel, helpmessage, user)
elif commands[0] == "join": elif commands[0] == "join":
@ -98,6 +96,10 @@ class Server(BaseServer):
if user == self.admin: if user == self.admin:
await self.send(build("JOIN", [commands[1]])) await self.send(build("JOIN", [commands[1]]))
await self.msg(channel, "joined the channel {}".format(commands[1]), user) 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": elif commands[0] == "addowner":
if len(commands) == 2: if len(commands) == 2:
if user == self.admin: if user == self.admin:

View File

@ -43,7 +43,8 @@ class Botany:
return [] return []
def score(self): def score(self):
i = self.getInfo() 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): class IRCBotany(Botany):
def plantDescription(self): def plantDescription(self):