diff --git a/plugin.go b/plugin.go index 0f6f5c4..e1a3178 100644 --- a/plugin.go +++ b/plugin.go @@ -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 } diff --git a/plugin_test.go b/plugin_test.go index faa3ab5..590db69 100644 --- a/plugin_test.go +++ b/plugin_test.go @@ -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) {