Пример #1
0
 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)
Пример #2
0
 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)
Пример #3
0
 def doBan():
     if irc.state.channels[channel].isOp(bannedNick):
         irc.queueMsg(ircmsgs.deop(channel, bannedNick))
     irc.queueMsg(ircmsgs.ban(channel, banmask))
     irc.queueMsg(ircmsgs.kick(channel, bannedNick, reason))
     def f():
         if channel in irc.state.channels and \
            banmask in irc.state.channels[channel].bans:
             irc.queueMsg(ircmsgs.unban(channel, banmask))
     schedule.addEvent(f, 3600)
Пример #4
0
 def doBan():
     if irc.state.channels[channel].isOp(bannedNick):
         irc.queueMsg(ircmsgs.deop(channel, bannedNick))
     irc.queueMsg(ircmsgs.ban(channel, banmask))
     irc.queueMsg(ircmsgs.kick(channel, bannedNick, reason))
     if expiry > 0:
         def f():
             if channel in irc.state.channels and \
                banmask in irc.state.channels[channel].bans:
                 irc.queueMsg(ircmsgs.unban(channel, banmask))
         schedule.addEvent(f, expiry)
Пример #5
0
    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)
Пример #6
0
    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)
Пример #7
0
 def testErrorsWithoutOps(self):
     for s in 'op deop halfop dehalfop voice devoice kick invite'.split():
         self.assertError('%s foo' % s)
         self.irc.feedMsg(ircmsgs.op(self.channel, self.nick))
         self.assertNotError('%s foo' % s)
         self.irc.feedMsg(ircmsgs.deop(self.channel, self.nick))
Пример #8
0
 def demote(self, irc, channel, nick):
     irc.queueMsg(ircmsgs.deop(channel, nick))
Пример #9
0
 def demote(self, irc, channel, nick):
     irc.queueMsg(ircmsgs.deop(channel, nick))