From dbcff9323706aad88d6dee8ddd6cc1d05447ea31 Mon Sep 17 00:00:00 2001 From: Ruben van de Ven Date: Sun, 16 Jun 2019 19:42:59 +0200 Subject: [PATCH] Fix bug that caused diversions with the same message to launch people back in their timeline --- hugvey/story.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hugvey/story.py b/hugvey/story.py index 9fb4213..01c56db 100644 --- a/hugvey/story.py +++ b/hugvey/story.py @@ -549,6 +549,7 @@ class Direction(object): self.conditions = [] self.conditionMet = None self.isDiversionReturn = False + self.diversionHasReturned = False # for isDiversionReturn. def __getstate__(self): @@ -1438,6 +1439,12 @@ class Story(object): chosenDirection = None metCondition = None for direction in directions: + if direction.isDiversionReturn and direction.diversionHasReturned: + # Prevent that returns created from the same message send you + # back to a previous point in time. +# self.logger.warn("Skipping double direction for diversion") + continue + condition = self._processDirection(direction) if not condition: continue @@ -1461,6 +1468,7 @@ class Story(object): if not isDiverging and chosenDirection: if chosenDirection.isDiversionReturn and self.currentDiversion: + chosenDirection.diversionHasReturned = True await self.currentDiversion.finalise(self) await self.setCurrentMessage(chosenDirection.msgTo, allowReplyInterrupt=allowReplyInterrupt)