summaryrefslogtreecommitdiffstats
path: root/metrics.py
blob: af07f1d33fd79d883dddf128deb87dcce9804ac2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from api import TeamSpeakApi


class TeamSpeakMetrics(TeamSpeakApi):
    """
    TeamSpeak metrics harvester
    """

    def __init__(self, url: str, apikey: str = None):
        # init teamspeak api
        super().__init__(apikey=apikey, url=url)

        # variables
        self.url = url

    def serverinfo(self, id: int = 1) -> dict:
        tmp = self.cmd(f"{id}/serverinfo")

        if tmp["status"]["code"] != 0:
            return {}
        else:
            return tmp["body"][0]