Added an example: automover

This commit is contained in:
2011-06-07 09:26:33 +01:00
parent 68aafbde35
commit 0621469930

30
examples/automover.py Normal file
View File

@@ -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)