diff --git a/myTS3.py b/myTS3.py index dc0916c..03e7384 100644 --- a/myTS3.py +++ b/myTS3.py @@ -16,7 +16,10 @@ from time import sleep # Custom import ts3 import dotenv # python-dotenv + +# Self import gecko +import util class MyTeamspeakBot: @@ -70,20 +73,27 @@ class MyTeamspeakBot: # Subscribe to a server movement events self.bot.servernotifyregister(event="server") + # Subscribe to server channel messages + self.bot.servernotifyregister(event="textserver") + + # Subscribe to channel messages + self.bot.servernotifyregister(event="textchannel") + # Subscribe to privat chat messages self.bot.servernotifyregister(event="textprivate") - # Subscribe to chat channel messages - self.bot.servernotifyregister(event="textchannel") - - # Subscribe to server channel messages - self.bot.servernotifyregister(event="textserver") - # Subscribe to channel movement events # self.bot.servernotifyregister(event="channel", id_=0) + # Start the timer for auto-updating crypto channels + channelname = f"{'[cspacerBTC]Bitcoin:':<33}" + f"{self.gecko.getSymbol('BTC', decimal=0):>5}€" + btc_timer = util.maketimer(3600, self.editChannelname(200, channelname)) + btc_timer.start() + channelname = f"{'[cspacerETH]Ethereum:':<30}" + f"{self.gecko.getSymbol('ETH', decimal=0):>5}€" + eth_timer = util.maketimer(3600, self.editChannelname(201, channelname)) + eth_timer.start() + # Notify connected admins - sleep(5) self.notifyAdmin() # ----------- LOOP HERE ------------- @@ -223,6 +233,7 @@ class MyTeamspeakBot: """ self.bot.channeledit(cid=cid, channel_name=name) + sleep(5) def list(self, what, invkr_id): """ diff --git a/util.py b/util.py new file mode 100644 index 0000000..c0877b3 --- /dev/null +++ b/util.py @@ -0,0 +1,29 @@ +""" +TBD +""" + +__author__ = "Lukas Mahler" +__version__ = "0.2.0" +__date__ = "23.09.2021" +__email__ = "m@hler.eu" +__status__ = "Development" + + +# Default +import threading + + +class MyTimer(threading.Timer): + def run(self): + while not self.finished.wait(self.interval): + self.function(*self.args, **self.kwargs) + + +def maketimer(cooldown, func): + timer = MyTimer(cooldown, func) + timer.daemon = True + return timer + + +if __name__ == "__main__": + exit()