mirror of
https://github.com/progval/Limnoria.git
synced 2025-04-27 13:31:08 -05:00
Channel: Add command @iban. Closes GH-282.
This commit is contained in:
parent
1fc11d0cea
commit
fe9c28ffa8
@ -299,7 +299,51 @@ class Channel(callbacks.Plugin):
|
|||||||
<channel> is only necessary if the message isn't sent in the channel
|
<channel> is only necessary if the message isn't sent in the channel
|
||||||
itself.
|
itself.
|
||||||
"""
|
"""
|
||||||
|
self._ban(irc, msg, args,
|
||||||
|
channel, optlist, bannedNick, expiry, reason, True)
|
||||||
|
kban = wrap(kban,
|
||||||
|
['op',
|
||||||
|
getopts({'exact':'', 'nick':'', 'user':'', 'host':''}),
|
||||||
|
('isGranted', _('kick or ban someone')),
|
||||||
|
'nickInChannel',
|
||||||
|
optional('expiry', 0),
|
||||||
|
additional('text')])
|
||||||
|
|
||||||
|
@internationalizeDocstring
|
||||||
|
def iban(self, irc, msg, args,
|
||||||
|
channel, optlist, bannedNick, expiry):
|
||||||
|
"""[<channel>] [--{exact,nick,user,host}] <nick> [<seconds>] [<reason>]
|
||||||
|
|
||||||
|
If you have the #channel,op capability, this will ban <nick> for
|
||||||
|
as many seconds as you specify, or else (if you specify 0 seconds or
|
||||||
|
don't specify a number of seconds) it will ban the person indefinitely.
|
||||||
|
--exact bans only the exact hostmask; --nick bans just the nick;
|
||||||
|
--user bans just the user, and --host bans just the host. You can
|
||||||
|
combine these options as you choose.
|
||||||
|
<channel> is only necessary if the message isn't sent in the channel
|
||||||
|
itself.
|
||||||
|
"""
|
||||||
|
self._ban(irc, msg, args,
|
||||||
|
channel, optlist, bannedNick, expiry, None, False)
|
||||||
|
iban = wrap(iban,
|
||||||
|
['op',
|
||||||
|
getopts({'exact':'', 'nick':'', 'user':'', 'host':''}),
|
||||||
|
('isGranted', _('ban someone')),
|
||||||
|
first('nick', 'hostmask'),
|
||||||
|
optional('expiry', 0)])
|
||||||
|
|
||||||
|
def _ban(self, irc, msg, args,
|
||||||
|
channel, optlist, target, expiry, reason, kick):
|
||||||
# Check that they're not trying to make us kickban ourself.
|
# Check that they're not trying to make us kickban ourself.
|
||||||
|
if irc.isNick(target):
|
||||||
|
bannedNick = target
|
||||||
|
try:
|
||||||
|
bannedHostmask = irc.state.nickToHostmask(target)
|
||||||
|
except KeyError:
|
||||||
|
irc.error(format(_('I haven\'t seen %s.'), bannedNick), Raise=True)
|
||||||
|
else:
|
||||||
|
bannedNick = ircutils.nickFromHostmask(target)
|
||||||
|
bannedHostmask = target
|
||||||
if not irc.isNick(bannedNick):
|
if not irc.isNick(bannedNick):
|
||||||
self.log.warning('%q tried to kban a non nick: %q',
|
self.log.warning('%q tried to kban a non nick: %q',
|
||||||
msg.prefix, bannedNick)
|
msg.prefix, bannedNick)
|
||||||
@ -310,10 +354,6 @@ class Channel(callbacks.Plugin):
|
|||||||
return
|
return
|
||||||
if not reason:
|
if not reason:
|
||||||
reason = msg.nick
|
reason = msg.nick
|
||||||
try:
|
|
||||||
bannedHostmask = irc.state.nickToHostmask(bannedNick)
|
|
||||||
except KeyError:
|
|
||||||
irc.error(format(_('I haven\'t seen %s.'), bannedNick), Raise=True)
|
|
||||||
capability = ircdb.makeChannelCapability(channel, 'op')
|
capability = ircdb.makeChannelCapability(channel, 'op')
|
||||||
banmaskstyle = conf.supybot.protocols.irc.banmask
|
banmaskstyle = conf.supybot.protocols.irc.banmask
|
||||||
banmask = banmaskstyle.makeBanmask(bannedHostmask, [o[0] for o in optlist])
|
banmask = banmaskstyle.makeBanmask(bannedHostmask, [o[0] for o in optlist])
|
||||||
@ -334,6 +374,7 @@ class Channel(callbacks.Plugin):
|
|||||||
if irc.state.channels[channel].isOp(bannedNick):
|
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))
|
||||||
|
if kick:
|
||||||
irc.queueMsg(ircmsgs.kick(channel, bannedNick, reason))
|
irc.queueMsg(ircmsgs.kick(channel, bannedNick, reason))
|
||||||
if expiry > 0:
|
if expiry > 0:
|
||||||
def f():
|
def f():
|
||||||
@ -357,13 +398,6 @@ class Channel(callbacks.Plugin):
|
|||||||
msg.prefix, capability)
|
msg.prefix, capability)
|
||||||
irc.errorNoCapability(capability)
|
irc.errorNoCapability(capability)
|
||||||
exact,nick,user,host
|
exact,nick,user,host
|
||||||
kban = wrap(kban,
|
|
||||||
['op',
|
|
||||||
getopts({'exact':'', 'nick':'', 'user':'', 'host':''}),
|
|
||||||
('isGranted', _('kick or ban someone')),
|
|
||||||
'nickInChannel',
|
|
||||||
optional('expiry', 0),
|
|
||||||
additional('text')])
|
|
||||||
|
|
||||||
@internationalizeDocstring
|
@internationalizeDocstring
|
||||||
def unban(self, irc, msg, args, channel, hostmask):
|
def unban(self, irc, msg, args, channel, hostmask):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user