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