mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 19:19:32 +01:00
Finish the implementation of command flood prevention
This commit is contained in:
parent
a9d1830303
commit
300443c8f6
@ -1,5 +1,6 @@
|
|||||||
###
|
###
|
||||||
# Copyright (c) 2002-2005, Jeremiah Fincher
|
# Copyright (c) 2002-2005, Jeremiah Fincher
|
||||||
|
# Copyright (c) 2008, James Vega
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
@ -30,6 +31,7 @@
|
|||||||
import gc
|
import gc
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
import socket
|
import socket
|
||||||
import linecache
|
import linecache
|
||||||
|
|
||||||
@ -275,6 +277,21 @@ class Owner(callbacks.Plugin):
|
|||||||
if ignored:
|
if ignored:
|
||||||
self.log.info('Ignoring command from %s.', msg.prefix)
|
self.log.info('Ignoring command from %s.', msg.prefix)
|
||||||
return
|
return
|
||||||
|
maximum = conf.supybot.abuse.flood.command.maximum()
|
||||||
|
self.commands.enqueue(msg)
|
||||||
|
if conf.supybot.abuse.flood.command() \
|
||||||
|
and self.commands.len(msg) > maximum \
|
||||||
|
and not ircdb.checkCapability(msg.prefix, 'owner'):
|
||||||
|
punishment = conf.supybot.abuse.flood.command.punishment()
|
||||||
|
banmask = ircutils.banmask(msg.prefix)
|
||||||
|
self.log.info('Ignoring %s for %s seconds due to an apparent '
|
||||||
|
'command flood.', banmask, punishment)
|
||||||
|
ircdb.ignores.add(banmask, time.time() + punishment)
|
||||||
|
irc.reply('You\'ve given me %s commands within the last '
|
||||||
|
'minute; I\'m now ignoring you for %s.' %
|
||||||
|
(maximum,
|
||||||
|
utils.timeElapsed(punishment, seconds=False))
|
||||||
|
return
|
||||||
try:
|
try:
|
||||||
tokens = callbacks.tokenize(s, channel=msg.args[0])
|
tokens = callbacks.tokenize(s, channel=msg.args[0])
|
||||||
self.Proxy(irc, msg, tokens)
|
self.Proxy(irc, msg, tokens)
|
||||||
|
Loading…
Reference in New Issue
Block a user