Skip to content

Commit

Permalink
Merge pull request thannaske#6 from Xyaren/patch-1
Browse files Browse the repository at this point in the history
Print Error to Stderr
  • Loading branch information
thannaske authored May 10, 2019
2 parents c0736e5 + 8b1bcaf commit f721504
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions teamspeak.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,32 @@ func main() {
c, err := ts3.NewClient(*serverPtr)

if err != nil {
fmt.Println("[Error] Could not establish server query connection to", *serverPtr)
fmt.Println(os.Stderr, "[Error] Could not establish server query connection to", *serverPtr)
os.Exit(1)
}

defer c.Close()

if err := c.Login(*usernamePtr, *passwordPtr); err != nil {
fmt.Println("[Error] Authentication failure")
fmt.Println(os.Stderr, "[Error] Authentication failure")
os.Exit(1)
}

if serverList, err := c.Server.ExtendedList(); err != nil {
fmt.Println("[Error] Could not iterate through Teamspeak 3 server instances")
fmt.Println(os.Stderr, "[Error] Could not iterate through Teamspeak 3 server instances")
os.Exit(1)
} else {
for _, server := range serverList {

err := c.Use(server.ID)

if err != nil {
if err.Error() == "server is not running (1033)" {
continue // ignore offline servers
} else {
fmt.Println("[Error] Could not select Teamspeak 3 server instance by ID")
os.Exit(1)
}
if err.Error() == "server is not running (1033)" {
continue // ignore offline servers
} else {
fmt.Println(os.Stderr, "[Error] Could not select Teamspeak 3 server instance by ID")
os.Exit(1)
}
}

var serverAutoStart int = 0
Expand Down

0 comments on commit f721504

Please sign in to comment.