Fix some bugs in Channel.kban

This commit is contained in:
James Vega 2004-11-30 05:21:16 +00:00
parent c87788dc62
commit d57788b5d2

View File

@ -40,11 +40,8 @@ __contributors__ = {
supybot.authors.skorobeus: ['enable', 'disable'], supybot.authors.skorobeus: ['enable', 'disable'],
} }
import supybot.fix as fix
import sys import sys
import time import time
import getopt
from itertools import imap from itertools import imap
@ -292,7 +289,7 @@ class Channel(callbacks.Privmsg):
additional('text')]) additional('text')])
def kban(self, irc, msg, args, def kban(self, irc, msg, args,
channel, optlist, bannedNick, length, reason): channel, optlist, bannedNick, expiry, reason):
"""[<channel>] [--{exact,nick,user,host}] <nick> [<seconds>] [<reason>] """[<channel>] [--{exact,nick,user,host}] <nick> [<seconds>] [<reason>]
If you have the #channel,op capability, this will kickban <nick> for If you have the #channel,op capability, this will kickban <nick> for
@ -307,7 +304,7 @@ class Channel(callbacks.Privmsg):
""" """
# Check that they're not trying to make us kickban ourself. # Check that they're not trying to make us kickban ourself.
self.log.debug('In kban') self.log.debug('In kban')
if not ircutils.isNick(bannedNick): if not irc.isNick(bannedNick):
self.log.warning('%s tried to kban a non nick: %s', self.log.warning('%s tried to kban a non nick: %s',
utils.quoted(msg.prefix), utils.quoted(msg.prefix),
utils.quoted(bannedNick)) utils.quoted(bannedNick))
@ -358,16 +355,16 @@ class Channel(callbacks.Privmsg):
# #channel,op and the bannee doesn't have #channel,op; or that the # #channel,op and the bannee doesn't have #channel,op; or that the
# bannee and the banner are both the same person. # bannee and the banner are both the same person.
def doBan(): def doBan():
if bannedNick in irc.state.channels[channel].ops: if irc.state.channels[channel].isOp(bannedNick):
irc.queueMsg(ircmsgs.deop(channel, bannedNick)) irc.queueMsg(ircmsgs.deop(channel, bannedNick))
irc.queueMsg(ircmsgs.ban(channel, banmask)) irc.queueMsg(ircmsgs.ban(channel, banmask))
irc.queueMsg(ircmsgs.kick(channel, bannedNick, reason)) irc.queueMsg(ircmsgs.kick(channel, bannedNick, reason))
if length > 0: if expiry > 0:
def f(): def f():
if channel in irc.state.channels and \ if channel in irc.state.channels and \
banmask in irc.state.channels[channel].bans: banmask in irc.state.channels[channel].bans:
irc.queueMsg(ircmsgs.unban(channel, banmask)) irc.queueMsg(ircmsgs.unban(channel, banmask))
schedule.addEvent(f, time.time() + length) schedule.addEvent(f, expiry)
if bannedNick == msg.nick: if bannedNick == msg.nick:
doBan() doBan()
elif ircdb.checkCapability(msg.prefix, capability): elif ircdb.checkCapability(msg.prefix, capability):
@ -386,7 +383,7 @@ class Channel(callbacks.Privmsg):
exact,nick,user,host exact,nick,user,host
kban = wrap(kban, kban = wrap(kban,
[('checkChannelCapability', 'op'), [('checkChannelCapability', 'op'),
getopts({'exact':None,'nick':None,'user':None,'host':None}), getopts({'exact':'', 'nick':'', 'user':'', 'host':''}),
('haveOp', 'kick or ban someone'), ('haveOp', 'kick or ban someone'),
'nickInChannel', 'nickInChannel',
optional('expiry', 0), optional('expiry', 0),