mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 21:29:24 +01:00
Misc: Avoid setting up "invalid command" flood handling if its not enabled
Closes: Sf#3088554 Signed-off-by: James McCoy <vega.james@gmail.com>
This commit is contained in:
parent
23bfe116ff
commit
865e87cf74
@ -60,31 +60,33 @@ class Misc(callbacks.Plugin):
|
|||||||
assert not msg.repliedTo, 'repliedTo msg in Misc.invalidCommand.'
|
assert not msg.repliedTo, 'repliedTo msg in Misc.invalidCommand.'
|
||||||
assert self is irc.callbacks[-1], 'Misc isn\'t last callback.'
|
assert self is irc.callbacks[-1], 'Misc isn\'t last callback.'
|
||||||
self.log.debug('Misc.invalidCommand called (tokens %s)', tokens)
|
self.log.debug('Misc.invalidCommand called (tokens %s)', tokens)
|
||||||
|
channel = msg.args[0]
|
||||||
|
# Only bother with the invaildCommand flood handling if it's actually
|
||||||
|
# enabled
|
||||||
|
if conf.supybot.abuse.flood.command.invalid():
|
||||||
# First, we check for invalidCommand floods. This is rightfully done
|
# First, we check for invalidCommand floods. This is rightfully done
|
||||||
# here since this will be the last invalidCommand called, and thus it
|
# here since this will be the last invalidCommand called, and thus it
|
||||||
# will only be called if this is *truly* an invalid command.
|
# will only be called if this is *truly* an invalid command.
|
||||||
maximum = conf.supybot.abuse.flood.command.invalid.maximum()
|
maximum = conf.supybot.abuse.flood.command.invalid.maximum()
|
||||||
|
banmasker = conf.supybot.protocols.irc.banmask.makeBanmask
|
||||||
self.invalidCommands.enqueue(msg)
|
self.invalidCommands.enqueue(msg)
|
||||||
if self.invalidCommands.len(msg) > maximum and \
|
if self.invalidCommands.len(msg) > maximum and \
|
||||||
conf.supybot.abuse.flood.command.invalid() and \
|
|
||||||
not ircdb.checkCapability(msg.prefix, 'owner'):
|
not ircdb.checkCapability(msg.prefix, 'owner'):
|
||||||
punishment = conf.supybot.abuse.flood.command.invalid.punishment()
|
penalty = conf.supybot.abuse.flood.command.invalid.punishment()
|
||||||
banmask = '*!%s@%s' % (msg.user, msg.host)
|
banmask = banmasker(msg.prefix)
|
||||||
self.log.info('Ignoring %s for %s seconds due to an apparent '
|
self.log.info('Ignoring %s for %s seconds due to an apparent '
|
||||||
'invalid command flood.', banmask, punishment)
|
'invalid command flood.', banmask, penalty)
|
||||||
if tokens and tokens[0] == 'Error:':
|
if tokens and tokens[0] == 'Error:':
|
||||||
self.log.warning('Apparent error loop with another Supybot '
|
self.log.warning('Apparent error loop with another Supybot '
|
||||||
'observed. Consider ignoring this bot '
|
'observed. Consider ignoring this bot '
|
||||||
'permanently.')
|
'permanently.')
|
||||||
ircdb.ignores.add(banmask, time.time() + punishment)
|
ircdb.ignores.add(banmask, time.time() + penalty)
|
||||||
if conf.supybot.abuse.flood.command.invalid.notify():
|
|
||||||
irc.reply('You\'ve given me %s invalid commands within the last '
|
irc.reply('You\'ve given me %s invalid commands within the last '
|
||||||
'minute; I\'m now ignoring you for %s.' %
|
'minute; I\'m now ignoring you for %s.' %
|
||||||
(maximum,
|
(maximum,
|
||||||
utils.timeElapsed(punishment, seconds=False)))
|
utils.timeElapsed(penalty, seconds=False)))
|
||||||
return
|
return
|
||||||
# Now, for normal handling.
|
# Now, for normal handling.
|
||||||
channel = msg.args[0]
|
|
||||||
if conf.get(conf.supybot.reply.whenNotCommand, channel):
|
if conf.get(conf.supybot.reply.whenNotCommand, channel):
|
||||||
if len(tokens) >= 2:
|
if len(tokens) >= 2:
|
||||||
cb = irc.getCallback(tokens[0])
|
cb = irc.getCallback(tokens[0])
|
||||||
|
Loading…
Reference in New Issue
Block a user