Timeout Diversion improvements
This commit is contained in:
parent
eeed9e3161
commit
6ea2a68bcd
2 changed files with 23 additions and 3 deletions
|
@ -586,6 +586,16 @@ class Diversion(object):
|
|||
# not applicable a direction has been chosen
|
||||
return
|
||||
|
||||
if not story.lastMsgFinishTime:
|
||||
# not during play back
|
||||
return
|
||||
|
||||
now = story.timer.getElapsed()
|
||||
if now - story.lastMsgFinishTime < float(self.params['minTimeAfterMessage']):
|
||||
# not less than x sec after it
|
||||
return
|
||||
|
||||
|
||||
interval = float(self.params['interval'])
|
||||
if not self.params['fromLastMessage']:
|
||||
# (1) last spoken at all
|
||||
|
@ -607,19 +617,19 @@ class Diversion(object):
|
|||
if story.stats['diversions']['timeout_last'] + 1 != self.params['timesOccured']:
|
||||
return
|
||||
|
||||
if story.lastMsgFinishTime is None or story.currentReply is not None:
|
||||
if story.currentReply is not None:
|
||||
# still playing back
|
||||
# or somebody has spoken already (timeout only works on silences)
|
||||
return
|
||||
|
||||
if time.time() - story.lastMsgFinishTime < interval:
|
||||
if now - story.lastMsgFinishTime < interval:
|
||||
return
|
||||
|
||||
story.currentMessage.timeoutDiversionCount += 1
|
||||
story.stats['diversions']['timeout_last'] += 1
|
||||
|
||||
# if we're still here, there's a match!
|
||||
story.logger.info(f"Diverge: Timeout {self.id}")
|
||||
story.logger.info(f"Diverge: Timeout {self.id} of {self.params['interval']}")
|
||||
story.stats['diversions']['timeout'] += 1
|
||||
|
||||
msg = story.get(self.params['msgId'])
|
||||
|
|
|
@ -448,6 +448,7 @@ class Graph {
|
|||
else if(type == 'timeout') {
|
||||
div['params']['interval'] = 20;
|
||||
div['params']['timesOccured'] = 0;
|
||||
div['params']['minTimeAfterMessage'] = 2.;
|
||||
div['params']['fromLastMessage'] = false;
|
||||
div['params']['returnAfterStrand'] = true;
|
||||
div['params']['msgId'] = "";
|
||||
|
@ -685,6 +686,15 @@ class Graph {
|
|||
}
|
||||
})
|
||||
),
|
||||
crel('label', 'Minimum time after message',
|
||||
crel('input', {
|
||||
'type': 'number',
|
||||
'value': div['params']['minTimeAfterMessage'],
|
||||
'on': {
|
||||
'change': (e) => div['params']['minTimeAfterMessage'] = parseFloat(e.target.value)
|
||||
}
|
||||
})
|
||||
),
|
||||
crel('label', 'Return to point of departure afterwards',
|
||||
crel('input', returnAttrs)
|
||||
),
|
||||
|
|
Loading…
Reference in a new issue