1
0
Fork 0
mirror of https://github.com/Luzifer/cmd-slack.git synced 2024-12-23 03:01:21 +00:00

Do not send message when output is empty

This commit is contained in:
Knut Ahlers 2016-05-22 20:19:50 +02:00
parent f7e94e4975
commit faea9b1bd5
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E

View file

@ -5,7 +5,9 @@ import (
"encoding/json" "encoding/json"
"log" "log"
"net/http" "net/http"
"os"
"os/exec" "os/exec"
"strings"
"github.com/Luzifer/rconfig" "github.com/Luzifer/rconfig"
) )
@ -39,6 +41,11 @@ func main() {
log.Fatalf("Command error: %s", err) log.Fatalf("Command error: %s", err)
} }
if strings.TrimSpace(buf.String()) == "" {
log.Printf("Command had empty output, ignoring")
os.Exit(0)
}
slo := slack{ slo := slack{
Username: cfg.Username, Username: cfg.Username,
Icon: cfg.Icon, Icon: cfg.Icon,