Skip to content
Samuel Grant edited this page Jun 23, 2020 · 30 revisions

Teamspeak-GO Guide

Teamspeak-GO is a simple library is in the early stages of development. The library is intended to be used by GO applications that need to manage a Team Speak server through the query interface.

Because the Team Speak query uses Telnet data, server queries are transmitted using plain text and could be vulnerable to snoopers. For security reasons you use this library on the same server as your Team Speak server and keep traffic protected behind a firewall.

Quick Reference Guides

Basic Setup/Usage

  1. Install a Team Speak server version 3.12.0 (or later)
  2. Start the server with HTTP enabled ./ts3server query_protocols=raw,ssh,http,https, or use Docker
  3. Create an API key
Docker Configuration
version: '3'
services:
    ts3:
        image: teamspeak
        command: ['ts3server', 'query_protocols=raw,ssh,http,https']
        ports:
            - 9987:9987/udp
            - 10011:10011
            - 30033:30033
            - 10080:10080
        environment:
            TS3SERVER_LICENSE: accept

The code below is a basic usage example and assumes you have imported ts3 "github.com/samuelgrant/Teamspeak-GO"

// These variables should come from environment variables and not be in your source code
  host, apikey := "localhost:10080": "<api key>"

  // Logging is disabled by default
  ts3.LoggingEnabled(true)

  // This needs to be done before you can make API calls
  ts3.ConfigureHttp(apiKey, host)

  // The default virtual server is 1
  // Override that at any time using the function below
  ts3.SelectVirtualServer(1)

  // Run a query but discard the results
  ts3.ServerGlobalMessage("Global text message sent to the server")

  // Run a query and handle the results
  qres, servers, err := ts3.ServersList()
  if err != nil || !qres.IsSuccess() {
    // handle error
  }

Create your own commands by using the get function

Commands

Planned

n/a

Server (Managing Virtual Servers)

Channel Groups

Privilege Keys

Server Groups

Manage Server Groups

Manage Memberships

User

func get (Custom Commands)

get("path", isGlobal, queries) is the magic that makes every function in this library work. You can use this function to create your own commands.

Params

Name Type Description
path string API URL Path (do not include the base), the path should match a command from this document
globalCmd bool Generally speaking, this value should be false. It should only be sent to true if the command does not get sent to a specific virtual server (example, Serverstart, Serverstop, Serverlist, Serverversion)
Queries []KeyValue OPTIONAL array of key value pairs that appended to the path as a URL query string.

Returns

Type Description
*status Query Response
string string of JSON content that was returned by the API
error