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