Fix !lastgame

It simply didn't work before now for a while (as in, you could still
join/start). Also make it function during join phase, because having
weird restrictions on which it does/doesn't disable the commands is
weird. The admin can still !fjoin/!fstart as needed if they do want to
run one more game after executing this command during join phase.
This commit is contained in:
skizzerz 2017-03-02 14:18:14 -06:00
parent 426a86e909
commit 54de373242

View File

@ -6709,12 +6709,19 @@ def aftergame(var, wrapper, message):
def _command_disabled(var, wrapper, message):
wrapper.send(messages["command_disabled_admin"])
def _command_disabled_oldapi(cli, nick, chan, rest):
# FIXME: kill this off when the old @cmd API is completely killed off
reply(cli, nick, chan, messages["command_disabled_admin"])
@command("lastgame", "flastgame", flag="D", pm=True)
def flastgame(var, wrapper, message):
"""Disables starting or joining a game, and optionally schedules a command to run after the current game ends."""
if var.PHASE != "join":
for decor in (COMMANDS["join"] + COMMANDS["start"]):
decor(_command_disabled)
for cmdcls in (COMMANDS["join"] + COMMANDS["start"]):
if isinstance(cmdcls, command):
cmdcls.func = _command_disabled
else:
# FIXME: kill this off when the old @cmd API is completely killed off
cmdcls.func = _command_disabled_oldapi
channels.Main.send(messages["disable_new_games"].format(wrapper.source))
var.ADMIN_TO_PING = wrapper.source