Update the notice toggle command

This commit is contained in:
Vgr E. Barry 2017-01-12 13:57:24 -05:00
parent eb5a54474e
commit ce8babec56

View File

@ -486,9 +486,6 @@ def pinger(cli, nick, chan, rest):
def mark_simple_notify(var, wrapper, message): def mark_simple_notify(var, wrapper, message):
"""Makes the bot give you simple role instructions, in case you are familiar with the roles.""" """Makes the bot give you simple role instructions, in case you are familiar with the roles."""
nick, _, ident, host = parse_nick(nick)
if users.exists(nick):
ident = irc_lower(users.get(nick).ident)
account = users.lower(wrapper.source.account) account = users.lower(wrapper.source.account)
userhost = users.lower(wrapper.source.userhost) userhost = users.lower(wrapper.source.userhost)
@ -503,71 +500,28 @@ def mark_simple_notify(var, wrapper, message):
action(value) action(value)
wrapper.pm(messages["simple_" + toggle]) wrapper.pm(messages["simple_" + toggle])
var.SIMPLE_NOTIFY.add(fullmask) @command("notice", pm=True)
db.toggle_simple(None, fullmask) def mark_prefer_notice(var, wrapper, message):
reply(cli, nick, chan, messages["simple_on"], private=True)
@cmd("notice", raw_nick=True, pm=True)
def mark_prefer_notice(cli, nick, chan, rest):
"""Makes the bot NOTICE you for every interaction.""" """Makes the bot NOTICE you for every interaction."""
nick, _, ident, host = parse_nick(nick) if wrapper.private and message:
if chan == nick and rest:
# Ignore if called in PM with parameters, likely a message to wolfchat # Ignore if called in PM with parameters, likely a message to wolfchat
# and not an intentional invocation of this command # and not an intentional invocation of this command
return return
if users.exists(nick): account = users.lower(wrapper.source.account)
ident = irc_lower(users.get(nick).ident) userhost = users.lower(wrapper.source.userhost)
host = users.get(nick).host.lower()
acc = irc_lower(users.get(nick).account)
else:
acc = None
if not acc or acc == "*":
acc = None
if acc and not var.DISABLE_ACCOUNTS: # Do things by account if logged in if account is None and var.ACCOUNTS_ONLY:
if acc in var.PREFER_NOTICE_ACCS: wrapper.pm(messages["not_logged_in"])
var.PREFER_NOTICE_ACCS.remove(acc)
db.toggle_notice(acc, None)
if host in var.PREFER_NOTICE:
var.PREFER_NOTICE.remove(host)
db.toggle_notice(None, host)
fullmask = ident + "@" + host
if fullmask in var.PREFER_NOTICE:
var.PREFER_NOTICE.remove(fullmask)
db.toggle_notice(None, fullmask)
reply(cli, nick, chan, messages["notice_off"], private=True)
return return
var.PREFER_NOTICE_ACCS.add(acc) notice = wrapper.source.prefers_notice()
db.toggle_notice(acc, None) notice_set, value = (var.PREFER_NOTICE, userhost) if account is None else (var.PREFER_NOTICE_ACCS, account)
elif var.ACCOUNTS_ONLY: action, toggle = (notice_set.discard, "off") if notice else (notice_set.add, "on")
reply(cli, nick, chan, messages["not_logged_in"], private=True)
return
else: # Not logged in action(value)
if host in var.PREFER_NOTICE: wrapper.pm(messages["notice_" + toggle])
var.PREFER_NOTICE.remove(host)
db.toggle_notice(None, host)
reply(cli, nick, chan, messages["notice_off"], private=True)
return
fullmask = ident + "@" + host
if fullmask in var.PREFER_NOTICE:
var.PREFER_NOTICE.remove(fullmask)
db.toggle_notice(None, fullmask)
reply(cli, nick, chan, messages["notice_off"], private=True)
return
var.PREFER_NOTICE.add(fullmask)
db.toggle_notice(None, fullmask)
reply(cli, nick, chan, messages["notice_on"], private=True)
@command("swap", "replace", pm=True, phases=("join", "day", "night")) @command("swap", "replace", pm=True, phases=("join", "day", "night"))
def replace(var, wrapper, message): def replace(var, wrapper, message):