From f15126d0e4485831d4b3e11642397ebeb4aea304 Mon Sep 17 00:00:00 2001 From: Ruben van de Ven Date: Tue, 12 Nov 2019 14:22:08 +0100 Subject: [PATCH] No critical on nonexisting message_played --- hugvey/central_command.py | 1 + hugvey/story.py | 4 +++- hugvey/tools.py | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/hugvey/central_command.py b/hugvey/central_command.py index c908320..36beab7 100644 --- a/hugvey/central_command.py +++ b/hugvey/central_command.py @@ -359,6 +359,7 @@ class CentralCommand(object): # stop if False, ie. when stream has gone return + #TODO: hugveyid in log and prevent duplicate messages logger.critical(f'Hugvey stopped (crashed?). Reinstantiate after 5 sec') time.sleep(5) diff --git a/hugvey/story.py b/hugvey/story.py index 99cbce1..7f519d3 100644 --- a/hugvey/story.py +++ b/hugvey/story.py @@ -485,7 +485,9 @@ class Condition(object): msgId = self.vars['msgId'].strip() msg = story.get(msgId) if not msg: - story.logger.critical(f"Condition on non-existing message: {msgId}") + if not self.logInfo: + # show error only once + story.logger.warning(f"Condition on non-existing message: {msgId}") # assigning false to r, keeps 'inverseMatch' working, even when msgId is wrong r = False else: diff --git a/hugvey/tools.py b/hugvey/tools.py index 9afe7af..19bacc0 100644 --- a/hugvey/tools.py +++ b/hugvey/tools.py @@ -148,6 +148,11 @@ class Toolbox: logger.info(f"Direction pointed to {item['source']}") logger.info(f"Will now point to {validMsg}") item['source'] = item['source']['@id'] + if item['@type'] == 'Condition': + if item['type'] == 'messagePlayed': + msgId = item['vars']['msgId'].strip() + if msgId not in itemsPerId: + logger.critical(f"Message played condition for non-existing message {msgId}!") with open(filename, 'w') as fp: json.dump(story, fp, indent=2)