From 57eb2119836050d04b10b0f51eeaef0db74ce623 Mon Sep 17 00:00:00 2001 From: skkiesel Date: Wed, 12 Apr 2017 09:02:00 -0400 Subject: [PATCH] Remove the responses when we think we have a babble request but there is no babbler or the babbler is empty --- plugins/babbler/babbler.go | 6 ++---- plugins/babbler/babbler_test.go | 8 +++----- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/plugins/babbler/babbler.go b/plugins/babbler/babbler.go index 8e75677..ea3166d 100644 --- a/plugins/babbler/babbler.go +++ b/plugins/babbler/babbler.go @@ -87,9 +87,7 @@ func (p *BabblerPlugin) Message(message msg.Message) bool { } else { saying = p.babbleSeed(tokens[0], tokens[2:]) } - if saying == "" { - p.Bot.SendMessage(message.Channel, "Ze ain't said nothin'") - } else { + if saying != "" { p.Bot.SendMessage(message.Channel, saying) } return true @@ -315,7 +313,7 @@ func (p *BabblerPlugin) babbleSeed(who string, seed []string) string { return strings.TrimSpace(strings.Join(words, " ")) } - return fmt.Sprintf("could not find babbler: %s", who) + return "" } func (into *babbler) merge(other *babbler, intoName, otherName string) { diff --git a/plugins/babbler/babbler_test.go b/plugins/babbler/babbler_test.go index 7fe4395..1a58873 100644 --- a/plugins/babbler/babbler_test.go +++ b/plugins/babbler/babbler_test.go @@ -30,10 +30,9 @@ func TestBabblerNoBabbler(t *testing.T) { c := New(mb) c.config.Babbler.DefaultUsers = []string{"seabass"} assert.NotNil(t, c) - res := c.Message(makeMessage("!seabass2 says")) - assert.Len(t, mb.Messages, 1) + c.Message(makeMessage("!seabass2 says")) + res := assert.Len(t, mb.Messages, 0) assert.True(t, res) - assert.Contains(t, mb.Messages[0], "could not find babbler: seabass2") } func TestBabblerNothingSaid(t *testing.T) { @@ -42,9 +41,8 @@ func TestBabblerNothingSaid(t *testing.T) { c.config.Babbler.DefaultUsers = []string{"seabass"} assert.NotNil(t, c) res := c.Message(makeMessage("!seabass says")) - assert.Len(t, mb.Messages, 1) + assert.Len(t, mb.Messages, 0) assert.True(t, res) - assert.Contains(t, mb.Messages[0], "Ze ain't said nothin") } func TestBabbler(t *testing.T) {