aboutsummaryrefslogtreecommitdiffstats
path: root/TSGroupAssigner
diff options
context:
space:
mode:
authornico <nico@magicbroccoli.de>2019-12-19 18:15:47 +0100
committernico <nico@magicbroccoli.de>2019-12-19 18:15:47 +0100
commit9b964690e79b5a4366e43fde01c6594de693be4d (patch)
tree72dd4c1ee364a44d6aedde66a798af239b3be44a /TSGroupAssigner
parent6f19f160ef0d2d72c1db35abcf03ee28a3982d7c (diff)
package finish up
* update setup.py * better format the main __init__ file * move exceptions to separate file for maintainability * small corrections
Diffstat (limited to 'TSGroupAssigner')
-rw-r--r--TSGroupAssigner/__init__.py8
-rw-r--r--TSGroupAssigner/exceptions.py8
-rw-r--r--TSGroupAssigner/group_assign.py17
3 files changed, 23 insertions, 10 deletions
diff --git a/TSGroupAssigner/__init__.py b/TSGroupAssigner/__init__.py
index 04fc467..e434073 100644
--- a/TSGroupAssigner/__init__.py
+++ b/TSGroupAssigner/__init__.py
@@ -1,4 +1,10 @@
# -*- coding: utf-8 -*-
+# version
+__version__ = "0.0.1"
+
+# modules
from .group_assign import GroupAssigner
-from .group_assign import DateException
+
+# utils
+from .exceptions import DateException
diff --git a/TSGroupAssigner/exceptions.py b/TSGroupAssigner/exceptions.py
new file mode 100644
index 0000000..a0bb55b
--- /dev/null
+++ b/TSGroupAssigner/exceptions.py
@@ -0,0 +1,8 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+__all__ = ['DateException']
+
+
+class DateException(Exception):
+ """Exceptions thrown if configured date is out of range"""
diff --git a/TSGroupAssigner/group_assign.py b/TSGroupAssigner/group_assign.py
index 9f43d35..1f9fdbb 100644
--- a/TSGroupAssigner/group_assign.py
+++ b/TSGroupAssigner/group_assign.py
@@ -8,9 +8,9 @@ from contextlib import suppress
import ts3
+from .exceptions import DateException
-class DateException(Exception):
- """raise this if the date delta exceeds the configured range"""
+__all__ = ['GroupAssigner']
class GroupAssigner:
@@ -107,7 +107,7 @@ class GroupAssigner:
# calculate remaining time delta
remaindelta = starttime - now
- logging.debug('target date will be reached in {sec} seconds -- sleeping'.format(sec=remaindelta.seconds))
+ logging.debug(f'target date will be reached in {remaindelta.seconds} seconds -- sleeping')
time.sleep(remaindelta.seconds + 1)
else:
@@ -119,9 +119,6 @@ class GroupAssigner:
if data['client_type'] != '0' or data['reasonid'] != '0':
return
- # check if the current date is still eligible
- self.__datecheck()
-
cldbid = data['client_database_id']
user_grps = data['client_servergroups'].split(sep=',')
@@ -133,8 +130,7 @@ class GroupAssigner:
try:
# Usage: servergroupaddclient sgid={groupID} cldbid={clientDBID}
- # cmd = self.conn.servergroupaddclient(sgid=self.gid, cldbid=cldbid)
- cmd = self.conn.clientdbinfo(cldbid=cldbid)
+ cmd = self.conn.servergroupaddclient(sgid=self.gid, cldbid=cldbid)
if cmd.error['id'] != '0':
logging.error(cmd.data[0].decode("utf-8"))
@@ -142,7 +138,7 @@ class GroupAssigner:
# log process
logging.info('{client_nickname}:{client_database_id} added to {gid}'.format(**data, gid=self.gid))
- # log possible key errors while the teamspeak 5 client is not fully working
+ # log possible key errors while the teamspeak 5 client is not fully released
except KeyError as err:
logging.error([err, data])
@@ -150,6 +146,9 @@ class GroupAssigner:
"""
event handler which separates events to their specific handlers
"""
+ # check if event is still eligible
+ self.__datecheck()
+
# client enter events
if event == "notifycliententerview":
self.__notifycliententerview(data)