diff --git a/bot.py b/bot.py index 8639b3b..92f6038 100644 --- a/bot.py +++ b/bot.py @@ -1,9 +1,21 @@ -import teambot, sys +import teambot, sys, tasks import os.path as fs class RadioBot(teambot.Handler): + def __init__(self,*args): + super(RadioBot,self).__init__(*args) + self.tasks = tasks.TaskPool(handler=self) + self.tasks.add_coroutine(self.check_nowplaying,1,dict(now_playing="",dj=None)) + self.channels = [x.split()[0] for x in args[0].channels] + self.tasks.run() + def check_nowplaying(self,state,basestate): + with open(fs.expanduser("~ben/public_html/radio/now_playing.txt")) as f: + text = f.read().rstrip() + print(text) #TODO: implement parsing def on_pubmsg(self,channel,nick,text): - pass # change this + if nick.startswith("khuxkm") and text.rstrip()=="!down": + self.tasks.stop() + self._bot.die("Stopping...") if __name__=="__main__": if not fs.exists("channels.txt"):