Exemplo n.º 1
0
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
}
Exemplo n.º 2
0
func sendNotification() bool {
	identity := pushover.Authenticate("ajUCEgKvd9QmeMKFHBmvwMct1DYytx", "iBzANa9RG4jhS3s9QK9MAGNruSoGSz")
	sent := pushover.Notify(identity, "turn on server")
	if !sent {
		///log
		return false
	}
	return true
}
Exemplo n.º 3
0
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)
	}
}
Exemplo n.º 4
0
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
	}
}