2016-01-17 18:00:44 +00:00
|
|
|
// © 2013 the CatBase Authors under the WTFPL. See AUTHORS for the list of authors.
|
2013-12-10 23:37:07 +00:00
|
|
|
|
2012-08-17 20:38:15 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2013-05-09 22:30:15 +00:00
|
|
|
"flag"
|
2013-06-02 01:59:55 +00:00
|
|
|
"log"
|
2014-04-20 16:54:01 +00:00
|
|
|
|
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"
|
2013-06-02 01:59:55 +00:00
|
|
|
)
|
2012-08-17 20:38:15 +00:00
|
|
|
|
2013-06-02 01:59:55 +00:00
|
|
|
func main() {
|
|
|
|
var cfile = flag.String("config", "config.json",
|
|
|
|
"Config file to load. (Defaults to config.json)")
|
2012-08-17 20:38:15 +00:00
|
|
|
flag.Parse() // parses the logging flags.
|
|
|
|
|
2016-03-10 18:37:07 +00:00
|
|
|
c := config.Readconfig(Version, *cfile)
|
|
|
|
var client bot.Connector
|
2013-06-02 01:59:55 +00:00
|
|
|
|
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)
|
2013-06-02 01:59:55 +00:00
|
|
|
}
|
|
|
|
|
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))
|
2013-06-02 01:59:55 +00:00
|
|
|
// catches anything left, will always return true
|
2016-03-10 18:37:07 +00:00
|
|
|
b.AddHandler("factoid", plugins.NewFactoidPlugin(b))
|
2013-01-23 00:22:32 +00:00
|
|
|
|
2016-03-10 18:37:07 +00:00
|
|
|
client.Serve()
|
2012-08-17 20:38:15 +00:00
|
|
|
}
|