def fmvoice(self, irc, msg, args, option): """Takes no arguments Podela igraca u dve grupe, voice/devoice.""" voices_empty = [] channel = msg.args[0] voices = irc.state.channels[channel].voices voices_length = len(voices) users = irc.state.channels[channel].users users_length = len(users) half_users_length = users_length / 2 list_of_users = list(users) if '--first' in msg.args[1]: for i in xrange(half_users_length + 2): nick = random.choice(list_of_users) if nick == "eRepublikBot" or nick == "DonVitoCorleone": continue if nick not in voices: irc.queueMsg(ircmsgs.voice(channel, nick)) elif '--devoice' in msg.args[1]: for i in users: irc.queueMsg(ircmsgs.devoice(channel, i)) else: for i in users: if i not in voices: irc.queueMsg(ircmsgs.voice(channel, i)) elif i == 'eRepublikBot' or i == "DonVitoCorleone" or i == "x-bot": continue else: irc.queueMsg(ircmsgs.devoice(channel, i))
def doMode(self, irc, msg): channel = msg.args[0] chanOp = ircdb.makeChannelCapability(channel, 'op') chanVoice = ircdb.makeChannelCapability(channel, 'voice') chanHalfOp = ircdb.makeChannelCapability(channel, 'halfop') if not ircdb.checkCapability(msg.prefix, chanOp): irc.sendMsg(ircmsgs.deop(channel, msg.nick)) for (mode, value) in ircutils.separateModes(msg.args[1:]): if not value: continue if ircutils.strEqual(value, msg.nick): # We allow someone to mode themselves to oblivion. continue if irc.isNick(value): hostmask = irc.state.nickToHostmask(value) if mode == '+o': if not self.isOp(irc, channel, hostmask): irc.queueMsg(ircmsgs.deop(channel, value)) elif mode == '+h': if not ircdb.checkCapability(hostmask, chanHalfOp): irc.queueMsg(ircmsgs.dehalfop(channel, value)) elif mode == '+v': if not ircdb.checkCapability(hostmask, chanVoice): irc.queueMsg(ircmsgs.devoice(channel, value)) elif mode == '-o': if ircdb.checkCapability(hostmask, chanOp): irc.queueMsg(ircmsgs.op(channel, value)) elif mode == '-h': if ircdb.checkCapability(hostmask, chanOp): irc.queueMsg(ircmsgs.halfop(channel, value)) elif mode == '-v': if ircdb.checkCapability(hostmask, chanOp): irc.queueMsg(ircmsgs.voice(channel, value)) else: assert ircutils.isUserHostmask(value)
def doMode(self, irc, msg): channel = msg.channel chanOp = ircdb.makeChannelCapability(channel, 'op') chanVoice = ircdb.makeChannelCapability(channel, 'voice') chanHalfOp = ircdb.makeChannelCapability(channel, 'halfop') if not ircdb.checkCapability(msg.prefix, chanOp): irc.sendMsg(ircmsgs.deop(channel, msg.nick)) for (mode, value) in ircutils.separateModes(msg.args[1:]): if not value: continue if ircutils.strEqual(value, msg.nick): # We allow someone to mode themselves to oblivion. continue if irc.isNick(value): hostmask = irc.state.nickToHostmask(value) if mode == '+o': if not self.isOp(irc, channel, hostmask): irc.queueMsg(ircmsgs.deop(channel, value)) elif mode == '+h': if not ircdb.checkCapability(hostmask, chanHalfOp): irc.queueMsg(ircmsgs.dehalfop(channel, value)) elif mode == '+v': if not ircdb.checkCapability(hostmask, chanVoice): irc.queueMsg(ircmsgs.devoice(channel, value)) elif mode == '-o': if ircdb.checkCapability(hostmask, chanOp): irc.queueMsg(ircmsgs.op(channel, value)) elif mode == '-h': if ircdb.checkCapability(hostmask, chanOp): irc.queueMsg(ircmsgs.halfop(channel, value)) elif mode == '-v': if ircdb.checkCapability(hostmask, chanOp): irc.queueMsg(ircmsgs.voice(channel, value)) else: assert ircutils.isUserHostmask(value)
def moderate(self, irc, msg, args, channel, nick): """[channel] nick Bascule tous les utilisateurs du canal en mode +v excépté 'nick' puis passe le canal en mode +m """ if not channel: channel = msg.args[0] if channel in irc.state.channels: # TODO: Spécifier la liste des nick au différents canaux self.nicks_moderated.append(nick) self.voice_func(irc, msg, args, channel) irc.queueMsg(ircmsgs.devoice(channel, nick)) #self.removeNick (irc, channel, nick, "Avertissement") irc.queueMsg(ircmsgs.mode(channel, ['+m']))
def moderate (self, irc, msg, args, channel, nick): """[channel] nick Bascule tous les utilisateurs du canal en mode +v excépté 'nick' puis passe le canal en mode +m """ if not channel: channel = msg.args[0] if channel in irc.state.channels: # TODO: Spécifier la liste des nick au différents canaux self.nicks_moderated.append (nick) self.voice_func (irc, msg, args, channel) irc.queueMsg (ircmsgs.devoice(channel, nick)) #self.removeNick (irc, channel, nick, "Avertissement") irc.queueMsg (ircmsgs.mode(channel, ['+m']))
def __call__(self, irc, msg): # only re-read the file every 60 seconds if self.lastCalled + 60 < int(time.time()): self.readMACs() self.lastCalled = int(time.time()) chan = msg.args[0]; # FIXME: change channel! if(ircutils.isChannel(chan) and chan == "#stratum0" and chan in irc.state.channels.keys()): self.log.info("voices: %s" % repr(irc.state.channels[chan].voices)) self.log.info("present: %s" % repr(self.presentEntities)) self.log.info("devoice %s" % repr(irc.state.channels[chan].voices - self.presentEntities)) self.log.info("voice: %s\n" % repr(self.presentEntities - irc.state.channels[chan].voices)) for nick in (irc.state.channels[chan].voices - self.presentEntities): irc.queueMsg(ircmsgs.devoice(chan, nick)) for nick in (self.presentEntities - irc.state.channels[chan].voices): irc.queueMsg(ircmsgs.voice(chan, nick))
def testHandlesModes(self): st = irclib.IrcState() st.addMsg(self.irc, ircmsgs.join('#foo', prefix=self.irc.prefix)) self.failIf('bar' in st.channels['#foo'].ops) st.addMsg(self.irc, ircmsgs.op('#foo', 'bar')) self.failUnless('bar' in st.channels['#foo'].ops) st.addMsg(self.irc, ircmsgs.deop('#foo', 'bar')) self.failIf('bar' in st.channels['#foo'].ops) self.failIf('bar' in st.channels['#foo'].voices) st.addMsg(self.irc, ircmsgs.voice('#foo', 'bar')) self.failUnless('bar' in st.channels['#foo'].voices) st.addMsg(self.irc, ircmsgs.devoice('#foo', 'bar')) self.failIf('bar' in st.channels['#foo'].voices) self.failIf('bar' in st.channels['#foo'].halfops) st.addMsg(self.irc, ircmsgs.halfop('#foo', 'bar')) self.failUnless('bar' in st.channels['#foo'].halfops) st.addMsg(self.irc, ircmsgs.dehalfop('#foo', 'bar')) self.failIf('bar' in st.channels['#foo'].halfops)
def _undoAutoVoice(self, irc): for nick in irc.state.channels[self.registryValue('monitorChannel')].voices: irc.queueMsg(ircmsgs.devoice(self.registryValue('monitorChannel'), nick))