Add telegram messaging for critical erros
This commit is contained in:
parent
a99c2dcfbf
commit
750406b784
6 changed files with 59 additions and 24 deletions
|
@ -28,6 +28,7 @@ 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
|
import datetime
|
||||||
|
import telegram_handler
|
||||||
|
|
||||||
mainLogger = logging.getLogger("hugvey")
|
mainLogger = logging.getLogger("hugvey")
|
||||||
|
|
||||||
|
@ -103,6 +104,21 @@ class CentralCommand(object):
|
||||||
|
|
||||||
self.panopticon = Panopticon(self, self.config, self.voiceStorage)
|
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<i>%(name)s:%(funcName)s (%(filename)s:%(lineno)d)</i>'
|
||||||
|
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):
|
def loadLanguages(self):
|
||||||
logger.debug('load language files')
|
logger.debug('load language files')
|
||||||
|
|
|
@ -41,7 +41,7 @@ if __name__ == '__main__':
|
||||||
logger = logging.getLogger("hugvey")
|
logger = logging.getLogger("hugvey")
|
||||||
# logger.setLevel(1) # to send all records to cutelog
|
# logger.setLevel(1) # to send all records to cutelog
|
||||||
socket_handler = logging.handlers.SocketHandler('127.0.0.1', 19996) # default listening address
|
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")
|
logger.info("Start server")
|
||||||
|
|
||||||
command = CentralCommand(args=args, debug_mode=args.verbose > 0)
|
command = CentralCommand(args=args, debug_mode=args.verbose > 0)
|
||||||
|
|
|
@ -51,3 +51,6 @@ light:
|
||||||
fade_duration_id: 37
|
fade_duration_id: 37
|
||||||
story:
|
story:
|
||||||
loop: true
|
loop: true
|
||||||
|
telegram:
|
||||||
|
token: null
|
||||||
|
chat_ids: []
|
|
@ -1,6 +1,17 @@
|
||||||
var ws = new ReconnectingWebSocket( window.location.origin.replace('http', 'ws') +'/ws', null, { debug: false, reconnectInterval: 3000 } );
|
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
|
//request close before unloading
|
||||||
window.addEventListener('beforeunload', function(){
|
window.addEventListener('beforeunload', function(){
|
||||||
|
@ -63,7 +74,6 @@ this.moveInterval = setInterval(function(){
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
var checkbox = document.getElementById('follow_checkbox')
|
var checkbox = document.getElementById('follow_checkbox')
|
||||||
|
|
||||||
checkbox.addEventListener('change', (event) => {
|
checkbox.addEventListener('change', (event) => {
|
||||||
if (event.target.checked) {
|
if (event.target.checked) {
|
||||||
this.moveInterval = setInterval(function(){
|
this.moveInterval = setInterval(function(){
|
||||||
|
@ -73,7 +83,7 @@ checkbox.addEventListener('change', (event) => {
|
||||||
} else {
|
} else {
|
||||||
clearInterval(this.moveInterval)
|
clearInterval(this.moveInterval)
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
|
|
||||||
ws.addEventListener( 'message', this);
|
ws.addEventListener( 'message', this);
|
||||||
|
@ -179,6 +189,9 @@ checkbox.addEventListener('change', (event) => {
|
||||||
this.eventDataSet.add({
|
this.eventDataSet.add({
|
||||||
content: msg['type'] +': ' + msg['info'] + (msg.hasOwnProperty('args')? ': '+msg['args'] : ""),
|
content: msg['type'] +': ' + msg['info'] + (msg.hasOwnProperty('args')? ': '+msg['args'] : ""),
|
||||||
start: new Date(), type: 'point', group: hv_id, 'className': msg['lvlname']});
|
start: new Date(), type: 'point', group: hv_id, 'className': msg['lvlname']});
|
||||||
|
if (msg['lvlname'] == 'CRITICAL' && playSoundOnError) {
|
||||||
|
// error_audio.play();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
BIN
www/siren.wav
Normal file
BIN
www/siren.wav
Normal file
Binary file not shown.
|
@ -76,7 +76,7 @@ font-size: 4.5pt;
|
||||||
border-color:darkred;
|
border-color:darkred;
|
||||||
border-radius:15px;
|
border-radius:15px;
|
||||||
}
|
}
|
||||||
#follow_button{
|
.buttons{
|
||||||
background: #669;
|
background: #669;
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
@ -129,7 +129,10 @@ padding: 0 5px;
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body id='timeline'>
|
<body id='timeline'>
|
||||||
|
<div class='buttons'>
|
||||||
<label id='follow_button'><input id="follow_checkbox" type="checkbox" name="follow" value="follow" checked> Follow timeline</label>
|
<label id='follow_button'><input id="follow_checkbox" type="checkbox" name="follow" value="follow" checked> Follow timeline</label>
|
||||||
|
<!-- <label id='sound_button'><input id="play_sound_on_error" type="checkbox" name="play_sound_on_error" value="play_sound_on_error" checked> Play sound on error</label>-->
|
||||||
|
</div>
|
||||||
<div id='line'></div>
|
<div id='line'></div>
|
||||||
|
|
||||||
<script type='application/javascript' src="/js/hugvey_timeline.js"></script>
|
<script type='application/javascript' src="/js/hugvey_timeline.js"></script>
|
||||||
|
|
Loading…
Reference in a new issue