Fix task erroring

This commit is contained in:
Robert Miles 2018-12-01 04:25:53 -05:00
parent 81c35b19a9
commit cc015c4571
1 changed files with 2 additions and 2 deletions

4
bot.py
View File

@ -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