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

24 lines
404 B
Go

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
}