Guarded IrcState.doMode to work only with channels.

This commit is contained in:
Jeremy Fincher 2003-09-29 07:44:27 +00:00
parent 1410d1af43
commit 6169822349
2 changed files with 20 additions and 14 deletions

View File

@ -268,20 +268,22 @@ class IrcState(IrcCommandDispatcher):
self.channels[channel] = chan
def doMode(self, irc, msg):
chan = self.channels[msg.args[0]]
for (mode, nick) in ircutils.separateModes(msg.args[1:]):
if mode == '-o':
chan.ops.discard(nick)
elif mode == '+o':
chan.ops.add(nick)
if mode == '-h':
chan.halfops.discard(nick)
elif mode == '+h':
chan.halfops.add(nick)
if mode == '-v':
chan.voices.discard(nick)
elif mode == '+v':
chan.voices.add(nick)
channel = msg.args[0]
if ircutils.isChannel(channel):
chan = self.channels[channel]
for (mode, nick) in ircutils.separateModes(msg.args[1:]):
if mode == '-o':
chan.ops.discard(nick)
elif mode == '+o':
chan.ops.add(nick)
if mode == '-h':
chan.halfops.discard(nick)
elif mode == '+h':
chan.halfops.add(nick)
if mode == '-v':
chan.voices.discard(nick)
elif mode == '+v':
chan.voices.add(nick)
def do353(self, irc, msg):
(_, _, channel, users) = msg.args

View File

@ -212,6 +212,10 @@ class IrcStateTestCase(unittest.TestCase):
st.addMsg(self.irc, ircmsgs.dehalfop('#foo', 'bar'))
self.failIf('bar' in st.channels['#foo'].halfops)
def testDoModeOnlyChannels(self):
st = irclib.IrcState()
self.assert_(st.addMsg(self.irc, ircmsgs.IrcMsg('MODE foo +i')) or 1)
"""
def testChannels(self):
channel =