mirror of https://github.com/velour/catbase.git
picker: make pick a command
This commit is contained in:
parent
595492a16b
commit
99817ad621
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue