mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-27 21:19:31 +01:00
antispam: add a "block" verb, and make textfilter use it by default
Closes #616.
This commit is contained in:
parent
de62b2e77a
commit
ebf7443d97
@ -846,8 +846,8 @@ stats:
|
|||||||
#enabled: true
|
#enabled: true
|
||||||
|
|
||||||
# Sets the punishment that Antispam should use against mass highlighters.
|
# Sets the punishment that Antispam should use against mass highlighters.
|
||||||
# Valid values include "kill", "kick", "ban", "quiet", and combinations of these strung
|
# Valid values include "kill", "kick", "ban", "quiet", "block", and combinations of these
|
||||||
# together with "+" (e.g. "kick+ban"). Defaults to "kick+ban" if not set.
|
# strung together with "+" (e.g. "kick+ban"). Defaults to "kick+ban" if not set.
|
||||||
#punishment: kick+ban
|
#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.
|
||||||
@ -868,10 +868,10 @@ stats:
|
|||||||
|
|
||||||
# Sets the punishment that Antispam's text spamfilter should use.
|
# Sets the punishment that Antispam's text spamfilter should use.
|
||||||
# Valid values include "kill", "kick", "ban", "quiet", and combinations of these strung
|
# 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.
|
# together with "+" (e.g. "kick+ban"). Defaults to "kick+ban+block" if not set.
|
||||||
# If you want Antispam to also monitor PM spam, you will want to change this to something
|
# If you want Antispam to also monitor PM spam, you will want to change this to something
|
||||||
# not channel-specific (such as "kill").
|
# not channel-specific (such as "kill" or "block").
|
||||||
#punishment: kick+ban
|
#punishment: kick+ban+block
|
||||||
|
|
||||||
# Sets the kick / kill message used when the text spamfilter is triggered.
|
# Sets the kick / kill message used when the text spamfilter is triggered.
|
||||||
#reason: "Spam is prohibited"
|
#reason: "Spam is prohibited"
|
||||||
|
@ -11,7 +11,7 @@ sbot = utils.register_service("antispam", default_nick="AntiSpam", desc=mydesc)
|
|||||||
def die(irc=None):
|
def die(irc=None):
|
||||||
utils.unregister_service("antispam")
|
utils.unregister_service("antispam")
|
||||||
|
|
||||||
PUNISH_OPTIONS = ['kill', 'ban', 'quiet', 'kick']
|
PUNISH_OPTIONS = ['kill', 'ban', 'quiet', 'kick', 'block']
|
||||||
EXEMPT_OPTIONS = ['voice', 'halfop', 'op']
|
EXEMPT_OPTIONS = ['voice', 'halfop', 'op']
|
||||||
DEFAULT_EXEMPT_OPTION = 'halfop'
|
DEFAULT_EXEMPT_OPTION = 'halfop'
|
||||||
def _punish(irc, target, channel, punishment, reason):
|
def _punish(irc, target, channel, punishment, reason):
|
||||||
@ -81,6 +81,9 @@ def _punish(irc, target, channel, punishment, reason):
|
|||||||
'these joined together with a "+".',
|
'these joined together with a "+".',
|
||||||
irc.name, punishment, ', '.join(PUNISH_OPTIONS))
|
irc.name, punishment, ', '.join(PUNISH_OPTIONS))
|
||||||
return
|
return
|
||||||
|
elif action == 'block':
|
||||||
|
# We only need to increment this for this function to return True
|
||||||
|
successful_punishments += 1
|
||||||
elif action == 'kill':
|
elif action == 'kill':
|
||||||
kill = True # Delay kills so that the user data doesn't disappear.
|
kill = True # Delay kills so that the user data doesn't disappear.
|
||||||
# XXX factorize these blocks
|
# XXX factorize these blocks
|
||||||
@ -122,6 +125,10 @@ def _punish(irc, target, channel, punishment, reason):
|
|||||||
else:
|
else:
|
||||||
successful_punishments += 1
|
successful_punishments += 1
|
||||||
|
|
||||||
|
if not successful_punishments:
|
||||||
|
log.warning('(%s) antispam: Failed to punish %s with %r, target was %s', irc.name,
|
||||||
|
target_nick, punishment, channel or 'a PM')
|
||||||
|
|
||||||
return bool(successful_punishments)
|
return bool(successful_punishments)
|
||||||
|
|
||||||
MASSHIGHLIGHT_DEFAULTS = {
|
MASSHIGHLIGHT_DEFAULTS = {
|
||||||
@ -204,7 +211,7 @@ utils.add_hook(handle_masshighlight, 'NOTICE', priority=1000)
|
|||||||
|
|
||||||
TEXTFILTER_DEFAULTS = {
|
TEXTFILTER_DEFAULTS = {
|
||||||
'reason': "Spam is prohibited",
|
'reason': "Spam is prohibited",
|
||||||
'punishment': 'kick+ban',
|
'punishment': 'kick+ban+block',
|
||||||
'watch_pms': 'false',
|
'watch_pms': 'false',
|
||||||
'enabled': False
|
'enabled': False
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user