refactor: DisableWebPagePreview

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu 2020-10-03 09:22:38 +08:00
parent dc17cf7288
commit 392621b9a5
2 changed files with 4 additions and 3 deletions

View File

@ -364,7 +364,7 @@ func (p Plugin) Exec() (err error) {
msg := tgbotapi.NewMessage(user, txt)
msg.ParseMode = p.Config.Format
msg.DisableWebPagePreview = !p.Config.DisableWebPagePreview
msg.DisableWebPagePreview = p.Config.DisableWebPagePreview
if err := p.Send(bot, msg); err != nil {
return err
}

View File

@ -140,12 +140,13 @@ func TestDisableWebPagePreviewMessage(t *testing.T) {
plugin.Config.Format = formatMarkdown
plugin.Config.Message = "DisableWebPagePreview https://www.google.com.tw"
err = plugin.Exec()
assert.NotNil(t, err)
assert.Nil(t, err)
// disable message
plugin.Config.DisableWebPagePreview = false
plugin.Config.Message = "EnableWebPagePreview https://www.google.com.tw"
err = plugin.Exec()
assert.NotNil(t, err)
assert.Nil(t, err)
}
func TestBotError(t *testing.T) {