Fix task erroring
This commit is contained in:
parent
81c35b19a9
commit
cc015c4571
4
bot.py
4
bot.py
|
@ -26,16 +26,16 @@ class RadioBot(teambot.Handler):
|
||||||
with open(fs.expanduser("~khuxkm/public_html/radiobot/now_playing.json")) as f:
|
with open(fs.expanduser("~khuxkm/public_html/radiobot/now_playing.json")) as f:
|
||||||
resp = json.loads(f.read().rstrip())
|
resp = json.loads(f.read().rstrip())
|
||||||
if resp["dj"] is not None and not state.get("dj_live",False):
|
if resp["dj"] is not None and not state.get("dj_live",False):
|
||||||
|
state["dj_live"]=True
|
||||||
notify = [bot.channels[0]]
|
notify = [bot.channels[0]]
|
||||||
notify.extend(self.subscribers)
|
notify.extend(self.subscribers)
|
||||||
for channel in notify:
|
for channel in notify:
|
||||||
bot.say(channel,"{} is now live!".format(resp["dj"]))
|
bot.say(channel,"{} is now live!".format(resp["dj"]))
|
||||||
state["dj"] = resp["dj"]
|
state["dj"] = resp["dj"]
|
||||||
state["dj_live"]=True
|
|
||||||
if resp["dj"] is None and state.get("dj_live",True):
|
if resp["dj"] is None and state.get("dj_live",True):
|
||||||
state["dj_live"]=False
|
state["dj_live"]=False
|
||||||
if resp["song"]!=state.get("song") or resp["listeners"]!=state.get("listeners"):
|
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["song"]=resp["song"]
|
||||||
state["listeners"]=resp["listeners"]
|
state["listeners"]=resp["listeners"]
|
||||||
basestate["handler"].task_state = state
|
basestate["handler"].task_state = state
|
||||||
|
|
Loading…
Reference in New Issue