From 8edba10b5d68ab0679d325e6b1f44f3de117de1b Mon Sep 17 00:00:00 2001 From: skkiesel Date: Wed, 7 Jun 2017 20:02:18 -0400 Subject: [PATCH] update babbler syntax --- plugins/babbler/babbler.go | 17 ++++++++++++----- plugins/babbler/babbler_test.go | 12 ++++++------ 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/plugins/babbler/babbler.go b/plugins/babbler/babbler.go index 68fb48a..a146f1c 100644 --- a/plugins/babbler/babbler.go +++ b/plugins/babbler/babbler.go @@ -110,16 +110,16 @@ func (p *BabblerPlugin) Message(message msg.Message) bool { saidSomething := false saidWhat := "" - if numTokens > 2 && tokens[1] == "says" && strings.Contains(lowercase, "syas") { - split := strings.Split(lowercase, "syas") + if numTokens > 2 && tokens[1] == "says-bridge" && strings.Contains(lowercase, "|") { + split := strings.Split(lowercase, "|") start := strings.Fields(split[0]) end := strings.Fields(split[1]) saidWhat, saidSomething = p.getBabbleWithBookends(start, end) } else if numTokens >= 2 && tokens[1] == "says" { saidWhat, saidSomething = p.getBabble(tokens) - } else if numTokens > 2 && tokens[1] == "syas" { + } else if numTokens > 2 && tokens[1] == "says-tail" { saidWhat, saidSomething = p.getBabbleWithSuffix(tokens) - } else if len(tokens) == 4 && strings.Index(lowercase, "initialize babbler for ") == 0 { + }else if len(tokens) == 4 && strings.Index(lowercase, "initialize babbler for ") == 0 { saidWhat, saidSomething = p.initializeBabbler(tokens) } else if strings.Index(lowercase, "batch learn for ") == 0 { saidWhat, saidSomething = p.batchLearn(tokens) @@ -137,7 +137,14 @@ func (p *BabblerPlugin) Message(message msg.Message) bool { } func (p *BabblerPlugin) Help(channel string, parts []string) { - p.Bot.SendMessage(channel, "initialize babbler for seabass\n\nseabass says") + commands := []string{ + "initialize babbler for seabass", + "merge babbler drseabass into seabass", + "seabass says ...", + "seabass says-tail ...", + "seabass says-bridge ... | ...", + } + p.Bot.SendMessage(channel, strings.Join(commands, "\n\n")) } func (p *BabblerPlugin) Event(kind string, message msg.Message) bool { diff --git a/plugins/babbler/babbler_test.go b/plugins/babbler/babbler_test.go index a54c625..a530602 100644 --- a/plugins/babbler/babbler_test.go +++ b/plugins/babbler/babbler_test.go @@ -169,8 +169,8 @@ func TestBabblerSuffixSeed(t *testing.T) { res = c.Message(seabass) seabass.Body = "hi there" res = c.Message(seabass) - res = c.Message(makeMessage("!seabass syas message one")) - res = c.Message(makeMessage("!seabass syas with unique")) + res = c.Message(makeMessage("!seabass says-tail message one")) + res = c.Message(makeMessage("!seabass says-tail with unique")) assert.Len(t, mb.Messages, 2) assert.True(t, res) assert.Contains(t, mb.Messages[0], "this is message one") @@ -189,7 +189,7 @@ func TestBabblerBadSuffixSeed(t *testing.T) { res = c.Message(seabass) seabass.Body = "hi there" res = c.Message(seabass) - res = c.Message(makeMessage("!seabass syas anything true")) + res = c.Message(makeMessage("!seabass says-tail anything true")) assert.Len(t, mb.Messages, 1) assert.True(t, res) assert.Contains(t, mb.Messages[0], "seabass never said 'anything true'") @@ -203,7 +203,7 @@ func TestBabblerBookendSeed(t *testing.T) { seabass := makeMessage("It's easier to test with unique messages") seabass.User = &user.User{Name: "seabass"} res := c.Message(seabass) - res = c.Message(makeMessage("!seabass says It's easier syas unique messages")) + res = c.Message(makeMessage("!seabass says-bridge It's easier | unique messages")) assert.Len(t, mb.Messages, 1) assert.True(t, res) assert.Contains(t, mb.Messages[0], "it's easier to test with unique messages") @@ -217,7 +217,7 @@ func TestBabblerBookendSeedShort(t *testing.T) { seabass := makeMessage("It's easier to test with unique messages") seabass.User = &user.User{Name: "seabass"} res := c.Message(seabass) - res = c.Message(makeMessage("!seabass says It's easier to test with syas unique messages")) + res = c.Message(makeMessage("!seabass says-bridge It's easier to test with | unique messages")) assert.Len(t, mb.Messages, 1) assert.True(t, res) assert.Contains(t, mb.Messages[0], "it's easier to test with unique messages") @@ -231,7 +231,7 @@ func TestBabblerBadBookendSeed(t *testing.T) { seabass := makeMessage("It's easier to test with unique messages") seabass.User = &user.User{Name: "seabass"} res := c.Message(seabass) - res = c.Message(makeMessage("!seabass says It's easier syas not unique messages")) + res = c.Message(makeMessage("!seabass says-bridge It's easier | not unique messages")) assert.Len(t, mb.Messages, 1) assert.True(t, res) assert.Contains(t, mb.Messages[0], "seabass never said 'it's easier ... not unique messages'")