aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Phillips <david@yeah.nah.nz>2019-02-23 06:33:22 +1300
committerDavid Phillips <david@yeah.nah.nz>2019-02-23 06:33:22 +1300
commitbd5a3db4a5d2b4ef6399593176e2e40b8a534f51 (patch)
tree4f25be4eddcf127c52738daa6ea9181de7ce3f74
parent19e26ac7fb21a16761859553487df0148b7f2914 (diff)
downloadidalius-bd5a3db4a5d2b4ef6399593176e2e40b8a534f51.tar.xz
Hmm: Add line-count cool-off
-rw-r--r--Plugin/Hmm.pm7
1 files changed, 7 insertions, 0 deletions
diff --git a/Plugin/Hmm.pm b/Plugin/Hmm.pm
index e3909a0..7f5814a 100644
--- a/Plugin/Hmm.pm
+++ b/Plugin/Hmm.pm
@@ -6,6 +6,7 @@ use warnings;
my $root_config;
my $config;
my %current_alarm;
+my %lines_since;
sub configure {
my $self = shift;
@@ -16,6 +17,7 @@ sub configure {
IdaliusConfig::assert_scalar($config, $self, "min_delay_sec");
IdaliusConfig::assert_scalar($config, $self, "max_delay_sec");
+ IdaliusConfig::assert_scalar($config, $self, "lines_break");
return $self;
}
@@ -34,6 +36,9 @@ sub on_message {
return if ref($where) ne "ARRAY";
$where = $where->[0];
+ # Require some minimum number of lines in a channel before hmming again
+ return unless $lines_since{$where}++ >= $config->{lines_break};
+
if (defined $current_alarm{$where}) {
$irc->delay_remove($current_alarm{$where});
}
@@ -43,6 +48,8 @@ sub on_message {
$current_alarm{$where} = $irc->delay([privmsg => $where => $response],
$config->{min_delay_sec} + rand($config->{max_delay_sec} - $config->{min_delay_sec}));
+ $lines_since{$where} = 0;
+
return;
}