def handle(self): global botglobal info = radio.getRadioState()[0] if botglobal.trackhurt["last_title"] != info: botglobal.trackhurt["last_title"] = info botglobal.trackhurt["voters"] = {} data = self.request[0] listeners = netstat() if ":" in data: ip, vote = data.rsplit(":", 2) if ip in listeners: if vote == "1" or vote == "0" or vote == "2": if vote == "1": botglobal.trackhurt["voters"][ip] = 1 elif vote == "0": botglobal.trackhurt["voters"][ip] = -1 else: if ip in botglobal.trackhurt["voters"]: del botglobal.trackhurt["voters"][ip] level = 0 for l, v in botglobal.trackhurt["voters"].items(): if l in listeners: level += v if level < -(len(listeners) / 5) and len( botglobal.trackhurt["voters"]) > 2: botglobal.commands["mpd"][1](botglobal, ["sh"]) thfile = open(botglobal.settings["th_file"], "w") thfile.write( str(level) + "/" + str(len(botglobal.trackhurt["voters"]))) thfile.close()
def handle(self): global botglobal info = radio.getRadioState()[0] if botglobal.trackhurt["last_title"] != info: botglobal.trackhurt["last_title"] = info botglobal.trackhurt["voters"] = {} data = self.request[0] listeners = netstat() if ":" in data: ip, vote = data.rsplit(":", 2) if ip in listeners: if vote == "1" or vote == "0" or vote == "2": if vote == "1": botglobal.trackhurt["voters"][ip] = 1 elif vote == "0": botglobal.trackhurt["voters"][ip] = -1 else: if ip in botglobal.trackhurt["voters"]: del botglobal.trackhurt["voters"][ip] level = 0 for l, v in botglobal.trackhurt["voters"].items(): if l in listeners: level += v if level < -(len(listeners) / 5) and len(botglobal.trackhurt["voters"]) > 2: botglobal.commands["mpd"][1](botglobal, ["sh"]) thfile = open(botglobal.settings["th_file"], "w") thfile.write(str(level) + "/" + str(len(botglobal.trackhurt["voters"]))) thfile.close()
def main(bot, args): if args: return info, list = radio.getRadioState() return u'%s %s' % (info, list)
def main(bot, args): if args: return info, list = radio.getRadioState() return u'%s %s' %(info, list)