diff --git a/libs/basic.js b/libs/basic.js index e8dea905..c2fefaa3 100644 --- a/libs/basic.js +++ b/libs/basic.js @@ -226,4 +226,19 @@ module.exports = function(s,config){ break; } } + s.createTimeout = function(timeoutVar,timeoutLength,defaultLength,multiplier,callback){ + var theTimeout + if(!multiplier)multiplier = 1000 * 60 + if(!timeoutLength || timeoutLength === ''){ + theTimeout = defaultLength + }else{ + theTimeout = parseFloat(timeoutLength) * multiplier + } + clearTimeout(timeoutVar) + timeoutVar = setTimeout(function(){ + clearTimeout(timeoutVar) + delete(timeoutVar) + if(callback)callback() + },theTimeout) + } } diff --git a/libs/events.js b/libs/events.js index f668b47f..9c2ad807 100644 --- a/libs/events.js +++ b/libs/events.js @@ -300,7 +300,7 @@ module.exports = function(s,config,lang){ }) if(filter.webhook && currentConfig.detector_webhook === '1'){ - var detector_webhook_url = addEventDetailsToString(currentConfig.detector_webhook_url) + var detector_webhook_url = addEventDetailsToString(d,currentConfig.detector_webhook_url) request({url:detector_webhook_url,method:'GET',encoding:null},function(err,data){ if(err){ s.userLog(d,{type:lang["Event Webhook Error"],msg:{error:err,data:data}}) @@ -309,8 +309,8 @@ module.exports = function(s,config,lang){ } if(filter.command && currentConfig.detector_command_enable === '1' && !s.group[d.ke].mon[d.id].detector_command){ - s.createMonitorTimeout('detector_command',currentConfig.detector_command_timeout,10) - var detector_command = addEventDetailsToString(currentConfig.detector_command) + s.createTimeout(s.group[d.ke].mon[d.id].detector_command,currentConfig.detector_command_timeout,10) + var detector_command = addEventDetailsToString(d,currentConfig.detector_command) exec(detector_command,{detached: true}) } } diff --git a/libs/monitor.js b/libs/monitor.js index 95906465..07095e04 100644 --- a/libs/monitor.js +++ b/libs/monitor.js @@ -1552,19 +1552,4 @@ module.exports = function(s,config,lang){ } }) } - s.createMonitorTimeout = function(nameOftTimeout,timeoutLength,defaultLength,multiplier,callback){ - var theTimeout - if(!multiplier)multiplier = 1000 * 60 - if(!timeoutLength || timeoutLength === ''){ - theTimeout = defaultLength - }else{ - theTimeout = parseFloat(timeoutLength) * multiplier - } - clearTimeout(s.group[d.ke].mon[d.id][nameOftTimeout]) - s.group[d.ke].mon[d.id][nameOftTimeout] = setTimeout(function(){ - clearTimeout(s.group[d.ke].mon[d.id][nameOftTimeout]) - delete(s.group[d.ke].mon[d.id][nameOftTimeout]) - if(callback)callback() - },theTimeout) - } }