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")
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
sayCh chan string
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
flag.Parse()
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
xlog.Info("%s started", SoftwareInfo())
|
|
|
|
modules.Init(sayCh, *mods)
|
|
|
|
modules.BotNick = strings.ToLower(*nick)
|
|
|
|
switch *protocol {
|
|
|
|
case "irc":
|
|
|
|
Irc()
|
|
|
|
case "matrix":
|
|
|
|
Matrix()
|
|
|
|
default:
|
|
|
|
xlog.Error("Unsupported protocol: %s", *protocol)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func SoftwareInfo() string {
|
|
|
|
return fmt.Sprintf("flokatimx %s-%s (%s) [%s]",
|
|
|
|
Version, Build, Builddate, runtime.Version())
|
|
|
|
}
|