catbase/main.go

52 lines
1.4 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"
2016-01-17 18:00:44 +00:00
"github.com/velour/catbase/plugins"
2016-03-19 18:02:46 +00:00
"github.com/velour/catbase/plugins/counter"
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)
}
2016-03-10 18:37:07 +00:00
b := bot.NewBot(c, client)
// b.AddHandler(plugins.NewTestPlugin(b))
b.AddHandler("admin", plugins.NewAdminPlugin(b))
2016-03-11 02:11:52 +00:00
// b.AddHandler("first", plugins.NewFirstPlugin(b))
2016-03-10 18:37:07 +00:00
b.AddHandler("downtime", plugins.NewDowntimePlugin(b))
b.AddHandler("talker", plugins.NewTalkerPlugin(b))
b.AddHandler("dice", plugins.NewDicePlugin(b))
b.AddHandler("beers", plugins.NewBeersPlugin(b))
2016-03-19 18:02:46 +00:00
b.AddHandler("counter", counter.NewCounterPlugin(b))
2016-03-10 18:37:07 +00:00
b.AddHandler("remember", plugins.NewRememberPlugin(b))
b.AddHandler("skeleton", plugins.NewSkeletonPlugin(b))
b.AddHandler("your", plugins.NewYourPlugin(b))
// catches anything left, will always return true
2016-03-10 18:37:07 +00:00
b.AddHandler("factoid", plugins.NewFactoidPlugin(b))
2016-03-10 18:37:07 +00:00
client.Serve()
}