Skip to content

Binary and library for sending messages to the pushover.net API

License

Notifications You must be signed in to change notification settings

invisiblethreat/go-pushover

Repository files navigation

Pushover API Go Package

DocumentationBuild Status

A Golang package for sending notifications via https://api.pushover.net.

This library is a mash-up of https://github.com/bdenning/go-pushover and https://github.com/gregdel/pushover. Neither did exactly what I wanted, in the way that I wanted.

Library Example

You can use the pushover package within your Golang applications as follows:

// Set your pushover API keys. These keys are fake.
export PUSHOVER_TOKEN="KzGDOReQKggMaC0QOYAMyEEuZJnyUi"
export PUSHOVER_USER="e9e1495ec45826de5983cd1abc8031"
package main
import (
  "fmt"

  "github.com/invisiblethreat/go-pushover/pushover"

)
// from environmental variables. Example of setting is above
config := pushover.GetConfigEnv()
// or form a YAML config file. pushover.yaml.sample is the template
config := pushover.GetConfigFile(file)

msg := pushover.NewMessageConfig(config)
res, err := msg.Push("message")

if err != nil {
    fmt.Errorf("Error sending message: %s\n", err.Error())
}

Dependencies

The dependency set is small- glide can be used to quickly resolve all of the needed repositories with glide install. More information about glide can be found here.

Command Line Tool

A binary is provided by:

  • running go install github.com/invisiblethreat/go-pushover, which installs in $GOPATH/bin/
  • running go build, which builds in the root directory.
Usage of ./go-pushover:
  -f, --file string      YAML config file location (default "pushover.yaml")
  -m, --message string   Message to send. Omit if piping from STDIN
  -t, --title string     Title for message. If empty, default name for the token will be used

Then messages can be sent by piping output to the pushover command.

export PUSHOVER_TOKEN="KzGDORePKggMaC0QOYAMyEEuZJnyUi" # fake
export PUSHOVER_USER="e9e1495ec75826de5983cd1abc8031"  # fake
echo "Foo is in a critical state" | go-pushover
# or
echo "Foo is in a critical state" | go-pushover --file ../../pushover.yaml
# or
go-pushover --file ../../pushover.yaml --message "Foo is in a critical state"

About

Binary and library for sending messages to the pushover.net API

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •