fixes to lots of bugs with the bot being in an alternate channel

This commit is contained in:
jacob1 2014-12-06 22:33:42 -05:00
parent 45f640e9c9
commit 8ecef11482

View File

@ -129,8 +129,11 @@ def connect_callback(cli):
cmodes.append(("-v", nick)) cmodes.append(("-v", nick))
# devoice all on connect # devoice all on connect
#bot can be tricked into thinking it's still opped by doing multiple modes at once
@hook("mode", hookid=294) @hook("mode", hookid=294)
def on_give_me_ops(cli, blah, blahh, modeaction, target="", *other): def on_give_me_ops(cli, nick, chan, modeaction, target="", *other):
if chan != botconfig.CHANNEL:
return
if modeaction == "+o" and target == botconfig.NICK: if modeaction == "+o" and target == botconfig.NICK:
var.OPPED = True var.OPPED = True
@ -326,7 +329,7 @@ def pinger(cli, nick, chan, rest):
TO_PING.sort(key=lambda x: x.lower()) TO_PING.sort(key=lambda x: x.lower())
cli.msg(botconfig.CHANNEL, "PING! "+" ".join(TO_PING)) cli.msg(chan, "PING! "+" ".join(TO_PING))
var.PINGING = False var.PINGING = False
minimum = datetime.now() + timedelta(seconds=var.PING_MIN_WAIT) minimum = datetime.now() + timedelta(seconds=var.PING_MIN_WAIT)
@ -335,7 +338,7 @@ def pinger(cli, nick, chan, rest):
decorators.unhook(HOOKS, 800) decorators.unhook(HOOKS, 800)
cli.who(botconfig.CHANNEL) cli.who(chan)
@cmd("simple", raw_nick = True) @cmd("simple", raw_nick = True)
@ -613,8 +616,9 @@ def fstart(cli, nick, chan, rest):
@hook("kick") @hook("kick")
def on_kicked(cli, nick, chan, victim, reason): def on_kicked(cli, nick, chan, victim, reason):
if victim == botconfig.NICK: if victim == botconfig.NICK:
cli.join(botconfig.CHANNEL) cli.join(chan)
cli.msg("ChanServ", "op "+botconfig.CHANNEL) if chan == botconfig.CHANNEL:
cli.msg("ChanServ", "op "+botconfig.CHANNEL)
@hook("account") @hook("account")
@ -1817,6 +1821,9 @@ def reaper(cli, gameid):
@cmd("") # update last said @cmd("") # update last said
def update_last_said(cli, nick, chan, rest): def update_last_said(cli, nick, chan, rest):
if chan != botconfig.CHANNEL:
return
if var.PHASE not in ("join", "none"): if var.PHASE not in ("join", "none"):
var.LAST_SAID_TIME[nick] = datetime.now() var.LAST_SAID_TIME[nick] = datetime.now()
@ -1844,6 +1851,8 @@ def on_join(cli, raw_nick, chan, acc="*", rname=""):
else: else:
var.USERS[nick]["cloak"] = cloak var.USERS[nick]["cloak"] = cloak
var.USERS[nick]["account"] = acc var.USERS[nick]["account"] = acc
if chan != botconfig.CHANNEL:
return
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]
@ -2147,7 +2156,7 @@ def on_nick(cli, oldnick, nick):
def leave(cli, what, nick, why=""): def leave(cli, what, nick, why=""):
nick, _, _, cloak = parse_nick(nick) nick, _, _, cloak = parse_nick(nick)
if what == "part" and why != botconfig.CHANNEL: return if what in ("part", "kick") and why != botconfig.CHANNEL: return
if why and why == botconfig.CHANGING_HOST_QUIT_MESSAGE: if why and why == botconfig.CHANGING_HOST_QUIT_MESSAGE:
return return
@ -2209,7 +2218,7 @@ def leave(cli, what, nick, why=""):
#Functions decorated with hook do not parse the nick by default #Functions decorated with hook do not parse the nick by default
hook("part")(lambda cli, nick, *rest: leave(cli, "part", nick, rest[0])) hook("part")(lambda cli, nick, *rest: leave(cli, "part", nick, rest[0]))
hook("quit")(lambda cli, nick, *rest: leave(cli, "quit", nick, rest[0])) hook("quit")(lambda cli, nick, *rest: leave(cli, "quit", nick, rest[0]))
hook("kick")(lambda cli, nick, *rest: leave(cli, "kick", rest[1])) hook("kick")(lambda cli, nick, *rest: leave(cli, "kick", rest[1], rest[0]))
@cmd("quit", "leave") @cmd("quit", "leave")
@ -5454,7 +5463,7 @@ def show_rules(cli, nick, chan, rest):
if var.PHASE in ("day", "night") and nick not in var.list_players(): if var.PHASE in ("day", "night") and nick not in var.list_players():
cli.notice(nick, var.RULES) cli.notice(nick, var.RULES)
return return
cli.msg(botconfig.CHANNEL, var.RULES) cli.msg(chan, var.RULES)
var.LOGGER.logMessage(var.RULES) var.LOGGER.logMessage(var.RULES)
@ -5588,7 +5597,10 @@ def show_admins(cli, nick, chan, rest):
decorators.unhook(HOOKS, 4) decorators.unhook(HOOKS, 4)
var.ADMIN_PINGING = False var.ADMIN_PINGING = False
cli.who(botconfig.CHANNEL) if nick == chan:
cli.who(botconfig.CHANNEL)
else:
cli.who(chan)
@pmcmd("admins", "ops") @pmcmd("admins", "ops")