add scoring function
This commit is contained in:
parent
5ba758e79d
commit
f26efff91f
17
bot.py
17
bot.py
@ -13,8 +13,8 @@ from botany import IRCBotany as Botany
|
|||||||
from secrets import PASSWORD
|
from secrets import PASSWORD
|
||||||
|
|
||||||
channels = [
|
channels = [
|
||||||
# "#bots",
|
"#bots",
|
||||||
"#club",
|
# "#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."
|
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)
|
await self.msg(channel, helpmessage, user)
|
||||||
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] == "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():
|
if self.isDrunk():
|
||||||
self.drunkentime = int(time.time())
|
self.drunkentime = int(time.time())
|
||||||
await self.msg(channel, "glug glug glug", user)
|
await self.msg(channel, "glug glug glug", user)
|
||||||
else:
|
else:
|
||||||
await self.msg(channel, "vodka? what's vodka? *burp*", user)
|
await self.msg(channel, "vodka? what's vodka? *burp*", user)
|
||||||
if commands[0] == "desc":
|
elif commands[0] == "desc":
|
||||||
if len(commands) == 2:
|
if len(commands) == 2:
|
||||||
if self.isDrunk():
|
if self.isDrunk():
|
||||||
b = Botany(commands[1])
|
b = Botany(commands[1])
|
||||||
|
@ -40,6 +40,9 @@ class Botany:
|
|||||||
except:
|
except:
|
||||||
print("error in getInfo()")
|
print("error in getInfo()")
|
||||||
return []
|
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):
|
class IRCBotany(Botany):
|
||||||
def plantDescription(self):
|
def plantDescription(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user