Menu
 

Game Server Integration - TeamSpeak Wiki

TeamSpeak: Game Server Integration Guide

Integrate TeamSpeak with popular games, overlays, and plugins. Includes API examples, webhook configurations, and automation for enhanced gaming communication.

Integration Methods

Available Integration Options

🔌 ServerQuery API

Direct server control via TCP/SSH connection

Best for: Automation, bots, custom tools

📡 ClientQuery API

Control TeamSpeak client programmatically

Best for: Overlays, game integrations

🎮 Game Plugins

Native game integration plugins

Best for: In-game overlays, positional audio

ServerQuery API Integration

Basic ServerQuery Connection

# Python example
import telnetlib

# Connect to ServerQuery
tn = telnetlib.Telnet("localhost", 10011)

# Read welcome message
tn.read_until(b"TS3")

# Login
tn.write(b"login serveradmin YOUR_PASSWORD\n")
tn.read_until(b"error id=0")

# Select virtual server
tn.write(b"use sid=1\n")
tn.read_until(b"error id=0")

# Send command
tn.write(b"clientlist\n")
response = tn.read_until(b"error id=0")
print(response.decode())

# Close connection
tn.write(b"quit\n")
tn.close()

Advanced Python Integration

#!/usr/bin/env python3
# teamspeak_bot.py

import ts3

class TeamspeakBot:
    def __init__(self, host, port, user, password):
        self.host = host
        self.port = port
        self.user = user
        self.password = password
        self.conn = None
    
    def connect(self):
        self.conn = ts3.query.TS3ServerConnection(self.host, self.port)
        self.conn.login(
            client_login_name=self.user,
            client_login_password=self.password
        )
        self.conn.use(sid=1)
    
    def get_online_users(self):
        clients = self.conn.clientlist()
        return [c for c in clients if c['client_type'] == '0']
    
    def send_message(self, client_id, message):
        self.conn.sendtextmessage(
            targetmode=1,  # Private message
            target=client_id,
            msg=message
        )
    
    def move_user(self, client_id, channel_id):
        self.conn.clientmove(cid=channel_id, clid=client_id)
    
    def kick_user(self, client_id, reason="Kicked by bot"):
        self.conn.clientkick(
            reasonid=5,  # Kick from server
            clid=client_id,
            reasonmsg=reason
        )

# Usage
bot = TeamspeakBot("localhost", 10011, "serveradmin", "password")
bot.connect()

# Get online users
users = bot.get_online_users()
for user in users:
    print(f"{user['client_nickname']} - {user['client_database_id']}")

# Send welcome message
for user in users:
    bot.send_message(user['clid'], "Welcome to the server!")

Game-Specific Integrations

Minecraft Integration

# Minecraft plugin (Java)
// TeamspeakBridge.java

public class TeamspeakBridge extends JavaPlugin {
    private TS3Api api;
    
    @Override
    public void onEnable() {
        // Connect to TeamSpeak
        TS3Config config = new TS3Config();
        config.setHost("localhost");
        config.setQueryPort(10011);
        
        TS3Query query = new TS3Query(config);
        query.connect();
        
        api = query.getApi();
        api.login("serveradmin", "password");
        api.selectVirtualServerById(1);
        
        // Sync online players
        getServer().getScheduler().scheduleSyncRepeatingTask(this, () -> {
            syncPlayers();
        }, 0L, 200L);  // Every 10 seconds
    }
    
    private void syncPlayers() {
        // Get Minecraft players
        for (Player player : Bukkit.getOnlinePlayers()) {
            String nickname = player.getName();
            
            // Find in TeamSpeak
            List clients = api.getClients();
            for (Client client : clients) {
                if (client.getNickname().equals(nickname)) {
                    // Move to game channel
                    api.moveClient(client.getId(), GAME_CHANNEL_ID);
                }
            }
        }
    }
}

Discord-TeamSpeak Bridge

#!/usr/bin/env python3
# discord_ts_bridge.py

import discord
import ts3
import asyncio

class DiscordTSBridge:
    def __init__(self, discord_token, ts_host, ts_port, ts_user, ts_pass):
        self.discord_client = discord.Client()
        self.ts_conn = ts3.query.TS3ServerConnection(ts_host, ts_port)
        
        # Connect to TeamSpeak
        self.ts_conn.login(
            client_login_name=ts_user,
            client_login_password=ts_pass
        )
        self.ts_conn.use(sid=1)
        
        # Discord events
        @self.discord_client.event
        async def on_message(message):
            if message.author == self.discord_client.user:
                return
            
            # Send to TeamSpeak
            self.broadcast_to_ts(
                f"[Discord] {message.author.name}: {message.content}"
            )
        
        # Start Discord bot
        self.discord_client.run(discord_token)
    
    def broadcast_to_ts(self, message):
        # Send to all online users
        clients = self.ts_conn.clientlist()
        for client in clients:
            if client['client_type'] == '0':  # Not a query client
                self.ts_conn.sendtextmessage(
                    targetmode=1,
                    target=client['clid'],
                    msg=message
                )

# Usage
bridge = DiscordTSBridge(
    discord_token="YOUR_DISCORD_TOKEN",
    ts_host="localhost",
    ts_port=10011,
    ts_user="serveradmin",
    ts_pass="password"
)

Webhook Integration

Event Webhooks

#!/usr/bin/env python3
# teamspeak_webhooks.py

import ts3
import requests
import json

class TSWebhooks:
    def __init__(self, webhook_url):
        self.webhook_url = webhook_url
        self.ts_conn = ts3.query.TS3ServerConnection("localhost", 10011)
        self.ts_conn.login(
            client_login_name="serveradmin",
            client_login_password="password"
        )
        self.ts_conn.use(sid=1)
        
        # Register for events
        self.ts_conn.servernotifyregister(event="server")
        self.ts_conn.servernotifyregister(event="channel", id=0)
    
    def listen_events(self):
        while True:
            event = self.ts_conn.wait_for_event()
            
            if event.event == "notifycliententerview":
                # User joined
                self.send_webhook({
                    "event": "user_join",
                    "user": event[0]['client_nickname'],
                    "uid": event[0]['client_unique_identifier']
                })
            
            elif event.event == "notifyclientleftview":
                # User left
                self.send_webhook({
                    "event": "user_leave",
                    "user": event[0]['client_nickname']
                })
    
    def send_webhook(self, data):
        payload = {
            "content": f"TeamSpeak Event: {data['event']}",
            "embeds": [{
                "title": data['event'].replace('_', ' ').title(),
                "description": json.dumps(data, indent=2),
                "color": 3447003
            }]
        }
        requests.post(self.webhook_url, json=payload)

# Usage
webhooks = TSWebhooks("https://discord.com/api/webhooks/YOUR_WEBHOOK")
webhooks.listen_events()

Music Bot Integration

SinusBot Setup

# Install SinusBot
wget https://www.sinusbot.com/dl/sinusbot.current.tar.bz2
tar -xjf sinusbot.current.tar.bz2
cd sinusbot

# Configure
cp config.ini.dist config.ini
nano config.ini

# Set TeamSpeak settings
[TS3]
Host = "127.0.0.1"
Port = 9987
ServerPassword = ""
Nickname = "MusicBot"
Channel = ""
ChannelPassword = ""

# Start bot
./sinusbot

# Access web interface
# http://localhost:8087

Custom Music Bot

#!/usr/bin/env python3
# simple_music_bot.py

import ts3
import vlc
import time

class MusicBot:
    def __init__(self):
        self.ts_conn = ts3.query.TS3ServerConnection("localhost", 10011)
        self.ts_conn.login(
            client_login_name="serveradmin",
            client_login_password="password"
        )
        self.ts_conn.use(sid=1)
        
        # VLC player
        self.player = vlc.MediaPlayer()
        self.playlist = []
    
    def play_song(self, url):
        self.player.set_media(vlc.Media(url))
        self.player.play()
        
        # Announce in TeamSpeak
        self.broadcast(f"Now playing: {url}")
    
    def broadcast(self, message):
        self.ts_conn.sendtextmessage(
            targetmode=3,  # Server broadcast
            target=1,
            msg=message
        )
    
    def listen_commands(self):
        self.ts_conn.servernotifyregister(event="textchannel")
        
        while True:
            event = self.ts_conn.wait_for_event()
            
            if event.event == "notifytextmessage":
                msg = event[0]['msg']
                
                if msg.startswith("!play "):
                    url = msg.split(" ", 1)[1]
                    self.play_song(url)
                
                elif msg == "!stop":
                    self.player.stop()
                    self.broadcast("Playback stopped")

# Usage
bot = MusicBot()
bot.listen_commands()

In-Game Overlay Integration

Overwolf Integration

// Overwolf TeamSpeak overlay
// manifest.json
{
  "name": "TeamSpeak Overlay",
  "version": "1.0.0",
  "permissions": ["GameInfo", "Hotkeys"],
  "data": {
    "windows": {
      "overlay": {
        "file": "overlay.html",
        "in_game_only": true,
        "transparent": true,
        "clickthrough": false
      }
    }
  }
}

// overlay.js
const TS_API_URL = "http://localhost:25639";

async function getTeamspeakData() {
    const response = await fetch(`${TS_API_URL}/clientlist`);
    const data = await response.json();
    
    // Update overlay with user list
    updateUserList(data.clients);
}

function updateUserList(clients) {
    const container = document.getElementById('users');
    container.innerHTML = '';
    
    clients.forEach(client => {
        const div = document.createElement('div');
        div.className = 'user';
        div.textContent = client.nickname;
        
        // Add talking indicator
        if (client.talking) {
            div.classList.add('talking');
        }
        
        container.appendChild(div);
    });
}

// Update every second
setInterval(getTeamspeakData, 1000);

Automation Scripts

Auto-Channel Management

#!/usr/bin/env python3
# auto_channel_manager.py

import ts3
import time

class ChannelManager:
    def __init__(self):
        self.ts_conn = ts3.query.TS3ServerConnection("localhost", 10011)
        self.ts_conn.login(
            client_login_name="serveradmin",
            client_login_password="password"
        )
        self.ts_conn.use(sid=1)
    
    def create_temp_channels(self):
        # Get all channels
        channels = self.ts_conn.channellist()
        
        # Find "Create Channel" trigger
        for channel in channels:
            if "Join to Create" in channel['channel_name']:
                # Check if users in channel
                clients = self.ts_conn.clientlist()
                users_in_channel = [c for c in clients 
                                  if c['cid'] == channel['cid']]
                
                if users_in_channel:
                    # Create new temp channel
                    new_channel = self.ts_conn.channelcreate(
                        channel_name=f"Temp {time.time()}",
                        channel_flag_temporary=1,
                        cpid=channel['pid']
                    )
                    
                    # Move users
                    for user in users_in_channel:
                        self.ts_conn.clientmove(
                            cid=new_channel['cid'],
                            clid=user['clid']
                        )
    
    def cleanup_empty_channels(self):
        channels = self.ts_conn.channellist()
        clients = self.ts_conn.clientlist()
        
        for channel in channels:
            # Check if temporary and empty
            if channel['channel_flag_temporary'] == '1':
                users_in_channel = [c for c in clients 
                                  if c['cid'] == channel['cid']]
                
                if not users_in_channel:
                    self.ts_conn.channeldelete(
                        cid=channel['cid'],
                        force=1
                    )

# Run manager
manager = ChannelManager()
while True:
    manager.create_temp_channels()
    manager.cleanup_empty_channels()
    time.sleep(5)

Pro Tip: Use ServerQuery API for server-side automation and ClientQuery API for client-side integrations like overlays.

Integrate TeamSpeak with your gaming ecosystem. Host your TeamSpeak server with Supercraft for reliable API access and integrations.

Top