forked from an/flokati
56 lines
1.1 KiB
Go
56 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"
|
||
|
"flokati/modules"
|
||
|
"fmt"
|
||
|
"runtime"
|
||
|
"strings"
|
||
|
|
||
|
"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())
|
||
|
}
|