diff --git a/hugvey/story.py b/hugvey/story.py index 92754d1..4ccabab 100644 --- a/hugvey/story.py +++ b/hugvey/story.py @@ -452,17 +452,16 @@ class Condition(object): capturedVariables = result.groupdict() - if ('instantMatch' in self.vars and self.vars['instantMatch']) or not r.isSpeaking(): - # try to avoid setting variables for intermediate strings - for captureGroup in capturedVariables: - story.setVariableValue(captureGroup, capturedVariables[captureGroup]) - if 'instantMatch' in self.vars and self.vars['instantMatch']: story.logger.info(f"Instant match on {self.vars['regex']}, {self.vars}") self.logInfo = "Instant match of {}, captured {}".format( self.vars['regex'], capturedVariables ) + # Set variables only when direction returns true + if capturedVariables is not None: + for captureGroup in capturedVariables: + story.setVariableValue(captureGroup, capturedVariables[captureGroup]) return True # TODO: implement 'instant match' -> don't wait for isFinished()