Support debug mode.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
541efa4e5b
commit
f80e79f1c6
@ -42,9 +42,10 @@ Execute from the working directory:
|
||||
|
||||
```
|
||||
docker run --rm \
|
||||
-e PLUGIN_TOKEN=xxxxxxx \
|
||||
-e PLUGIN_TELEGRAM_TOKEN=xxxxxxx \
|
||||
-e PLUGIN_TO=xxxxxxx \
|
||||
-e PLUGIN_MESSAGE=test \
|
||||
-e PLUGIN_DEBUG=true \
|
||||
-e DRONE_REPO_OWNER=appleboy \
|
||||
-e DRONE_REPO_NAME=go-hello \
|
||||
-e DRONE_COMMIT_SHA=e5e82b5eb3737205c25955dcc3dcacc839b7be52 \
|
||||
|
6
main.go
6
main.go
@ -32,6 +32,11 @@ func main() {
|
||||
Usage: "send telegram message",
|
||||
EnvVar: "PLUGIN_MESSAGE",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "debug",
|
||||
Usage: "enable debug message",
|
||||
EnvVar: "PLUGIN_DEBUG",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "repo.owner",
|
||||
Usage: "repository owner",
|
||||
@ -107,6 +112,7 @@ func run(c *cli.Context) error {
|
||||
},
|
||||
Config: Config{
|
||||
Token: c.String("telegram.token"),
|
||||
Debug: c.Bool("debug"),
|
||||
To: c.StringSlice("to"),
|
||||
Message: c.StringSlice("message"),
|
||||
},
|
||||
|
@ -32,6 +32,7 @@ type (
|
||||
// Config for the plugin.
|
||||
Config struct {
|
||||
Token string
|
||||
Debug bool
|
||||
To []string
|
||||
Message []string
|
||||
}
|
||||
@ -98,7 +99,7 @@ func (p Plugin) Exec() error {
|
||||
return err
|
||||
}
|
||||
|
||||
bot.Debug = false
|
||||
bot.Debug = p.Config.Debug
|
||||
|
||||
// parse ids
|
||||
ids := parseID(p.Config.To)
|
||||
|
@ -69,6 +69,7 @@ func TestSendMessage(t *testing.T) {
|
||||
Token: os.Getenv("TELEGRAM_TOKEN"),
|
||||
To: []string{os.Getenv("TELEGRAM_TO"), "中文ID", "1234567890"},
|
||||
Message: []string{"Test Telegram Chat Bot From Travis or Local", " "},
|
||||
Debug: false,
|
||||
},
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user