Add auto update support for crypto channel names
This commit is contained in:
parent
9bc1e0ec1f
commit
41a1d1018e
25
myTS3.py
25
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):
|
||||
"""
|
||||
|
|
|
@ -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()
|
Loading…
Reference in New Issue