From 06f1e92fcde528a1b459147232677b1096c5b44c Mon Sep 17 00:00:00 2001 From: Ruben van de Ven Date: Mon, 26 Aug 2019 10:25:22 +0200 Subject: [PATCH] Automatically trim msgId on message_played condition --- hugvey/story.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hugvey/story.py b/hugvey/story.py index 0912782..c3fac7d 100644 --- a/hugvey/story.py +++ b/hugvey/story.py @@ -464,9 +464,10 @@ class Condition(object): if not story.lastMsgFinishTime: return False - msg = story.get(self.vars['msgId']) + msgId = self.vars['msgId'].strip() + msg = story.get(msgId) 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 r = False else: @@ -474,7 +475,7 @@ class Condition(object): r = msg.isFinished() 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']: # inverse: @@ -482,7 +483,7 @@ class Condition(object): self.logInfo = "Has {} played msg {}".format( 'not' if 'inverseMatch' in self.vars and self.vars['inverseMatch'] else '', - self.vars['msgId'] + msgId ) return r