improve channel name
This commit is contained in:
parent
94c0cdde24
commit
b68b341862
2 changed files with 15 additions and 13 deletions
13
main.go
13
main.go
|
|
@ -20,10 +20,11 @@ func main() {
|
||||||
}
|
}
|
||||||
parser.MustParse(os.Args[1:])
|
parser.MustParse(os.Args[1:])
|
||||||
|
|
||||||
|
NotifyChannel = fmt.Sprintf("%s-%d", args.Street, args.Home)
|
||||||
|
|
||||||
streetNumbers, err := GetStreetNumbers()
|
streetNumbers, err := GetStreetNumbers()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
_ = SendErr(err)
|
||||||
_ = SendErr(args.Street, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -34,8 +35,7 @@ func main() {
|
||||||
|
|
||||||
tomorrow, err := AwlTomorrow(streetNumber, args.Home)
|
tomorrow, err := AwlTomorrow(streetNumber, args.Home)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
_ = SendErr(err)
|
||||||
_ = SendErr(args.Street, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -43,10 +43,9 @@ func main() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = SendAwlNotification(args.Street, tomorrow)
|
err = SendAwlNotification(tomorrow)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
_ = SendErr(err)
|
||||||
_ = SendErr(args.Street, err)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
15
ntfy.go
15
ntfy.go
|
|
@ -6,7 +6,9 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func SendAwlNotification(channel string, binColors []string) error {
|
var NotifyChannel string
|
||||||
|
|
||||||
|
func SendAwlNotification(binColors []string) error {
|
||||||
var bins = make([]string, 0, 5)
|
var bins = make([]string, 0, 5)
|
||||||
for _, color := range binColors {
|
for _, color := range binColors {
|
||||||
switch color {
|
switch color {
|
||||||
|
|
@ -30,17 +32,18 @@ func SendAwlNotification(channel string, binColors []string) error {
|
||||||
message = "Morgen werden folgende Tonnen abgeholt: "
|
message = "Morgen werden folgende Tonnen abgeholt: "
|
||||||
}
|
}
|
||||||
message += strings.Join(bins, ", ")
|
message += strings.Join(bins, ", ")
|
||||||
return SendNotification(channel, message)
|
return SendNotification(message)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SendNotification(channel, message string) error {
|
func SendNotification(message string) error {
|
||||||
topic := fmt.Sprintf("https://ntfy.sh/awl_neuss_%s", channel)
|
topic := fmt.Sprintf("https://ntfy.sh/awl-neuss-%s", NotifyChannel)
|
||||||
_, err := http.Post(topic, "text/plain", strings.NewReader(message))
|
_, err := http.Post(topic, "text/plain", strings.NewReader(message))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func SendErr(channel string, err error) error {
|
func SendErr(err error) error {
|
||||||
topic := fmt.Sprintf("https://ntfy.sh/awl_neuss_%s_err", channel)
|
fmt.Println(err)
|
||||||
|
topic := fmt.Sprintf("https://ntfy.sh/awl-neuss-%s-err", NotifyChannel)
|
||||||
_, err = http.Post(topic, "text/plain", strings.NewReader(err.Error()))
|
_, err = http.Post(topic, "text/plain", strings.NewReader(err.Error()))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue