mirror of https://github.com/velour/catbase.git
quiet down the babbler
This commit is contained in:
parent
11c4f78bbd
commit
8735a2283b
|
@ -121,11 +121,16 @@ func (p *BabblerPlugin) Message(message msg.Message) bool {
|
|||
saidWhat, saidSomething = p.getBabbleWithSuffix(tokens)
|
||||
} else if numTokens >= 2 && tokens[1] == "says-middle-out" {
|
||||
saidWhatStart, saidSomethingStart := p.getBabbleWithSuffix(tokens)
|
||||
if !saidSomethingStart || saidWhatStart == strings.Join(tokens[2:], " ") {
|
||||
saidSomething = saidSomethingStart
|
||||
saidWhat = saidWhatStart
|
||||
} else {
|
||||
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)
|
||||
} else if strings.Index(lowercase, "batch learn for ") == 0 {
|
||||
|
|
|
@ -31,9 +31,9 @@ func TestBabblerNoBabbler(t *testing.T) {
|
|||
c.config.Babbler.DefaultUsers = []string{"seabass"}
|
||||
assert.NotNil(t, c)
|
||||
c.Message(makeMessage("!seabass2 says"))
|
||||
res := assert.Len(t, mb.Messages, 1)
|
||||
res := assert.Len(t, mb.Messages, 0)
|
||||
assert.True(t, res)
|
||||
assert.Contains(t, mb.Messages[0], "seabass2 babbler not found")
|
||||
// assert.Contains(t, mb.Messages[0], "seabass2 babbler not found")
|
||||
}
|
||||
|
||||
func TestBabblerNothingSaid(t *testing.T) {
|
||||
|
@ -251,6 +251,21 @@ func TestBabblerMiddleOutSeed(t *testing.T) {
|
|||
assert.Contains(t, mb.Messages[0], "it's easier to test with unique messages")
|
||||
}
|
||||
|
||||
func TestBabblerBadMiddleOutSeed(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 anything true"))
|
||||
assert.Len(t, mb.Messages, 1)
|
||||
assert.True(t, res)
|
||||
assert.Contains(t, mb.Messages[0], "seabass never said 'anything true'")
|
||||
}
|
||||
|
||||
|
||||
func TestBabblerBatch(t *testing.T) {
|
||||
mb := bot.NewMockBot()
|
||||
c := New(mb)
|
||||
|
|
|
@ -28,7 +28,8 @@ func (p *BabblerPlugin) getBabble(tokens []string) (string, bool) {
|
|||
|
||||
if err != nil {
|
||||
if err == NO_BABBLER {
|
||||
return fmt.Sprintf("%s babbler not found.", who), true
|
||||
// return fmt.Sprintf("%s babbler not found.", who), true
|
||||
return "", false
|
||||
}
|
||||
} else {
|
||||
|
||||
|
@ -58,7 +59,8 @@ func (p *BabblerPlugin) getBabbleWithSuffix(tokens []string) (string, bool) {
|
|||
|
||||
if err != nil {
|
||||
if err == NO_BABBLER {
|
||||
return fmt.Sprintf("%s babbler not found.", who), true
|
||||
// return fmt.Sprintf("%s babbler not found.", who), true
|
||||
return "", false
|
||||
}
|
||||
} else {
|
||||
|
||||
|
@ -83,7 +85,8 @@ func (p *BabblerPlugin) getBabbleWithBookends(start, end []string) (string, bool
|
|||
|
||||
if err != nil {
|
||||
if err == NO_BABBLER {
|
||||
return fmt.Sprintf("%s babbler not found.", who), true
|
||||
// return fmt.Sprintf("%s babbler not found.", who), true
|
||||
return "", false
|
||||
}
|
||||
} else {
|
||||
|
||||
|
|
Loading…
Reference in New Issue