diff --git a/main.go b/main.go index 3a06ea2..8f373a5 100644 --- a/main.go +++ b/main.go @@ -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) } diff --git a/matrix.go b/matrix.go index 1c282ce..bc8376c 100644 --- a/matrix.go +++ b/matrix.go @@ -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 }