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.google = None
|
||||
self.notShuttingDown = True # TODO: allow shutdown of object
|
||||
self.startMsgId = None
|
||||
|
||||
def getStatus(self):
|
||||
if self.story.isFinished():
|
||||
|
@ -362,18 +363,20 @@ class HugveyState(object):
|
|||
if self.story is None:
|
||||
return
|
||||
|
||||
# self.story.stop()
|
||||
self.pause()
|
||||
self.startMsgId = event['msg_id']
|
||||
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
|
||||
await asyncio.sleep(.1)
|
||||
self.logger.debug('restarted')
|
||||
msg = self.story.get(event['msg_id'])
|
||||
if not msg:
|
||||
self.logger.critical("Invalid ID to play: {}".format(event['msg_id']))
|
||||
else:
|
||||
self.story.setCurrentMessage(msg)
|
||||
|
||||
self.resume()
|
||||
# await asyncio.sleep(.1)
|
||||
# self.logger.debug('restarted')
|
||||
# msg = self.story.get(event['msg_id'])
|
||||
# if not msg:
|
||||
# self.logger.critical("Invalid ID to play: {}".format(event['msg_id']))
|
||||
# else:
|
||||
# self.story.setCurrentMessage(msg)
|
||||
#
|
||||
# self.resume()
|
||||
|
||||
self.eventQueue = None
|
||||
|
||||
|
@ -434,8 +437,11 @@ class HugveyState(object):
|
|||
|
||||
# new story instance on each run
|
||||
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])
|
||||
await self.story.run()
|
||||
await self.story.run(startMsgId)
|
||||
# self.story = None
|
||||
|
||||
def getStreamer(self):
|
||||
|
|
|
@ -606,11 +606,15 @@ class Story(object):
|
|||
else:
|
||||
return self.directionsPerMsg[self.currentMessage.id]
|
||||
|
||||
async def run(self):
|
||||
async def run(self, customStartMsgId = None):
|
||||
logger.info("Starting story")
|
||||
self.timer.reset()
|
||||
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()
|
||||
|
||||
def isFinished(self):
|
||||
|
|
Loading…
Reference in a new issue