From d0cd1a25d7d02f0ce4dc0ef54ed0f1b1cf8d5e21 Mon Sep 17 00:00:00 2001 From: Ruben van de Ven Date: Sat, 30 Nov 2019 18:15:09 +0100 Subject: [PATCH] Use label in eventLog/timeline --- hugvey/story.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/hugvey/story.py b/hugvey/story.py index 8870c78..a7183b8 100644 --- a/hugvey/story.py +++ b/hugvey/story.py @@ -57,6 +57,7 @@ class Message(object): def __init__(self, id, text): self.id = id self.text = text + self.label = None self.isStart = False self.isStrandStart = False self.chapterStart = False @@ -106,6 +107,7 @@ class Message(object): msg.chapterStart = bool(data['chapterStart']) if 'chapterStart' in data else False msg.afterrunTime = data['afterrun'] if 'afterrun' in data else 0. # TODO: investigate deprecation? msg.color = data['color'] if 'color' in data else None + msg.label = data['label'] if 'label' in data else None if 'audio' in data and data['audio'] is not None: msg.audioFile = data['audio']['file'] msg.setStory(story) @@ -164,6 +166,14 @@ class Message(object): text = text.replace('$'+var, replacement) return text + def getLabel(self): + """ + When a label is set, return that, else the original text + """ + if self.label and len(self.label): + return self.label + return self.getText() + def setReply(self, reply): self.reply = reply @@ -1878,7 +1888,7 @@ class Story(object): if message.id != self.startMessage.id: self.addToLog(message) - self.hugvey.eventLogger.info(f"message: {message.id} {message.uuid} start \"{message.getText()}\"") + self.hugvey.eventLogger.info(f"message: {message.id} {message.uuid} start \"{message.getLabel()}\"") # TODO: prep events & timer etc. fn = await message.getAudioFilePath()