Update the simple toggle command

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

View File

@ -482,56 +482,26 @@ def pinger(cli, nick, chan, rest):
cmd_char=botconfig.CMD_CHAR, cmd_char=botconfig.CMD_CHAR,
goat_action=random.choice(messages["goat_actions"]))) goat_action=random.choice(messages["goat_actions"])))
@cmd("simple", raw_nick=True, pm=True) @command("simple", pm=True)
def mark_simple_notify(cli, nick, chan, rest): 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) nick, _, ident, host = parse_nick(nick)
if users.exists(nick): if users.exists(nick):
ident = irc_lower(users.get(nick).ident) ident = irc_lower(users.get(nick).ident)
host = users.get(nick).host.lower() account = users.lower(wrapper.source.account)
acc = irc_lower(users.get(nick).account) userhost = users.lower(wrapper.source.userhost)
else:
acc = None
if not acc or acc == "*":
acc = None
if acc: # Prioritize account if account is None and var.ACCOUNTS_ONLY:
if acc in var.SIMPLE_NOTIFY_ACCS: wrapper.pm(messages["not_logged_in"])
var.SIMPLE_NOTIFY_ACCS.remove(acc)
db.toggle_simple(acc, None)
if host in var.SIMPLE_NOTIFY:
var.SIMPLE_NOTIFY.remove(host)
db.toggle_simple(None, host)
fullmask = ident + "@" + host
if fullmask in var.SIMPLE_NOTIFY:
var.SIMPLE_NOTIFY.remove(fullmask)
db.toggle_simple(None, fullmask)
reply(cli, nick, chan, messages["simple_off"], private=True)
return
var.SIMPLE_NOTIFY_ACCS.add(acc)
db.toggle_simple(acc, None)
elif var.ACCOUNTS_ONLY:
reply(cli, nick, chan, messages["not_logged_in"], private=True)
return return
else: # Not logged in, fall back to ident@hostmask simple = wrapper.source.prefers_simple()
if host in var.SIMPLE_NOTIFY: simple_set, value = (var.SIMPLE_NOTIFY, userhost) if account is None else (var.SIMPLE_NOTIFY_ACCS, account)
var.SIMPLE_NOTIFY.remove(host) action, toggle = (simple_set.discard, "off") if simple else (simple_set.add, "on")
db.toggle_simple(None, host)
reply(cli, nick, chan, messages["simple_off"], private=True) action(value)
return wrapper.pm(messages["simple_" + toggle])
fullmask = ident + "@" + host
if fullmask in var.SIMPLE_NOTIFY:
var.SIMPLE_NOTIFY.remove(fullmask)
db.toggle_simple(None, fullmask)
reply(cli, nick, chan, messages["simple_off"], private=True)
return
var.SIMPLE_NOTIFY.add(fullmask) var.SIMPLE_NOTIFY.add(fullmask)
db.toggle_simple(None, fullmask) db.toggle_simple(None, fullmask)