From 9caec68257c0cd0c12b8136c808ee14f885e366b Mon Sep 17 00:00:00 2001 From: OldTyT Date: Thu, 27 Feb 2025 22:46:15 +0300 Subject: [PATCH] feat: added support for include and exclude event --- README.md | 2 ++ internal/config/config.go | 4 ++++ internal/frigate/frigate.go | 13 +++++++++++++ 3 files changed, 19 insertions(+) diff --git a/README.md b/README.md index 86b1c9e..3d13468 100644 --- a/README.md +++ b/README.md @@ -48,3 +48,5 @@ docker compose up -d | `SEND_TEXT_EVENT` | `False` | Send text event without media | | `FRIGATE_EXCLUDE_CAMERA` | `None` | List exclude frigate camera, separate `,` | | `FRIGATE_INCLUDE_CAMERA` | `All` | List Include frigate camera, separate `,` | +| `FRIGATE_EXCLUDE_LABEL` | `None` | List exclude frigate event, separate `,` | +| `FRIGATE_INCLUDE_LABEL` | `All` | List Include frigate event, separate `,` | diff --git a/internal/config/config.go b/internal/config/config.go index 6efad11..0914cef 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -24,6 +24,8 @@ type Config struct { SendTextEvent bool FrigateIncludeCamera []string FrigateExcludeCamera []string + FrigateExcludeLabel []string + FrigateIncludeLabel []string } // New returns a new Config struct @@ -46,6 +48,8 @@ func New() *Config { SendTextEvent: getEnvAsBool("SEND_TEXT_EVENT", false), FrigateExcludeCamera: getEnvAsSlice("FRIGATE_EXCLUDE_CAMERA", []string{"None"}, ","), FrigateIncludeCamera: getEnvAsSlice("FRIGATE_INCLUDE_CAMERA", []string{"All"}, ","), + FrigateExcludeLabel: getEnvAsSlice("FRIGATE_EXCLUDE_LABEL", []string{"None"}, ","), + FrigateIncludeLabel: getEnvAsSlice("FRIGATE_INCLUDE_LABEL", []string{"All"}, ","), } } diff --git a/internal/frigate/frigate.go b/internal/frigate/frigate.go index 741fac0..9e00552 100644 --- a/internal/frigate/frigate.go +++ b/internal/frigate/frigate.go @@ -322,6 +322,19 @@ func ParseEvents(FrigateEvents EventsStruct, bot *tgbotapi.BotAPI, WatchDog bool continue } } + if !(len(conf.FrigateExcludeLabel) == 1 && conf.FrigateExcludeLabel[0] == "None") { + if StringsContains(FrigateEvents[Event].Label, conf.FrigateExcludeLabel) { + log.Debug.Println("Skip event from camera: " + FrigateEvents[Event].Label) + continue + } + } + if !(len(conf.FrigateIncludeLabel) == 1 && conf.FrigateIncludeLabel[0] == "All") { + if !(StringsContains(FrigateEvents[Event].Label, conf.FrigateIncludeLabel)) { + log.Debug.Println("Skip event from camera: " + FrigateEvents[Event].Label) + continue + } + } + if redis.CheckEvent(RedisKeyPrefix + FrigateEvents[Event].ID) { if WatchDog { SendTextEvent(FrigateEvents[Event], bot)