Make !update not pull if a game is running

The reason we defer pulling is because if an error happens before
restarting, the line numbers in the traceback may not reflect the
actual line numbers since the code has changed.
This commit is contained in:
nyuszika7h 2016-10-25 17:49:10 +02:00
parent 946e84cbd3
commit 6ac05fb3e6

View File

@ -7297,6 +7297,16 @@ def fpull(cli, nick, chan, rest):
def update(cli, nick, chan, rest): def update(cli, nick, chan, rest):
"""Pulls from the repository and restarts the bot to update it.""" """Pulls from the repository and restarts the bot to update it."""
force = (rest.strip() == "-force")
if var.PHASE in var.GAME_PHASES:
if var.PHASE == "join" or force:
stop_game(cli, log=False)
else:
reply(cli, nick, chan, messages["stop_bot_ingame_safeguard"].format(
what="restart", cmd="update", prefix=botconfig.CMD_CHAR), private=True)
return
if update.aftergame: if update.aftergame:
# Display "Scheduled restart" instead of "Forced restart" when called with !faftergame # Display "Scheduled restart" instead of "Forced restart" when called with !faftergame
restart_program.aftergame = True restart_program.aftergame = True