Skip to content

Commit

Permalink
Add feature to toggle web-page preview (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafi authored and appleboy committed Sep 11, 2017
1 parent eaeb3f6 commit 709c4ce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions main.go
Expand Up @@ -83,6 +83,11 @@ func main() {
Usage: "send message when only match email",
EnvVar: "PLUGIN_ONLY_MATCH_EMAIL",
},
cli.BoolTFlag{
Name: "webpage.preview",
Usage: "toggle web-page preview",
EnvVar: "PLUGIN_WEBPAGE_PREVIEW",
},
cli.StringFlag{
Name: "format",
Value: "markdown",
Expand Down Expand Up @@ -205,6 +210,7 @@ func run(c *cli.Context) error {
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"),
Photo: c.StringSlice("photo"),
Expand Down
2 changes: 2 additions & 0 deletions plugin.go
Expand Up @@ -41,6 +41,7 @@ type (
Token string
Debug bool
MatchEmail bool
WebPreview bool
To []string
Message []string
Photo []string
Expand Down Expand Up @@ -260,6 +261,7 @@ func (p Plugin) Exec() error {

msg := tgbotapi.NewMessage(user, txt)
msg.ParseMode = p.Config.Format
msg.DisableWebPagePreview = !p.Config.WebPreview
p.Send(bot, msg)
}

Expand Down

0 comments on commit 709c4ce

Please sign in to comment.