From: Frédéric Péters Date: Thu, 19 Mar 2020 15:24:12 +0000 (+0100) Subject: add cmdline argument to start in a specific channel X-Git-Url: https://git.0d.be/?p=barnard.git;a=commitdiff_plain;h=7aaa6f73874a615fdb433e9fc14b62bb1551003d;ds=sidebyside add cmdline argument to start in a specific channel --- diff --git a/barnard.go b/barnard.go index 0e121b3..769151e 100644 --- a/barnard.go +++ b/barnard.go @@ -14,6 +14,7 @@ type Barnard struct { Address string TLSConfig tls.Config + DefaultChannel string Stream *gumbleopenal.Stream diff --git a/client.go b/client.go index 6f932e5..060e059 100644 --- a/client.go +++ b/client.go @@ -45,6 +45,10 @@ func (b *Barnard) OnConnect(e *gumble.ConnectEvent) { if e.WelcomeMessage != nil { b.AddOutputLine(fmt.Sprintf("Welcome message: %s", esc(*e.WelcomeMessage))) } + if (b.DefaultChannel != "") { + b.Client.Self.Move(b.Client.Channels.Find(b.DefaultChannel)) + } + } func (b *Barnard) OnDisconnect(e *gumble.DisconnectEvent) { diff --git a/main.go b/main.go index 7a779d5..bbe84fa 100644 --- a/main.go +++ b/main.go @@ -18,6 +18,7 @@ func main() { password := flag.String("password", "", "the password of the server") insecure := flag.Bool("insecure", false, "skip server certificate verification") certificate := flag.String("certificate", "", "PEM encoded certificate and private key") + channel := flag.String("channel", "", "initial channel") flag.Parse() @@ -25,6 +26,7 @@ func main() { b := Barnard{ Config: gumble.NewConfig(), Address: *server, + DefaultChannel: *channel, } b.Config.Username = *username