Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gregdel/pushover
Go wrapper for the Pushover API
https://github.com/gregdel/pushover
api-client api-wrapper go golang hacktoberfest push-notifications pushover
Last synced: about 1 month ago
JSON representation
Go wrapper for the Pushover API
- Host: GitHub
- URL: https://github.com/gregdel/pushover
- Owner: gregdel
- License: mit
- Created: 2015-02-19T15:30:05.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-09-07T13:21:48.000Z (9 months ago)
- Last Synced: 2024-01-13T15:46:36.724Z (5 months ago)
- Topics: api-client, api-wrapper, go, golang, hacktoberfest, push-notifications, pushover
- Language: Go
- Homepage:
- Size: 59.6 KB
- Stars: 139
- Watchers: 5
- Forks: 12
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-go - pushover - Go wrapper for the Pushover API. (Third-party APIs / Utility/Miscellaneous)
- awesome-go - pushover - Go wrapper for the Pushover API. (Third-party APIs / Utility/Miscellaneous)
- awesome-stars - pushover
- awesome-go-extra - pushover - 02-19T15:30:05Z|2021-10-21T12:21:35Z| (Third-party APIs / Fail injection)
- awesome-go-cn - pushover
- awesome-go-zh - pushover
- awesome-go - pushover - Go wrapper for the Pushover API. (Third-party APIs / Utility/Miscellaneous)
- fucking-awesome-go - :octocat: pushover - Go wrapper for the Pushover API. :star: 11 :fork_and_knife: 2 (Third-party APIs / Advanced Console UIs)
- awesome-go - pushover - Go wrapper for the Pushover API. (Third-party APIs / HTTP Clients)
- awesome-go-projects - pushover - Go wrapper for the Pushover API. (Third-party APIs / HTTP Clients)
- awesome-go - pushover - | - | - | (Third-party APIs / HTTP Clients)
- awesome-go - pushover - Go wrapper for the Pushover API. (Third-party APIs / Advanced Console UIs)
- awesome-go-with-framework - pushover - Go wrapper for the Pushover API. (Third-party APIs / HTTP Clients)
- awesome-go - pushover - Go wrapper for the Pushover API. (Third-party APIs / Utility/Miscellaneous)
- awesome-go - pushover - Go wrapper for the Pushover API. (Third-party APIs / Utility/Miscellaneous)
- go-awesome-cn-star - pushover
- awesome-go-stars - pushover - Go wrapper for the Pushover API. (Third-party APIs / Utility/Miscellaneous)
- awesome-go-cn - pushover
- awesome-go - pushover - Go wrapper for the Pushover API. (Third-party APIs / Advanced Console UIs)
- awesome-go - pushover - Go wrapper for the Pushover API. (Third-party APIs / HTTP Clients)
- awesome-go. - pushover - Go wrapper for the Pushover API. (Third-party APIs / Advanced Console UIs)
- awesome-go - pushover - Go wrapper for the Pushover API. (<span id="第三方api-third-party-apis">第三方API Third-party APIs</span> / <span id="高级控制台用户界面-advanced-console-uis">高级控制台用户界面 Advanced Console UIs</span>)
- awesome-Char - pushover - Go wrapper for the Pushover API. (Third-party APIs / HTTP Clients)
- awesome-go-cn - pushover - Pushover API 的 Go 语言封装 (第三方 APIs / 高级控制台界面)
- awesome-go-with-stars - pushover - Go wrapper for the Pushover API. (Third-party APIs / Utility/Miscellaneous)
- awesome-go - pushover - Go wrapper for the Pushover API. (Third-party APIs / HTTP Clients)
- repo-1316-awesome-go-cn - pushover
- repo-1211-awesome-go-cn - pushover
- awesome-go-zh - pushover
- awesome-reader - pushover - Go wrapper for the Pushover API. (Third-party APIs / HTTP Clients)
- awesome-go - pushover - Go wrapper for the Pushover API. (Third-party APIs / HTTP Clients)
- Go-awesome - pushover - Go wrapper for the Pushover API. (Third-party APIs / Utility/Miscellaneous)
- awesome-go-cn - pushover
- awesome-go - pushover - Go wrapper for the Pushover API. (Third-party APIs / Advanced Console UIs)
- awesome-go - pushover - Go wrapper for the Pushover API. (Third-party APIs / Advanced Console UIs)
- awesome-go-cn - pushover
- awesome-go-handwritten - pushover - Go wrapper for the Pushover API. (Third-party APIs / HTTP Clients)
- awesome-go - pushover - Pushover API 的 Go 語言封裝 (第三方 APIs / 高級控制台界面)
- awesome-go - pushover - Go wrapper for the Pushover API. - :arrow_down:12 - :star:13 (Third-party APIs / HTTP Clients)
- awesome-go - pushover - Go wrapper for the Pushover API - ★ 47 (Third-party APIs)
- awesome-go2 - pushover - Go wrapper for the Pushover API. (Third-party APIs / Advanced Console UIs)
- awesome-go - pushover - Go wrapper for the Pushover API. (Third-party APIs / HTTP Clients)
- awesome-go - pushover - Go wrapper for the Pushover API. (Third-party APIs / Utility/Miscellaneous)
- awesome-go - pushover - Go wrapper for the Pushover API. (Third-party APIs / Advanced Console UIs)
- awesome-go - pushover - Go wrapper for the Pushover API. (Third-party APIs / HTTP Clients)
- awesome-go-cn - pushover
- awesome-go - pushover - Go wrapper for the Pushover API. (Third-party APIs / Utility/Miscellaneous)
- awesome-go - pushover - Go wrapper for the Pushover API. (Third-party APIs / Utility/Miscellaneous)
README
pushover
=========[![GoDoc](https://godoc.org/github.com/gregdel/pushover?status.svg)](http://godoc.org/github.com/gregdel/pushover)
[![Build Status](https://travis-ci.org/gregdel/pushover.svg?branch=master)](https://travis-ci.org/gregdel/pushover)
[![Coverage Status](https://coveralls.io/repos/gregdel/pushover/badge.svg?branch=master&service=github)](https://coveralls.io/github/gregdel/pushover?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/gregdel/pushover)](https://goreportcard.com/report/github.com/gregdel/pushover)pushover is a wrapper around the Superblock's Pushover API written in go.
Based on their [documentation](https://pushover.net/api). It's a convenient way to send notifications from a go program with only a few lines of code.## Messages
### Send a simple message
Here is a simple example for sending a notification to a recipient. A recipient can be a user or a group. There is no real difference, they both use a notification token.
```go
package mainimport (
"log""github.com/gregdel/pushover"
)func main() {
// Create a new pushover app with a token
app := pushover.New("uQiRzpo4DXghDmr9QzzfQu27cmVRsG")// Create a new recipient
recipient := pushover.NewRecipient("gznej3rKEVAvPUxu9vvNnqpmZpokzF")// Create the message to send
message := pushover.NewMessage("Hello !")// Send the message to the recipient
response, err := app.SendMessage(message, recipient)
if err != nil {
log.Panic(err)
}// Print the response if you want
log.Println(response)
}
```### Send a message with a title
There is a simple way to create a message with a title. Instead of using pushover.NewMessage you can use pushover.NewMessageWithTitle.
```go
message := pushover.NewMessageWithTitle("My awesome message", "My title")
```### Send a fancy message
If you want a more detailed message you can still do it.
```go
message := &pushover.Message{
Message: "My awesome message",
Title: "My title",
Priority: pushover.PriorityEmergency,
URL: "http://google.com",
URLTitle: "Google",
Timestamp: time.Now().Unix(),
Retry: 60 * time.Second,
Expire: time.Hour,
DeviceName: "SuperDevice",
CallbackURL: "http://yourapp.com/callback",
Sound: pushover.SoundCosmic,
}
```### Send a message with an attachment
You can send an image attachment along with the message.
```go
file, err := os.Open("/some/image.png")
if err != nil {
panic(err)
}
defer file.Close()message := pushover.NewMessage("Hello !")
if err := message.AddAttachment(file); err != nil {
panic(err)
}
```## Callbacks and receipts
If you're using an emergency notification you'll have to specify a retry period and an expiration delay. You can get the receipt details using the token in the message response.
```go
...
response, err := app.SendMessage(message, recipient)
if err != nil {
log.Panic(err)
}receiptDetails, err := app.GetReceiptDetails(response.Receipt)
if err != nil {
log.Panic(err)
}fmt.Println("Acknowledged status :", receiptDetails.Acknowledged)
```You can also cancel an emergency notification before the expiration time.
```go
response, err := app.CancelEmergencyNotification(response.Receipt)
if err != nil {
log.Panic(err)
}
```## User verification
If you want to validate that the recipient token is valid.
```go
...
recipientDetails, err := app.GetRecipientDetails(recipient)
if err != nil {
log.Panic(err)
}fmt.Println(recipientDetails)
```