better notifications for telegram, matrix, and pushover
parent
54f51557e3
commit
29dcec2810
|
|
@ -2,6 +2,7 @@ const fs = require("fs")
|
||||||
const fetch = require("node-fetch")
|
const fetch = require("node-fetch")
|
||||||
module.exports = function(s,config,lang,getSnapshot){
|
module.exports = function(s,config,lang,getSnapshot){
|
||||||
const {
|
const {
|
||||||
|
getObjectTagNotifyText,
|
||||||
getEventBasedRecordingUponCompletion,
|
getEventBasedRecordingUponCompletion,
|
||||||
} = require('../events/utils.js')(s,config,lang)
|
} = require('../events/utils.js')(s,config,lang)
|
||||||
//matrix bot
|
//matrix bot
|
||||||
|
|
@ -76,6 +77,7 @@ module.exports = function(s,config,lang,getSnapshot){
|
||||||
// d = event object
|
// d = event object
|
||||||
const isEnabled = filter.matrixBot || monitorConfig.details.detector_matrixbot === '1' || monitorConfig.details.notify_matrix === '1'
|
const isEnabled = filter.matrixBot || monitorConfig.details.detector_matrixbot === '1' || monitorConfig.details.notify_matrix === '1'
|
||||||
if(s.group[d.ke].matrixBot && isEnabled && !s.group[d.ke].activeMonitors[d.id].detector_matrixbot){
|
if(s.group[d.ke].matrixBot && isEnabled && !s.group[d.ke].activeMonitors[d.id].detector_matrixbot){
|
||||||
|
const notifyText = getObjectTagNotifyText(d)
|
||||||
var detector_matrixbot_timeout
|
var detector_matrixbot_timeout
|
||||||
if(!monitorConfig.details.detector_matrixbot_timeout||monitorConfig.details.detector_matrixbot_timeout===''){
|
if(!monitorConfig.details.detector_matrixbot_timeout||monitorConfig.details.detector_matrixbot_timeout===''){
|
||||||
detector_matrixbot_timeout = 1000 * 60 * 10;
|
detector_matrixbot_timeout = 1000 * 60 * 10;
|
||||||
|
|
@ -88,9 +90,8 @@ module.exports = function(s,config,lang,getSnapshot){
|
||||||
},detector_matrixbot_timeout)
|
},detector_matrixbot_timeout)
|
||||||
await getSnapshot(d,monitorConfig)
|
await getSnapshot(d,monitorConfig)
|
||||||
if(d.screenshotBuffer){
|
if(d.screenshotBuffer){
|
||||||
const imageEventText = `${lang.Event} ${d.screenshotName} ${d.currentTimestamp}`
|
|
||||||
sendMessage({
|
sendMessage({
|
||||||
text: imageEventText,
|
text: notifyText,
|
||||||
},[
|
},[
|
||||||
{
|
{
|
||||||
buffer: d.screenshotBuffer,
|
buffer: d.screenshotBuffer,
|
||||||
|
|
@ -119,7 +120,9 @@ module.exports = function(s,config,lang,getSnapshot){
|
||||||
videoName = siftedVideoFileFromRam.filename
|
videoName = siftedVideoFileFromRam.filename
|
||||||
}
|
}
|
||||||
if(videoPath){
|
if(videoPath){
|
||||||
sendMessage({},[
|
sendMessage({
|
||||||
|
text: notifyText,
|
||||||
|
},[
|
||||||
{
|
{
|
||||||
buffer: await fs.promises.readFile(videoPath),
|
buffer: await fs.promises.readFile(videoPath),
|
||||||
name: videoName,
|
name: videoName,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
module.exports = function (s, config, lang, getSnapshot) {
|
module.exports = function (s, config, lang, getSnapshot) {
|
||||||
const { getEventBasedRecordingUponCompletion } =
|
const {
|
||||||
require('../events/utils.js')(s, config, lang);
|
getObjectTagNotifyText,
|
||||||
|
getEventBasedRecordingUponCompletion,
|
||||||
|
} = require('../events/utils.js')(s,config,lang)
|
||||||
|
|
||||||
if (config.pushover === true) {
|
if (config.pushover === true) {
|
||||||
const Pushover = require('pushover-notifications');
|
const Pushover = require('pushover-notifications');
|
||||||
|
|
@ -116,6 +118,7 @@ module.exports = function (s, config, lang, getSnapshot) {
|
||||||
(filter.pushover || monitorConfig.details.notify_pushover === '1') &&
|
(filter.pushover || monitorConfig.details.notify_pushover === '1') &&
|
||||||
!s.group[d.ke].activeMonitors[d.id].detector_pushover
|
!s.group[d.ke].activeMonitors[d.id].detector_pushover
|
||||||
) {
|
) {
|
||||||
|
const notifyText = getObjectTagNotifyText(d)
|
||||||
var detector_pushover_timeout;
|
var detector_pushover_timeout;
|
||||||
if (
|
if (
|
||||||
!monitorConfig.details.detector_pushover_timeout ||
|
!monitorConfig.details.detector_pushover_timeout ||
|
||||||
|
|
@ -144,9 +147,8 @@ module.exports = function (s, config, lang, getSnapshot) {
|
||||||
if (d.screenshotBuffer) {
|
if (d.screenshotBuffer) {
|
||||||
sendMessage(
|
sendMessage(
|
||||||
{
|
{
|
||||||
title: lang.Event + ' - ' + d.screenshotName,
|
title: notifyText,
|
||||||
description:
|
description: lang.EventText1 + ' ' + d.currentTimestamp,
|
||||||
lang.EventText1 + ' ' + d.currentTimestamp,
|
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ var fs = require("fs")
|
||||||
// }
|
// }
|
||||||
module.exports = function(s,config,lang,getSnapshot){
|
module.exports = function(s,config,lang,getSnapshot){
|
||||||
const {
|
const {
|
||||||
|
getObjectTagNotifyText,
|
||||||
getEventBasedRecordingUponCompletion,
|
getEventBasedRecordingUponCompletion,
|
||||||
} = require('../events/utils.js')(s,config,lang)
|
} = require('../events/utils.js')(s,config,lang)
|
||||||
const {
|
const {
|
||||||
|
|
@ -99,6 +100,7 @@ module.exports = function(s,config,lang,getSnapshot){
|
||||||
// d = event object
|
// d = event object
|
||||||
//telegram bot
|
//telegram bot
|
||||||
if(s.group[d.ke].telegramBot && (filter.telegram || monitorConfig.details.notify_telegram === '1') && !s.group[d.ke].activeMonitors[d.id].detector_telegrambot){
|
if(s.group[d.ke].telegramBot && (filter.telegram || monitorConfig.details.notify_telegram === '1') && !s.group[d.ke].activeMonitors[d.id].detector_telegrambot){
|
||||||
|
const notifyText = getObjectTagNotifyText(d)
|
||||||
var detector_telegrambot_timeout
|
var detector_telegrambot_timeout
|
||||||
if(!monitorConfig.details.detector_telegrambot_timeout||monitorConfig.details.detector_telegrambot_timeout===''){
|
if(!monitorConfig.details.detector_telegrambot_timeout||monitorConfig.details.detector_telegrambot_timeout===''){
|
||||||
detector_telegrambot_timeout = 1000 * 60 * 10;
|
detector_telegrambot_timeout = 1000 * 60 * 10;
|
||||||
|
|
@ -112,13 +114,13 @@ module.exports = function(s,config,lang,getSnapshot){
|
||||||
await getSnapshot(d,monitorConfig)
|
await getSnapshot(d,monitorConfig)
|
||||||
if(d.screenshotBuffer){
|
if(d.screenshotBuffer){
|
||||||
sendMessage({
|
sendMessage({
|
||||||
title: lang.Event+' - '+d.screenshotName,
|
title: notifyText,
|
||||||
description: lang.EventText1+' '+d.currentTimestamp,
|
description: lang.EventText1+' '+d.currentTimestamp,
|
||||||
},[
|
},[
|
||||||
{
|
{
|
||||||
type: 'photo',
|
type: 'photo',
|
||||||
attachment: d.screenshotBuffer,
|
attachment: d.screenshotBuffer,
|
||||||
name: d.screenshotName+'.jpg'
|
name: notifyText + '.jpg'
|
||||||
}
|
}
|
||||||
],d.ke)
|
],d.ke)
|
||||||
}
|
}
|
||||||
|
|
@ -142,12 +144,12 @@ module.exports = function(s,config,lang,getSnapshot){
|
||||||
const thumbFile = getStreamDirectory(d) + 'thumb.jpg';
|
const thumbFile = getStreamDirectory(d) + 'thumb.jpg';
|
||||||
fs.writeFileSync(thumbFile, d.screenshotBuffer)
|
fs.writeFileSync(thumbFile, d.screenshotBuffer)
|
||||||
sendMessage({
|
sendMessage({
|
||||||
title: videoName,
|
title: notifyText,
|
||||||
},[
|
},[
|
||||||
{
|
{
|
||||||
type: 'video',
|
type: 'video',
|
||||||
attachment: videoPath,
|
attachment: videoPath,
|
||||||
name: videoName,
|
name: notifyText + '.mp4',
|
||||||
thumb: thumbFile
|
thumb: thumbFile
|
||||||
}
|
}
|
||||||
],d.ke)
|
],d.ke)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue