|
|
@ -20,37 +20,36 @@ def connect_callback(cli): |
|
|
|
cli.msg(botconfig.CHANNEL, "\u0002Wolfbot2 is here.\u0002") |
|
|
|
cli.msg(botconfig.CHANNEL, "\u0002Wolfbot2 is here.\u0002") |
|
|
|
|
|
|
|
|
|
|
|
def reset_game(): |
|
|
|
def reset_game(): |
|
|
|
vars.GAME_STARTED = False |
|
|
|
|
|
|
|
vars.ROLES = {"person" : []} |
|
|
|
vars.ROLES = {"person" : []} |
|
|
|
vars.PHASE = "none" |
|
|
|
vars.PHASE = "none" |
|
|
|
|
|
|
|
|
|
|
|
# Command Handlers: |
|
|
|
# Command Handlers: |
|
|
|
@cmd("!say") |
|
|
|
@cmd("!say") |
|
|
|
def say(cli, rawnick, rest): # To be removed later |
|
|
|
def say(cli, nick, rest): # To be removed later |
|
|
|
cli.msg(botconfig.CHANNEL, "{0} says: {1}".format(parse_nick(rawnick)[0], rest)) |
|
|
|
cli.msg(botconfig.CHANNEL, "{0} says: {1}".format(nick, rest)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pmcmd("!bye") |
|
|
|
@pmcmd("!bye") |
|
|
|
@cmd("!bye") |
|
|
|
@cmd("!bye") |
|
|
|
def forced_exit(cli, rawnick, *rest): # Admin Only |
|
|
|
def forced_exit(cli, nick, *rest): # Admin Only |
|
|
|
if parse_nick(rawnick)[0] in botconfig.ADMINS: |
|
|
|
if nick in botconfig.ADMINS: |
|
|
|
cli.quit("Forced quit from admin") |
|
|
|
cli.quit("Forced quit from admin") |
|
|
|
raise SystemExit |
|
|
|
raise SystemExit |
|
|
|
|
|
|
|
|
|
|
|
@cmd("!exec") |
|
|
|
@cmd("!exec") |
|
|
|
def py(cli, rawnick, chan, rest): |
|
|
|
def py(cli, nick, chan, rest): |
|
|
|
if parse_nick(rawnick)[0] in botconfig.ADMINS: |
|
|
|
if nick in botconfig.ADMINS: |
|
|
|
exec(rest) |
|
|
|
exec(rest) |
|
|
|
|
|
|
|
|
|
|
|
@cmd("!ping") |
|
|
|
@cmd("!ping") |
|
|
|
def pinger(cli, rawnick, chan, rest): |
|
|
|
def pinger(cli, nick, chan, rest): |
|
|
|
vars.PINGING = True |
|
|
|
vars.PINGING = True |
|
|
|
TO_PING = [] |
|
|
|
TO_PING = [] |
|
|
|
|
|
|
|
|
|
|
|
@hook("whoreply") |
|
|
|
@hook("whoreply") |
|
|
|
def on_whoreply(server, dunno, chan, dunno1, dunno2, dunno3, user, status, dunno4): |
|
|
|
def on_whoreply(server, dunno, chan, dunno1, dunno2, dunno3, user, status, dunno4): |
|
|
|
if not vars.PINGING: return |
|
|
|
if not vars.PINGING: return |
|
|
|
if user in (botconfig.NICK, parse_nick(rawnick)[0]): return # Don't ping self. |
|
|
|
if user in (botconfig.NICK, nick): return # Don't ping self. |
|
|
|
|
|
|
|
|
|
|
|
if vars.PINGING and 'G' not in status and '+' not in status: |
|
|
|
if vars.PINGING and 'G' not in status and '+' not in status: |
|
|
|
# TODO: check if the user has AWAY'D himself |
|
|
|
# TODO: check if the user has AWAY'D himself |
|
|
@ -69,37 +68,36 @@ def pinger(cli, rawnick, chan, rest): |
|
|
|
|
|
|
|
|
|
|
|
cli.send("WHO "+chan) |
|
|
|
cli.send("WHO "+chan) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@cmd("!join") |
|
|
|
@cmd("!join") |
|
|
|
def join(cli, rawnick, chan, rest): |
|
|
|
def join(cli, nick, chan, rest): |
|
|
|
if vars.PHASE != "none": |
|
|
|
if vars.PHASE == "none": |
|
|
|
return |
|
|
|
vars.ROLES["person"].append(nick) |
|
|
|
|
|
|
|
vars.PHASE = "join" |
|
|
|
vars.GAME_STARTED = True |
|
|
|
cli.msg(chan, '\u0002{0}\u0002 has started a game of Werewolf. \ |
|
|
|
|
|
|
|
|
|
|
|
nick = parse_nick(rawnick)[0] |
|
|
|
|
|
|
|
cli.msg(chan, '{0} has started a game of Werewolf. \ |
|
|
|
|
|
|
|
Type "!join" to join. Type "!start" to start the game. \ |
|
|
|
Type "!join" to join. Type "!start" to start the game. \ |
|
|
|
Type "!wait" to increase join wait time.'.format(nick)) |
|
|
|
Type "!wait" to increase join wait time.'.format(nick)) |
|
|
|
|
|
|
|
elif nick in list_players(): |
|
|
|
|
|
|
|
cli.notice(nick, "You're already playing!") |
|
|
|
|
|
|
|
elif vars.PHASE != "join": |
|
|
|
|
|
|
|
cli.notice(nick, "Sorry but the game is already running. Try again next time.") |
|
|
|
|
|
|
|
else: |
|
|
|
vars.ROLES["person"].append(nick) |
|
|
|
vars.ROLES["person"].append(nick) |
|
|
|
vars.PHASE = "join" |
|
|
|
cli.msg(chan, '\u0002{0}\u0002 has joined the game.'.format(nick)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@cmd("!stats") |
|
|
|
@cmd("!stats") |
|
|
|
def stats(cli, rawnick, chan, rest): |
|
|
|
def stats(cli, nick, chan, rest): |
|
|
|
if vars.PHASE == "none": |
|
|
|
if vars.PHASE == "none": |
|
|
|
return |
|
|
|
return |
|
|
|
nick = parse_nick(rawnick)[0] |
|
|
|
pl = list_players() |
|
|
|
pl = [] |
|
|
|
|
|
|
|
for x in vars.ROLES.values(): pl.extend(x) |
|
|
|
|
|
|
|
if len(pl) > 1: |
|
|
|
if len(pl) > 1: |
|
|
|
cli.msg(chan, '{0}: {1} players: {2}'.format(nick, |
|
|
|
cli.msg(chan, '{0}: {1} players: {2}'.format(nick, |
|
|
|
len(pl), ", ".join(pl))) |
|
|
|
len(pl), ", ".join(pl))) |
|
|
|
else: |
|
|
|
else: |
|
|
|
cli.msg(chan, '{0}: 1 player: {1}'.format(nick, pl[0])) |
|
|
|
cli.msg(chan, '{0}: 1 player: {1}'.format(nick, pl[0])) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if vars.PHASE == "join": |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
msg = [] |
|
|
|
msg = [] |
|
|
|
for role in vars.ROLES.keys(): |
|
|
|
for role in vars.ROLES.keys(): |
|
|
|
num = len(vars.ROLES[role]) |
|
|
|
num = len(vars.ROLES[role]) |
|
|
@ -117,4 +115,11 @@ def stats(cli, rawnick, chan, rest): |
|
|
|
elif len(msg) == 1: |
|
|
|
elif len(msg) == 1: |
|
|
|
cli.msg(chan, "{0}: There is ".format(nick) + msg[0] + ".") |
|
|
|
cli.msg(chan, "{0}: There is ".format(nick) + msg[0] + ".") |
|
|
|
|
|
|
|
|
|
|
|
# Game Logic Ends |
|
|
|
@cmd("!start") |
|
|
|
|
|
|
|
def start(cli, nick, chan, rest): |
|
|
|
|
|
|
|
pl = list_players() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(len(pl)) < 4: |
|
|
|
|
|
|
|
cli.msg(chan, "{0}: Four or more players are required to play.".format(nick)) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
|