func notify(destination, message string) error { // TODO: cache this. pushauth := pushover.Authenticate(config.PushoverKey, destination) if !pushover.Notify(pushauth, message) { return fmt.Errorf("pushover notification failed.") } return nil }
func sendNotification() bool { identity := pushover.Authenticate("ajUCEgKvd9QmeMKFHBmvwMct1DYytx", "iBzANa9RG4jhS3s9QK9MAGNruSoGSz") sent := pushover.Notify(identity, "turn on server") if !sent { ///log return false } return true }
func PushoverBackend(file *ini.File, event *string, text *string) { api_key, ok := file.Get("pushover", "api_key") if !ok { log.Fatal("Pushover API key not found") } user_key, ok := file.Get("pushover", "user_key") if !ok { log.Fatal("Pushover User key not found") } identity := pushover.Authenticate(api_key, user_key) sent := pushover.Notify(identity, fmt.Sprintf("%s:%s", event, text)) if !sent { fmt.Println("[!] notification failed.") os.Exit(1) } }
func (n *Notificator) notifier() notifier { switch n.Type { case "smtp": user, server := parseSMTPAuth(n.From) return &smtpNotification{ addr: server, from: fmt.Sprintf("%v@%v", user, server), to: n.Destination, } case "pushover": return &pushoverNotification{ identity: pushover.Authenticate(pushoverKey, n.From), } default: log.Printf("Ignoring unknown notifier type %q", n.Type) return nil } }