fixed clientkick command as it was not working properly

This commit is contained in:
Krzysztof Jagiello
2011-06-06 16:59:29 +02:00
committed by Andrew Williams
parent 8adc3c75c0
commit ec2a030d1b

View File

@@ -321,26 +321,29 @@ class TS3Server(TS3Proto):
if cldbid: if cldbid:
response = self.send_command('clientlist') response = self.send_command('clientlist')
for cl in response.data: for cl in response.data:
if int(cl['keys']['client_database_id']) == cldbid: if int(cl['client_database_id']) == cldbid:
client = cl['keys']['clid'] client = cl['clid']
self.logger.debug("clientkick - identified user from clid (%s = %s)" % (cldbid, client)) self.logger.debug("clientkick - identified user from clid (%s = %s)" % (cldbid, client))
break break
client = 0
if not client:
# we should throw an exception here actually
self.logger.debug("clientkick - no client with specified cldbid (%s) was found" % cldbid)
return False
elif clid: elif clid:
client = clid client = clid
else: else:
raise InvalidArguments('No clid or cldbid provided') raise InvalidArguments('No clid or cldbid provided')
if type == REASON_KICK_CHANNEL: if not message:
if not message: message = ''
message = '' else:
else: # Kick message can only be 40 characters
# Kick message can only be 40 characters message = message[:40]
message = message[:40]
if client: if client:
self.logger.debug("clientkick - Kicking clid %s" % client) self.logger.debug("clientkick - Kicking clid %s" % client)
response = self.send_command('clientkick', keys={'clid': client, 'reasonid': type, 'reasonmsg': message}) response = self.send_command('clientkick', keys={'clid': client, 'reasonid': type, 'reasonmsg': message})
return response.is_successful return response.is_successful
return false return False