Add support for generic templates by using custom extra vars (#84)

* Fix DOCS.md example configuration with custom message from file

* Move .test.message to a better named file

* Add support for additional, custom extra vars to be used in the message template

* Add cmdline/envvars to support the extra vars

* Enhance DOCS.md with example configuration using generic template file with custom vars

* Add testcase for custom template vars
This commit is contained in:
Daniel M. Lambea
2019-10-29 02:57:00 +00:00
committed by Bo-Yi Wu
parent 866e25b433
commit b7f97df101
6 changed files with 124 additions and 41 deletions
+23 -17
View File
@@ -41,6 +41,11 @@ func main() {
Usage: "send telegram message from file",
EnvVar: "PLUGIN_MESSAGE_FILE,TELEGRAM_MESSAGE_FILE,INPUT_MESSAGE_FILE",
},
cli.StringFlag{
Name: "template.vars",
Usage: "additional template vars to be used in message, as JSON string",
EnvVar: "PLUGIN_TEMPLATE_VARS,TELEGRAM_TEMPLATE_VARS,INPUT_TEMPLATE_VARS",
},
cli.StringSliceFlag{
Name: "photo",
Usage: "send photo message",
@@ -287,23 +292,24 @@ func run(c *cli.Context) error {
DeployTo: c.String("deploy.to"),
},
Config: Config{
Token: c.String("token"),
Debug: c.Bool("debug"),
MatchEmail: c.Bool("match.email"),
WebPreview: c.Bool("webpage.preview"),
To: c.StringSlice("to"),
Message: c.StringSlice("message"),
MessageFile: c.String("message.file"),
Photo: c.StringSlice("photo"),
Document: c.StringSlice("document"),
Sticker: c.StringSlice("sticker"),
Audio: c.StringSlice("audio"),
Voice: c.StringSlice("voice"),
Location: c.StringSlice("location"),
Video: c.StringSlice("video"),
Venue: c.StringSlice("venue"),
Format: c.String("format"),
GitHub: c.Bool("github"),
Token: c.String("token"),
Debug: c.Bool("debug"),
MatchEmail: c.Bool("match.email"),
WebPreview: c.Bool("webpage.preview"),
To: c.StringSlice("to"),
Message: c.StringSlice("message"),
MessageFile: c.String("message.file"),
TemplateVars: c.String("template.vars"),
Photo: c.StringSlice("photo"),
Document: c.StringSlice("document"),
Sticker: c.StringSlice("sticker"),
Audio: c.StringSlice("audio"),
Voice: c.StringSlice("voice"),
Location: c.StringSlice("location"),
Video: c.StringSlice("video"),
Venue: c.StringSlice("venue"),
Format: c.String("format"),
GitHub: c.Bool("github"),
},
}