### Install ts3 library using pip Source: https://github.com/benediktschmitt/py-ts3/blob/master/docs/source/installation.rst This command installs the 'ts3' Python library from PyPi using the pip3 package manager. It is the standard way to get the library onto your system. ```bash $ pip3 install ts3 ``` -------------------------------- ### Simple TS3 Server Viewer (Python) Source: https://github.com/benediktschmitt/py-ts3/blob/master/README.rst Python example showing how to use the built-in viewer functionality from the ts3.examples.viewer module to display the structure of a virtual server after connecting and logging in. ```python #!/usr/bin/python3 import ts3 # The examples package already contains this implementation. # Note, that the ts3.examples.viewer module has an helpful class to # build a complete channel tree of a virtual server: ChannelTreeNode from ts3.examples.viewer import view with ts3.query.TS3Connection("localhost") as ts3conn: ts3conn.login( client_login_name="serveradmin", client_login_password="FoOBa9" ) view(ts3conn, sid=1) ``` -------------------------------- ### Installing PyTS3 with pip Source: https://github.com/benediktschmitt/py-ts3/blob/master/README.rst Command to install the PyTS3 library using the pip package manager for Python 3. ```bash $ pip3 install ts3 ``` -------------------------------- ### Listing TS3 Clients (Python) Source: https://github.com/benediktschmitt/py-ts3/blob/master/README.rst Python example demonstrating how to connect to a TeamSpeak 3 server query interface, log in, select a virtual server, and retrieve a list of connected clients. It also shows how to handle potential login errors and iterate through the response. ```python #!/usr/bin/python3 import ts3 with ts3.query.TS3Connection("localhost") as ts3conn: # Note, that the client will wait for the response and raise a # **TS3QueryError** if the error id of the response is not 0. try: ts3conn.login( client_login_name="serveradmin", client_login_password="FoOBa9" ) except ts3.query.TS3QueryError as err: print("Login failed:", err.resp.error["msg"]) exit(1) ts3conn.use(sid=1) # Each query method will return a **TS3QueryResponse** instance, # with the response. resp = ts3conn.clientlist() print("Clients on the server:", resp.parsed) print("Error:", resp.error["id"], resp.error["msg"]) # Note, the TS3Response class and therefore the TS3QueryResponse # class too, can work as a rudimentary container. So, these two # commands are equal: for client in resp.parsed: print(client) for client in resp: print(client) ``` -------------------------------- ### Handling TS3 Server Events (Python) Source: https://github.com/benediktschmitt/py-ts3/blob/master/README.rst Python example demonstrating how to connect, log in, select a virtual server, register for server events, and enter a loop to wait for and process incoming events, specifically greeting new clients upon connection. ```python #!/usr/bin/python3 import time import ts3 with ts3.query.TS3Connection("localhost") as ts3conn: ts3conn.login( client_login_name="serveradmin", client_login_password="FoOBa9" ) ts3conn.use(sid=1) # Register for events ts3conn.servernotifyregister(event="server") while True: event = ts3conn.wait_for_event() # Greet new clients. if event[0]["reasonid"] == "0": print("client connected") ts3conn.clientpoke(clid=event[0]["clid"], msg="Hello :)") ``` -------------------------------- ### TS3 File Transfer (Python) Source: https://github.com/benediktschmitt/py-ts3/blob/master/README.rst Python example demonstrating how to connect, log in, and use the TS3FileTransfer class to upload a local file to a channel on the TeamSpeak server and download a file from a channel. ```python #!/usr/bin/python3 import ts3 with ts3.query.TS3Connection("localhost") as ts3conn: ts3conn.login( client_login_name="serveradmin", client_login_password="FoOBa9" ) # Create a new TS3FileTransfer instance associated with the # TS3Connection. ts3ft = ts3.filetransfer.TS3FileTransfer(ts3conn) # Upload the image *baz.png* to the channel with the id 2 on the # TS3 server. # Note the opening mode ("rb"). with open("baz.png", "rb") as file: ts3ft.init_upload(input_file=file, name="/baz.png", cid=2) # Download the file into *baz1.png*. with open("baz1.png", "wb") as file: ts3ft.init_download(output_file=file, name="/baz.png", cid=2) ``` -------------------------------- ### Sending Messages to TS3 Clients (Python) Source: https://github.com/benediktschmitt/py-ts3/blob/master/README.rst Python example showing how to connect, log in, select a virtual server, retrieve the client list, and send a poke message to each connected client using their nickname. ```python #!/usr/bin/python3 import ts3 with ts3.query.TS3Connection("localhost") as ts3conn: ts3conn.login( client_login_name="serveradmin", client_login_password="FoOBa9" ) ts3conn.use(sid=1) for client in ts3conn.clientlist(): msg = "Hi {}".format(client["client_nickname"]) ts3conn.clientpoke(clid=client["clid"], msg=msg) ``` -------------------------------- ### Update ts3 library using pip Source: https://github.com/benediktschmitt/py-ts3/blob/master/docs/source/installation.rst This command updates the 'ts3' Python library to the latest version available on PyPi using the pip3 package manager. It ensures you have the most recent features and bug fixes. ```bash $ pip3 install --upgrade ts3 ``` -------------------------------- ### Add IP to TS3 Query Whitelist (Bash) Source: https://github.com/benediktschmitt/py-ts3/blob/master/docs/source/faq.rst This bash command adds a specific IP address (192.168.178.42 in this example) to the `query_ip_whitelist.txt` file located in the TeamSpeak 3 server's main directory. Adding the IP address from which the py-ts3 script is run to this whitelist prevents the server's anti-flood mechanism from disconnecting the client. ```bash $ # In your TS3 server folder: $ echo "192.168.178.42" >> query_ip_whitelist.txt ``` -------------------------------- ### Whitelisting IP for TS3 Query Source: https://github.com/benediktschmitt/py-ts3/blob/master/README.rst Command to add an IP address to the TeamSpeak 3 server's query IP whitelist to prevent anti-flood protection issues. ```bash $ echo "192.168.178.42" >> path/to/ts3/server/directory/query_ip_whitelist.txt ``` -------------------------------- ### PyTS3 MIT License Source: https://github.com/benediktschmitt/py-ts3/blob/master/docs/source/license.rst This snippet contains the full text of the MIT License under which the PyTS3 package is distributed. It includes the standard permissions, conditions, and disclaimers associated with the MIT License. ```none Copyright (c) 2013-2018 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.