catbase/main.go

59 lines
1.6 KiB
Go
Raw Normal View History

2016-01-17 18:00:44 +00:00
// © 2013 the CatBase Authors under the WTFPL. See AUTHORS for the list of authors.
package main
import (
"flag"
"log"
2016-01-17 18:00:44 +00:00
"github.com/velour/catbase/bot"
"github.com/velour/catbase/config"
2016-03-10 18:37:07 +00:00
"github.com/velour/catbase/irc"
"github.com/velour/catbase/plugins/admin"
"github.com/velour/catbase/plugins/beers"
2016-04-04 14:33:32 +00:00
"github.com/velour/catbase/plugins/counter"
"github.com/velour/catbase/plugins/dice"
"github.com/velour/catbase/plugins/downtime"
"github.com/velour/catbase/plugins/fact"
2016-03-25 16:25:00 +00:00
"github.com/velour/catbase/plugins/leftpad"
"github.com/velour/catbase/plugins/talker"
"github.com/velour/catbase/plugins/your"
2016-03-11 02:11:52 +00:00
"github.com/velour/catbase/slack"
)
func main() {
var cfile = flag.String("config", "config.json",
"Config file to load. (Defaults to config.json)")
flag.Parse() // parses the logging flags.
2016-03-10 18:37:07 +00:00
c := config.Readconfig(Version, *cfile)
var client bot.Connector
2016-03-10 18:37:07 +00:00
switch c.Type {
case "irc":
client = irc.New(c)
2016-03-11 02:11:52 +00:00
case "slack":
client = slack.New(c)
2016-03-10 18:37:07 +00:00
default:
log.Fatalf("Unknown connection type: %s", c.Type)
}
b := bot.New(c, client)
2016-03-10 18:37:07 +00:00
// b.AddHandler(plugins.NewTestPlugin(b))
b.AddHandler("admin", admin.New(b))
2016-03-11 02:11:52 +00:00
// b.AddHandler("first", plugins.NewFirstPlugin(b))
2016-03-25 16:25:00 +00:00
b.AddHandler("leftpad", leftpad.New(b))
b.AddHandler("downtime", downtime.New(b))
b.AddHandler("talker", talker.New(b))
b.AddHandler("dice", dice.New(b))
b.AddHandler("beers", beers.New(b))
b.AddHandler("remember", fact.NewRemember(b))
b.AddHandler("your", your.New(b))
2016-04-04 14:33:32 +00:00
b.AddHandler("counter", counter.New(b))
// catches anything left, will always return true
b.AddHandler("factoid", fact.New(b))
2016-03-10 18:37:07 +00:00
client.Serve()
}