mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-23 02:24:12 +01:00
Fixed a possible uncaught KeyError, and added the ability for a kban to work on the person requesting it (so we can put it in aliases :))
This commit is contained in:
parent
6004181695
commit
9b20e1dfb6
@ -113,11 +113,16 @@ class Channel(callbacks.Privmsg):
|
||||
channel = privmsgs.getChannel(msg, args)
|
||||
(bannedNick, length) = privmsgs.getArgs(args, optional=1)
|
||||
length = int(length or 0)
|
||||
try:
|
||||
bannedHostmask = irc.state.nickToHostmask(bannedNick)
|
||||
except KeyError:
|
||||
irc.error(msg, 'I haven\'t seen %s.' % bannedNick)
|
||||
return
|
||||
capability = ircdb.makeChannelCapability(channel, 'op')
|
||||
banmask = ircutils.banmask(bannedHostmask)
|
||||
if ircdb.checkCapability(msg.prefix, capability)\
|
||||
and not ircdb.checkCapability(bannedHostmask, capability):
|
||||
if bannedNick == msg.nick or \
|
||||
(ircdb.checkCapability(msg.prefix, capability) \
|
||||
and not ircdb.checkCapability(bannedHostmask, capability)):
|
||||
if irc.nick in irc.state.channels[channel].ops:
|
||||
irc.queueMsg(ircmsgs.ban(channel, banmask))
|
||||
irc.queueMsg(ircmsgs.kick(channel, bannedNick, msg.nick))
|
||||
|
@ -64,7 +64,11 @@ class ChannelTestCase(ChannelPluginTestCase, PluginDocumentation):
|
||||
self.irc.feedMsg(ircmsgs.join(self.channel, prefix='foobar!user@host'))
|
||||
self.assertError('kban foobar')
|
||||
self.irc.feedMsg(ircmsgs.op(self.channel, self.nick))
|
||||
self.assertNotError('kban foobar')
|
||||
m = self.getMsg('kban foobar')
|
||||
self.assertEqual(m, ircmsgs.ban(self.channel, '*!*@host'))
|
||||
m = self.getMsg(' ')
|
||||
self.assertEqual(m, ircmsgs.kick(self.channel, 'foobar', self.nick))
|
||||
self.assertNotRegexp('kban adlkfajsdlfkjsd', 'KeyError')
|
||||
|
||||
def testLobotomizers(self):
|
||||
self.assertNotError('lobotomize')
|
||||
|
Loading…
Reference in New Issue
Block a user