This directory contains example Python scripts demonstrating TsPy plugin capabilities.
Real-time Audio Monitoring with PyGame UI
A comprehensive audio monitoring tool featuring:
- Real-time VU meter (-60dB to 0dB visualization)
- Color-coded audio levels (green/yellow/red)
- Recording control button
- Live list of currently talking clients
- PyGame window at 800x600 @ 30 FPS
Requirements:
pip install pygameUsage:
/tspy python load audio_monitor
Features:
- Polls
ts3api.get_audio_level()every frame for smooth updates - Click recording button to start/stop voice recording
- Event handler updates talking clients list in real-time
- Press ESC or close window to exit
Automatic Welcome Messages
Sends a friendly greeting when you connect to a server.
Usage:
/tspy python load auto_greeter
Event Handlers:
on_connect()- Sends channel message when connected
Ham Radio Callsign Logger
Logs ham radio callsigns from text messages (format: W1ABC, K2XYZ, etc.).
Usage:
/tspy python load callsign_logger
Event Handlers:
on_text_message()- Detects and logs callsigns from messages
Features:
- Regex pattern matching for valid callsigns
- Logs to plugin log file with timestamp
Basic Example
Minimal example demonstrating basic TsPy functionality.
Usage:
/tspy python load hello_world
Features:
- Simple print message on load
- Demonstrates basic ts3api usage
Copy any example to your TeamSpeak scripts folder:
Copy-Item "examples\audio_monitor.py" "$env:APPDATA\TS3Client\plugins\scripts\"Use the /tspy python load command:
/tspy python load audio_monitor
Verify script is running:
/tspy python status
Stop a running script:
/tspy python unload audio_monitor
import ts3api
def on_connect(server_id, client_id):
"""Called when you connect to a server"""
ts3api.print_message("Hello from Python!")
def on_text_message(server_id, from_id, to_id, target_mode, message):
"""Called when a text message is received"""
print(f"Received: {message}")on_connect(server_id, client_id)- Server connectionon_disconnect(server_id)- Server disconnectionon_client_move(server_id, client_id, old_channel, new_channel)- Client movementon_text_message(server_id, from_id, to_id, target_mode, message)- Text messageson_talk_status_change(server_id, status, client_id)- Talk status (1=talking, 0=stopped)
# Information
client_id = ts3api.get_client_id(server_id)
name = ts3api.get_client_name(server_id, client_id)
# Messaging
ts3api.print_message("Text")
ts3api.send_channel_message(server_id, "Text")
ts3api.send_server_message(server_id, "Text")
# Audio
level = ts3api.get_audio_level(server_id) # Returns dB
ts3api.start_recording(server_id)
ts3api.stop_recording(server_id)
# Logging
ts3api.log("Message", level=0) # 0=INFO, 1=WARNING, 2=ERROR- Check script is in:
%APPDATA%\TS3Client\plugins\scripts\ - Verify Python engine:
/tspy python status - Check plugin log:
%APPDATA%\TS3Client\plugins\tspy_plugin.log
- Install pygame:
pip install pygame - Connect to a server first
- Check microphone is enabled in TeamSpeak
- Ensure you only
import ts3api(builtin module) - Standard library imports work:
import re,import json, etc. - External packages need to be installed:
pip install package_name
- Auto-loading: Add your script to
scripts/tspy_init.pyfor automatic loading - Debugging: Use
ts3api.log()to write debug messages to plugin log - Testing: Use
/tspy python reload <script>to reload after editing - Safety: Avoid infinite loops - they will freeze TeamSpeak
- Performance: Heavy processing should be done in separate threads
Happy scripting! 🚀