pushover

package module
v0.0.0-...-cb8a974 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 28, 2016 License: GPL-3.0 Imports: 4 Imported by: 1

README

Pushover Golang Package

Documentation Build Status Coverage Status

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

This library is not intended for production use and was written by its author as an exercise to learn more about golang. Please don't import it and use it in any projects that you care about.

Package Example

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

// Set your pushover API keys
token := "KzGDORePKggMaC0QOYAMyEEuZJnyUi"
user := "e9e1495ec75826de5983cd1abc8031"

// Send your message
m := pushover.NewMessage(token, user)
m.Push("Server exchange01.example.net is in a critical state.")

Command Line Tool

A command line tool is provided under cmd/pushover. Build and install the command using:

$ make install

Before using the command line tool, you must first set the following environment variables.

$ export PUSHOVER_TOKEN="KzGDORePKggMaC0QOYAMyEEuZJnyUi"
$ export PUSHOVER_USER="e9e1495ec75826de5983cd1abc8031"

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

$ echo "Server exchange01.example.net is in a critical state" | pushover

Documentation

Overview

Package pushover provides methods for sending messages using the http://pushover.net API.

Index

Examples

Constants

View Source
const (
	// PushoverURL is the API endpoint that will be used for sending all messages.
	PushoverURL = "https://api.pushover.net/1/messages.json"
	// StatusSuccess is the expected status code when a message has been succesfully sent.
	StatusSuccess = 1
)

Variables

View Source
var (
	// ErrHTTPStatus is returned when pushover.net response with a non HTTP 200 response code.
	ErrHTTPStatus = errors.New("Recieved a non HTTP 200 (OK) response from the pushover.net API")
	// ErrUnknown is used to indicate that an error has occurred but its underlying cause could not be determined.
	ErrUnknown = errors.New("Recieved a status code indicating an error but did not receive an error message from pushover.net")
)

Functions

This section is empty.

Types

type Message

type Message struct {
	Token string
	User  string
	URL   string
}

Message contains all the required settings for sending messages via the pushover.net API

func NewMessage

func NewMessage(token string, user string) *Message

NewMessage returns a new Message with API token values and a recipient device configured.

func (*Message) Push

func (m *Message) Push(message string) (r *Response, err error)

Push sends a message via the pushover.net API and returns the json response

Example
// You'll need to configure these by logging in to https://pushover.net.
token := "KzGDORePKggMaC0QOYAMyEEuZJnyUi"
user := "e9e1495ec75826de5983cd1abc8031"

// Send a new message using the Push method.
m := pushover.NewMessage(token, user)
m.Push("Test message contents")
Output:

type Response

type Response struct {
	Request string   `json:"request"`
	Status  int      `json:"status"`
	Errors  []string `json:"errors"`
}

Response contains the JSON response returned by the pushover.net API

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL