Browse Source

added support for account-notify

master
Jimmy Cao 13 years ago
parent
commit
4fb2a1679d
  1. 23
      wolfgame.py

23
wolfgame.py

@ -48,7 +48,9 @@ def connect_callback(cli):
cli.nickname = user cli.nickname = user
cli.ident = ident cli.ident = ident
cli.hostmask = cloak cli.hostmask = cloak
var.USERS[user] = cloak if acc == "0":
acc = "*"
var.USERS[user] = dict(cloak=cloak,account=acc)
@hook("endofwho", id=294) @hook("endofwho", id=294)
def afterwho(*args): def afterwho(*args):
@ -424,6 +426,11 @@ def on_kicked(cli, nick, chan, victim, reason):
cli.msg("ChanServ", "op "+botconfig.CHANNEL) cli.msg("ChanServ", "op "+botconfig.CHANNEL)
@hook("account")
def on_account(cli, nick, acc):
nick = parse_nick(nick)[0]
if nick in var.USERS.keys():
var.USERS[nick]["account"] = acc
@cmd("stats") @cmd("stats")
def stats(cli, nick, chan, rest): def stats(cli, nick, chan, rest):
@ -707,7 +714,7 @@ def stop_game(cli, winner = ""):
else: else:
continue # something wrong happened continue # something wrong happened
else: else:
clk = var.USERS[plr] clk = var.USERS[plr]["cloak"]
# determine if this player's team won # determine if this player's team won
if plr in (var.ORIGINAL_ROLES["wolf"] + var.ORIGINAL_ROLES["traitor"] + if plr in (var.ORIGINAL_ROLES["wolf"] + var.ORIGINAL_ROLES["traitor"] +
@ -945,10 +952,10 @@ def update_last_said(cli, nick, chan, rest):
@hook("join") @hook("join")
def on_join(cli, raw_nick, chan, acc="", rname=""): def on_join(cli, raw_nick, chan, acc="*", rname=""):
nick,m,u,cloak = parse_nick(raw_nick) nick,m,u,cloak = parse_nick(raw_nick)
if nick not in var.USERS.keys() and nick != botconfig.NICK: if nick not in var.USERS.keys() and nick != botconfig.NICK:
var.USERS[nick] = cloak var.USERS[nick] = dict(cloak=cloak,account=acc)
with var.GRAVEYARD_LOCK: with var.GRAVEYARD_LOCK:
if nick in var.DISCONNECTED.keys(): if nick in var.DISCONNECTED.keys():
clk = var.DISCONNECTED[nick][0] clk = var.DISCONNECTED[nick][0]
@ -2594,7 +2601,7 @@ if botconfig.DEBUG_MODE:
did = False did = False
if PM_COMMANDS.get(cmd) and not PM_COMMANDS[cmd][0].owner_only: if PM_COMMANDS.get(cmd) and not PM_COMMANDS[cmd][0].owner_only:
if (PM_COMMANDS[cmd][0].admin_only and nick in var.USERS and if (PM_COMMANDS[cmd][0].admin_only and nick in var.USERS and
not is_admin(var.USERS[nick])): not is_admin(var.USERS[nick]["cloak"])):
# Not a full admin # Not a full admin
cli.notice(nick, "Only full admins can force an admin-only command.") cli.notice(nick, "Only full admins can force an admin-only command.")
return return
@ -2612,7 +2619,7 @@ if botconfig.DEBUG_MODE:
# chk_nightdone(cli) # chk_nightdone(cli)
elif COMMANDS.get(cmd) and not COMMANDS[cmd][0].owner_only: elif COMMANDS.get(cmd) and not COMMANDS[cmd][0].owner_only:
if (COMMANDS[cmd][0].admin_only and nick in var.USERS and if (COMMANDS[cmd][0].admin_only and nick in var.USERS and
not is_admin(var.USERS[nick])): not is_admin(var.USERS[nick]["cloak"])):
# Not a full admin # Not a full admin
cli.notice(nick, "Only full admins can force an admin-only command.") cli.notice(nick, "Only full admins can force an admin-only command.")
return return
@ -2651,7 +2658,7 @@ if botconfig.DEBUG_MODE:
cmd = rst.pop(0).lower().replace(botconfig.CMD_CHAR, "", 1) cmd = rst.pop(0).lower().replace(botconfig.CMD_CHAR, "", 1)
if PM_COMMANDS.get(cmd) and not PM_COMMANDS[cmd][0].owner_only: if PM_COMMANDS.get(cmd) and not PM_COMMANDS[cmd][0].owner_only:
if (PM_COMMANDS[cmd][0].admin_only and nick in var.USERS and if (PM_COMMANDS[cmd][0].admin_only and nick in var.USERS and
not is_admin(var.USERS[nick])): not is_admin(var.USERS[nick]["cloak"])):
# Not a full admin # Not a full admin
cli.notice(nick, "Only full admins can force an admin-only command.") cli.notice(nick, "Only full admins can force an admin-only command.")
return return
@ -2664,7 +2671,7 @@ if botconfig.DEBUG_MODE:
# chk_nightdone(cli) # chk_nightdone(cli)
elif cmd.lower() in COMMANDS.keys() and not COMMANDS[cmd][0].owner_only: elif cmd.lower() in COMMANDS.keys() and not COMMANDS[cmd][0].owner_only:
if (COMMANDS[cmd][0].admin_only and nick in var.USERS and if (COMMANDS[cmd][0].admin_only and nick in var.USERS and
not is_admin(var.USERS[nick])): not is_admin(var.USERS[nick]["cloak"])):
# Not a full admin # Not a full admin
cli.notice(nick, "Only full admins can force an admin-only command.") cli.notice(nick, "Only full admins can force an admin-only command.")
return return

Loading…
Cancel
Save