Stop story after 30 minutes of silence from the audience
This commit is contained in:
parent
44958e8340
commit
d65a79d378
2 changed files with 17 additions and 1 deletions
|
@ -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):
|
||||
|
|
|
@ -1763,6 +1763,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):
|
||||
"""
|
||||
every 1/10 sec. determine what needs to be done based on the current story state
|
||||
|
@ -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!'})
|
||||
|
|
Loading…
Reference in a new issue