Times in timeline
This commit is contained in:
parent
0418091ac0
commit
17a89b2494
4 changed files with 42 additions and 3 deletions
|
@ -27,6 +27,7 @@ from pythonosc import udp_client, osc_server, dispatcher
|
|||
import copy
|
||||
from pythonosc.osc_server import AsyncIOOSCUDPServer
|
||||
from hugvey.variablestore import VariableStore
|
||||
import datetime
|
||||
|
||||
mainLogger = logging.getLogger("hugvey")
|
||||
|
||||
|
@ -143,6 +144,22 @@ class CentralCommand(object):
|
|||
status['has_state'] = Story.hugveyHasSavedState(hv.lightId)
|
||||
status['variables'] = {} if not isSelected or not hv.story else hv.story.variableValues
|
||||
|
||||
if not hv.story:
|
||||
status['time_since_hugvey_spoke'] = '-'
|
||||
status['time_since_visitor_spoke'] = '-'
|
||||
else:
|
||||
if not hv.story.lastMsgStartTime:
|
||||
status['time_since_hugvey_spoke'] = '?'
|
||||
elif not hv.story.lastMsgFinishTime:
|
||||
status['time_since_hugvey_spoke'] = 'speaking'
|
||||
else:
|
||||
status['time_since_hugvey_spoke'] = str(datetime.timedelta(seconds=int(hv.story.timer.getElapsed() - hv.story.lastMsgFinishTime)))
|
||||
|
||||
if not hv.story.timer.hasMark('last_speech'):
|
||||
status['time_since_visitor_spoke'] = 'never'
|
||||
else:
|
||||
status['time_since_visitor_spoke'] = str(datetime.timedelta(seconds=int(hv.story.timer.getElapsed('last_speech'))))
|
||||
|
||||
return status
|
||||
|
||||
def getStatusSummary(self, selected_ids = []):
|
||||
|
|
|
@ -74,6 +74,7 @@ class Message(object):
|
|||
self.uuid = None # Have a unique id each time the message is played back.
|
||||
self.color = None
|
||||
self.lightChange = None
|
||||
self.didRepeat = False
|
||||
|
||||
# Used by diversions, autogenerated directions should link to next chapter mark instead of the given msgTo
|
||||
self.generatedDirectionsJumpToChapter = False
|
||||
|
@ -345,6 +346,9 @@ class Condition(object):
|
|||
|
||||
if 'vars' in data:
|
||||
condition.vars = data['vars']
|
||||
|
||||
if 'regex' in condition.vars:
|
||||
condition.vars['regex'] = condition.vars['regex'].rstrip()
|
||||
|
||||
return condition
|
||||
|
||||
|
@ -669,7 +673,7 @@ class Diversion(object):
|
|||
self.method = self._divergeIfReplyContains
|
||||
self.finaliseMethod = self._returnAfterReplyContains
|
||||
if len(self.params['regex']) > 0:
|
||||
self.regex = re.compile(self.params['regex'])
|
||||
self.regex = re.compile(self.params['regex'].rstrip())
|
||||
else:
|
||||
self.regex = None
|
||||
|
||||
|
@ -680,7 +684,7 @@ class Diversion(object):
|
|||
self.method = self._divergeIfCollectiveMoment
|
||||
if type == 'repeat':
|
||||
self.method = self._divergeIfRepeatRequest
|
||||
self.regex = re.compile(self.params['regex'])
|
||||
self.regex = re.compile(self.params['regex'].rstrip())
|
||||
if type == 'interrupt':
|
||||
self.method = self._divergeIfInterrupted
|
||||
|
||||
|
@ -982,6 +986,10 @@ class Diversion(object):
|
|||
# Perhaps set isFinished when matching condition.
|
||||
if story.currentReply is None or story.currentReply.getTimeSinceLastUtterance() < 1.8:
|
||||
return
|
||||
|
||||
if story.currentMessage.didRepeat:
|
||||
# repeat only once
|
||||
return
|
||||
|
||||
r = self.regex.search(story.currentReply.getText())
|
||||
if r is None:
|
||||
|
@ -990,6 +998,7 @@ class Diversion(object):
|
|||
logger.info(f"Diverge: request repeat {self.id}")
|
||||
story.stats['diversions']['repeat'] += 1
|
||||
await story.setCurrentMessage(story.currentMessage)
|
||||
story.currentMessage.didRepeat = True
|
||||
return True
|
||||
|
||||
async def _divergeIfTimeout(self, story, msgFrom, msgTo, direction):
|
||||
|
@ -1505,6 +1514,7 @@ class Story(object):
|
|||
# if self.currentDiversion is not None:
|
||||
# await self.currentDiversion.finalise(self)
|
||||
# else:
|
||||
# TODO: check if direction that exists are diversion returns, and if they are already taken. Otherwise story blocks
|
||||
self.logger.info("THE END!")
|
||||
self._finish()
|
||||
return
|
||||
|
|
|
@ -99,7 +99,7 @@ checkbox.addEventListener('change', (event) => {
|
|||
console.log(hv['language'], hv['status']);
|
||||
let evenOdd = parseInt(hv['id'])%2 ? 'odd': 'even';
|
||||
let availableClass = hv['available'] ? 'is-available' : 'is-not-available'
|
||||
this.dataGroups.update({id: parseInt(hv['id']), content: 'Hugvey #'+hv['id'], className: `status-${hv['status']} ${availableClass} lang-${hv['language']} ${evenOdd}`})
|
||||
this.dataGroups.update({id: parseInt(hv['id']), content: `<div class='title'>Hugvey #${hv['id']}</div><div class='times'><span>${hv['time_since_hugvey_spoke']}</span><span>${hv['time_since_visitor_spoke']}</span></div>`, className: `status-${hv['status']} ${availableClass} lang-${hv['language']} ${evenOdd}`})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -114,6 +114,18 @@ font-size: 20pt;
|
|||
.status-running.lang-de-DE{
|
||||
background: slategray;
|
||||
}
|
||||
.vis-label .vis-inner div.title{
|
||||
display:inline-block;
|
||||
padding-top:0;
|
||||
}
|
||||
.vis-label .vis-inner div.times{
|
||||
float:right;
|
||||
font-size: 50%;line-height:1;
|
||||
}
|
||||
.vis-label .vis-inner div.times span{
|
||||
display:block;
|
||||
padding: 0 5px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body id='timeline'>
|
||||
|
|
Loading…
Reference in a new issue