discord notifications more verbose

node-20
Moe 2023-08-25 06:45:36 -07:00
parent 1684ebe8ea
commit 54f51557e3
4 changed files with 119 additions and 9 deletions

84
definitions/glyphs.js Normal file
View File

@ -0,0 +1,84 @@
module.exports = {
"person": "🙅‍♂️",
"bicycle": "🚲",
"car": "🚗",
"motorcycle": "🏍",
"airplane": "✈️",
"bus": "🚌",
"train": "🚂",
"truck": "🚚",
"boat": "⛵",
"traffic light": "🚦",
"fire hydrant": "🚒",
"stop sign": "🛑",
"parking meter": "🅿️",
"bench": "🪑",
"bird": "🐦",
"cat": "🐈",
"dog": "🐕",
"horse": "🐎",
"sheep": "🐏",
"cow": "🐄",
"elephant": "🐘",
"bear": "🐻",
"zebra": "🦓",
"giraffe": "🦒",
"backpack": "🎒",
"umbrella": "☂️",
"handbag": "👜",
"tie": "👔",
"suitcase": "🧳",
"frisbee": "🥏",
"skis": "🎿",
"snowboard": "🏂",
"sports ball": "⚽",
"kite": "🪁",
"skateboard": "🛹",
"surfboard": "🏄",
"tennis racket": "🎾",
"bottle": "🍼",
"wine glass": "🍷",
"cup": "☕",
"fork": "🍴",
"knife": "🔪",
"spoon": "🥄",
"bowl": "🍲",
"banana": "🍌",
"apple": "🍏",
"sandwich": "🥪",
"orange": "🍊",
"broccoli": "🥦",
"carrot": "🥕",
"hot dog": "🌭",
"pizza": "🍕",
"donut": "🍩",
"cake": "🍰",
"chair": "🪑",
"couch": "🛋",
"potted plant": "🪴",
"bed": "🛏",
"toilet": "🚽",
"tv": "📺",
"laptop": "💻",
"mouse": "🖱",
"remote": "📱",
"keyboard": "⌨️",
"cell phone": "📱",
"microwave": "🌊",
"toaster": "🍞",
"refrigerator": "🍽",
"book": "📚",
"clock": "⏰",
"vase": "🏺",
"scissors": "✂️",
"teddy bear": "🧸",
"hair drier": "💨",
"toothbrush": "🪥",
"baseball bat": "🏏",
"baseball glove": "🥅",
"dining table": "🍽",
"oven": "🔥",
"sink": "🚰",
"Clock Format": "⏲",
"_default": "🏃‍♂️"
}

View File

@ -1552,6 +1552,7 @@
"MQTT Outbound": "MQTT Outbound",
"MQTT Client": "MQTT Client",
"Buffer Time from Event": "Buffer Time from Event",
"detected": "detected",
"fieldTextEventFilters": "Enable to have all Events honor your Event Filter rules.",
"fieldTextBufferTimeFromEvent": "The amount of seconds to record before the trigger happened. If this is consistently inaccurate you will need to look at the <a target='_blank' href='https://hub.shinobi.video/articles/view/DmWIID78VtvEfnf'>optimization guide</a> or force encoding on the server.",
"fieldTextMode": "This is the primary task of the monitor.",

View File

@ -35,6 +35,7 @@ module.exports = (s,config,lang) => {
isEven,
fetchTimeout,
} = require('../basic/utils.js')(process.cwd(),config)
const glyphs = require('../../definitions/glyphs.js')
async function saveImageFromEvent(options,frameBuffer){
const monitorId = options.mid || options.id
const groupKey = options.ke
@ -828,7 +829,27 @@ module.exports = (s,config,lang) => {
return newRegions;
}
function getTagWithIcon(tag){
var icon = glyphs[tag.toLowerCase()] || glyphs._default
return `${icon} ${tag}`;
}
function getObjectTagsFromMatrices(d){
if(d.details.reason === 'motion'){
return [getTagWithIcon(lang.Motion)]
}else{
const matrices = d.details.matrices
return [...new Set(matrices.map(matrix => getTagWithIcon(matrix.tag)))];
}
}
function getObjectTagNotifyText(d){
const monitorId = d.mid || d.id
const monitorName = s.group[d.ke].rawMonitorConfigurations[monitorId].name
const tags = getObjectTagsFromMatrices(d)
return `${tags.join(', ')} ${lang.detected} in ${monitorName}`
}
return {
getObjectTagNotifyText,
getObjectTagsFromMatrices,
countObjects: countObjects,
isAtleastOneMatrixInRegion,
convertRegionPointsToNewDimensions,

View File

@ -2,6 +2,7 @@ var fs = require("fs")
var Discord = require("discord.js")
module.exports = function(s,config,lang,getSnapshot){
const {
getObjectTagNotifyText,
getEventBasedRecordingUponCompletion,
} = require('../events/utils.js')(s,config,lang)
//discord bot
@ -56,6 +57,8 @@ module.exports = function(s,config,lang,getSnapshot){
//discord bot
const isEnabled = filter.discord || monitorConfig.details.detector_discordbot === '1' || monitorConfig.details.notify_discord === '1'
if(s.group[d.ke].discordBot && isEnabled && !s.group[d.ke].activeMonitors[d.id].detector_discordbot){
const monitorName = s.group[d.ke].rawMonitorConfigurations[d.id].name
const notifyText = getObjectTagNotifyText(d)
var detector_discordbot_timeout
if(!monitorConfig.details.detector_discordbot_timeout||monitorConfig.details.detector_discordbot_timeout===''){
detector_discordbot_timeout = 1000 * 60 * 10;
@ -70,11 +73,11 @@ module.exports = function(s,config,lang,getSnapshot){
if(d.screenshotBuffer){
sendMessage({
author: {
name: s.group[d.ke].rawMonitorConfigurations[d.id].name,
name: monitorName,
icon_url: config.iconURL
},
title: lang.Event+' - '+d.screenshotName,
description: lang.EventText1+' '+d.currentTimestamp,
title: notifyText,
description: notifyText+' '+d.currentTimestamp,
fields: [],
timestamp: d.currentTime,
footer: {
@ -84,7 +87,7 @@ module.exports = function(s,config,lang,getSnapshot){
},[
{
attachment: d.screenshotBuffer,
name: d.screenshotName+'.jpg'
name: notifyText + '.jpg'
}
],d.ke)
}
@ -106,20 +109,21 @@ module.exports = function(s,config,lang,getSnapshot){
if(videoPath){
sendMessage({
author: {
name: s.group[d.ke].rawMonitorConfigurations[d.id].name,
name: monitorName,
icon_url: config.iconURL
},
title: videoName,
title: `${notifyText}`,
description: notifyText,
fields: [],
timestamp: d.currentTime,
footer: {
icon_url: config.iconURL,
text: "Shinobi Systems"
icon_url: config.iconURL,
text: "Shinobi Systems"
}
},[
{
attachment: videoPath,
name: videoName
name: notifyText + '.mp4'
}
],d.ke)
}