diff --git a/hugvey/central_command.py b/hugvey/central_command.py index 5225d83..a516527 100644 --- a/hugvey/central_command.py +++ b/hugvey/central_command.py @@ -28,6 +28,7 @@ import copy from pythonosc.osc_server import AsyncIOOSCUDPServer from hugvey.variablestore import VariableStore import datetime +import telegram_handler mainLogger = logging.getLogger("hugvey") @@ -102,6 +103,21 @@ class CentralCommand(object): self.variableStore = VariableStore(varDb) self.panopticon = Panopticon(self, self.config, self.voiceStorage) + + # extra handlers so we get some info when AFK: + if 'telegram' in self.config and self.config['telegram']['token']: + fmt = '%(message)s\n%(name)s:%(funcName)s (%(filename)s:%(lineno)d)' + formatter = telegram_handler.HtmlFormatter(fmt=fmt, use_emoji = False) + for chat_id in self.config['telegram']['chat_ids']: + handler = telegram_handler.TelegramHandler( + token=self.config['telegram']['token'], + level=logging.CRITICAL, + chat_id=chat_id + ) + handler.setFormatter(formatter) + logging.getLogger('hugvey').addHandler(handler) + logger.critical("Start server with Telegram integration") + # telegram_handler.formatter.use_emoji = True def loadLanguages(self): diff --git a/hugvey_server.py b/hugvey_server.py index 09c52c6..5828a54 100644 --- a/hugvey_server.py +++ b/hugvey_server.py @@ -41,7 +41,7 @@ if __name__ == '__main__': logger = logging.getLogger("hugvey") # logger.setLevel(1) # to send all records to cutelog socket_handler = logging.handlers.SocketHandler('127.0.0.1', 19996) # default listening address - logger.addHandler(socket_handler); + logger.addHandler(socket_handler) logger.info("Start server") command = CentralCommand(args=args, debug_mode=args.verbose > 0) diff --git a/server_config.yml b/server_config.yml index 1f10b4f..2a63c59 100644 --- a/server_config.yml +++ b/server_config.yml @@ -50,4 +50,7 @@ light: off_intensity: 0 fade_duration_id: 37 story: - loop: true \ No newline at end of file + loop: true +telegram: + token: null + chat_ids: [] \ No newline at end of file diff --git a/www/js/hugvey_timeline.js b/www/js/hugvey_timeline.js index f151438..0e2e054 100644 --- a/www/js/hugvey_timeline.js +++ b/www/js/hugvey_timeline.js @@ -1,6 +1,17 @@ var ws = new ReconnectingWebSocket( window.location.origin.replace('http', 'ws') +'/ws', null, { debug: false, reconnectInterval: 3000 } ); -var seeme = true +var seeme = true; + +var error_audio = new Audio('siren.wav'); +var playSoundOnError = true; +var checkbox_sound = document.getElementById('play_sound_on_error') +checkbox_sound.addEventListener('change', (event) => { + if (event.target.checked) { + playSoundOnError = true; + } else { + playSoundOnError = false; + } +}) //request close before unloading window.addEventListener('beforeunload', function(){ @@ -50,30 +61,29 @@ class Timeline{ let endDate = new Date(); endDate.setMinutes(endDate.getMinutes()+20); - - -//follow the timeline or not if checkbox is checked -setTimeout(function(){ - tl.setWindow(startDate, endDate); -}, 500); - -this.moveInterval = setInterval(function(){ - // skip movement if not visible - tl.moveTo(new Date()); -}, 1000); - -var checkbox = document.getElementById('follow_checkbox') - -checkbox.addEventListener('change', (event) => { - if (event.target.checked) { + + + //follow the timeline or not if checkbox is checked + setTimeout(function(){ + tl.setWindow(startDate, endDate); + }, 500); + this.moveInterval = setInterval(function(){ // skip movement if not visible tl.moveTo(new Date()); }, 1000); - } else { - clearInterval(this.moveInterval) - } -}) + + var checkbox = document.getElementById('follow_checkbox') + checkbox.addEventListener('change', (event) => { + if (event.target.checked) { + this.moveInterval = setInterval(function(){ + // skip movement if not visible + tl.moveTo(new Date()); + }, 1000); + } else { + clearInterval(this.moveInterval) + } + }); ws.addEventListener( 'message', this); @@ -179,6 +189,9 @@ checkbox.addEventListener('change', (event) => { this.eventDataSet.add({ content: msg['type'] +': ' + msg['info'] + (msg.hasOwnProperty('args')? ': '+msg['args'] : ""), start: new Date(), type: 'point', group: hv_id, 'className': msg['lvlname']}); + if (msg['lvlname'] == 'CRITICAL' && playSoundOnError) { +// error_audio.play(); + } break; } } diff --git a/www/siren.wav b/www/siren.wav new file mode 100644 index 0000000..1ed30d1 Binary files /dev/null and b/www/siren.wav differ diff --git a/www/timeline.html b/www/timeline.html index 12b7e16..3dd0edc 100644 --- a/www/timeline.html +++ b/www/timeline.html @@ -76,7 +76,7 @@ font-size: 4.5pt; border-color:darkred; border-radius:15px; } -#follow_button{ +.buttons{ background: #669; border-radius: 2px; position: absolute; @@ -129,7 +129,10 @@ padding: 0 5px;
+