forked from an/flokati
53 lines
1.1 KiB
Go
53 lines
1.1 KiB
Go
// 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"
|
|
|
|
"git.dnix.de/an/flokati/modules"
|
|
"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() {
|
|
say := make(chan string, 1024)
|
|
xlog.Info("%s started", SoftwareInfo())
|
|
modules.Init(say, *mods)
|
|
modules.BotNick = strings.ToLower(*nick)
|
|
switch *protocol {
|
|
case "irc":
|
|
Irc(say)
|
|
case "matrix":
|
|
Matrix(say)
|
|
default:
|
|
xlog.Error("Unsupported protocol: %s", *protocol)
|
|
}
|
|
}
|
|
|
|
func SoftwareInfo() string {
|
|
return fmt.Sprintf("flokati/%s %s-%s (%s) [%s]",
|
|
*protocol, Version, Build, Builddate, runtime.Version())
|
|
}
|