summaryrefslogtreecommitdiffstats
path: root/lib/ASM/Commander.pm
diff options
context:
space:
mode:
authorLibravatarJanik Kleinhoff <ilbelkyr@shalture.org>2016-10-07 23:10:11 +0000
committerLibravatarJanik Kleinhoff <ilbelkyr@shalture.org>2016-10-07 23:16:13 +0000
commit546df459147cf5842724d88428794eaf296cb879 (patch)
tree4101e0d7bc407e2d35dc2aaabea2aa99b051228f /lib/ASM/Commander.pm
parente29b1456c06576b607fd255f5da34a3cc3e97ca2 (diff)
Avoid !ops restriction messages silencing alerts
This fixes T9. It's not a particularly nice fix, and the code surrounding this could really use some cleanup, but it works. ASM::Commander did not return a true value explicitly so we have to do that as well. It's a coincidence that it worked until now ...
Diffstat (limited to 'lib/ASM/Commander.pm')
-rw-r--r--lib/ASM/Commander.pm19
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/ASM/Commander.pm b/lib/ASM/Commander.pm
index 91fa311..c2012d3 100644
--- a/lib/ASM/Commander.pm
+++ b/lib/ASM/Commander.pm
@@ -868,6 +868,8 @@ sub cmd_restrict {
ASM::Config->writeRestrictions();
}
+my %ops_ignored;
+
sub cmd_ops {
my ($conn, $event) = @_;
@@ -920,21 +922,31 @@ sub cmd_ops {
my $txtz = "[\x02$tgt\x02] - $event->{nick} wants op attention";
if ((time-$::sc{$tgt}{users}{$nick}{jointime}) > 90) {
$txtz .= " ($msg) $hilite !att-$tgt-opalert";
+ $::ignored{$tgt} = $::RISKS{'opalert'};
+ $conn->schedule(45, sub { delete($::ignored{$tgt}) if $::ignored{$tgt} == $::RISKS{'opalert'} });
+ }
+ elsif ($ops_ignored{$tgt}) {
+ return;
+ }
+ else {
+ $ops_ignored{$tgt} = 1;
+ $conn->schedule(45, sub { delete $ops_ignored{$tgt} });
}
my $uuid = $::log->incident($tgt, "$tgt: $event->{nick} requested op attention\n");
$txtz = $txtz . ' ' . ASM::Shortener->shorturl($::settings->{web}->{detectdir} . $uuid . '.txt');
my @tgts = ASM::Util->getAlert($tgt, 'opalert', 'msgs');
ASM::Util->sendLongMsg($conn, \@tgts, $txtz);
} else {
- unless (defined($::ignored{$tgt}) && ($::ignored{$tgt} >= $::RISKS{'opalert'})) {
+ unless (defined($::ignored{$tgt}) && ($::ignored{$tgt} >= $::RISKS{'opalert'})
+ or $ops_ignored{$tgt}) {
my @tgts = ASM::Util->getAlert($tgt, 'opalert', 'msgs');
foreach my $chan (@tgts) {
$conn->privmsg($chan, $event->{nick} . " tried to use the ops trigger for $tgt but is restricted from doing so.");
}
+ $ops_ignored{$tgt} = 1;
+ $conn->schedule(45, sub { delete $ops_ignored{$tgt} });
}
}
- $::ignored{$tgt} = $::RISKS{'opalert'};
- $conn->schedule(45, sub { delete($::ignored{$tgt}) if $::ignored{$tgt} == $::RISKS{'opalert'} });
}
sub cmd_blacklist {
@@ -1044,4 +1056,5 @@ sub cmd_version {
$conn->privmsg($event->replyto, $::version);
}
+1;
# vim: ts=8:sts=8:sw=8:noexpandtab