Prevent stacked timeout diversion and fix request for repeat
This commit is contained in:
parent
d4ce360e24
commit
02dcf17858
1 changed files with 15 additions and 5 deletions
|
@ -243,6 +243,12 @@ class Reply(object):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def getTimeSinceLastUtterance(self):
|
||||||
|
if not self.hasUtterances():
|
||||||
|
return None
|
||||||
|
|
||||||
|
return self.forMessage.story.timer.getElapsed() - self.getLastUtterance().lastUpdateTime
|
||||||
|
|
||||||
class Condition(object):
|
class Condition(object):
|
||||||
"""
|
"""
|
||||||
A condition, basic conditions are built in, custom condition can be given by
|
A condition, basic conditions are built in, custom condition can be given by
|
||||||
|
@ -408,7 +414,7 @@ class Condition(object):
|
||||||
delays = sorted(self.vars['delays'], key=lambda k: float(k['minReplyDuration']), reverse=True)
|
delays = sorted(self.vars['delays'], key=lambda k: float(k['minReplyDuration']), reverse=True)
|
||||||
for delay in delays:
|
for delay in delays:
|
||||||
if replyDuration > float(delay['minReplyDuration']):
|
if replyDuration > float(delay['minReplyDuration']):
|
||||||
timeSinceReply = story.timer.getElapsed() - r.getLastUtterance().lastUpdateTime
|
timeSinceReply = r.getTimeSinceLastUtterance()
|
||||||
story.logger.log(LOG_BS, f"check delay duration is now {replyDuration}, already waiting for {timeSinceReply}, have to wait {delay['waitTime']}")
|
story.logger.log(LOG_BS, f"check delay duration is now {replyDuration}, already waiting for {timeSinceReply}, have to wait {delay['waitTime']}")
|
||||||
if timeSinceReply > float(delay['waitTime']):
|
if timeSinceReply > float(delay['waitTime']):
|
||||||
# if variables are captured, only set them the moment the condition matches
|
# if variables are captured, only set them the moment the condition matches
|
||||||
|
@ -738,21 +744,22 @@ class Diversion(object):
|
||||||
"""
|
"""
|
||||||
Participant asks if message can be repeated.
|
Participant asks if message can be repeated.
|
||||||
"""
|
"""
|
||||||
if not msgFrom or not msgTo:
|
# if not msgFrom or not msgTo:
|
||||||
return
|
# return
|
||||||
|
|
||||||
# TODO: how to handle this now we sometimes use different timings.
|
# TODO: how to handle this now we sometimes use different timings.
|
||||||
# Perhaps set isFinished when matching condition.
|
# Perhaps set isFinished when matching condition.
|
||||||
if story.currentReply is None or story.currentReply.isSpeaking():
|
if story.currentReply is None or story.currentReply.getTimeSinceLastUtterance() > 1:
|
||||||
return
|
return
|
||||||
|
|
||||||
r = self.regex.search(story.currentReply.getText())
|
r = self.regex.search(story.currentReply.getText())
|
||||||
|
print('repeat?', r)
|
||||||
if r is None:
|
if r is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
logger.info(f"Diverge: request repeat {self.id}")
|
logger.info(f"Diverge: request repeat {self.id}")
|
||||||
story.stats['diversions']['repeat'] += 1
|
story.stats['diversions']['repeat'] += 1
|
||||||
await story.setCurrentMessage(msgFrom)
|
await story.setCurrentMessage(story.currentMessage)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
async def _divergeIfTimeout(self, story, msgFrom, msgTo, direction):
|
async def _divergeIfTimeout(self, story, msgFrom, msgTo, direction):
|
||||||
|
@ -760,6 +767,9 @@ class Diversion(object):
|
||||||
(1) last spoken at all
|
(1) last spoken at all
|
||||||
(2) or duration for this last reply only
|
(2) or duration for this last reply only
|
||||||
"""
|
"""
|
||||||
|
if story.currentDiversion:
|
||||||
|
return
|
||||||
|
|
||||||
if msgFrom or msgTo:
|
if msgFrom or msgTo:
|
||||||
# not applicable a direction has been chosen
|
# not applicable a direction has been chosen
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue