From 6ac05fb3e69e8b097353e90e7765a709aaad14f6 Mon Sep 17 00:00:00 2001 From: nyuszika7h Date: Tue, 25 Oct 2016 17:49:10 +0200 Subject: [PATCH] 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. --- src/wolfgame.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/wolfgame.py b/src/wolfgame.py index 4265ea8..3c8d3ae 100644 --- a/src/wolfgame.py +++ b/src/wolfgame.py @@ -7297,6 +7297,16 @@ def fpull(cli, nick, chan, rest): def update(cli, nick, chan, rest): """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: # Display "Scheduled restart" instead of "Forced restart" when called with !faftergame restart_program.aftergame = True