Skip to content

Commit

Permalink
Merge pull request #27 from OldTyT/feat/event_managment
Browse files Browse the repository at this point in the history
Feat/event managment
  • Loading branch information
OldTyT authored Feb 27, 2025
2 parents 84c1581 + 9caec68 commit f5fbe92
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
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

0 comments on commit f5fbe92

Please sign in to comment.