diff --git a/plugins/picker/picker.go b/plugins/picker/picker.go index d6ae53b..0c6e9e3 100644 --- a/plugins/picker/picker.go +++ b/plugins/picker/picker.go @@ -35,7 +35,7 @@ func New(b bot.Bot) *PickerPlugin { // This function returns true if the plugin responds in a meaningful way to the users message. // Otherwise, the function returns false and the bot continues execution of other plugins. func (p *PickerPlugin) message(c bot.Connector, kind bot.Kind, message msg.Message, args ...interface{}) bool { - if !strings.HasPrefix(message.Body, "pick") { + if !strings.HasPrefix(message.Body, "pick") || !message.Command { return false } diff --git a/plugins/picker/picker_test.go b/plugins/picker/picker_test.go index cca1eba..9bbec38 100644 --- a/plugins/picker/picker_test.go +++ b/plugins/picker/picker_test.go @@ -98,3 +98,20 @@ func TestKnownBrokenPick(t *testing.T) { assert.NotContains(t, mb.Messages[0], "hot picks") log.Debug().Str("resp", mb.Messages[0]).Msg("choose") } + +func TestPickIsCommand(t *testing.T) { + mb := bot.NewMockBot() + c := New(mb) + _ = c.message(makeMessage("!pick⌘ { bagel/egg/smoked turkey/butte/cheese ⌘ fuck all that, just have a bagel and cream cheese }")) + assert.Len(t, mb.Messages, 1) + assert.Contains(t, mb.Messages[0], "I've chosen") + assert.NotContains(t, mb.Messages[0], "hot picks") + log.Debug().Str("resp", mb.Messages[0]).Msg("choose") +} + +func TestPickMustBeCommand(t *testing.T) { + mb := bot.NewMockBot() + c := New(mb) + _ = c.message(makeMessage("pick⌘ { bagel/egg/smoked turkey/butte/cheese ⌘ fuck all that, just have a bagel and cream cheese }")) + assert.Len(t, mb.Messages, 0) +}