Add feature to toggle web-page preview (#52)
This commit is contained in:
parent
eaeb3f678e
commit
709c4ce6a8
6
main.go
6
main.go
@ -83,6 +83,11 @@ func main() {
|
|||||||
Usage: "send message when only match email",
|
Usage: "send message when only match email",
|
||||||
EnvVar: "PLUGIN_ONLY_MATCH_EMAIL",
|
EnvVar: "PLUGIN_ONLY_MATCH_EMAIL",
|
||||||
},
|
},
|
||||||
|
cli.BoolTFlag{
|
||||||
|
Name: "webpage.preview",
|
||||||
|
Usage: "toggle web-page preview",
|
||||||
|
EnvVar: "PLUGIN_WEBPAGE_PREVIEW",
|
||||||
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "format",
|
Name: "format",
|
||||||
Value: "markdown",
|
Value: "markdown",
|
||||||
@ -205,6 +210,7 @@ func run(c *cli.Context) error {
|
|||||||
Token: c.String("token"),
|
Token: c.String("token"),
|
||||||
Debug: c.Bool("debug"),
|
Debug: c.Bool("debug"),
|
||||||
MatchEmail: c.Bool("match.email"),
|
MatchEmail: c.Bool("match.email"),
|
||||||
|
WebPreview: c.Bool("webpage.preview"),
|
||||||
To: c.StringSlice("to"),
|
To: c.StringSlice("to"),
|
||||||
Message: c.StringSlice("message"),
|
Message: c.StringSlice("message"),
|
||||||
Photo: c.StringSlice("photo"),
|
Photo: c.StringSlice("photo"),
|
||||||
|
@ -41,6 +41,7 @@ type (
|
|||||||
Token string
|
Token string
|
||||||
Debug bool
|
Debug bool
|
||||||
MatchEmail bool
|
MatchEmail bool
|
||||||
|
WebPreview bool
|
||||||
To []string
|
To []string
|
||||||
Message []string
|
Message []string
|
||||||
Photo []string
|
Photo []string
|
||||||
@ -260,6 +261,7 @@ func (p Plugin) Exec() error {
|
|||||||
|
|
||||||
msg := tgbotapi.NewMessage(user, txt)
|
msg := tgbotapi.NewMessage(user, txt)
|
||||||
msg.ParseMode = p.Config.Format
|
msg.ParseMode = p.Config.Format
|
||||||
|
msg.DisableWebPagePreview = !p.Config.WebPreview
|
||||||
p.Send(bot, msg)
|
p.Send(bot, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user