Automatically trim msgId on message_played condition

This commit is contained in:
Ruben van de Ven 2019-08-26 10:25:22 +02:00
parent efd5298e45
commit 06f1e92fcd

View file

@ -464,9 +464,10 @@ class Condition(object):
if not story.lastMsgFinishTime: if not story.lastMsgFinishTime:
return False return False
msg = story.get(self.vars['msgId']) msgId = self.vars['msgId'].strip()
msg = story.get(msgId)
if not msg: if not msg:
story.logger.critical(f"Condition on non-existing message: {self.vars['msgId']}") story.logger.critical(f"Condition on non-existing message: {msgId}")
# assigning false to r, keeps 'inverseMatch' working, even when msgId is wrong # assigning false to r, keeps 'inverseMatch' working, even when msgId is wrong
r = False r = False
else: else:
@ -474,7 +475,7 @@ class Condition(object):
r = msg.isFinished() r = msg.isFinished()
if r: if r:
story.logger.debug(f"Msg {self.vars['msgId']} has been played.") story.logger.debug(f"Msg {msgId} has been played.")
if 'inverseMatch' in self.vars and self.vars['inverseMatch']: if 'inverseMatch' in self.vars and self.vars['inverseMatch']:
# inverse: # inverse:
@ -482,7 +483,7 @@ class Condition(object):
self.logInfo = "Has {} played msg {}".format( self.logInfo = "Has {} played msg {}".format(
'not' if 'inverseMatch' in self.vars and self.vars['inverseMatch'] else '', 'not' if 'inverseMatch' in self.vars and self.vars['inverseMatch'] else '',
self.vars['msgId'] msgId
) )
return r return r