From 06214699304e9045b68cbeb3c4930929883d85a1 Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Tue, 7 Jun 2011 09:26:33 +0100 Subject: [PATCH] Added an example: automover --- examples/automover.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 examples/automover.py diff --git a/examples/automover.py b/examples/automover.py new file mode 100644 index 0000000..3a93b74 --- /dev/null +++ b/examples/automover.py @@ -0,0 +1,30 @@ +from time import sleep +from ts3 import TS3Server + +""" +Automover + +Automatically moves a list of Client DB IDs to a specified room, and checks for +them every 5 seconds +""" + +# List of cldbids to move +moveids = [1111] + +# Destination channel +destination = 5 + +#### + +server = TS3Server('127.0.0.1', 10011, 1) +server.login('serveradmin', 'supersecretpassword') + +while True: + resp = server.send_command('clientlist') + + for client in resp.data: + if client['client_database_id'] in moveids and not int(client['cid']) == destination: + print "Found ID %s: %s" (client['client_database_id'], client['client_nickname']) + if server.send_client('clientmove', keys={'clid': client['clid'], 'cid': channel}).is_successful: + print "Moved %s to Channel %s" % (client['client_nickname'], channel) + sleep(5)