AttackProtector: Add support for temporary bans.

master
Valentin Lorentz 2013-05-18 18:01:53 +02:00
parent cca795c62f
commit a9dbcf4f1b
2 changed files with 11 additions and 3 deletions

View File

@ -67,12 +67,13 @@ class Punishment(registry.String):
if s not in ('ban', 'kick', 'kban') and not s.startswith('mode+') and \
not s.startswith('mode-') and not s.startswith('umode-') and \
not s.startswith('umode+') and \
not s.startswith('command ') and not s.startswith('kban+'):
not s.startswith('command ') and \
not s.startswith('kban+') and not s.startswith('ban+') :
self.error()
return
if s.startswith('kban+'):
if s.startswith('kban+') or s.startswith('ban+'):
try:
int(s[5:])
int(s.split('+', 1)[1])
except ValueError:
self.error()
return

View File

@ -207,6 +207,13 @@ class AttackProtector(callbacks.Plugin):
elif punishment == 'ban':
msg = ircmsgs.ban(channel, banmask)
irc.queueMsg(msg)
if punishment.startswith('ban+'):
time = int(punishment[4:])
unban = functools.partial(irc.queueMsg,
ircmsgs.unban(channel, banmask))
schedule.addEvent(unban, time)
elif punishment.startswith('kban'):
msg = ircmsgs.ban(channel, banmask)
irc.queueMsg(msg)