def handle_relaydel(bot, ievent): """ relay-del <botname> <channel> <botname> <channel> .. delete a relay """ try: (botnamefrom, channelfrom, botnameto, channelto) = ievent.args except ValueError: ievent.missing('<botnamefrom> <channelfrom> <botnameto> <channelto>') return try: relay[jsonstring([botnamefrom, channelfrom.lower()])].remove([botnameto, \ channelto.lower()]) except (KeyError, ValueError): ievent.reply("there is no %s %s - %s %s relay" % \ (botnamefrom, channelfrom, botnameto, channelto)) return if len(relay[jsonstring([botnamefrom, channelfrom.lower()])]) == 0: del relay[jsonstring([botnamefrom, channelfrom.lower()])] relay.save() ievent.reply('relay deleted')
def handle_relayadd(bot, ievent): """ relay-add <botname> <channel> <botname> <channel> .. add a relay """ try: (botnamefrom, channelfrom, botnameto, channelto) = ievent.args except ValueError: ievent.missing('<botnamefrom> <channelfrom> <botnameto> <channelto>') return relay[jsonstring([botnamefrom, channelfrom.lower()])] = [botnameto, channelto.lower()] relay.save() ievent.reply('relay added')
def check(self, botname, channel, txt, fromm=None): """ check if we relay on (botname, channel) .. if so do output """ channel = channel.lower() indexstring = jsonstring((botname, channel)) if self.data.has_key(indexstring): for i in self.data[indexstring]: if i != indexstring: bot = fleet.byname(i[0]) if bot: if txt.count('[%s]' % bot.nick) > 0: return if not bot.stopped: time.sleep(1) bot.outputnolog(i[1], txt, 'msg', fromm=fromm)
def wouldrelay(self, botname, channel): """ check if (botname, channel) would relay """ return self.data.has_key(jsonstring((botname, channel.lower())))