summaryrefslogtreecommitdiffstats
path: root/lib/ASM
diff options
context:
space:
mode:
authorLibravatarJanik Kleinhoff <ilbelkyr@shalture.org>2016-02-14 02:11:51 +0000
committerLibravatarJanik Kleinhoff <ilbelkyr@shalture.org>2016-02-14 02:11:51 +0000
commit81e6f71199f062a54e6f663f48921c8d763ab4e2 (patch)
tree70788211363453a9106df6f236aaecca26cb3b96 /lib/ASM
parent2ef56bf45f2fb3726bb84773dbc692174c1fbd39 (diff)
splitflood: allow whitelisting certain regex per channel
Accessible via editing the config only; this is a feature that is probably only useful to a handful of channels.
Diffstat (limited to 'lib/ASM')
-rw-r--r--lib/ASM/Classes.pm24
-rw-r--r--lib/ASM/Util.pm9
2 files changed, 33 insertions, 0 deletions
diff --git a/lib/ASM/Classes.pm b/lib/ASM/Classes.pm
index 8a0b36a..bee81e1 100644
--- a/lib/ASM/Classes.pm
+++ b/lib/ASM/Classes.pm
@@ -300,8 +300,14 @@ sub nickspam {
my %cf=();
my %bs=();
my $cfc = 0;
+my %fpo_seen;
sub process_cf
{
+ for my $fpoid (values %fpo_seen) {
+ for my $fptext (keys %$fpoid) {
+ delete $fpoid->{$fptext} if $fpoid->{$fptext} <= time;
+ }
+ }
foreach my $nid ( keys %cf ) {
foreach my $xchan ( keys %{$cf{$nid}} ) {
next if $xchan eq 'timeout';
@@ -321,6 +327,22 @@ sub process_cf
}
}
+# this is a mess, sorry about that
+sub fpo {
+ my ($chan, $nick, $text, $how_long) = @_;
+
+ return undef unless ASM::Util->isFloodedPhraseOK($chan, $text);
+
+ my $okay = 0;
+
+ if ( ( $fpo_seen{$chan}{ $::sn{$nick}{host} }{$text} // 0 ) <= time) {
+ $okay = 1;
+ }
+
+ $fpo_seen{$chan}{ $::sn{$nick}{host} }{$text} = time + $how_long;
+ return $okay;
+}
+
sub splitflood {
my ($chk, $id, $event, $chan) = @_;
my $text;
@@ -337,6 +359,7 @@ sub splitflood {
my $msgtime = $::sc{$chan}{users}{$nick}{msgtime} // 0;
$msgtime ||= 1 if !$::sc{$chan}{users}{$nick}{jointime};
return if $text =~ /^[^\w\s]+\w+\s*$/ && $msgtime && ($msgtime + $cf{$id}{timeout}) < time;
+ return if fpo($chan, $nick, $text, 2 * int($cut[1]));
# return unless length($text) >= 10;
if (defined($bs{$id}{$text}) && (time <= $bs{$id}{$text} + 600)) {
return 1;
@@ -367,6 +390,7 @@ sub advsplitflood {
$text=$event->{args}->[0];
}
return unless defined($text);
+ return if fpo($chan, lc $event->{nick}, $text, 3 * int($cut[1]));
$text=~s/^\d*(.*)\d*$/$1/;
return unless length($text) >= 10;
if (defined($bs{$id}{$text}) && (time <= $bs{$id}{$text} + 600)) {
diff --git a/lib/ASM/Util.pm b/lib/ASM/Util.pm
index 6372037..4b0137d 100644
--- a/lib/ASM/Util.pm
+++ b/lib/ASM/Util.pm
@@ -131,6 +131,15 @@ sub mayAlert {
return !( ($::channels->{channel}{lc $chan}{monitor} // 'yes') eq 'no' || $module->isSuppressed($chan) );
}
+sub isFloodedPhraseOK {
+ my ($module, $chan, $text) = @_;
+
+ return undef unless exists $::channels->{channel}{$chan}{floodedphraseok};
+ my $exempt_regex = $::channels->{channel}{$chan}{floodedphraseok};
+
+ return $text =~ $exempt_regex;
+}
+
#this item is a stub, dur
sub hostip {
return gethostbyname($_[0]);