flokati/main.go

54 lines
1.2 KiB
Go
Raw Normal View History

2019-08-01 08:50:13 +00:00
// vi:ts=4:sts=4:sw=4:noet:tw=72
//
// flokatimx
//
// Copyright (c) 2015-2019 Andreas Neue <an@dnix.de>
package main
import (
"flag"
"fmt"
"runtime"
"strings"
2019-08-01 09:04:31 +00:00
"git.dnix.de/an/flokati/modules"
2019-08-01 08:50:13 +00:00
"git.dnix.de/an/xlog"
)
var (
protocol = flag.String("protocol", "", "Protocol")
mods = flag.String("mods", "", "Modules to load")
name = flag.String("name", "flokati", "Bot name")
nick = flag.String("nick", "flokati", "Nickname")
server = flag.String("server", "https://matrix.org", "Host to connect to")
channels = flag.String("chan", "", "Channels")
password = flag.String("password", "", "Login password")
token = flag.String("token", "", "Login token")
)
func init() {
flag.Parse()
}
func main() {
2019-08-01 10:58:44 +00:00
say := make(chan string, 1024)
2019-08-01 08:50:13 +00:00
xlog.Info("%s started", SoftwareInfo())
2019-08-01 10:58:44 +00:00
modules.Init(say, *mods)
2019-08-01 08:50:13 +00:00
modules.BotNick = strings.ToLower(*nick)
2019-08-24 05:37:39 +00:00
modules.BotName = strings.ToLower(*name)
2019-08-01 08:50:13 +00:00
switch *protocol {
2019-08-01 11:28:01 +00:00
case "irc":
Irc(say)
2019-08-01 08:50:13 +00:00
case "matrix":
2019-08-01 10:58:44 +00:00
Matrix(say)
2019-08-01 08:50:13 +00:00
default:
xlog.Error("Unsupported protocol: %s", *protocol)
}
}
func SoftwareInfo() string {
2019-08-01 09:36:35 +00:00
return fmt.Sprintf("flokati/%s %s-%s (%s) [%s]",
*protocol, Version, Build, Builddate, runtime.Version())
2019-08-01 08:50:13 +00:00
}