mirror of https://github.com/velour/catbase.git
TL;DR Latent Dirichlet Allocation summarizer
This commit is contained in:
parent
bd169dd85b
commit
650ccb190d
2
main.go
2
main.go
|
@ -38,6 +38,7 @@ import (
|
|||
"github.com/velour/catbase/plugins/sisyphus"
|
||||
"github.com/velour/catbase/plugins/talker"
|
||||
"github.com/velour/catbase/plugins/tell"
|
||||
"github.com/velour/catbase/plugins/tldr"
|
||||
"github.com/velour/catbase/plugins/twitch"
|
||||
"github.com/velour/catbase/plugins/your"
|
||||
"github.com/velour/catbase/plugins/zork"
|
||||
|
@ -119,6 +120,7 @@ func main() {
|
|||
b.AddPlugin(tell.New(b))
|
||||
b.AddPlugin(couldashouldawoulda.New(b))
|
||||
b.AddPlugin(nerdepedia.New(b))
|
||||
b.AddPlugin(tldr.New(b))
|
||||
// catches anything left, will always return true
|
||||
b.AddPlugin(fact.New(b))
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,44 @@
|
|||
package tldr
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/velour/catbase/bot"
|
||||
"github.com/velour/catbase/bot/msg"
|
||||
"github.com/velour/catbase/bot/user"
|
||||
)
|
||||
|
||||
func makeMessageBy(payload, by string) (bot.Kind, msg.Message) {
|
||||
isCmd := strings.HasPrefix(payload, "!")
|
||||
if isCmd {
|
||||
payload = payload[1:]
|
||||
}
|
||||
return bot.Message, msg.Message{
|
||||
User: &user.User{Name: by},
|
||||
Channel: "test",
|
||||
Body: payload,
|
||||
Command: isCmd,
|
||||
}
|
||||
}
|
||||
|
||||
func makeMessage(payload string) (bot.Kind, msg.Message) {
|
||||
return makeMessageBy(payload, "tester")
|
||||
}
|
||||
|
||||
func setup(t *testing.T) (*TLDRPlugin, *bot.MockBot) {
|
||||
mb := bot.NewMockBot()
|
||||
r := New(mb)
|
||||
return r, mb
|
||||
}
|
||||
|
||||
func Test(t *testing.T) {
|
||||
c, mb := setup(t)
|
||||
res := c.message(makeMessage("The quick brown fox jumped over the lazy dog"))
|
||||
res = c.message(makeMessage("The cow jumped over the moon"))
|
||||
res = c.message(makeMessage("The little dog laughed to see such fun"))
|
||||
res = c.message(makeMessage("tl;dr"))
|
||||
assert.True(t, res)
|
||||
assert.Len(t, mb.Messages, 1)
|
||||
}
|
Loading…
Reference in New Issue