### Install ts3API Python Package Source: https://github.com/murgeye/teamspeak3-python-api/blob/master/README.md Instructions for installing the ts3API Python package using pip. It also mentions the optional dependency 'Paramiko' for SSH connection support. ```bash pip install ts3API pip install paramiko ``` -------------------------------- ### Connect and Handle Teamspeak 3 Events with Python Source: https://github.com/murgeye/teamspeak3-python-api/blob/master/README.md This Python code demonstrates how to connect to a Teamspeak 3 server using the ts3API library, log in, set up event handlers for various events (like client bans, kicks, and messages), and start a keepalive loop. It requires the 'ts3API' library and optionally 'paramiko' for SSH connections. ```python from ts3API.TS3Connection import TS3Connection import ts3API.Events as Events HOST = "serverhost" PORT = 10011 # Default Port USER = 'serveradmin' # Default login PASS = 'password' DEFAULTCHANNEL = 'Botchannel-or-any-other' SID = 1 # Virtual server id NICKNAME = "aName" def on_event(sender, **kw): """ Event handling method """ # Get the parsed event from the dictionary event = kw["event"] print(type(event)) """ # This generates output for every event. Remove the comment if you want more output for attr, value in event.__dict__.items(): print("\t"+attr+":", value) """ if isinstance(event, Events.ClientBannedEvent): print("Client was banned!") print("\tClient ID:", event.client_id) print("\tReason Message:", event.reason_msg) print("\tInvokerID:", event.invoker_id) print("\tInvokerName:", event.invoker_name) print("\tBantime:", event.ban_time) if isinstance(event, Events.ClientKickedEvent): print("Client was kicked!") print("\tClient ID:", event.client_id) print("\tReason Message:", event.reason_msg) print("\tInvokerID:", event.invoker_id) print("\tInvokerName:", event.invoker_name) if isinstance(event, Events.ClientLeftEvent): print("Client left!") print("\tClient ID:", event.client_id) print("\tReason Message:", event.reason_msg) if type(event) is Events.TextMessageEvent: # Prevent the client from sending messages to itself if event.invoker_id != int(ts3conn.whoami()["client_id"]): ts3conn.sendtextmessage(targetmode=1, target=event.invoker_id, msg="I received your message!") # Connect to the Query Port ts3conn = TS3Connection(HOST, PORT) # Login with query credentials ts3conn.login(USER, PASS) # Choose a virtual server ts3conn.use(sid=SID) # Find the channel to move the query client to channel = ts3conn.channelfind(pattern=DEFAULTCHANNEL)[0]["cid"] # Give the Query Client a name ts3conn.clientupdate(["client_nickname="+NICKNAME]) # Move the Query client ts3conn.clientmove(channel, int(ts3conn.whoami()["client_id"])) # Register for server wide events ts3conn.register_for_server_events(on_event) # Register for private messages ts3conn.register_for_private_messages(on_event) # Register for channel message in botchannel ts3conn.register_for_channel_events(channel, on_event) # Start the loop to send connection keepalive messages ts3conn.start_keepalive_loop() ``` -------------------------------- ### Execute Dynamic TeamSpeak 3 Server Query Commands in Python Source: https://context7.com/murgeye/teamspeak3-python-api/llms.txt Dynamically execute any TeamSpeak 3 server query command, even those not explicitly implemented in the library. This method uses keyword arguments for parameters and positional arguments for flags. It requires the `ts3API.TS3Connection` class. Examples include adding/removing clients from server groups, retrieving client lists, banning clients, and managing channels. ```python from ts3API.TS3Connection import TS3Connection ts3conn = TS3Connection("localhost", 10011) ts3conn.login("serveradmin", "password") ts3conn.use(sid=1) # Add client to server group (not explicitly implemented) ts3conn.servergroupaddclient(sgid=6, cldbid=42) # Remove client from server group ts3conn.servergroupdelclient(sgid=6, cldbid=42) # Get client database list with parameters # Positional args become flags (prefixed with -) # Keyword args become key=value parameters clients = ts3conn.clientdblist("count", start=0, duration=25) for client in clients: print(f"DB ID: {client['cldbid']}, Name: {client.get('client_nickname')}") # Ban a client ts3conn.banclient(clid=5, time=3600, banreason="Rule violation") # Get ban list bans = ts3conn.banlist() for ban in bans: print(f"Ban ID: {ban['banid']}, Reason: {ban.get('reason')}") # Create a channel ts3conn.channelcreate( channel_name="New Channel", channel_topic="A new channel", channel_flag_permanent=1 ) # Delete a channel ts3conn.channeldelete(cid=25, force=1) ``` -------------------------------- ### Get Detailed Client Information (Python) Source: https://context7.com/murgeye/teamspeak3-python-api/llms.txt Illustrates how to retrieve comprehensive information about a specific client using their client ID with the `clientinfo` method. Returns details such as nickname, unique ID, IP address, platform, and connection timestamps. Requires an active TS3Connection. ```python from ts3API.TS3Connection import TS3Connection ts3conn = TS3Connection("localhost", 10011) ts3conn.login("serveradmin", "password") ts3conn.use(sid=1) # Get client info by client ID client_id = 5 info = ts3conn.clientinfo(client_id) print(f"Nickname: {info.get('client_nickname')}") print(f"Unique ID: {info.get('client_unique_identifier')}") print(f"Database ID: {info.get('client_database_id')}") print(f"IP Address: {info.get('connection_client_ip')}") print(f"Platform: {info.get('client_platform')}") print(f"Version: {info.get('client_version')}") print(f"Connected since: {info.get('client_created')}") print(f"Idle time: {info.get('client_idle_time')}") ``` -------------------------------- ### Register for Text Message Events - Python Source: https://context7.com/murgeye/teamspeak3-python-api/llms.txt This snippet shows how to register callbacks for private, channel, and server text messages. It includes example handlers for each message type and demonstrates an auto-reply mechanism for private messages. Requires TS3Connection and Events imports. ```python from ts3API.TS3Connection import TS3Connection import ts3API.Events as Events def on_private_message(sender, **kw): event = kw["event"] if isinstance(event, Events.TextMessageEvent): print(f"Private message from {event.invoker_name}: {event.message}") # Auto-reply (avoid replying to self) if event.invoker_id != int(ts3conn.whoami()["client_id"]): ts3conn.sendtextmessage( targetmode=1, target=event.invoker_id, msg=f"Thanks for your message! You said: {event.message}" ) def on_channel_message(sender, **kw): event = kw["event"] if isinstance(event, Events.TextMessageEvent): print(f"Channel message from {event.invoker_name}: {event.message}") def on_server_message(sender, **kw): event = kw["event"] if isinstance(event, Events.TextMessageEvent): print(f"Server message from {event.invoker_name}: {event.message}") ts3conn = TS3Connection("localhost", 10011) ts3conn.login("serveradmin", "password") ts3conn.use(sid=1) # Register for different message types ts3conn.register_for_private_messages(on_private_message) ts3conn.register_for_channel_messages(on_channel_message) ts3conn.register_for_server_messages(on_server_message) ts3conn.start_keepalive_loop() ``` -------------------------------- ### Establish and Manage TS3 Connections (Python) Source: https://context7.com/murgeye/teamspeak3-python-api/llms.txt Demonstrates how to establish and manage connections to a TeamSpeak 3 server query interface using the TS3Connection class. Supports both telnet and SSH connections, including login, server selection, and retrieving basic query client information. Requires the 'paramiko' library for SSH connections. ```python from ts3API.TS3Connection import TS3Connection # Basic telnet connection ts3conn = TS3Connection( host="your-ts3-server.com", port=10011, # Default telnet query port log_file="ts3api.log" ) # Login with server query credentials ts3conn.login(user="serveradmin", password="your_password") # Select virtual server (SID) ts3conn.use(sid=1) # Get info about the connected query client whoami = ts3conn.whoami() print(f"Client ID: {whoami['client_id']}") print(f"Channel ID: {whoami['client_channel_id']}") # SSH connection (requires paramiko: pip install paramiko) ssh_conn = TS3Connection( host="your-ts3-server.com", port=10022, # SSH query port use_ssh=True, username="serveradmin", password="your_password", accept_all_keys=True, # Accept all host keys (use cautiously) sshtimeout=10, sshtimeoutlimit=3 ) ``` -------------------------------- ### List and Find Channels (Python) Source: https://context7.com/murgeye/teamspeak3-python-api/llms.txt Demonstrates using `channellist` to retrieve all channels on a TeamSpeak 3 server and `channelfind` to search for channels by name. Both methods return lists of dictionaries containing channel details, with support for fetching additional parameters. Requires an active TS3Connection. ```python from ts3API.TS3Connection import TS3Connection ts3conn = TS3Connection("localhost", 10011) ts3conn.login("serveradmin", "password") ts3conn.use(sid=1) # Get all channels channels = ts3conn.channellist() for channel in channels: print(f"Channel ID: {channel['cid']}, Name: {channel.get('channel_name')}") # Get channel list with additional parameters # Available params: topic, flags, voice, limits, icon, secondsempty detailed_channels = ts3conn.channellist(params=["topic", "flags"]) for channel in detailed_channels: print(f"{channel.get('channel_name')}: {channel.get('channel_topic', 'No topic')}") ``` -------------------------------- ### Call Unimplemented Teamspeak 3 Server Commands in Python Source: https://github.com/murgeye/teamspeak3-python-api/blob/master/README.md Demonstrates how to call TeamSpeak 3 server commands that are not explicitly implemented in the ts3API library. This is achieved by passing command names and their required keyword arguments directly. ```python servergroupaddclient(sgid=servergroup_id, cldbid=client_db_id) ``` -------------------------------- ### Retrieve Connected Clients List (Python) Source: https://context7.com/murgeye/teamspeak3-python-api/llms.txt Shows how to retrieve a list of all clients connected to a TeamSpeak 3 virtual server using the `clientlist` method. Supports fetching basic client information or detailed information with specified parameters. Requires an active TS3Connection. ```python from ts3API.TS3Connection import TS3Connection ts3conn = TS3Connection("localhost", 10011) ts3conn.login("serveradmin", "password") ts3conn.use(sid=1) # Get basic client list clients = ts3conn.clientlist() for client in clients: print(f"ID: {client['clid']}, Name: {client.get('client_nickname', 'Unknown')}") # Get client list with additional parameters # Available params: uid, away, voice, times, groups, info, country, ip, badges detailed_clients = ts3conn.clientlist(params=["uid", "away", "country", "groups"]) for client in detailed_clients: print(f"Client: {client.get('client_nickname')}") print(f" UID: {client.get('client_unique_identifier')}") print(f" Country: {client.get('client_country')}") print(f" Away: {client.get('client_away')}") print(f" Server Groups: {client.get('client_servergroups')}") ``` -------------------------------- ### Retrieve TeamSpeak Server Information Source: https://context7.com/murgeye/teamspeak3-python-api/llms.txt Fetches various information about the TeamSpeak host, instance, and virtual server. Includes details like uptime, bandwidth, server limits, and current client counts. Requires an active TS3Connection object. ```python from ts3API.TS3Connection import TS3Connection ts3conn = TS3Connection("localhost", 10011) ts3conn.login("serveradmin", "password") ts3conn.use(sid=1) # Get host information (physical server) host = ts3conn.hostinfo() print(f"Host uptime: {host.get('instance_uptime')} seconds") print(f"Total bandwidth in: {host.get('connection_bandwidth_received_last_minute_total')}") # Get instance information instance = ts3conn.instanceinfo() print(f"Max virtual servers: {instance.get('serverinstance_serverquery_max_connections_per_ip')}") # Get virtual server information server = ts3conn.serverinfo() print(f"Server name: {server.get('virtualserver_name')}") print(f"Max clients: {server.get('virtualserver_maxclients')}") print(f"Clients online: {server.get('virtualserver_clientsonline')}") print(f"Uptime: {server.get('virtualserver_uptime')} seconds") ``` -------------------------------- ### Retrieve and Find Server Groups - Python Source: https://context7.com/murgeye/teamspeak3-python-api/llms.txt This snippet demonstrates how to fetch all server groups and find a specific server group by its name using the ts3API. It requires establishing a TS3 connection and logging in. ```python from ts3API.TS3Connection import TS3Connection ts3conn = TS3Connection("localhost", 10011) ts3conn.login("serveradmin", "password") ts3conn.use(sid=1) # Get all server groups groups = ts3conn.servergrouplist() for group in groups: print(f"Group ID: {group['sgid']}, Name: {group['name']}, Type: {group.get('type')}") # Find a specific server group by name admin_group = ts3conn.find_servergroup_by_name("Server Admin") if admin_group: print(f"Admin group ID: {admin_group['sgid']}") ``` -------------------------------- ### Python TeamSpeak Bot with Event Handling and Reconnection Source: https://context7.com/murgeye/teamspeak3-python-api/llms.txt This Python script demonstrates a complete TeamSpeak bot using the ts3API. It connects to a server, handles text messages and client events, and automatically reconnects. Dependencies include the ts3API library. It takes server connection details and bot configuration as input and outputs bot responses and logs. ```python from ts3API.TS3Connection import TS3Connection, TS3QueryException import ts3API.Events as Events HOST = "your-ts3-server.com" PORT = 10011 USER = "serveradmin" PASS = "your_password" SID = 1 BOT_NAME = "MyBot" BOT_CHANNEL = "Bot Channel" def on_event(sender, **kw): event = kw["event"] # Handle text messages if isinstance(event, Events.TextMessageEvent): # Ignore own messages if event.invoker_id == int(ts3conn.whoami()["client_id"]): return msg = event.message.lower() if msg == "!help": ts3conn.sendtextmessage( targetmode=1, target=event.invoker_id, msg="Available commands: !help, !info, !users" ) elif msg == "!info": server = ts3conn.serverinfo() ts3conn.sendtextmessage( targetmode=1, target=event.invoker_id, msg=f"Server: {server.get('virtualserver_name')}, " f"Online: {server.get('virtualserver_clientsonline')}" ) elif msg == "!users": clients = ts3conn.clientlist() users = [c.get('client_nickname', 'Unknown') for c in clients if c.get('client_type') == '0'] ts3conn.sendtextmessage( targetmode=1, target=event.invoker_id, msg=f"Online users: {', '.join(users)}" ) # Handle client events elif isinstance(event, Events.ClientEnteredEvent): # Welcome new clients ts3conn.sendtextmessage( targetmode=1, target=event.client_id, msg=f"Welcome {event.client_name}! Type !help for commands." ) elif isinstance(event, Events.ClientKickedEvent): print(f"Client {event.client_id} was kicked by {event.invoker_name}") elif isinstance(event, Events.ClientBannedEvent): print(f"Client {event.client_id} was banned for {event.ban_time}s") # Connect and setup ts3conn = TS3Connection(HOST, PORT) ts3conn.login(USER, PASS) ts3conn.use(sid=SID) # Set bot nickname ts3conn.clientupdate(params=[f"client_nickname={BOT_NAME}"]) # Move to bot channel try: channel = ts3conn.channelfind(pattern=BOT_CHANNEL)[0] my_id = int(ts3conn.whoami()["client_id"]) ts3conn.clientmove(channel_id=int(channel["cid"]), client_id=my_id) except (IndexError, TS3QueryException): print("Could not find or move to bot channel") # Register for all events ts3conn.register_for_server_events(on_event) ts3conn.register_for_private_messages(on_event) ts3conn.register_for_channel_events(0, on_event) # 0 = all channels # Start keepalive loop (blocking) print(f"{BOT_NAME} is now running...") ts3conn.start_keepalive_loop(interval=5) ``` -------------------------------- ### Move TeamSpeak Clients Between Channels Source: https://context7.com/murgeye/teamspeak3-python-api/llms.txt Moves a specified client to a different channel on the TeamSpeak server. Requires the client ID and the target channel ID. Can also move the query client itself. Dependencies include TS3Connection and client/channel IDs. ```python from ts3API.TS3Connection import TS3Connection ts3conn = TS3Connection("localhost", 10011) ts3conn.login("serveradmin", "password") ts3conn.use(sid=1) # Find the target channel target_channel = ts3conn.channelfind(pattern="AFK Room")[0] channel_id = target_channel["cid"] # Move a specific client to the channel client_id = 5 ts3conn.clientmove(channel_id=int(channel_id), client_id=client_id) # Move the query client itself to a channel my_id = int(ts3conn.whoami()["client_id"]) bot_channel = ts3conn.channelfind(pattern="Bot Channel")[0]["cid"] ts3conn.clientmove(channel_id=int(bot_channel), client_id=my_id) ``` -------------------------------- ### Register for Server Events - Python Source: https://context7.com/murgeye/teamspeak3-python-api/llms.txt This code registers callbacks for various server-wide events such as client entering or leaving, client kicks, bans, and server edits. It requires importing the TS3Connection and Events modules. The handler function processes different event types. ```python from ts3API.TS3Connection import TS3Connection import ts3API.Events as Events def on_server_event(sender, **kw): event = kw["event"] if isinstance(event, Events.ClientEnteredEvent): print(f"Client joined: {event.client_name} (ID: {event.client_id})") print(f" UID: {event.client_uid}") print(f" Country: {event.client_country}") print(f" Channel: {event.target_channel_id}") elif isinstance(event, Events.ClientLeftEvent): print(f"Client left: ID {event.client_id}") print(f" Reason: {event.reason_msg}") elif isinstance(event, Events.ClientKickedEvent): print(f"Client kicked: ID {event.client_id}") print(f" By: {event.invoker_name}") print(f" Reason: {event.reason_msg}") elif isinstance(event, Events.ClientBannedEvent): print(f"Client banned: ID {event.client_id}") print(f" By: {event.invoker_name}") print(f" Duration: {event.ban_time} seconds") print(f" Reason: {event.reason_msg}") elif isinstance(event, Events.ServerEditedEvent): print(f"Server edited by: {event.invoker_name}") print(f" Changed properties: {event.changed_properties}") ts3conn = TS3Connection("localhost", 10011) ts3conn.login("serveradmin", "password") ts3conn.use(sid=1) # Register for server events ts3conn.register_for_server_events(on_server_event) # Start keepalive loop to maintain connection ts3conn.start_keepalive_loop(interval=5) ``` -------------------------------- ### Find TeamSpeak Channels Source: https://context7.com/murgeye/teamspeak3-python-api/llms.txt Retrieves channel information from the TeamSpeak server. Supports finding all channel names, channels by a pattern, or by an exact name. Requires an active TS3Connection object. ```python channel_names = ts3conn.channel_name_list() print("All channels:", channel_names) matching = ts3conn.channelfind(pattern="Lobby") for ch in matching: print(f"Found: {ch['channel_name']} (ID: {ch['cid']})") exact_match = ts3conn.channelfind_by_name("Main Lobby") if exact_match: print(f"Exact match channel ID: {exact_match[0]['cid']}") ``` -------------------------------- ### Register for Channel Events in Python Source: https://context7.com/murgeye/teamspeak3-python-api/llms.txt Register callbacks for various events occurring within specific TeamSpeak 3 channels. This includes client movements, channel edits, creations, deletions, and more. It requires the `ts3API.TS3Connection` and `ts3API.Events` modules. The function `on_channel_event` processes different event types, and events can be registered for a specific channel ID or all channels (using ID 0). ```python from ts3API.TS3Connection import TS3Connection import ts3API.Events as Events def on_channel_event(sender, **kw): event = kw["event"] if isinstance(event, Events.ClientMovedEvent): print(f"Client {event.client_id} moved to channel {event.target_channel_id}") print(f" Moved by: {event.invoker_name}") elif isinstance(event, Events.ClientMovedSelfEvent): print(f"Client {event.client_id} moved themselves to channel {event.target_channel_id}") elif isinstance(event, Events.ChannelEditedEvent): print(f"Channel {event.channel_id} edited by {event.invoker_name}") elif isinstance(event, Events.ChannelCreatedEvent): print(f"Channel {event.channel_id} created by {event.invoker_name}") elif isinstance(event, Events.ChannelDeletedEvent): print(f"Channel {event.channel_id} deleted by {event.invoker_name}") elif isinstance(event, Events.ChannelMovedEvent): print(f"Channel {event.channel_id} moved to parent {event.channel_pid}") elif isinstance(event, Events.ChannelDescriptionEditedEvent): print(f"Channel {event.channel_id} description changed") elif isinstance(event, Events.ChannelPasswordChangedEvent): print(f"Channel {event.channel_id} password changed") ts3conn = TS3Connection("localhost", 10011) ts3conn.login("serveradmin", "password") ts3conn.use(sid=1) # Register for events in a specific channel channel_id = ts3conn.channelfind(pattern="Lobby")[0]["cid"] ts3conn.register_for_channel_events(channel_id, on_channel_event) # Register for events in ALL channels (use channel_id=0) ts3conn.register_for_channel_events(0, on_channel_event) ts3conn.start_keepalive_loop() ``` -------------------------------- ### Handle TeamSpeak 3 API Exceptions in Python Source: https://context7.com/murgeye/teamspeak3-python-api/llms.txt Manage potential errors during TeamSpeak 3 API interactions using specific exception types provided by the library. This includes `TS3QueryException` for query-related errors and `TS3ConnectionClosedException` for connection issues. The `TS3QueryExceptionType` enum helps in identifying specific query error reasons. It requires importing `TS3Connection`, `TS3QueryException`, `TS3Exception`, `TS3ConnectionClosedException`, and `TS3QueryExceptionType`. ```python from ts3API.TS3Connection import TS3Connection, TS3QueryException from ts3API.utilities import TS3Exception, TS3ConnectionClosedException from ts3API.TS3QueryExceptionType import TS3QueryExceptionType ts3conn = TS3Connection("localhost", 10011) ts3conn.login("serveradmin", "password") ts3conn.use(sid=1) try: # Try to get info for non-existent client info = ts3conn.clientinfo(9999) except TS3QueryException as e: print(f"Query failed!") print(f" Error ID: {e.id}") print(f" Message: {e.message}") print(f" Type: {e.type}") # Check specific error types if e.type == TS3QueryExceptionType.CLIENT_INVALID_ID: print(" The specified client does not exist") elif e.type == TS3QueryExceptionType.PERMISSIONS_CLIENT_INSUFFICIENT: print(" Insufficient permissions for this action") elif e.type == TS3QueryExceptionType.CHANNEL_INVALID_ID: print(" The specified channel does not exist") try: ts3conn = TS3Connection("invalid-host", 10011) except TS3ConnectionClosedException as e: print(f"Connection closed: {e}") except TS3Exception as e: print(f"General TS3 error: {e}") ``` -------------------------------- ### Poke a TeamSpeak Client Source: https://context7.com/murgeye/teamspeak3-python-api/llms.txt Sends a poke notification to a specific client, which appears as a popup message. Requires the client ID and the message content. Dependencies include TS3Connection. ```python from ts3API.TS3Connection import TS3Connection ts3conn = TS3Connection("localhost", 10011) ts3conn.login("serveradmin", "password") ts3conn.use(sid=1) # Poke a client client_id = 5 ts3conn.clientpoke( clid=client_id, msg="Please check the announcements channel!" ) ``` -------------------------------- ### Kick TeamSpeak Clients from Server or Channel Source: https://context7.com/murgeye/teamspeak3-python-api/llms.txt Removes a client from the TeamSpeak server or the current channel. Supports an optional reason message. Requires client ID and a reason ID (4 for channel, 5 for server). Dependencies include TS3Connection. ```python from ts3API.TS3Connection import TS3Connection ts3conn = TS3Connection("localhost", 10011) ts3conn.login("serveradmin", "password") ts3conn.use(sid=1) client_id = 5 # Kick from channel (reason_id=4) ts3conn.clientkick( client_id=client_id, reason_id=4, # 4 = kick from channel reason_msg="Please use a different channel" ) # Kick from server (reason_id=5) ts3conn.clientkick( client_id=client_id, reason_id=5, # 5 = kick from server reason_msg="Violation of server rules" ) ``` -------------------------------- ### Update Query Client Properties Source: https://context7.com/murgeye/teamspeak3-python-api/llms.txt Modifies properties of the connected query client, such as its nickname or description. Accepts a list of key-value pairs for the properties to update. Dependencies include TS3Connection. ```python from ts3API.TS3Connection import TS3Connection ts3conn = TS3Connection("localhost", 10011) ts3conn.login("serveradmin", "password") ts3conn.use(sid=1) # Set the query client's nickname ts3conn.clientupdate(params=["client_nickname=MyBot"]) # Update multiple properties ts3conn.clientupdate(params=[ "client_nickname=ServerBot", "client_description=Automated server management bot" ]) ``` -------------------------------- ### Send TeamSpeak Text Messages Source: https://context7.com/murgeye/teamspeak3-python-api/llms.txt Sends text messages to clients, channels, or the entire server. The targetmode parameter specifies the destination (1 for private, 2 for channel, 3 for server). Requires TS3Connection, target ID, and message content. ```python from ts3API.TS3Connection import TS3Connection ts3conn = TS3Connection("localhost", 10011) ts3conn.login("serveradmin", "password") ts3conn.use(sid=1) # Send private message to a client (targetmode=1) client_id = 5 ts3conn.sendtextmessage( targetmode=1, # 1 = private message target=client_id, msg="Hello! This is a private message." ) # Send message to a channel (targetmode=2) channel_id = 10 ts3conn.sendtextmessage( targetmode=2, # 2 = channel message target=channel_id, msg="Announcement: Server maintenance in 30 minutes!" ) # Send message to entire server (targetmode=3) ts3conn.sendtextmessage( targetmode=3, # 3 = server message target=1, # Virtual server ID msg="Welcome to our TeamSpeak server!" ) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.