!force works on commands with raw_nick (vote) + some logic changes

This commit is contained in:
jacob1 2015-01-16 01:02:56 -05:00
parent 91c2c26a45
commit 7f2e3153e7

View File

@ -6655,8 +6655,8 @@ if botconfig.DEBUG_MODE or botconfig.ALLOWED_NORMAL_MODE_COMMANDS:
# DO NOT MAKE THIS A PMCOMMAND ALSO # DO NOT MAKE THIS A PMCOMMAND ALSO
@cmd("force", admin_only=True, game=True) @cmd("force", admin_only=True)
def forcepm(cli, nick, chan, rest): def force(cli, nick, chan, rest):
rst = re.split(" +",rest) rst = re.split(" +",rest)
if len(rst) < 2: if len(rst) < 2:
cli.msg(chan, "The syntax is incorrect.") cli.msg(chan, "The syntax is incorrect.")
@ -6665,46 +6665,38 @@ if botconfig.DEBUG_MODE or botconfig.ALLOWED_NORMAL_MODE_COMMANDS:
if not who or who == botconfig.NICK: if not who or who == botconfig.NICK:
cli.msg(chan, "That won't work.") cli.msg(chan, "That won't work.")
return return
if who == "*":
who = var.list_players()
else:
if not is_fake_nick(who) and who != "*": if not is_fake_nick(who) and who != "*":
ul = list(var.USERS.keys()) ul = list(var.USERS.keys())
ull = [u.lower() for u in ul] ull = [u.lower() for u in ul]
if who.lower() not in ull: if who.lower() not in ull:
cli.msg(chan, "This can only be done on fake nicks.") cli.msg(chan, "This can only be done on players in the channel or fake nicks.")
return return
else: else:
who = ul[ull.index(who.lower())] who = [ul[ull.index(who.lower())]]
if who == "*":
who = var.list_players()
else:
who = [who]
comm = rst.pop(0).lower().replace(botconfig.CMD_CHAR, "", 1) comm = rst.pop(0).lower().replace(botconfig.CMD_CHAR, "", 1)
did = False
if comm in COMMANDS and not COMMANDS[comm][0].owner_only: if comm in COMMANDS and not COMMANDS[comm][0].owner_only:
if (COMMANDS[comm][0].admin_only and nick in var.USERS and for fn in COMMANDS[comm]:
not is_admin(nick)): if fn.owner_only:
continue
if fn.admin_only and nick in var.USERS and not is_admin(nick):
# 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
for fn in COMMANDS[comm]:
for guy in who:
if fn.raw_nick:
continue continue
for user in who:
if fn.chan: if fn.chan:
fn(cli, guy, chan, " ".join(rst)) fn(cli, user, chan, " ".join(rst))
else: else:
fn(cli, guy, guy, " ".join(rst)) fn(cli, user, user, " ".join(rst))
did = True
if did:
cli.msg(chan, "Operation successful.") cli.msg(chan, "Operation successful.")
else:
cli.msg(chan, "Not possible with this command.")
else: else:
cli.msg(chan, "That command was not found.") cli.msg(chan, "That command was not found.")
@cmd("rforce", admin_only=True) @cmd("rforce", admin_only=True)
def rforcepm(cli, nick, chan, rest): def rforce(cli, nick, chan, rest):
rst = re.split(" +",rest) rst = re.split(" +",rest)
if len(rst) < 2: if len(rst) < 2:
cli.msg(chan, "The syntax is incorrect.") cli.msg(chan, "The syntax is incorrect.")
@ -6725,18 +6717,18 @@ if botconfig.DEBUG_MODE or botconfig.ALLOWED_NORMAL_MODE_COMMANDS:
comm = rst.pop(0).lower().replace(botconfig.CMD_CHAR, "", 1) comm = rst.pop(0).lower().replace(botconfig.CMD_CHAR, "", 1)
if comm in COMMANDS and not COMMANDS[comm][0].owner_only: if comm in COMMANDS and not COMMANDS[comm][0].owner_only:
if (COMMANDS[comm][0].admin_only and nick in var.USERS and for fn in COMMANDS[comm]:
not is_admin(nick)): if fn.owner_only:
continue
if fn.admin_only and nick in var.USERS and not is_admin(nick):
# 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 continue
for user in tgt[:]:
for fn in COMMANDS[comm]:
for guy in tgt[:]:
if fn.chan: if fn.chan:
fn(cli, guy, chan, " ".join(rst)) fn(cli, user, chan, " ".join(rst))
else: else:
fn(cli, guy, guy, " ".join(rst)) fn(cli, user, user, " ".join(rst))
cli.msg(chan, "Operation successful.") cli.msg(chan, "Operation successful.")
else: else:
cli.msg(chan, "That command was not found.") cli.msg(chan, "That command was not found.")