

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):
            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)

dataset/ETHPy150Open ProgVal/Limnoria/plugins/Protector/plugin.py Protector.doMode/original