From 392621b9a52c3263514235b1d1199bd3e3e16cf9 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Sat, 3 Oct 2020 09:22:38 +0800 Subject: [PATCH] refactor: DisableWebPagePreview Signed-off-by: Bo-Yi Wu --- plugin.go | 2 +- plugin_test.go | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) 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) {