mirror of
https://github.com/nikdoof/python-ts3.git
synced 2025-12-13 07:22:15 +00:00
Fix sample scripts for Py3
This commit is contained in:
@@ -21,7 +21,7 @@ moveids = {
|
||||
server = TS3Server('127.0.0.1', 10011, 1)
|
||||
server.login('serveradmin', 'supersecretpassword')
|
||||
|
||||
print "Logged In"
|
||||
print("Logged In")
|
||||
|
||||
poke = []
|
||||
|
||||
@@ -32,19 +32,19 @@ while True:
|
||||
# Check if the client is in the Move IDs
|
||||
if int(client['client_database_id']) in moveids:
|
||||
clinfo = moveids[int(client['client_database_id'])]
|
||||
print "Found ID %s: %s" % (client['client_database_id'], client['client_nickname'])
|
||||
print("Found ID %s: %s" % (client['client_database_id'], client['client_nickname']))
|
||||
|
||||
# If we have a channel defined and they're not in it, move them
|
||||
if 'destination' in clinfo and not int(client['cid']) == clinfo['destination']:
|
||||
if server.send_command('clientmove', keys={'clid': client['clid'], 'cid': clinfo['destination']}).is_successful:
|
||||
print "Moved %s to Channel %s" % (client['client_nickname'], clinfo['destination'])
|
||||
print("Moved %s to Channel %s" % (client['client_nickname'], clinfo['destination']))
|
||||
|
||||
# If we have a fixed name defined, tell them to change it or kick them
|
||||
if 'name' in clinfo and not client['client_nickname'] == clinfo['name']:
|
||||
if not client['clid'] in poke:
|
||||
poke[client['clid']] = 0
|
||||
poke[client['clid']] += 1
|
||||
print "Warning %s out of 3" % poke[client['clid']]
|
||||
print("Warning %s out of 3" % poke[client['clid']])
|
||||
server.send_command('clientpoke', keys={'clid': client['clid'], 'msg': 'Change your name to "%s"! Warning %s of 3' % (clinfo['name'], poke[client['clid']])})
|
||||
if poke > 3:
|
||||
server.send_command('clientkick', keys={'clid': client['clid'], 'reasonid': 5})
|
||||
|
||||
@@ -72,7 +72,7 @@ def main():
|
||||
else:
|
||||
response = ts3.send_command('privilegekeyadd', keys={'tokentype': TOKEN_CHANNEL_GROUP, 'tokenid1': args['channelgroup'], 'tokenid2': args['channel']})
|
||||
if response.is_successful:
|
||||
print response.data[0]['token']
|
||||
print(response.data[0]['token'])
|
||||
sys.exit(0)
|
||||
else:
|
||||
sys.exit("Error creating key: %s" % response.response['msg'])
|
||||
|
||||
Reference in New Issue
Block a user