Option to attach video on event (Discord and Email)

merge-requests/3/head
Moe 2018-07-12 11:27:15 -07:00
parent 70500dca7a
commit 950fc7c8c1
3 changed files with 44 additions and 17 deletions

View File

@ -284,6 +284,10 @@ if(config.discordBot === true){
var Discord = require("discord.js")
s.sendDiscordAlert = function(data,files,groupKey){
if(!data)data = {};
var bot = s.group[groupKey].discordBot
if(!bot){
s.log({ke:groupKey,mid:'$USER'},{type:lang.DiscordFailedText,msg:lang.DiscordNotEnabledText})
}
var sendBody = Object.assign({
color: 3447003,
title: 'Alert from Shinobi',
@ -295,7 +299,7 @@ if(config.discordBot === true){
text: "Shinobi Systems"
}
},data)
s.group[groupKey].discordBot.channels.get(s.group[groupKey].init.discordbot_channel).send({
bot.channels.get(s.group[groupKey].init.discordbot_channel).send({
embed: sendBody,
files: files
})
@ -3443,15 +3447,17 @@ s.camera=function(x,e,cn,tx){
}
},files,d.ke)
}
if(!detectorStreamBuffers){
detectorStreamBuffers = s.getDetectorStreams(d)
}
detectorStreamBuffers.slice(detectorStreamBuffers.length - 2,detectorStreamBuffers.length).forEach(function(filepath,n){
files.push({
attachment: filepath,
name: 'Video Clip '+n+'.ts'
if(d.mon.details.detector_discordbot_send_video === '1'){
if(!detectorStreamBuffers){
detectorStreamBuffers = s.getDetectorStreams(d)
}
detectorStreamBuffers.slice(detectorStreamBuffers.length - 2,detectorStreamBuffers.length).forEach(function(filepath,n){
files.push({
attachment: filepath,
name: 'Video Clip '+n+'.ts'
})
})
})
}
if(screenshotBuffer){
sendAlert()
}else if(d.mon.details.snap === '1'){
@ -3506,15 +3512,17 @@ s.camera=function(x,e,cn,tx){
}
})
}
if(!detectorStreamBuffers){
detectorStreamBuffers = s.getDetectorStreams(d)
}
detectorStreamBuffers.slice(detectorStreamBuffers.length - 2,detectorStreamBuffers.length).forEach(function(filepath,n){
files.push({
filename: 'Video Clip '+n+'.ts',
content: fs.readFileSync(filepath)
if(d.mon.details.detector_mail_send_video === '1'){
if(!detectorStreamBuffers){
detectorStreamBuffers = s.getDetectorStreams(d)
}
detectorStreamBuffers.slice(detectorStreamBuffers.length - 2,detectorStreamBuffers.length).forEach(function(filepath,n){
files.push({
filename: 'Video Clip '+n+'.ts',
content: fs.readFileSync(filepath)
})
})
})
}
if(screenshotBuffer){
sendMail()
}else if(d.mon.details.snap === '1'){

View File

@ -378,9 +378,12 @@
"Allow Next Trigger": "Allow Next Trigger <small>in Milliseconds</small>",
"Save Events to SQL": "Save Events to SQL",
"Email on Trigger": "Email on Trigger <small>Emails go to the main account holder's login address.</small>",
"Attach Video Clip": "Attach Video Clip",
"Discord Alert on Trigger": "Discord Alert on Trigger",
"Allow Next Email": "Allow Next Email <small>in Minutes</small>",
"Allow Next Discord Alert": "Allow Next Discord Alert <small>in Minutes</small>",
"DiscordFailedText": "Sending to Discord Failed",
"DiscordNotEnabledText": "Discord Bot Not Enabled, Enable it in your Account Settings.",
"How to Record": "How to Record",
"Trigger Record": "Trigger Record",
"Recording Timeout": "Recording Timeout <small>in Minutes</small>",

View File

@ -961,6 +961,14 @@
</select></div>
</label>
</div>
<div class="form-group h_det_email_input h_det_email_1">
<label><div><span><%-lang['Attach Video Clip']%></span></div>
<div><select class="form-control" detail="detector_discordbot_send_video">
<option value="0" selected><%-lang.No%></option>
<option value="1"><%-lang.Yes%></option>
</select></div>
</label>
</div>
<div class="form-group h_det_email_input h_det_email_1">
<label><div><span><%-lang['Allow Next Email']%></span></div>
<div><input class="form-control" detail="detector_mail_timeout" placeholder="10"></div>
@ -974,6 +982,14 @@
</select></div>
</label>
</div>
<div class="form-group h_det_discord_input h_det_discord_1">
<label><div><span><%-lang['Attach Video Clip']%></span></div>
<div><select class="form-control" detail="detector_discordbot_send_video">
<option value="0" selected><%-lang.No%></option>
<option value="1"><%-lang.Yes%></option>
</select></div>
</label>
</div>
<div class="form-group h_det_discord_input h_det_discord_1">
<label><div><span><%-lang['Allow Next Discord Alert']%></span></div>
<div><input class="form-control" detail="detector_discordbot_timeout" placeholder="10"></div>