API¶
Log¶
-
class
tsstats.log.TimedLog(path, timestamp)¶ -
path¶ Alias for field number 0
-
timestamp¶ Alias for field number 1
-
-
class
tsstats.log.Server(sid, clients)¶ -
clients¶ Alias for field number 1
-
sid¶ Alias for field number 0
-
Client¶
-
class
tsstats.client.Client(identifier, nick=None)[source]¶ Client provides high-level-access to a Teamspeak-Client
-
__init__(identifier, nick=None)[source]¶ Initialize a new Client
Parameters: identifier (int or str) – Identifier of the client
-
connect(timestamp)[source]¶ Connect client at timestamp
Parameters: timestamp (int) – time of connect
-
Template¶
-
class
tsstats.template.SortedClients(onlinetime, kicks, pkicks, bans, pbans)¶ -
bans¶ Alias for field number 3
-
kicks¶ Alias for field number 1
-
onlinetime¶ Alias for field number 0
-
pbans¶ Alias for field number 4
-
pkicks¶ Alias for field number 2
-
-
tsstats.template.prepare_clients(clients, onlinetime_threshold=-1)[source]¶ Prepare clients for rendering
sort them, clean their nick-history and convert onlinetime to string
Parameters: - clients (tsstats.client.Clients) – List of clients to prepare
- onlinetime_threshold – threshold for clients onlinetime
Returns: clients sorted by onlinetime, kics, pkicks, bans and pbans
Return type:
-
tsstats.template.render_servers(servers, output, title='TeamspeakStats', template='index.jinja2', datetime_fmt='%x %X %Z', onlinetime_threshold=-1, lastseen_relative=True)[source]¶ Render servers
Parameters: - servers ([tsstats.log.Server]) – list of servers to render
- output (str) – path to output-file
- template_name (str) – path to template-file
- title (str) – title of the resulting html-document
- template_path (str) – path to template-file
- datetime_fmt (str) – custom datetime-format
- onlinetime_threshold (int) – threshold for clients onlinetime
- lastseen_relative (bool) – render last seen timestamp relative
Config¶
Exceptions¶
Utils¶
-
tsstats.utils.sort_clients(clients, key_l)[source]¶ sort clients by key
Parameters: - clients (tsstats.client.Clients) – clients to sort
- key_l (function) – lambda/function returning the value of key for a client
Returns: sorted clients
Return type: list
-
tsstats.utils.seconds_to_text(seconds)[source]¶ convert seconds to a text-representation
Parameters: seconds (int) – seconds to convert Returns: seconds as text-representation Return type: str
-
tsstats.utils.filter_threshold(clients, threshold)[source]¶ Filter clients by threshold
Parameters: clients (list) – List of clients as returned by tsstats.utils.sort_clients Returns: Clients matching given threshold Return type: list
-
tsstats.utils.transform_pretty_identmap(pretty_identmap)[source]¶ Transforms a list of client ID mappings from a more descriptive format to the traditional format of alternative IDs to actual ID.
Parameters: pretty_identmap (list) – ID mapping in “nice” form Returns: ID mapping in simple key/value pairs Return type: dict