Documentation
¶
Overview ¶
Package pushover provides methods for sending messages using the http://pushover.net API.
Index ¶
- type Config
- type Message
- func (m *Message) EmergencyParamsSet() error
- func (m *Message) GetDevice() string
- func (m *Message) GetExpiry() int
- func (m *Message) GetMessage() string
- func (m *Message) GetPriority() Priority
- func (m *Message) GetRetry() int
- func (m *Message) GetSound() Sound
- func (m *Message) GetTitle() string
- func (m *Message) GetURL() string
- func (m *Message) GetURLTitle() string
- func (m *Message) GetUnixTimestamp() int32
- func (m *Message) Push(message string) (r *Response, err error)
- func (m *Message) SetDevice(s string)
- func (m *Message) SetEmergencyDefault()
- func (m *Message) SetExpiry(i int) error
- func (m *Message) SetMessage(s string)
- func (m *Message) SetPriority(p Priority)
- func (m *Message) SetRetry(i int) error
- func (m *Message) SetSound(s Sound)
- func (m *Message) SetTitle(s string)
- func (m *Message) SetURL(s string)
- func (m *Message) SetURLTitle(s string)
- func (m *Message) SetUnixTimestamp(t int32)
- type Priority
- type Response
- type Sound
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
Config helps with managing the ability to enforce constraints more easily
func GetConfigEnv ¶
GetConfigEnv reads environment variables returns a Config struct.
func GetConfigFile ¶
GetConfigFile reads YAML file and returns a Config struct.
type Message ¶
type Message struct { // Required Token string `json:"token"` User string `json:"user"` Message string `json:"message"` //Optional Device string `json:"device"` Title string `json:"title"` URL string `json:"url"` URLTitle string `json:"url_title"` Priority Priority `json:"priority"` Timestamp int32 `json:"timestamp"` Sound Sound `json:"sound"` // For when we have PriorityEmergency messages Retry int `json:"retry"` // Must be greater than 30s Expire int `json:"expire"` // Must be less than 10800s (3h) }
Message contains all the required settings for sending messages via the pushover.net API. https://pushover.net/api
func NewMessage ¶
NewMessage returns a new Message with API token values and a user configured .
func NewMessageConfig ¶
NewMessageConfig returns a new Message with API token values and a user configured. The argument of Config type allow for easier constraint checking
func (*Message) EmergencyParamsSet ¶
EmergencyParamsSet tests if required items are set for sending an emergency message
func (*Message) GetMessage ¶
GetMessage returns the set message for the message.
func (*Message) GetPriority ¶
GetPriority returns the priority of the message
func (*Message) GetURLTitle ¶
GetURLTitle returns the value of the title for the clickable URL
func (*Message) GetUnixTimestamp ¶
GetUnixTimestamp returns the timestamp supplied to the record.
func (*Message) SetEmergencyDefault ¶
func (m *Message) SetEmergencyDefault()
SetEmergencyDefault sets the expiry to 1h and retry to 5m
func (*Message) SetMessage ¶
SetMessage will be in frequently used due to the current Push method
func (*Message) SetPriority ¶
SetPriority sets the priority of the message. See vars.go for the levels.
func (*Message) SetTitle ¶
SetTitle sets the title of a message. If unset, the default Pushover name will be used
func (*Message) SetURLTitle ¶
SetURLTitle Alternate text for the clickable URL
func (*Message) SetUnixTimestamp ¶
SetUnixTimestamp will set a time to be used rather than the time the message was received at the Pushover server
type Priority ¶
type Priority int
Priority is an acceptable priority for the Pushover API
const ( // PriorityLowest makes no sounds, alerts, or popups PriorityLowest Priority = -2 // PriorityLow makes no sounds or alerts, but will make a popup PriorityLow Priority = -1 // PriorityNormal will make a sound, alert, and popup. If this message is // received during quiet hours, it will be treated as PriorityLow PriorityNormal Priority = 0 // PriorityHigh will bypass quiet hours, and will be highlighted in red PriorityHigh Priority = 1 // PriorityEmergency are the same as PriorityHigh but require acknowledged. // Additionally, 'retry' and 'expiry' must be set in the message PriorityEmergency Priority = 2 )
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
type Sound ¶
type Sound string
Sound is a an acceptable string for the Pushover API
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 // SoundPushover is a Pushover API sound SoundPushover Sound = "pushover" // SoundClassical is a Pushover API sound SoundClassical Sound = "classical" // SoundCosmic is a Pushover API sound SoundCosmic Sound = "cosmic" // SoundFalling is a Pushover API sound SoundFalling Sound = "falling" // SoundGamelan is a Pushover API sound SoundGamelan Sound = "gamelan" // SoundIncoming is a Pushover API sound SoundIncoming Sound = "incoming" // SoundIntermission is a Pushover API sound SoundIntermission Sound = "intermission" // SoundMagic is a Pushover API sound SoundMagic Sound = "magic" // SoundMechanical is a Pushover API sound SoundMechanical Sound = "mechanical" // SoundPianobar is a Pushover API sound SoundPianobar Sound = "pianobar" // SoundSiren is a Pushover API sound SoundSiren Sound = "siren" // SoundSpaceAlarm is a Pushover API sound SoundSpaceAlarm Sound = "spacealarm" // SoundTugBoat is a Pushover API sound SoundTugBoat Sound = "tugboat" // SoundAlien is a Pushover API sound SoundAlien Sound = "alien" // SoundClimb is a Pushover API sound SoundClimb Sound = "climb" // SoundPersistent is a Pushover API sound SoundPersistent Sound = "persistent" // SoundEcho is a Pushover API sound SoundEcho Sound = "echo" // SoundUpDown is a Pushover API sound SoundUpDown Sound = "updown" )