mirror of
https://github.com/jlu5/PyLink.git
synced 2025-03-28 10:31:01 +01:00
antispam: make punishments method-specific
This commit is contained in:
parent
8cc4527ff7
commit
e65d84960a
@ -829,10 +829,15 @@ stats:
|
|||||||
# false if not set.
|
# false if not set.
|
||||||
#enabled: true
|
#enabled: true
|
||||||
|
|
||||||
|
# Sets the punishment that Antispam should use to punish mass highlighters.
|
||||||
|
# Valid values include "kill", "kick", "ban", "quiet", and combinations of these strung
|
||||||
|
# together with "+" (e.g. "kick+ban"). Defaults to "kick+ban" if not set.
|
||||||
|
#punishment: kick+ban
|
||||||
|
|
||||||
# Sets the kick / kill message used when mass highlight prevention is triggered.
|
# Sets the kick / kill message used when mass highlight prevention is triggered.
|
||||||
#reason: "Mass highlight spam is prohibited"
|
#reason: "Mass highlight spam is prohibited"
|
||||||
|
|
||||||
# Sets the minimum message length and amount of nicks needed in a message for
|
# Sets the minimum message length and amount of nicks needed in a message for
|
||||||
# masshighlight prevention to trigger.
|
# mass highlight prevention to trigger.
|
||||||
#min_length: 50
|
#min_length: 50
|
||||||
#min_nicks: 5
|
#min_nicks: 5
|
||||||
|
@ -12,7 +12,7 @@ def die(irc=None):
|
|||||||
PUNISH_OPTIONS = ['kill', 'ban', 'quiet', 'kick']
|
PUNISH_OPTIONS = ['kill', 'ban', 'quiet', 'kick']
|
||||||
EXEMPT_OPTIONS = ['voice', 'halfop', 'op']
|
EXEMPT_OPTIONS = ['voice', 'halfop', 'op']
|
||||||
DEFAULT_EXEMPT_OPTION = 'halfop'
|
DEFAULT_EXEMPT_OPTION = 'halfop'
|
||||||
def _punish(irc, target, channel, reason):
|
def _punish(irc, target, channel, punishment, reason):
|
||||||
"""Punishes the target user. This function returns True if the user was successfully punished."""
|
"""Punishes the target user. This function returns True if the user was successfully punished."""
|
||||||
if irc.is_oper(target, allowAuthed=False):
|
if irc.is_oper(target, allowAuthed=False):
|
||||||
log.debug("(%s) antispam: refusing to punish oper %s/%s", irc.name, target, irc.get_friendly_name(target))
|
log.debug("(%s) antispam: refusing to punish oper %s/%s", irc.name, target, irc.get_friendly_name(target))
|
||||||
@ -42,8 +42,6 @@ def _punish(irc, target, channel, reason):
|
|||||||
if irc.pseudoclient and not irc.has_cap('can-spawn-clients'):
|
if irc.pseudoclient and not irc.has_cap('can-spawn-clients'):
|
||||||
my_uid = irc.pseudoclient.uid
|
my_uid = irc.pseudoclient.uid
|
||||||
|
|
||||||
punishment = irc.get_service_option('antispam', 'punishment',
|
|
||||||
'kick+ban').lower()
|
|
||||||
bans = set()
|
bans = set()
|
||||||
log.debug('(%s) antispam: got %r as punishment for %s/%s', irc.name, punishment,
|
log.debug('(%s) antispam: got %r as punishment for %s/%s', irc.name, punishment,
|
||||||
target, irc.get_friendly_name(target))
|
target, irc.get_friendly_name(target))
|
||||||
@ -95,6 +93,7 @@ MASSHIGHLIGHT_DEFAULTS = {
|
|||||||
'min_length': 50,
|
'min_length': 50,
|
||||||
'min_nicks': 5,
|
'min_nicks': 5,
|
||||||
'reason': "Mass highlight spam is prohibited",
|
'reason': "Mass highlight spam is prohibited",
|
||||||
|
'punishment': 'kick+ban',
|
||||||
'enabled': False
|
'enabled': False
|
||||||
}
|
}
|
||||||
def handle_masshighlight(irc, source, command, args):
|
def handle_masshighlight(irc, source, command, args):
|
||||||
@ -147,10 +146,13 @@ def handle_masshighlight(irc, source, command, args):
|
|||||||
if word in userlist:
|
if word in userlist:
|
||||||
nicks_caught.add(word)
|
nicks_caught.add(word)
|
||||||
if len(nicks_caught) >= min_nicks:
|
if len(nicks_caught) >= min_nicks:
|
||||||
|
# Get the punishment and reason.
|
||||||
|
punishment = mhl_settings.get('punishment', MASSHIGHLIGHT_DEFAULTS['punishment']).lower()
|
||||||
reason = mhl_settings.get('reason', MASSHIGHLIGHT_DEFAULTS['reason'])
|
reason = mhl_settings.get('reason', MASSHIGHLIGHT_DEFAULTS['reason'])
|
||||||
|
|
||||||
log.debug('(%s) antispam: calling _punish on %s/%s', irc.name,
|
log.debug('(%s) antispam: calling _punish on %s/%s', irc.name,
|
||||||
source, irc.get_friendly_name(source))
|
source, irc.get_friendly_name(source))
|
||||||
punished = _punish(irc, source, channel, reason)
|
punished = _punish(irc, source, channel, punishment, reason)
|
||||||
break
|
break
|
||||||
|
|
||||||
log.debug('(%s) antispam: got %s/%s nicks on message to %r', irc.name, len(nicks_caught), min_nicks, channel)
|
log.debug('(%s) antispam: got %s/%s nicks on message to %r', irc.name, len(nicks_caught), min_nicks, channel)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user