|
|
@ -1,11 +1,12 @@
|
|
|
|
package cmd
|
|
|
|
package pushbullet
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"log"
|
|
|
|
"log"
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/kha7iq/pingme/service/helpers"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/nikoksr/notify"
|
|
|
|
"github.com/nikoksr/notify"
|
|
|
|
"github.com/nikoksr/notify/service/pushbullet"
|
|
|
|
"github.com/nikoksr/notify/service/pushbullet"
|
|
|
|
"github.com/urfave/cli/v2"
|
|
|
|
"github.com/urfave/cli/v2"
|
|
|
@ -21,11 +22,11 @@ type pushBullet struct {
|
|
|
|
SMS bool
|
|
|
|
SMS bool
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// SendToPushBullet parse values from *cli.context and return *cli.Command.
|
|
|
|
// Send parse values from *cli.context and return *cli.Command.
|
|
|
|
// Values include pushbullet token, Device, phone number, Message and Title.
|
|
|
|
// Values include pushbullet token, Device, phone number, Message and Title.
|
|
|
|
// If multiple devices are provided they the string is split with "," separator and
|
|
|
|
// If multiple devices are provided they the string is split with "," separator and
|
|
|
|
// each device is added to receiver.
|
|
|
|
// each device is added to receiver.
|
|
|
|
func SendToPushBullet() *cli.Command {
|
|
|
|
func Send() *cli.Command {
|
|
|
|
var pushBulletOpts pushBullet
|
|
|
|
var pushBulletOpts pushBullet
|
|
|
|
return &cli.Command{
|
|
|
|
return &cli.Command{
|
|
|
|
Name: "pushbullet",
|
|
|
|
Name: "pushbullet",
|
|
|
@ -68,7 +69,7 @@ Multiple device nicknames or numbers can be used separated by comma.`,
|
|
|
|
&cli.StringFlag{
|
|
|
|
&cli.StringFlag{
|
|
|
|
Destination: &pushBulletOpts.Title,
|
|
|
|
Destination: &pushBulletOpts.Title,
|
|
|
|
Name: "title",
|
|
|
|
Name: "title",
|
|
|
|
Value: TimeValue,
|
|
|
|
Value: helpers.TimeValue,
|
|
|
|
Usage: "Title of the message.",
|
|
|
|
Usage: "Title of the message.",
|
|
|
|
EnvVars: []string{"PUSHBULLET_TITLE"},
|
|
|
|
EnvVars: []string{"PUSHBULLET_TITLE"},
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -92,7 +93,7 @@ Multiple device nicknames or numbers can be used separated by comma.`,
|
|
|
|
devices := strings.Split(pushBulletOpts.PhoneNumber, ",")
|
|
|
|
devices := strings.Split(pushBulletOpts.PhoneNumber, ",")
|
|
|
|
for _, v := range devices {
|
|
|
|
for _, v := range devices {
|
|
|
|
if len(v) <= 0 {
|
|
|
|
if len(v) <= 0 {
|
|
|
|
return fmt.Errorf(EmptyChannel)
|
|
|
|
return helpers.ErrChannel
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pushBulletSmsSvc.AddReceivers(v)
|
|
|
|
pushBulletSmsSvc.AddReceivers(v)
|
|
|
|
|
|
|
|
|
|
|
@ -112,7 +113,7 @@ Multiple device nicknames or numbers can be used separated by comma.`,
|
|
|
|
devices := strings.Split(pushBulletOpts.Device, ",")
|
|
|
|
devices := strings.Split(pushBulletOpts.Device, ",")
|
|
|
|
for _, v := range devices {
|
|
|
|
for _, v := range devices {
|
|
|
|
if len(v) <= 0 {
|
|
|
|
if len(v) <= 0 {
|
|
|
|
return fmt.Errorf(EmptyChannel)
|
|
|
|
return helpers.ErrChannel
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pushBulletSvc.AddReceivers(v)
|
|
|
|
pushBulletSvc.AddReceivers(v)
|
|
|
|
}
|
|
|
|
}
|