From 7f3cafbfbd297d147f5673765db4a42d5aeec0f6 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Wed, 3 Dec 2003 20:17:13 +0000 Subject: [PATCH] Fixed ops, deops, halfops, dehalfops, voices, and devoices. --- src/ircmsgs.py | 12 ++++++------ test/test_ircmsgs.py | 24 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/ircmsgs.py b/src/ircmsgs.py index cd0df8635..ddf3d0f79 100644 --- a/src/ircmsgs.py +++ b/src/ircmsgs.py @@ -301,7 +301,7 @@ def ops(channel, nicks, prefix=''): assert isChannel(channel), repr(channel) assert all(isNick, nicks), nicks return IrcMsg(prefix=prefix, command=MODE, - args=(channel, '+' + ('o'*len(nicks)), nicks)) + args=(channel, '+' + ('o'*len(nicks))) + tuple(nicks)) def deop(channel, nick, prefix=''): """Returns a MODE to deop nick on channel.""" @@ -314,7 +314,7 @@ def deops(channel, nicks, prefix=''): assert isChannel(channel), repr(channel) assert all(isNick, nicks), nicks return IrcMsg(prefix=prefix, command=MODE, - args=(channel, '-' + ('o'*len(nicks)), nicks)) + args=(channel, '-' + ('o'*len(nicks))) + tuple(nicks)) def halfop(channel, nick, prefix=''): """Returns a MODE to halfop nick on channel.""" @@ -328,7 +328,7 @@ def halfops(channel, nicks, prefix=''): assert all(isNick, nicks), nicks return IrcMsg(prefix=prefix, command=MODE, - args=(channel, '+' + ('h'*len(nicks)), nicks)) + args=(channel, '+' + ('h'*len(nicks))) + tuple(nicks)) def dehalfop(channel, nick, prefix=''): """Returns a MODE to dehalfop nick on channel.""" @@ -341,7 +341,7 @@ def dehalfops(channel, nicks, prefix=''): assert isChannel(channel), repr(channel) assert all(isNick, nicks), nicks return IrcMsg(prefix=prefix, command=MODE, - args=(channel, '-' + ('h'*len(nicks)), nicks)) + args=(channel, '-' + ('h'*len(nicks))) + tuple(nicks)) def voice(channel, nick, prefix=''): """Returns a MODE to voice nick on channel.""" @@ -354,7 +354,7 @@ def voices(channel, nicks, prefix=''): assert isChannel(channel), repr(channel) assert all(isNick, nicks) return IrcMsg(prefix=prefix, command=MODE, - args=(channel, '+' + ('v'*len(nicks)), nicks)) + args=(channel, '+' + ('v'*len(nicks))) + tuple(nicks)) def devoice(channel, nick, prefix=''): """Returns a MODE to devoice nick on channel.""" @@ -367,7 +367,7 @@ def devoices(channel, nicks, prefix=''): assert isChannel(channel), repr(channel) assert all(isNick, nicks), nicks return IrcMsg(prefix=prefix, command=MODE, - args=(channel, '-' + ('v'*len(nicks)), nicks)) + args=(channel, '-' + ('v'*len(nicks))) + tuple(nicks)) def ban(channel, hostmask, exception='', prefix=''): """Returns a MODE to ban nick on channel.""" diff --git a/test/test_ircmsgs.py b/test/test_ircmsgs.py index 237b0690f..a1d389e34 100644 --- a/test/test_ircmsgs.py +++ b/test/test_ircmsgs.py @@ -187,5 +187,29 @@ class FunctionsTestCase(unittest.TestCase): def testQuit(self): self.failUnless(ircmsgs.quit(prefix='foo!bar@baz')) + def testOps(self): + m = ircmsgs.ops('#foo', ['foo', 'bar', 'baz']) + self.assertEqual(str(m), 'MODE #foo +ooo foo bar :baz\r\n') + + def testDeops(self): + m = ircmsgs.deops('#foo', ['foo', 'bar', 'baz']) + self.assertEqual(str(m), 'MODE #foo -ooo foo bar :baz\r\n') + + def testVoices(self): + m = ircmsgs.voices('#foo', ['foo', 'bar', 'baz']) + self.assertEqual(str(m), 'MODE #foo +vvv foo bar :baz\r\n') + + def testDevoices(self): + m = ircmsgs.devoices('#foo', ['foo', 'bar', 'baz']) + self.assertEqual(str(m), 'MODE #foo -vvv foo bar :baz\r\n') + + def testHalfops(self): + m = ircmsgs.halfops('#foo', ['foo', 'bar', 'baz']) + self.assertEqual(str(m), 'MODE #foo +hhh foo bar :baz\r\n') + + def testDehalfops(self): + m = ircmsgs.dehalfops('#foo', ['foo', 'bar', 'baz']) + self.assertEqual(str(m), 'MODE #foo -hhh foo bar :baz\r\n') + # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: