mirror of
https://github.com/nikdoof/python-ts3.git
synced 2025-12-17 03:49:25 +00:00
Added an example: automover
This commit is contained in:
30
examples/automover.py
Normal file
30
examples/automover.py
Normal 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)
|
||||
Reference in New Issue
Block a user