Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/event managment #28

Merged
merged 2 commits into from
Mar 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `,` |
4 changes: 4 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ type Config struct {
SendTextEvent bool
FrigateIncludeCamera []string
FrigateExcludeCamera []string
FrigateExcludeLabel []string
FrigateIncludeLabel []string
}

// New returns a new Config struct
Expand All @@ -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"}, ","),
}
}

Expand Down
13 changes: 13 additions & 0 deletions internal/frigate/frigate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading