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)