Fixes save & play from message
This commit is contained in:
parent
31490fe514
commit
138ede6ad6
2 changed files with 24 additions and 14 deletions
|
@ -265,6 +265,7 @@ class HugveyState(object):
|
||||||
self.status = self.STATE_PAUSE
|
self.status = self.STATE_PAUSE
|
||||||
self.google = None
|
self.google = None
|
||||||
self.notShuttingDown = True # TODO: allow shutdown of object
|
self.notShuttingDown = True # TODO: allow shutdown of object
|
||||||
|
self.startMsgId = None
|
||||||
|
|
||||||
def getStatus(self):
|
def getStatus(self):
|
||||||
if self.story.isFinished():
|
if self.story.isFinished():
|
||||||
|
@ -362,18 +363,20 @@ class HugveyState(object):
|
||||||
if self.story is None:
|
if self.story is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
# self.story.stop()
|
self.startMsgId = event['msg_id']
|
||||||
self.pause()
|
self.logger.debug(f"Restart from {self.startMsgId}")
|
||||||
|
self.restart()
|
||||||
|
# self.pause() # this doesn't reload story data!! Make sure we restart
|
||||||
# wait a tat for the restart loops to complete
|
# wait a tat for the restart loops to complete
|
||||||
await asyncio.sleep(.1)
|
# await asyncio.sleep(.1)
|
||||||
self.logger.debug('restarted')
|
# self.logger.debug('restarted')
|
||||||
msg = self.story.get(event['msg_id'])
|
# msg = self.story.get(event['msg_id'])
|
||||||
if not msg:
|
# if not msg:
|
||||||
self.logger.critical("Invalid ID to play: {}".format(event['msg_id']))
|
# self.logger.critical("Invalid ID to play: {}".format(event['msg_id']))
|
||||||
else:
|
# else:
|
||||||
self.story.setCurrentMessage(msg)
|
# self.story.setCurrentMessage(msg)
|
||||||
|
#
|
||||||
self.resume()
|
# self.resume()
|
||||||
|
|
||||||
self.eventQueue = None
|
self.eventQueue = None
|
||||||
|
|
||||||
|
@ -434,8 +437,11 @@ class HugveyState(object):
|
||||||
|
|
||||||
# new story instance on each run
|
# new story instance on each run
|
||||||
self.story = Story(self)
|
self.story = Story(self)
|
||||||
|
startMsgId = self.startMsgId
|
||||||
|
self.startMsgId = None # use only once, reset before 'run'
|
||||||
|
self.logger.warn(f"Starting from {startMsgId}")
|
||||||
self.story.setStoryData(self.command.languages[self.language_code])
|
self.story.setStoryData(self.command.languages[self.language_code])
|
||||||
await self.story.run()
|
await self.story.run(startMsgId)
|
||||||
# self.story = None
|
# self.story = None
|
||||||
|
|
||||||
def getStreamer(self):
|
def getStreamer(self):
|
||||||
|
|
|
@ -606,11 +606,15 @@ class Story(object):
|
||||||
else:
|
else:
|
||||||
return self.directionsPerMsg[self.currentMessage.id]
|
return self.directionsPerMsg[self.currentMessage.id]
|
||||||
|
|
||||||
async def run(self):
|
async def run(self, customStartMsgId = None):
|
||||||
logger.info("Starting story")
|
logger.info("Starting story")
|
||||||
self.timer.reset()
|
self.timer.reset()
|
||||||
self.isRunning = True
|
self.isRunning = True
|
||||||
self.setCurrentMessage(self.startMessage)
|
if customStartMsgId is not None:
|
||||||
|
startMsg = self.get(customStartMsgId)
|
||||||
|
else:
|
||||||
|
startMsg = self.startMessage
|
||||||
|
self.setCurrentMessage(startMsg)
|
||||||
await self._renderer()
|
await self._renderer()
|
||||||
|
|
||||||
def isFinished(self):
|
def isFinished(self):
|
||||||
|
|
Loading…
Reference in a new issue