Add DJ timer to 'dj' command output

Specifically, store 'broadcast_start' from the AzuraCast API, and use that + current time to calculate how long the DJ has been streaming for.
This commit is contained in:
Robert Miles 2020-09-20 04:36:02 +00:00
parent 86153e1c63
commit 2edaa2e471
1 changed files with 5 additions and 0 deletions

View File

@ -88,6 +88,7 @@ class Module(ModuleManager.BaseModule):
# self.song = data["now_playing"]["song"]["text"]
self.is_online = data["live"]["is_live"]
self.dj = data["live"]["streamer_name"]
self.broadcast_start = data["live"]["broadcast_start"]
#self.listeners = data["listeners"]["current"]
def format_nowplaying(self):
@ -289,6 +290,10 @@ class Module(ModuleManager.BaseModule):
message = "no one is currently on the air"
else:
message = f"{self.dj} is now streaming!"
if self.broadcast_start:
now = utils.datetime.utcnow().timestamp()
total_seconds = now - self.broadcast_start
message += " (for {})".format(util.datetime.to_pretty_time(total_seconds))
event["stdout"].write(message)
@utils.hook("received.command.slogan")