mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-13 22:40:16 +02:00
Fixing Server Admin assignment
Changed _add_user_to_group() to take group ID instead of group name. addgroups and remgroups are now lists instead of dictionaries because I don't need the group names anymore. Removed debug logging from _add_user_to_group() and send_command()
This commit is contained in:
parent
478d855d62
commit
7039cffddb
@ -94,23 +94,14 @@ class Teamspeak3Manager:
|
|||||||
return outlist
|
return outlist
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _add_user_to_group(uid, groupname):
|
def _add_user_to_group(uid, groupid):
|
||||||
print("--RUNNING _add_user_to_groups()--")
|
|
||||||
groupname = groupname[:30]
|
|
||||||
print("groupname = {0}").format(groupname)
|
|
||||||
server = Teamspeak3Manager.__get_created_server()
|
server = Teamspeak3Manager.__get_created_server()
|
||||||
server_groups = Teamspeak3Manager._group_list()
|
server_groups = Teamspeak3Manager._group_list()
|
||||||
print("server_groups = {0}").format(server_groups)
|
|
||||||
user_groups = Teamspeak3Manager._user_group_list(uid)
|
user_groups = Teamspeak3Manager._user_group_list(uid)
|
||||||
print("user_groups = {0}").format(user_groups)
|
|
||||||
|
if not groupid in user_groups.values():
|
||||||
if not groupname in server_groups:
|
server.send_command('servergroupaddclient',
|
||||||
#Teamspeak3Manager._create_group(groupname)
|
{'sgid': groupid, 'cldbid': uid})
|
||||||
print("----GROUP NAME WAS NOT FOUND IN SERVER GROUPS----")
|
|
||||||
if not groupname in user_groups:
|
|
||||||
resp = server.send_command('servergroupaddclient',
|
|
||||||
{'sgid': Teamspeak3Manager._group_id_by_name(groupname), 'cldbid': uid})
|
|
||||||
print(resp)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _remove_user_from_group(uid, groupname):
|
def _remove_user_from_group(uid, groupname):
|
||||||
@ -129,6 +120,9 @@ class Teamspeak3Manager:
|
|||||||
def _sync_ts_group_db():
|
def _sync_ts_group_db():
|
||||||
remote_groups = Teamspeak3Manager._group_list()
|
remote_groups = Teamspeak3Manager._group_list()
|
||||||
local_groups = TSgroup.objects.all()
|
local_groups = TSgroup.objects.all()
|
||||||
|
for group in local_groups:
|
||||||
|
if group.ts_group_id not in remote_groups.values()
|
||||||
|
TSgroup.objects.filter(ts_group_id=group.ts_group_id).delete()
|
||||||
for key in remote_groups:
|
for key in remote_groups:
|
||||||
TSgroup.objects.update_or_create(ts_group_id=remote_groups[key],ts_group_name=key)
|
TSgroup.objects.update_or_create(ts_group_id=remote_groups[key],ts_group_name=key)
|
||||||
|
|
||||||
@ -225,8 +219,8 @@ class Teamspeak3Manager:
|
|||||||
print uid
|
print uid
|
||||||
print ts_groups
|
print ts_groups
|
||||||
userid = Teamspeak3Manager._get_userid(uid)
|
userid = Teamspeak3Manager._get_userid(uid)
|
||||||
addgroups = {}
|
addgroups = []
|
||||||
remgroups = {}
|
remgroups = []
|
||||||
if userid is not None:
|
if userid is not None:
|
||||||
user_ts_groups = Teamspeak3Manager._user_group_list(userid)
|
user_ts_groups = Teamspeak3Manager._user_group_list(userid)
|
||||||
for key in user_ts_groups:
|
for key in user_ts_groups:
|
||||||
@ -236,12 +230,12 @@ class Teamspeak3Manager:
|
|||||||
print("(For addgroups) GID {0}").format(ts_group_key)
|
print("(For addgroups) GID {0}").format(ts_group_key)
|
||||||
if ts_groups[ts_group_key] not in user_ts_groups.values():
|
if ts_groups[ts_group_key] not in user_ts_groups.values():
|
||||||
print("Adding {0}").format(ts_group_key)
|
print("Adding {0}").format(ts_group_key)
|
||||||
addgroups[ts_group_key] = ts_groups[ts_group_key]
|
addgroups.append(ts_groups[ts_group_key])
|
||||||
for user_ts_group_key in user_ts_groups:
|
for user_ts_group_key in user_ts_groups:
|
||||||
print("(For remgroups) GID {0}").format(user_ts_group_key)
|
print("(For remgroups) GID {0}").format(user_ts_group_key)
|
||||||
if user_ts_groups[user_ts_group_key] not in ts_groups.values():
|
if user_ts_groups[user_ts_group_key] not in ts_groups.values():
|
||||||
print("Value {0} not found").format(user_ts_groups[user_ts_group_key])
|
print("Value {0} not found").format(user_ts_groups[user_ts_group_key])
|
||||||
remgroups[user_ts_group_key] = user_ts_groups[user_ts_group_key]
|
remgroups.append(user_ts_groups[user_ts_group_key])
|
||||||
|
|
||||||
print userid
|
print userid
|
||||||
print addgroups
|
print addgroups
|
||||||
|
@ -60,8 +60,6 @@ class TS3Proto():
|
|||||||
def send_command(self, command, keys=None, opts=None):
|
def send_command(self, command, keys=None, opts=None):
|
||||||
cmd = self.construct_command(command, keys=keys, opts=opts)
|
cmd = self.construct_command(command, keys=keys, opts=opts)
|
||||||
self.send('%s\n' % cmd)
|
self.send('%s\n' % cmd)
|
||||||
|
|
||||||
print("Command to be sent: {0}").format(cmd)
|
|
||||||
|
|
||||||
data = []
|
data = []
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user