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

View File

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