mirror of https://github.com/velour/catbase.git
add middle out compression, I mean babbles
This commit is contained in:
parent
8edba10b5d
commit
bd7cf6be7c
|
@ -119,7 +119,14 @@ func (p *BabblerPlugin) Message(message msg.Message) bool {
|
||||||
saidWhat, saidSomething = p.getBabble(tokens)
|
saidWhat, saidSomething = p.getBabble(tokens)
|
||||||
} else if numTokens > 2 && tokens[1] == "says-tail" {
|
} else if numTokens > 2 && tokens[1] == "says-tail" {
|
||||||
saidWhat, saidSomething = p.getBabbleWithSuffix(tokens)
|
saidWhat, saidSomething = p.getBabbleWithSuffix(tokens)
|
||||||
}else if len(tokens) == 4 && strings.Index(lowercase, "initialize babbler for ") == 0 {
|
} else if numTokens >= 2 && tokens[1] == "says-middle-out" {
|
||||||
|
saidWhatStart, saidSomethingStart := p.getBabbleWithSuffix(tokens)
|
||||||
|
saidWhatEnd, saidSomethingEnd := p.getBabble(tokens)
|
||||||
|
saidSomething = saidSomethingStart && saidSomethingEnd
|
||||||
|
if saidSomething {
|
||||||
|
saidWhat = saidWhatStart + " " + strings.Join(strings.Fields(saidWhatEnd)[len(tokens)-2:], " ")
|
||||||
|
}
|
||||||
|
} else if len(tokens) == 4 && strings.Index(lowercase, "initialize babbler for ") == 0 {
|
||||||
saidWhat, saidSomething = p.initializeBabbler(tokens)
|
saidWhat, saidSomething = p.initializeBabbler(tokens)
|
||||||
} else if strings.Index(lowercase, "batch learn for ") == 0 {
|
} else if strings.Index(lowercase, "batch learn for ") == 0 {
|
||||||
saidWhat, saidSomething = p.batchLearn(tokens)
|
saidWhat, saidSomething = p.batchLearn(tokens)
|
||||||
|
@ -142,6 +149,7 @@ func (p *BabblerPlugin) Help(channel string, parts []string) {
|
||||||
"merge babbler drseabass into seabass",
|
"merge babbler drseabass into seabass",
|
||||||
"seabass says ...",
|
"seabass says ...",
|
||||||
"seabass says-tail ...",
|
"seabass says-tail ...",
|
||||||
|
"seabass says-middle-out ...",
|
||||||
"seabass says-bridge ... | ...",
|
"seabass says-bridge ... | ...",
|
||||||
}
|
}
|
||||||
p.Bot.SendMessage(channel, strings.Join(commands, "\n\n"))
|
p.Bot.SendMessage(channel, strings.Join(commands, "\n\n"))
|
||||||
|
|
|
@ -237,6 +237,20 @@ func TestBabblerBadBookendSeed(t *testing.T) {
|
||||||
assert.Contains(t, mb.Messages[0], "seabass never said 'it's easier ... not unique messages'")
|
assert.Contains(t, mb.Messages[0], "seabass never said 'it's easier ... not unique messages'")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestBabblerMiddleOutSeed(t *testing.T) {
|
||||||
|
mb := bot.NewMockBot()
|
||||||
|
c := New(mb)
|
||||||
|
c.config.Babbler.DefaultUsers = []string{"seabass"}
|
||||||
|
assert.NotNil(t, c)
|
||||||
|
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-middle-out test with"))
|
||||||
|
assert.Len(t, mb.Messages, 1)
|
||||||
|
assert.True(t, res)
|
||||||
|
assert.Contains(t, mb.Messages[0], "it's easier to test with unique messages")
|
||||||
|
}
|
||||||
|
|
||||||
func TestBabblerBatch(t *testing.T) {
|
func TestBabblerBatch(t *testing.T) {
|
||||||
mb := bot.NewMockBot()
|
mb := bot.NewMockBot()
|
||||||
c := New(mb)
|
c := New(mb)
|
||||||
|
|
Loading…
Reference in New Issue