No critical on nonexisting message_played

This commit is contained in:
Ruben van de Ven 2019-11-12 14:22:08 +01:00
parent 76d440fd8f
commit f15126d0e4
3 changed files with 9 additions and 1 deletions

View file

@ -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)

View file

@ -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:

View file

@ -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)