From 600ce268ac16c46f8118907daeb801e4ff900525 Mon Sep 17 00:00:00 2001 From: Khaliq Date: Thu, 23 Nov 2023 17:24:31 +0800 Subject: [PATCH] feat: add priority for pushover messages --- service/pushover/pushover.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/service/pushover/pushover.go b/service/pushover/pushover.go index 3d4adb1..abd92ce 100644 --- a/service/pushover/pushover.go +++ b/service/pushover/pushover.go @@ -16,6 +16,7 @@ type pushOver struct { Recipient string Message string Title string + Priority int } // Send parse values from *cli.context and return *cli.Command. @@ -61,10 +62,27 @@ All configuration options are also available via environment variables.`, Usage: "Title of the message.", EnvVars: []string{"PUSHOVER_TITLE"}, }, + &cli.IntFlag{ + Destination: &pushOverOpts.Priority, + Name: "priority", + Aliases: []string{"p"}, + Value: 0, + Usage: "Priority of the message.", + EnvVars: []string{"PUSHOVER_PRIORITY"}, + }, }, Action: func(ctx *cli.Context) error { app := pushover.New(pushOverOpts.Token) - message := pushover.NewMessageWithTitle(pushOverOpts.Message, pushOverOpts.Title) + + // message := &pushover.Message{Title: pushOverOpts.Title, Message: pushOverOpts.Message, Priority: pushOverOpts.Priority} + + message := &pushover.Message{Title: pushOverOpts.Title, + Message: pushOverOpts.Message, + Priority: pushOverOpts.Priority, + Retry: 60, + Expire: 3600, + } + users := strings.Split(pushOverOpts.Recipient, ",") for _, v := range users {