From 4cf4308ef88670920e01cec7b1714e3a60caee49 Mon Sep 17 00:00:00 2001 From: Steve McCoy Date: Thu, 30 Aug 2018 14:20:44 -0400 Subject: [PATCH 1/2] Fix hilarious cat-astrophy --- plugins/picker/picker.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/picker/picker.go b/plugins/picker/picker.go index 1b6a16d..c92d6fc 100644 --- a/plugins/picker/picker.go +++ b/plugins/picker/picker.go @@ -3,7 +3,9 @@ package picker import ( + "errors" "regexp" + "strconv" "strings" "fmt" @@ -62,7 +64,7 @@ var pickerListItem = regexp.MustCompile(`^([^,]+),[ \t]+`) func (p * PickerPlugin) parse(body string) (int, []string, error) { subs := pickerListPrologue.FindStringSubmatch(body) - if subs == nil { + if subs == nil && !strings.HasPrefix(body, "pick") { return 0, nil, errors.New("saddle up for a syntax error") } From fa7ed79ff68108389b4ea7f995b114ee56f06fd0 Mon Sep 17 00:00:00 2001 From: Steve McCoy Date: Thu, 30 Aug 2018 14:23:19 -0400 Subject: [PATCH 2/2] "A" "better" "fix" --- plugins/picker/picker.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/picker/picker.go b/plugins/picker/picker.go index c92d6fc..e3e375e 100644 --- a/plugins/picker/picker.go +++ b/plugins/picker/picker.go @@ -30,6 +30,10 @@ func New(bot 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(message msg.Message) bool { + if !strings.HasPrefix(body, "pick") { + return false + } + n, items, err := p.parse(message.Body) if err != nil { p.Bot.SendMessage(message.Channel, err.Error()) @@ -64,7 +68,7 @@ var pickerListItem = regexp.MustCompile(`^([^,]+),[ \t]+`) func (p * PickerPlugin) parse(body string) (int, []string, error) { subs := pickerListPrologue.FindStringSubmatch(body) - if subs == nil && !strings.HasPrefix(body, "pick") { + if subs == nil { return 0, nil, errors.New("saddle up for a syntax error") }