support markdown and html format.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu 2016-10-07 00:41:28 +08:00
parent 75c04eafaa
commit 2e602c4560
2 changed files with 10 additions and 1 deletions

View File

@ -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"),
},
}

View File

@ -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)