Skip to content
rocketscienceggPublic

About

A golang TeamSpeak 3 ServerQuery client

Resources

Stars

51 stars

Watchers

33 watching

Forks

Latest commit

 

History

41 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TeamSpeak 3 Go Report Card License GoDoc

go-ts3 is a Go client for the TeamSpeak 3 ServerQuery Protocol.

Features

Installation

Requires Go 1.26 or later.

go get -u github.com/multiplay/go-ts3

Concurrency and timeouts

Commands on a client may be called from multiple goroutines. Each complete command/response exchange is serialized so responses are returned to the correct caller. Callers must not concurrently modify a shared command or response target.

The Timeout option bounds a command, including time spent waiting for another command to finish. A timeout before sending leaves the connection usable. If a sent command times out, the client closes the connection to prevent a late response from being returned to a later command. Create a new client to reconnect. Subsequent commands on the disconnected client return ErrNotConnected. Close on an already disconnected client also returns ErrNotConnected.

Examples

Using go-ts3 is simple just create a client, login and then send commands e.g.

package main

import (
	"log"

        "github.com/multiplay/go-ts3"
)

func main() {
        c, err := ts3.NewClient("192.168.1.102:10011")
	if err != nil {
		log.Fatal(err)
	}
	defer c.Close()

	if err := c.Login(user, pass); err != nil {
		log.Fatal(err)
	}

	if v, err := c.Version(); err != nil {
		log.Fatal(err)
	} else {
		log.Println("server is running:", v)
	}
}

Detailed online client information

Use c.Server.ClientInfo(clientID) after selecting a virtual server to retrieve a *ts3.DetailedOnlineClient. Its ID is the requested client ID, while ChannelID is the client's current channel. Created and LastConnected are time.Time values; IdleTime and ConnectionConnectedTime are time.Duration values converted from the protocol's milliseconds. ServerGroups contains the numeric group IDs. TalkRequest is the time the client requested permission to talk, or the zero time.Time when no request is pending. IconID is a CRC32 value normalized to uint32, including when older servers send its signed representation.

The detailed result is independent of OnlineClient and its optional ClientList extensions. The ts3.ClientInfo constant still selects the -info extension for ClientList; it is not the detailed query method. Metadata and badges are not exposed by the detailed result. Conversion and server errors return a nil result and a non-nil error.

Documentation

Optional client information

c.Server.ClientList() requests only the basic client list. Select additional information explicitly rather than requesting every extension on every call:

clients, err := c.Server.ClientList(ts3.ClientAway, ts3.ClientVoice, ts3.ClientCountry)
if err != nil {
	log.Fatal(err)
}
for _, client := range clients {
	log.Println(client.Nickname, client.Away, client.AwayMessage)
	if client.OnlineClientExt == nil {
		continue
	}
	if client.Country != nil {
		log.Println("country:", *client.Country)
	}
	if client.OnlineClientVoice == nil {
		continue
	}
	if client.InputMuted != nil && client.OutputMuted != nil {
		log.Println("muted:", *client.InputMuted, *client.OutputMuted)
	}
}

ClientList(ts3.ClientListFull) requests all supported extensions. Country and voice fields are pointers: nil means the field was not returned, while a non-nil pointer can contain an empty country or a false mute status. Check the embedded extension pointers before accessing their fields. Away and AwayMessage retain their non-pointer types for compatibility.

License

go-ts3 is available under the BSD 2-Clause License.

About

A golang TeamSpeak 3 ServerQuery client

Resources

Stars

51 stars

Watchers

33 watching

Forks

Releases

Packages

Used by

Contributors

Languages