feat(service): add service line

pull/41/head
Nate 4 years ago
parent e34eba00b5
commit 024b150b43

@ -13,11 +13,11 @@ import (
// Line struct holds data parsed via flags for the service // Line struct holds data parsed via flags for the service
type Line struct { type Line struct {
ChanSecret string Secret string
ChanAccessToken string Token string
Message string Message string
Receivers string Receivers string
Title string Title string
} }
// Send parses values from *cli.context and returns a *cli.Command. // Send parses values from *cli.context and returns a *cli.Command.
@ -26,24 +26,26 @@ type Line struct {
func Send() *cli.Command { func Send() *cli.Command {
var lineOpts Line var lineOpts Line
return &cli.Command{ return &cli.Command{
Name: "line", Name: "line",
Usage: "Send message to line messenger", Usage: "Send message to line messenger",
Description: `Line messenger uses a channel secret and a channel access token to authenticate & send messages through line to various receivers. Multiple receiver IDs can be used separated by comma ','. All configuration options are also available via environment variables.`, Description: `Line messenger uses a channel secret and
UsageText: "pingme line --channelsecret '123' --channelaccesstoken '123' --msg 'some message' --receivers '123,456,789'", a channel access token to authenticate & send messages
through line to various receivers.`,
UsageText: "pingme line --secret '123' --token '123' --msg 'some message' --receivers '123,456,789'",
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.StringFlag{ &cli.StringFlag{
Destination: &lineOpts.ChanSecret, Destination: &lineOpts.Secret,
Name: "channelsecret", Name: "secret",
Required: true, Required: true,
Usage: "Channel secret.", Usage: "Channel secret.",
EnvVars: []string{"LINE_CHANNELSECRET"}, EnvVars: []string{"LINE_SECRET"},
}, },
&cli.StringFlag{ &cli.StringFlag{
Destination: &lineOpts.ChanAccessToken, Destination: &lineOpts.Token,
Name: "channelaccesstoken", Name: "token",
Required: true, Required: true,
Usage: "Channel access token.", Usage: "Channel access token.",
EnvVars: []string{"LINE_CHANNELACCESSTOKEN"}, EnvVars: []string{"LINE_TOKEN"},
}, },
&cli.StringFlag{ &cli.StringFlag{
Destination: &lineOpts.Message, Destination: &lineOpts.Message,
@ -69,7 +71,7 @@ func Send() *cli.Command {
}, },
Action: func(ctx *cli.Context) error { Action: func(ctx *cli.Context) error {
notifier := notify.New() notifier := notify.New()
lineSvc, err := line.New(lineOpts.ChanSecret, lineOpts.ChanAccessToken) lineSvc, err := line.New(lineOpts.Secret, lineOpts.Token)
if err != nil { if err != nil {
return err return err
} }

Loading…
Cancel
Save