Skip to main content
=======

The MIT License (MIT)

Copyright (c) 2013-2018 <see AUTHORS.txt>

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.

Download-URL: https://github.com/benediktschmitt/Py-TS3/archive/master.zip
Description: PyTS3
=====

>> Check out `version 2 <https://github.com/benediktschmitt/py-ts3/tree/v2>`_,
which also supports the TS3 Client Query API and SSH!**. v1 will only receive
bug fixes, but no more updates. So better start using v2. <<

This package provides a **Python 3 API** for:

* TS3 query connections
* TS3 query events
* TS3 file transfers

You can find a complete API documentation
`here <http://py-ts3.readthedocs.org>`_.

Installation
------------

This package is registered on PyPi, so you're done with:

.. code-block:: bash

$ pip3 install ts3

TS3 Server configuration
------------------------

If you want to send lots of queries to the TS3 server, make sure, that you're
connection is not closed by the **anti-flood protection** of the TS3 server.
So it may be wise to add the host that runs the TS3 queries to the
``query_ip_whitelist.txt`` of your TS3 server:

.. code-block:: bash

$ echo "192.168.178.42" >> path/to/ts3/server/directory/query_ip_whitelist.txt

Introduction
------------

The easiest way to get to grips with this library is taking a look at the
`examples <https://github.com/benediktschmitt/py-ts3/tree/master/ts3/examples>`_.

If you need information about the possible query commands, take a look at the
**TS3 Server Query Manual**.

Examples
''''''''

You can find more examples in the ``ts3.examples`` package.

* Show all clients on the virtual server with the server id 1:

.. code-block:: 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)

* Say hello to all clients:

.. code-block:: 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)

* Event handling:

.. code-block:: 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 :)")

* A simple TS3 viewer:

.. code-block:: 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)

* Download and upload files:

.. code-block:: 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)

Bugs
----

If you found a bug please report it or sent a pull request.

Please report grammar or spelling errors too.

Versioning
----------

For the version numbers, take a look at http://semver.org/.

License
-------

This package is licensed under the MIT License.

The docstrings copied from the TS3 Server Query Manual are the property of the
`TeamSpeak Systems GmbH <http://www.teamspeak.com/>`_.

Platform: UNKNOWN
Classifier: License :: OSI Approved :: MIT License
Classifier: Development Status :: 4 - Beta
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Communications
Classifier: Topic :: Internet
Classifier: Topic :: Software Development :: Libraries

Release files for ts3 1.0.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ts3 1.0.11
File Size Uploaded
ts3-1.0.11.tar.gz 40.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ts3 1.0.11
File Interpreter ABI Platform
ts3-1.0.11-py3-none-any.whl Python 3 none any Details

Total release size: 95.0 kB

Release files / ts3-1.0.11.tar.gz

Download URL ts3-1.0.11.tar.gz
Size 40.5 kB
Tags Source
SHA-256 checksum
How to use checksums
5c7ddee40f4446d4b6c541665cc536d270481f82c27adfe1c2e371426ddbd0d7
BLAKE2b-256 checksum
How to use checksums
583e8937ebc6dad9b08d2f6e2635aff0ffe9d3ecdd5e7f4563b13f0a8da91fbc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.9.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.5.2

Release files / ts3-1.0.11-py3-none-any.whl

Download URL ts3-1.0.11-py3-none-any.whl
Size 54.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
65eae95451f89e4c22cd698e5526f304124ca929c9d98f0a74b042f9cc57d8d6
BLAKE2b-256 checksum
How to use checksums
fc5e5fd5eaac9cdd2110bf97b92b68563f0aedfc9f0cef4a97235dc3ca34099f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.9.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.5.2

Release history Release notifications | RSS feed

This release

1.0.11 This release

2 release files

1.0.10

1 release file

1.0.6

1 release file

1.0.5

1 release file

1.0.4

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

0.7.1

1 release file

0.6.7

1 release file

0.6.6

1 release file

0.6.5

1 release file

0.6.4

1 release file

0.6.3

1 release file

0.6.2

1 release file

0.6.1

1 release file

0.6.0

1 release file

0.5.2

1 release file

0.5.1

1 release file

0.4.1

1 release file

0.4.0

1 release file

0.3.4

1 release file

0.3.3

1 release file

0.3.2

1 release file

0.3.1

1 release file

0.3.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page