diff --git a/hugvey/central_command.py b/hugvey/central_command.py index aca3e36..5bef6db 100644 --- a/hugvey/central_command.py +++ b/hugvey/central_command.py @@ -429,7 +429,7 @@ class CentralCommand(object): return #TODO: hugveyid in log and prevent duplicate messages - logger.critical(f'Hugvey stopped (crashed?). Reinstantiate after 5 sec') + logger.critical(f'Hugvey {hugvey_id} stopped (crashed?). Reinstantiate after 5 sec') time.sleep(5) async def timerEmitter(self): diff --git a/hugvey/story.py b/hugvey/story.py index 19a211a..f1c0290 100644 --- a/hugvey/story.py +++ b/hugvey/story.py @@ -1762,6 +1762,21 @@ class Story(object): def logHasMsg(self, node): return node in self.msgLog + + def checkIfGone(self): + ''' + Make a guestimation if the audience has left... just really a simple timer check. + + If we do think so, give an error and stop the conversation + ''' + if not self.lastMsgFinishTime: + # don't do it when hugvey is speaking + return + + if self.timer.hasMark('last_speech') and self.timer.getElapsed('last_speech') > 30*60: + self.hugvey.eventLogger.warning("Audience is quiet for too long...stopping") + self.logger.warning("Audience is quiet, force END!") + self._finish() async def _renderer(self): """ @@ -1782,6 +1797,7 @@ class Story(object): directions = self.getCurrentDirections() await self._processDirections(directions) + self.checkIfGone() # TODO create timer event # self.commands.append({'msg':'TEST!'})