mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
Fixed a bug and caught some interesting issues with strictRfc. Still need
to look into Channel.kban
This commit is contained in:
parent
d9d1aefac3
commit
90a0529696
@ -131,7 +131,7 @@ class Channel(callbacks.Privmsg):
|
|||||||
else:
|
else:
|
||||||
irc.error('How can I deop someone? I\'m not opped!')
|
irc.error('How can I deop someone? I\'m not opped!')
|
||||||
deop = privmsgs.checkChannelCapability(deop, 'op')
|
deop = privmsgs.checkChannelCapability(deop, 'op')
|
||||||
|
|
||||||
def dehalfop(self, irc, msg, args, channel):
|
def dehalfop(self, irc, msg, args, channel):
|
||||||
"""[<channel>] [<nick> ...]
|
"""[<channel>] [<nick> ...]
|
||||||
|
|
||||||
@ -150,7 +150,7 @@ class Channel(callbacks.Privmsg):
|
|||||||
else:
|
else:
|
||||||
irc.error('How can I dehalfop someone? I\'m not opped!')
|
irc.error('How can I dehalfop someone? I\'m not opped!')
|
||||||
dehalfop = privmsgs.checkChannelCapability(dehalfop, 'op')
|
dehalfop = privmsgs.checkChannelCapability(dehalfop, 'op')
|
||||||
|
|
||||||
def devoice(self, irc, msg, args, channel):
|
def devoice(self, irc, msg, args, channel):
|
||||||
"""[<channel>] [<nick> ...]
|
"""[<channel>] [<nick> ...]
|
||||||
|
|
||||||
@ -169,7 +169,7 @@ class Channel(callbacks.Privmsg):
|
|||||||
else:
|
else:
|
||||||
irc.error('How can I devoice someone? I\'m not opped!')
|
irc.error('How can I devoice someone? I\'m not opped!')
|
||||||
devoice = privmsgs.checkChannelCapability(devoice, 'op')
|
devoice = privmsgs.checkChannelCapability(devoice, 'op')
|
||||||
|
|
||||||
def cycle(self, irc, msg, args, channel):
|
def cycle(self, irc, msg, args, channel):
|
||||||
"""[<channel>] [<key>]
|
"""[<channel>] [<key>]
|
||||||
|
|
||||||
@ -319,10 +319,10 @@ class Channel(callbacks.Privmsg):
|
|||||||
else:
|
else:
|
||||||
irc.error('How can I unban someone? I\'m not opped.')
|
irc.error('How can I unban someone? I\'m not opped.')
|
||||||
unban = privmsgs.checkChannelCapability(unban, 'op')
|
unban = privmsgs.checkChannelCapability(unban, 'op')
|
||||||
|
|
||||||
def invite(self, irc, msg, args, channel):
|
def invite(self, irc, msg, args, channel):
|
||||||
"""[<channel>] <nick>
|
"""[<channel>] <nick>
|
||||||
|
|
||||||
If you have the #channel,op capability, this will invite <nick>
|
If you have the #channel,op capability, this will invite <nick>
|
||||||
to join <channel>. <channel> is only necessary if the message isn't
|
to join <channel>. <channel> is only necessary if the message isn't
|
||||||
sent in the channel itself.
|
sent in the channel itself.
|
||||||
@ -362,6 +362,24 @@ class Channel(callbacks.Privmsg):
|
|||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
unlobotomize = privmsgs.checkChannelCapability(unlobotomize, 'op')
|
unlobotomize = privmsgs.checkChannelCapability(unlobotomize, 'op')
|
||||||
|
|
||||||
|
def _getBanmask(self, irc, arg):
|
||||||
|
if ircutils.isNick(arg):
|
||||||
|
if not conf.supybot.protocols.irc.strictRfc():
|
||||||
|
try:
|
||||||
|
hostmask = irc.state.nickToHostmask(arg)
|
||||||
|
banmask = ircutils.banmask(hostmask)
|
||||||
|
except KeyError:
|
||||||
|
if ircutils.isUserHostmask(arg):
|
||||||
|
banmask = arg
|
||||||
|
else:
|
||||||
|
hostmask = irc.state.nickToHostmask(arg)
|
||||||
|
banmask = ircutils.banmask(hostmask)
|
||||||
|
elif ircutils.isUserHostmask(arg):
|
||||||
|
banmask = arg
|
||||||
|
else:
|
||||||
|
banmask = None
|
||||||
|
return banmask
|
||||||
|
|
||||||
def permban(self, irc, msg, args, channel):
|
def permban(self, irc, msg, args, channel):
|
||||||
"""[<channel>] <nick|hostmask>
|
"""[<channel>] <nick|hostmask>
|
||||||
|
|
||||||
@ -371,11 +389,8 @@ class Channel(callbacks.Privmsg):
|
|||||||
necessary if the message isn't sent in the channel itself.
|
necessary if the message isn't sent in the channel itself.
|
||||||
"""
|
"""
|
||||||
arg = privmsgs.getArgs(args)
|
arg = privmsgs.getArgs(args)
|
||||||
if ircutils.isNick(arg):
|
banmask = self._getBanmask(irc, arg)
|
||||||
banmask = ircutils.banmask(irc.state.nickToHostmask(arg))
|
if banmask is None:
|
||||||
elif ircutils.isUserHostmask(arg):
|
|
||||||
banmask = arg
|
|
||||||
else:
|
|
||||||
irc.error('That\'s not a valid nick or hostmask.')
|
irc.error('That\'s not a valid nick or hostmask.')
|
||||||
return
|
return
|
||||||
c = ircdb.channels.getChannel(channel)
|
c = ircdb.channels.getChannel(channel)
|
||||||
@ -407,11 +422,8 @@ class Channel(callbacks.Privmsg):
|
|||||||
the channel itself.
|
the channel itself.
|
||||||
"""
|
"""
|
||||||
arg = privmsgs.getArgs(args)
|
arg = privmsgs.getArgs(args)
|
||||||
if ircutils.isNick(arg):
|
banmask = self._getBanmask(irc, arg)
|
||||||
banmask = ircutils.banmask(irc.state.nickToHostmask(arg))
|
if banmask is None:
|
||||||
elif ircutils.isUserHostmask(arg):
|
|
||||||
banmask = arg
|
|
||||||
else:
|
|
||||||
irc.error('That\'s not a valid nick or hostmask.')
|
irc.error('That\'s not a valid nick or hostmask.')
|
||||||
return
|
return
|
||||||
c = ircdb.channels.getChannel(channel)
|
c = ircdb.channels.getChannel(channel)
|
||||||
@ -541,9 +553,12 @@ class Channel(callbacks.Privmsg):
|
|||||||
"""
|
"""
|
||||||
capability = privmsgs.getArgs(args)
|
capability = privmsgs.getArgs(args)
|
||||||
c = ircdb.channels.getChannel(channel)
|
c = ircdb.channels.getChannel(channel)
|
||||||
c.removeCapability(capability)
|
try:
|
||||||
ircdb.channels.setChannel(channel, c)
|
c.removeCapability(capability)
|
||||||
irc.replySuccess()
|
ircdb.channels.setChannel(channel, c)
|
||||||
|
irc.replySuccess()
|
||||||
|
except KeyError:
|
||||||
|
irc.error('I do not know about that channel capability.')
|
||||||
unsetcapability = privmsgs.checkChannelCapability(unsetcapability, 'op')
|
unsetcapability = privmsgs.checkChannelCapability(unsetcapability, 'op')
|
||||||
|
|
||||||
def capabilities(self, irc, msg, args):
|
def capabilities(self, irc, msg, args):
|
||||||
@ -583,8 +598,8 @@ class Channel(callbacks.Privmsg):
|
|||||||
L = list(irc.state.channels[channel].users)
|
L = list(irc.state.channels[channel].users)
|
||||||
utils.sortBy(str.lower, L)
|
utils.sortBy(str.lower, L)
|
||||||
irc.reply(utils.commaAndify(L))
|
irc.reply(utils.commaAndify(L))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Class = Channel
|
Class = Channel
|
||||||
|
|
||||||
|
@ -56,6 +56,9 @@ class ChannelTestCase(ChannelPluginTestCase, PluginDocumentation):
|
|||||||
|
|
||||||
def testCapabilities(self):
|
def testCapabilities(self):
|
||||||
self.assertNotError('channel capabilities')
|
self.assertNotError('channel capabilities')
|
||||||
|
self.assertNotError('channel setcapability -foo')
|
||||||
|
self.assertNotError('channel unsetcapability -foo')
|
||||||
|
self.assertError('channel unsetcapability -foo')
|
||||||
|
|
||||||
def testUnban(self):
|
def testUnban(self):
|
||||||
self.assertError('unban foo!bar@baz')
|
self.assertError('unban foo!bar@baz')
|
||||||
@ -64,7 +67,7 @@ class ChannelTestCase(ChannelPluginTestCase, PluginDocumentation):
|
|||||||
self.assertEqual(m.command, 'MODE')
|
self.assertEqual(m.command, 'MODE')
|
||||||
self.assertEqual(m.args, (self.channel, '-b', 'foo!bar@baz'))
|
self.assertEqual(m.args, (self.channel, '-b', 'foo!bar@baz'))
|
||||||
self.assertNoResponse(' ', 2)
|
self.assertNoResponse(' ', 2)
|
||||||
|
|
||||||
def testErrorsWithoutOps(self):
|
def testErrorsWithoutOps(self):
|
||||||
for s in 'op deop halfop dehalfop voice devoice kick invite'.split():
|
for s in 'op deop halfop dehalfop voice devoice kick invite'.split():
|
||||||
self.assertError('%s foo' % s)
|
self.assertError('%s foo' % s)
|
||||||
@ -87,7 +90,7 @@ class ChannelTestCase(ChannelPluginTestCase, PluginDocumentation):
|
|||||||
m = self.getMsg('op foo bar')
|
m = self.getMsg('op foo bar')
|
||||||
self.failUnless(m.command == 'MODE' and
|
self.failUnless(m.command == 'MODE' and
|
||||||
m.args == (self.channel, '+oo', 'foo', 'bar'))
|
m.args == (self.channel, '+oo', 'foo', 'bar'))
|
||||||
|
|
||||||
def testHalfOp(self):
|
def testHalfOp(self):
|
||||||
self.assertError('halfop')
|
self.assertError('halfop')
|
||||||
self.irc.feedMsg(ircmsgs.op(self.channel, self.nick))
|
self.irc.feedMsg(ircmsgs.op(self.channel, self.nick))
|
||||||
@ -109,7 +112,7 @@ class ChannelTestCase(ChannelPluginTestCase, PluginDocumentation):
|
|||||||
m = self.getMsg('voice foo bar')
|
m = self.getMsg('voice foo bar')
|
||||||
self.failUnless(m.command == 'MODE' and
|
self.failUnless(m.command == 'MODE' and
|
||||||
m.args == (self.channel, '+vv', 'foo', 'bar'))
|
m.args == (self.channel, '+vv', 'foo', 'bar'))
|
||||||
|
|
||||||
def assertBan(self, query, hostmask, **kwargs):
|
def assertBan(self, query, hostmask, **kwargs):
|
||||||
m = self.getMsg(query, **kwargs)
|
m = self.getMsg(query, **kwargs)
|
||||||
self.assertEqual(m, ircmsgs.ban(self.channel, hostmask))
|
self.assertEqual(m, ircmsgs.ban(self.channel, hostmask))
|
||||||
|
Loading…
Reference in New Issue
Block a user