Fix lykos on IRCds that do not have WHOX support

- Disable account support if we do not have WHOX so that bot still works
  (and have it use regular WHO replies in that case).
- Don't join alt channels if there aren't any (prevents null JOINs being
  sent to server).
- Allow configuring how the bot quiets users with QUIET_MODE and
  QUIET_PREFIX, the default is "q" and "" so it sets +q n!u@h, but you
  could configure it to say "b" and "~q:" where it will set +b ~q:n!u@h.
- Properly error out if we have sasl enabled but the ircd does not.

Known Issues:
- pstats does not work, as it is still tied to nickserv accounts
This commit is contained in:
skizzerz 2015-04-03 22:23:02 -05:00
parent 2d14bdc0fe
commit 5264a2a0da
3 changed files with 58 additions and 8 deletions

View File

@ -111,9 +111,14 @@ hook = decorators.generate(HOOKS, raw_nick=True, permissions=False)
def connect_callback(cli):
def prepare_stuff(*args):
# just in case we haven't managed to successfully auth yet
if not botconfig.SASL_AUTHENTICATION:
cli.ns_identify(botconfig.PASS)
cli.join(botconfig.CHANNEL)
cli.join(botconfig.ALT_CHANNELS)
cli.join(",".join(chan.lstrip("".join(var.STATUSMSG_PREFIXES)) for chan in botconfig.DEV_CHANNEL.split(",")))
if botconfig.ALT_CHANNELS:
cli.join(botconfig.ALT_CHANNELS)
if botconfig.DEV_CHANNEL:
cli.join(",".join(chan.lstrip("".join(var.STATUSMSG_PREFIXES)) for chan in botconfig.DEV_CHANNEL.split(",")))
cli.msg("ChanServ", "op "+botconfig.CHANNEL)
cli.cap("REQ", "extended-join")
@ -163,6 +168,9 @@ def connect_callback(cli):
def on_cap(cli, svr, mynick, ack, cap):
if ack.upper() == "ACK" and "sasl" in cap:
cli.send("AUTHENTICATE PLAIN")
elif ack.upper() == "NAK" and "sasl" in cap:
cli.quit()
alog("Server does not support SASL authentication")
@hook("903")
def on_successful_auth(cli, blah, blahh, blahhh):
@ -193,3 +201,5 @@ if botconfig.DEBUG_MODE:
cli.msg(chan, "Module {0} is now active.".format(rest))
else:
cli.msg(chan, "Module {0} does not exist.".format(rest))
# vim: set expandtab:sw=4:ts=4:

View File

@ -152,8 +152,37 @@ def connect_callback(cli):
@hook("quietlist", hookid=294)
def on_quietlist(cli, server, botnick, channel, q, quieted, by, something):
if re.match(".+\!\*@\*", quieted): # only unquiet people quieted by bot
cmodes.append(("-q", quieted))
if re.match("{0}.+\!\*@\*".format(var.QUIET_PREFIX), quieted): # only unquiet people quieted by bot
cmodes.append(("-{0}".format(var.QUIET_MODE), quieted))
@hook("banlist", hookid=294)
def on_banlist(cli, server, botnick, channel, ban, by, timestamp):
if re.match("{0}.+\!\*@\*".format(var.QUIET_PREFIX), ban):
cmodes.append(("-{0}".format(var.QUIET_MODE), ban))
@hook("whoreply", hookid=294)
def on_whoreply(cli, svr, botnick, chan, user, host, server, nick, status, rest):
if not var.DISABLE_ACCOUNTS:
plog("IRCd does not support accounts, disabling account-related features.")
var.DISABLE_ACCOUNTS = True
var.ACCOUNTS_ONLY = False
if nick in var.USERS:
return
if nick == botconfig.NICK:
cli.nickname = nick
cli.ident = user
cli.hostmask = host
if "+" in status:
to_be_devoiced.append(user)
newstat = ""
for stat in status:
if not stat in var.MODES_PREFIXES:
continue
newstat += var.MODES_PREFIXES[stat]
var.USERS[nick] = dict(cloak=host,account="*",inchan=True,modes=set(newstat),moded=set())
@hook("whospcrpl", hookid=294)
def on_whoreply(cli, server, nick, ident, cloak, _, user, status, acc):
@ -204,14 +233,21 @@ def connect_callback(cli):
def on_quietlist_end(cli, svr, nick, chan, *etc):
if chan == botconfig.CHANNEL:
mass_mode(cli, cmodes, ["-m"])
@hook("endofbanlist", 294)
def on_banlist_end(cli, svr, nick, chan, *etc):
if chan == botconfig.CHANNEL:
mass_mode(cli, cmodes, ["-m"])
cli.mode(botconfig.CHANNEL, "q") # unquiet all
cli.mode(botconfig.CHANNEL, var.QUIET_MODE) # unquiet all
elif modeaction == "-o" and target == botconfig.NICK:
var.OPPED = False
cli.msg("ChanServ", "op " + botconfig.CHANNEL)
cli.who(botconfig.CHANNEL, "%uhsnfa")
if var.DISABLE_ACCOUNTS:
cli.who(botconfig.CHANNEL)
else:
cli.who(botconfig.CHANNEL, "%uhsnfa")
@hook("mode")
def check_for_modes(cli, rnick, chan, modeaction, *target):
@ -356,7 +392,7 @@ def reset_modes_timers(cli):
if var.QUIET_DEAD_PLAYERS:
for deadguy in var.DEAD:
if not is_fake_nick(deadguy):
cmodes.append(("-q", deadguy+"!*@*"))
cmodes.append(("-{0}".format(var.QUIET_MODE), var.QUIET_PREFIX+deadguy+"!*@*"))
mass_mode(cli, cmodes, ["-m"])
def reset():
@ -2551,7 +2587,7 @@ def del_player(cli, nick, forced_death = False, devoice = True, end_game = True,
if var.PHASE != "join":
# Died during the game, so quiet!
if var.QUIET_DEAD_PLAYERS and not is_fake_nick(nick):
cmode.append(("+q", nick+"!*@*"))
cmode.append(("+{0}".format(var.QUIET_MODE), var.QUIET_PREFIX+nick+"!*@*"))
mass_mode(cli, cmode, [])
if nick not in var.DEAD:
var.DEAD.append(nick)

View File

@ -52,6 +52,8 @@ PART_STASIS_PENALTY = 1
ACC_STASIS_PENALTY = 1
LEAVE_ON_LOGOUT = False # If True, the bot will consider a NickServ logout as a quit
QUIET_DEAD_PLAYERS = False
QUIET_MODE = "q" # "q" or "b"
QUIET_PREFIX = "" # "" or "~q:"
# The bot will automatically toggle those modes of people joining
AUTO_TOGGLE_MODES = ""
@ -133,6 +135,8 @@ PREFER_NOTICE = [] # cloaks of people who !notice, who want everything /notice'
PREFER_NOTICE_ACCS = [] # Same as above, except accounts. takes precedence
ACCOUNTS_ONLY = False # If True, will use only accounts for everything
DISABLE_ACCOUNTS = False # If True, all account-related features are disabled. Automatically set if we discover we do not have proper ircd support for accounts
# This will override ACCOUNTS_ONLY if it is set
STASISED = defaultdict(int)
STASISED_ACCS = defaultdict(int)