def delete(self, using=None): from main.teamspeak import ts_connect import logging logger = logging.getLogger("site.messages") ts_server = ts_connect() if ts_server: if ts_server.send_command("clientdbdelete", {"cldbid": int(self.database_id)}).is_successful: logger.info("Delete from teamspeak user with cldbid #%s" % self.database_id) else: logger.warning("Failed to remove the user from teamspeak with cldbid #%s" % self.database_id) super(TsAccount, self).delete()
def find_user(name): ts_server = ts_connect() if ts_server: clients = ts_server.clientlist() ts_server.disconnect() cldbid = False for client in clients.values(): if client['client_nickname'] == name: cldbid = client['client_database_id'] break return cldbid else: raise Exception('Teamspeak server not responding. Try to register later.')
def register_user(sgid, cldbid): ts_server = ts_connect() if ts_server: response = ts_server.send_command( 'servergroupaddclient', { 'sgid': sgid, 'cldbid': cldbid } ) ts_server.disconnect() return response.is_successful else: raise Exception( 'Teamspeak server not responding. Try to register later.' )