"A" "better" "fix"

This commit is contained in:
Steve McCoy 2018-08-30 14:23:19 -04:00 committed by GitHub
parent 4cf4308ef8
commit fa7ed79ff6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -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")
}