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
|
import copy
|
||||||
from pythonosc.osc_server import AsyncIOOSCUDPServer
|
from pythonosc.osc_server import AsyncIOOSCUDPServer
|
||||||
from hugvey.variablestore import VariableStore
|
from hugvey.variablestore import VariableStore
|
||||||
|
import datetime
|
||||||
|
|
||||||
mainLogger = logging.getLogger("hugvey")
|
mainLogger = logging.getLogger("hugvey")
|
||||||
|
|
||||||
|
@ -143,6 +144,22 @@ class CentralCommand(object):
|
||||||
status['has_state'] = Story.hugveyHasSavedState(hv.lightId)
|
status['has_state'] = Story.hugveyHasSavedState(hv.lightId)
|
||||||
status['variables'] = {} if not isSelected or not hv.story else hv.story.variableValues
|
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
|
return status
|
||||||
|
|
||||||
def getStatusSummary(self, selected_ids = []):
|
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.uuid = None # Have a unique id each time the message is played back.
|
||||||
self.color = None
|
self.color = None
|
||||||
self.lightChange = None
|
self.lightChange = None
|
||||||
|
self.didRepeat = False
|
||||||
|
|
||||||
# Used by diversions, autogenerated directions should link to next chapter mark instead of the given msgTo
|
# Used by diversions, autogenerated directions should link to next chapter mark instead of the given msgTo
|
||||||
self.generatedDirectionsJumpToChapter = False
|
self.generatedDirectionsJumpToChapter = False
|
||||||
|
@ -345,6 +346,9 @@ class Condition(object):
|
||||||
|
|
||||||
if 'vars' in data:
|
if 'vars' in data:
|
||||||
condition.vars = data['vars']
|
condition.vars = data['vars']
|
||||||
|
|
||||||
|
if 'regex' in condition.vars:
|
||||||
|
condition.vars['regex'] = condition.vars['regex'].rstrip()
|
||||||
|
|
||||||
return condition
|
return condition
|
||||||
|
|
||||||
|
@ -669,7 +673,7 @@ class Diversion(object):
|
||||||
self.method = self._divergeIfReplyContains
|
self.method = self._divergeIfReplyContains
|
||||||
self.finaliseMethod = self._returnAfterReplyContains
|
self.finaliseMethod = self._returnAfterReplyContains
|
||||||
if len(self.params['regex']) > 0:
|
if len(self.params['regex']) > 0:
|
||||||
self.regex = re.compile(self.params['regex'])
|
self.regex = re.compile(self.params['regex'].rstrip())
|
||||||
else:
|
else:
|
||||||
self.regex = None
|
self.regex = None
|
||||||
|
|
||||||
|
@ -680,7 +684,7 @@ class Diversion(object):
|
||||||
self.method = self._divergeIfCollectiveMoment
|
self.method = self._divergeIfCollectiveMoment
|
||||||
if type == 'repeat':
|
if type == 'repeat':
|
||||||
self.method = self._divergeIfRepeatRequest
|
self.method = self._divergeIfRepeatRequest
|
||||||
self.regex = re.compile(self.params['regex'])
|
self.regex = re.compile(self.params['regex'].rstrip())
|
||||||
if type == 'interrupt':
|
if type == 'interrupt':
|
||||||
self.method = self._divergeIfInterrupted
|
self.method = self._divergeIfInterrupted
|
||||||
|
|
||||||
|
@ -982,6 +986,10 @@ class Diversion(object):
|
||||||
# Perhaps set isFinished when matching condition.
|
# Perhaps set isFinished when matching condition.
|
||||||
if story.currentReply is None or story.currentReply.getTimeSinceLastUtterance() < 1.8:
|
if story.currentReply is None or story.currentReply.getTimeSinceLastUtterance() < 1.8:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if story.currentMessage.didRepeat:
|
||||||
|
# repeat only once
|
||||||
|
return
|
||||||
|
|
||||||
r = self.regex.search(story.currentReply.getText())
|
r = self.regex.search(story.currentReply.getText())
|
||||||
if r is None:
|
if r is None:
|
||||||
|
@ -990,6 +998,7 @@ class Diversion(object):
|
||||||
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(story.currentMessage)
|
await story.setCurrentMessage(story.currentMessage)
|
||||||
|
story.currentMessage.didRepeat = True
|
||||||
return True
|
return True
|
||||||
|
|
||||||
async def _divergeIfTimeout(self, story, msgFrom, msgTo, direction):
|
async def _divergeIfTimeout(self, story, msgFrom, msgTo, direction):
|
||||||
|
@ -1505,6 +1514,7 @@ class Story(object):
|
||||||
# if self.currentDiversion is not None:
|
# if self.currentDiversion is not None:
|
||||||
# await self.currentDiversion.finalise(self)
|
# await self.currentDiversion.finalise(self)
|
||||||
# else:
|
# 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.logger.info("THE END!")
|
||||||
self._finish()
|
self._finish()
|
||||||
return
|
return
|
||||||
|
|
|
@ -99,7 +99,7 @@ checkbox.addEventListener('change', (event) => {
|
||||||
console.log(hv['language'], hv['status']);
|
console.log(hv['language'], hv['status']);
|
||||||
let evenOdd = parseInt(hv['id'])%2 ? 'odd': 'even';
|
let evenOdd = parseInt(hv['id'])%2 ? 'odd': 'even';
|
||||||
let availableClass = hv['available'] ? 'is-available' : 'is-not-available'
|
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{
|
.status-running.lang-de-DE{
|
||||||
background: slategray;
|
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>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body id='timeline'>
|
<body id='timeline'>
|
||||||
|
|
Loading…
Reference in a new issue