fix some bugs
This commit is contained in:
parent
48096c3c6b
commit
7aac5d09a0
52
bot.py
52
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:
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue