mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-18 14:40:51 +01:00
Added op/halfop/voice handling in IrcState.
This commit is contained in:
parent
8e45ffc020
commit
fe4af22e50
@ -267,6 +267,22 @@ class IrcState(IrcCommandDispatcher):
|
|||||||
chan.addUser(msg.nick)
|
chan.addUser(msg.nick)
|
||||||
self.channels[channel] = chan
|
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)
|
||||||
|
|
||||||
def do353(self, irc, msg):
|
def do353(self, irc, msg):
|
||||||
(_, _, channel, users) = msg.args
|
(_, _, channel, users) = msg.args
|
||||||
chan = self.channels[channel]
|
chan = self.channels[channel]
|
||||||
|
@ -149,6 +149,7 @@ class ChannelTestCase(unittest.TestCase):
|
|||||||
class IrcStateTestCase(unittest.TestCase):
|
class IrcStateTestCase(unittest.TestCase):
|
||||||
class FakeIrc:
|
class FakeIrc:
|
||||||
nick = 'nick'
|
nick = 'nick'
|
||||||
|
prefix = 'nick!user@host'
|
||||||
irc = FakeIrc()
|
irc = FakeIrc()
|
||||||
def testHistory(self):
|
def testHistory(self):
|
||||||
oldconfmaxhistory = conf.maxHistory
|
oldconfmaxhistory = conf.maxHistory
|
||||||
@ -190,6 +191,26 @@ class IrcStateTestCase(unittest.TestCase):
|
|||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
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 testChannels(self):
|
def testChannels(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user