Initial changes for team mode

This commit is contained in:
Lovetocode999 2021-07-10 17:14:15 -06:00
parent 76801c0091
commit f7d696ce59
3 changed files with 20 additions and 5 deletions

2
bot.py
View File

@ -194,6 +194,6 @@ class IRCBot:
if teardown is not None: teardown()
if __name__=="__main__":
bot = IRCBot("bunbot","bunbot",channels=["#bungame"])
bot = IRCBot("teambun","teambun",channels=["#teambun"])
bot.load_modules()
bot.start()

View File

@ -1,6 +1,6 @@
from events import Event
from bot import IRCLine
ADMIN_HOSTMASKS = [x+"!khuxkm@fuckup.club" for x in "khuxkm".split()]
ADMIN_HOSTMASKS = [x+"!lovetocode@3.1415926535897932384626433832795028841971693993751058209749445" for x in "lovetocode999".split()]
BOT = None
def admin(event):

View File

@ -21,6 +21,7 @@ if "bun_time" not in bungame_data: bungame_data["bun_time"]=time.time()
if "buns" not in bungame_data: bungame_data["buns"]=dict()
if "score_cache" not in bungame_data: bungame_data["score_cache"]=dict()
if "association" not in bungame_data: bungame_data["association"]=dict()
if "teams" not in bungame_data: bungame_data["teams"]=dict()
def check_bun_active(channel):
"""Checks if a bun is active in channel.
@ -96,14 +97,21 @@ def on_befriend(event):
respond(event,"You missed the bun!")
return
account = event.tags["account"]
team = False
for i in bungame_data["teams"]:
if account in bungame_data["teams"][i]:
team = i
if not team:
respond(event,"You are not a part of any team!")
return
score, final_delta = get_bun_score(event.target)
deactivate_bun(event.target)
first_bun = False
# add the bun to their account and regenerate the score cache
try:
bungame_data["buns"][account].append(final_delta)
bungame_data["buns"][team].append(final_delta)
except KeyError:
bungame_data["buns"][account]=[final_delta]
bungame_data["buns"][team]=[final_delta]
bungame_data.save()
redo_score_cache()
# now tell them about it
@ -132,7 +140,14 @@ def on_stats(event):
respond(event,"You need a NickServ account to participate. (/msg NickServ help register)")
return
account = event.tags["account"]
buns = bungame_data["buns"].get(account)
team = False
for i in bungame_data["teams"]:
if account in bungame_data["teams"][i]:
team = i
if not team:
respond(event,"You are not a part of any team!")
return
buns = bungame_data["buns"].get(team)
if not buns:
respond(event,"You haven't befriended any buns!")
return