Stop story after 30 minutes of silence from the audience

This commit is contained in:
Ruben van de Ven 2019-11-28 18:47:58 +01:00
parent 44958e8340
commit d65a79d378
2 changed files with 17 additions and 1 deletions

View File

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

View File

@ -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!'})