From 2e602c45605f918933facb9ae21025872608f2b6 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Fri, 7 Oct 2016 00:41:28 +0800 Subject: [PATCH] support markdown and html format. Signed-off-by: Bo-Yi Wu --- main.go | 7 +++++++ plugin.go | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 042b718..52555dc 100644 --- a/main.go +++ b/main.go @@ -37,6 +37,12 @@ func main() { Usage: "enable debug message", EnvVar: "PLUGIN_DEBUG", }, + cli.StringFlag{ + Name: "format", + Value: "markdown", + Usage: "telegram message format", + EnvVar: "PLUGIN_FORMAT", + }, cli.StringFlag{ Name: "repo.owner", Usage: "repository owner", @@ -115,6 +121,7 @@ func run(c *cli.Context) error { Debug: c.Bool("debug"), To: c.StringSlice("to"), Message: c.StringSlice("message"), + Format: c.String("format"), }, } diff --git a/plugin.go b/plugin.go index 18dd9c9..5553bf9 100644 --- a/plugin.go +++ b/plugin.go @@ -35,6 +35,7 @@ type ( Debug bool To []string Message []string + Format string } // Plugin values. @@ -107,8 +108,9 @@ func (p Plugin) Exec() error { // send message. for _, user := range ids { for _, value := range trimElement(message) { + log.Println(user) msg := tgbotapi.NewMessage(user, value) - msg.ParseMode = "markdown" + msg.ParseMode = p.Config.Format _, err := bot.Send(msg)