From f1612a726a48c41511239f95e771dbafc4764cc6 Mon Sep 17 00:00:00 2001 From: nico Date: Mon, 23 Dec 2019 02:03:34 +0100 Subject: nickname and readme + add friendly client_nickname the bot assigns itself * small readme updates --- README.md | 21 +++++++++++++-------- TSGroupAssigner/__init__.py | 2 +- TSGroupAssigner/group_assign.py | 3 +++ 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index bd5729e..6786768 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,26 @@ # TeamSpeak GroupAssigner -[![CodeFactor](https://www.codefactor.io/repository/github/mightybroccoli/tsgroupassigner/badge)](https://www.codefactor.io/repository/github/mightybroccoli/tsgroupassigner) +[![PyPI](https://img.shields.io/pypi/v/TSGroupAssigner.svg)](https://pypi.python.org/pypi/TSGroupAssigner) +[![PyPI](https://img.shields.io/pypi/pyversions/TSGroupAssigner.svg)](https://pypi.python.org/pypi/TSGroupAssigner) +[![CodeFactor](https://www.codefactor.io/repository/github/mightybroccoli/TSGroupAssigner/badge)](https://www.codefactor.io/repository/github/mightybroccoli/TSGroupAssigner) ## Overview TSGroupAssigner is a module which allows to automatically assign server groups to voice clients, if they connect within -a specified date range. +a specific date range. -### example -This small example could be called on the 23.12 to assign the group `24` to every voice client connecting +### example +This small example script could be called before christmas to assign the group `24` to every voice client connecting to the server id `1`. -The process will terminate gracefully when the configured date range is exceeded. +The process will terminate gracefully, when the configured date range is exceeded. ```python import datetime as dt import logging -from TSGroupAssigner import GroupAssigner +from TSGroupAssigner import GroupAssigner, DateException logger = logging.getLogger() logger.setLevel(logging.INFO) -creds = { +params = { 'host': 'localhost', 'port': 10011, 'user': 'serveradmin', @@ -30,5 +32,8 @@ creds = { target = dt.date(year=2019, month=24, day=12) duration = dt.timedelta(days=2) -GroupAssigner(date=target, delta=duration, **creds).start() +try: + GroupAssigner(date=target, delta=duration, **params).start() +except DateException as err: + logger.error(err) ``` diff --git a/TSGroupAssigner/__init__.py b/TSGroupAssigner/__init__.py index 6feef67..f8d4327 100644 --- a/TSGroupAssigner/__init__.py +++ b/TSGroupAssigner/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # version -__version__ = "0.1" +__version__ = "0.1.1" # modules from .group_assign import GroupAssigner diff --git a/TSGroupAssigner/group_assign.py b/TSGroupAssigner/group_assign.py index 589b820..41ecbd1 100644 --- a/TSGroupAssigner/group_assign.py +++ b/TSGroupAssigner/group_assign.py @@ -45,6 +45,9 @@ class GroupAssigner: # select specified sid self.conn.use(sid=self.sid) + # assign friendly nickname + self.conn.clientupdate(client_nickname=__name__) + def __disconnect(self): """ gracefully logout and disconnect the connection, this should only be called if the exit is intentional """ try: -- cgit v1.2.3-18-g5258