Fixed bug similar to Munchen bug - on multiple hits of the same diverison (or one that shares messages) it went back to old moment in the story

This commit is contained in:
Ruben van de Ven 2019-08-30 21:46:25 +02:00
parent 293bc3a2ea
commit c24e0aa529
1 changed files with 9 additions and 1 deletions

View File

@ -814,6 +814,7 @@ class Diversion(object):
story.add(condition2)
direction.isDiversionReturn = True # will clear the currentDiversion on story
story.diversionDirections.append(direction)
story.logger.info(f"Created direction: {direction.id} ({msg.id} -> {usedReturnMessage.id}) {condition.id} with timeout {finalTimeoutDuration}s")
story.add(condition)
story.add(direction)
@ -1399,6 +1400,7 @@ class Story(object):
self.variableValues = {} # captured variables from replies
self.finish_time = False
self.runId = uuid.uuid4().hex
self.diversionDirections = []
self.events = [] # queue of received events
self.commands = [] # queue of commands to send
@ -1602,10 +1604,16 @@ class Story(object):
if not isDiverging and chosenDirection:
if chosenDirection.isDiversionReturn and self.currentDiversion:
chosenDirection.diversionHasReturned = True
for direction in self.diversionDirections:
if direction.isDiversionReturn and not direction.diversionHasReturned:
self.logger.info(f"Mark diversion as returned for return direction {direction.id}")
direction.diversionHasReturned = True
# chosenDirection.diversionHasReturned = True
await self.currentDiversion.finalise(self)
await self.setCurrentMessage(chosenDirection.msgTo, allowReplyInterrupt=allowReplyInterrupt)
return chosenDirection