From 2ffbc6fb93f5dce882f6492366f7c641fcd98344 Mon Sep 17 00:00:00 2001 From: Chris Sexton Date: Fri, 26 Oct 2018 11:01:01 -0400 Subject: [PATCH] reminder: change the confirmation of remind me --- plugins/beers/beers_test.go | 1 + plugins/reminder/reminder.go | 7 ++++--- plugins/reminder/reminder_test.go | 12 ++++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/plugins/beers/beers_test.go b/plugins/beers/beers_test.go index aed25a9..46840fc 100644 --- a/plugins/beers/beers_test.go +++ b/plugins/beers/beers_test.go @@ -31,6 +31,7 @@ func makeBeersPlugin(t *testing.T) (*BeersPlugin, *bot.MockBot) { counter.New(mb) b := New(mb) assert.NotNil(t, b) + b.Message(makeMessage("!mkalias beer :beer:")) return b, mb } diff --git a/plugins/reminder/reminder.go b/plugins/reminder/reminder.go index 8a384ef..3361528 100644 --- a/plugins/reminder/reminder.go +++ b/plugins/reminder/reminder.go @@ -146,9 +146,10 @@ func (p *ReminderPlugin) Message(message msg.Message) bool { return true } - if doConfirm { - response := fmt.Sprintf("Sure %s, I'll remind %s.", from, who) - p.Bot.SendMessage(channel, response) + if doConfirm && from == who { + p.Bot.SendMessage(channel, fmt.Sprintf("Okay. I'll remind you.")) + } else if doConfirm { + p.Bot.SendMessage(channel, fmt.Sprintf("Sure %s, I'll remind %s.", from, who)) } p.queueUpNextReminder() diff --git a/plugins/reminder/reminder_test.go b/plugins/reminder/reminder_test.go index 6901e43..cd76931 100644 --- a/plugins/reminder/reminder_test.go +++ b/plugins/reminder/reminder_test.go @@ -40,6 +40,18 @@ func makeMessageBy(payload, by string) msg.Message { } } +func TestMeReminder(t *testing.T) { + mb := bot.NewMockBot() + c := New(mb) + assert.NotNil(t, c) + res := c.Message(makeMessage("!remind me in 1s don't fail this test")) + time.Sleep(2 * time.Second) + assert.Len(t, mb.Messages, 2) + assert.True(t, res) + assert.Contains(t, mb.Messages[0], "Okay. I'll remind you.") + assert.Contains(t, mb.Messages[1], "Hey tester, you wanted you to be reminded: don't fail this test") +} + func TestReminder(t *testing.T) { mb := bot.NewMockBot() c := New(mb)