1
0
Fork 0
hswro-alarm-bot/filters.go

24 lines
404 B
Go
Raw Normal View History

2024-02-13 22:20:15 +00:00
package main
import (
"github.com/probakowski/go-satel"
)
func FilterByType(ev <-chan satel.Event, allowedTypes []satel.ChangeType) <-chan satel.Event {
returnChan := make(chan satel.Event)
go func() {
for e := range ev {
for _, allowedType := range allowedTypes {
if allowedType == e.Type {
returnChan <- e
continue
}
}
}
close(returnChan)
}()
return returnChan
}