This commit is contained in:
Andreas Neue 2019-08-01 12:58:44 +02:00
parent d128cc7491
commit 2215d331e4
2 changed files with 6 additions and 10 deletions

10
main.go
View File

@ -27,24 +27,20 @@ var (
token = flag.String("token", "", "Login token")
)
var (
sayCh chan string
)
func init() {
flag.Parse()
}
func main() {
sayCh := make(chan string, 1024)
say := make(chan string, 1024)
xlog.Info("%s started", SoftwareInfo())
modules.Init(sayCh, *mods)
modules.Init(say, *mods)
modules.BotNick = strings.ToLower(*nick)
switch *protocol {
//case "irc":
// Irc()
case "matrix":
Matrix()
Matrix(say)
default:
xlog.Error("Unsupported protocol: %s", *protocol)
}

View File

@ -16,7 +16,7 @@ import (
"github.com/matrix-org/gomatrix"
)
func Matrix() {
func Matrix(say chan string) {
cl, err := gomatrix.NewClient(*server, *name, *token)
fmt.Println(err)
@ -40,11 +40,11 @@ func Matrix() {
}
}()
sayCh <- fmt.Sprintf("%s\n%s", "*", SoftwareInfo())
say <- fmt.Sprintf("%s\n%s", "*", SoftwareInfo())
for {
var targets string
line := strings.Split(<-sayCh, "\n")
line := strings.Split(<-say, "\n")
if len(line) < 2 {
continue
}