diff --git a/bot.py b/bot.py index dfd3f05..06f3d99 100644 --- a/bot.py +++ b/bot.py @@ -26,16 +26,16 @@ class RadioBot(teambot.Handler): with open(fs.expanduser("~khuxkm/public_html/radiobot/now_playing.json")) as f: resp = json.loads(f.read().rstrip()) if resp["dj"] is not None and not state.get("dj_live",False): + state["dj_live"]=True notify = [bot.channels[0]] notify.extend(self.subscribers) for channel in notify: bot.say(channel,"{} is now live!".format(resp["dj"])) state["dj"] = resp["dj"] - state["dj_live"]=True if resp["dj"] is None and state.get("dj_live",True): state["dj_live"]=False if resp["song"]!=state.get("song") or resp["listeners"]!=state.get("listeners"): - bot.say(bot.channels[0],"now playing: {} ({!s} listeners{})".format(resp["song"],resp["listeners"],(", played by "+resp["dj"] if resp["dj_live"] else ""))) + bot.say(bot.channels[0],"now playing: {} ({!s} listeners{})".format(resp["song"],resp["listeners"],(", played by "+resp["dj"] if state["dj_live"] else ""))) state["song"]=resp["song"] state["listeners"]=resp["listeners"] basestate["handler"].task_state = state