summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatarDoug Freed <dwfreed@mtu.edu>2015-03-01 05:56:36 +0400
committerLibravatarJanik Kleinhoff <janik@kleinhoff.de>2015-03-01 05:56:36 +0400
commitadac91d1edcc84edac13e90a2016ae3b8bb1e87f (patch)
tree668ca1b9f468a67122a97936770e0f7572d3c9ca
parentb405bba0c0ea2136d0e21bce5eef0b0fce59787f (diff)
Make !ops respect monitor flag; fix alert rate limiting bug
-rw-r--r--config-default/commands.xml89
-rw-r--r--modules/inspect.pl4
2 files changed, 49 insertions, 44 deletions
diff --git a/config-default/commands.xml b/config-default/commands.xml
index 6589458..6828438 100644
--- a/config-default/commands.xml
+++ b/config-default/commands.xml
@@ -529,44 +529,14 @@
$tgt = lc $1 if (defined($1));
my $msg = $1;
$msg = $2 if defined($2);
- if (ASM::Util->notRestricted(lc $event->{nick}, "noops")) {
- my $tgt = lc $event->{to}->[0];
- $tgt = lc $1 if (defined($1));
- my $msg = $1;
- $msg = $2 if defined($2);
- unless (lc $tgt ~~ $::sn{lc $event->{nick}}->{mship}) {
- return; #they're not on the channel they're calling !ops for
- }
- unless (defined($::ignored{$tgt}) && ($::ignored{$tgt} >= $::RISKS{'opalert'})) {
- if (lc $event->{to}->[0] eq '##linux') {
- $conn->privmsg($event->{nick}, "I've summoned op attention. In the future, please use /msg " .
- "$conn->{_nick} !ops $event->{to}->[0] reasonGoesHere - this allows ops to " .
- "be notified while minimizing channel hostility.");
- } elsif ((lc $event->{to}->[0] eq '#wikipedia-en-help') && (!defined($msg))) {
- $conn->privmsg($event->{nick}, "I've summoned op attention, but in the future, please specify " .
- "a reason, e.g. !ops reasongoeshere - so ops know what is going on. Thanks! :)");
- } elsif (lc $event->{to}->[0] eq lc $conn->{_nick}) {
- if (lc $tgt eq lc $conn->{_nick}) { # they privmsged the bot without providing a target
- $conn->privmsg($event->{nick}, "Sorry, it looks like you've tried to use the !ops command " .
- "via PM but haven't specified a target. Try again with /msg $conn->{_nick} " .
- "!ops #channelGoesHere ReasonGoesHere");
- return;
- } else {
- $conn->privmsg($event->{nick}, "Thanks, I'm notifying $tgt ops.");
- }
- }
- $::ignored{$tgt} = $::RISKS{'opalert'};
- $conn->schedule(30, sub { delete($::ignored{$tgt})});
- my $hilite=ASM::Util->commaAndify(ASM::Util->getAlert($tgt, 'opalert', 'hilights'));
- my $txtz = "[\x02$tgt\x02] - $event->{nick} wants op attention";
- if ((time-$::sc{$tgt}{users}{lc $event->{nick}}{jointime}) > 90) {
-# return; #they've been on the channel for less than 90 seconds, probably nuisance botspam
- $txtz = "$txtz ($msg) $hilite !att-$tgt-opalert";
- }
- my @tgts = ASM::Util->getAlert($tgt, 'opalert', 'msgs');
- ASM::Util->sendLongMsg($conn, \@tgts, $txtz);
- $::log->incident($tgt, "$tgt: $event->{nick} requested op attention\n");
- } else { # ops has recently been called
+ if ((defined($::channels->{channel}->{$tgt}->{monitor})) and ($::channels->{channel}->{$tgt}->{monitor} eq "no")) {
+ return;
+ }
+ unless (lc $tgt ~~ $::sn{lc $event->{nick}}->{mship}) {
+ return; #they're not on the channel they're calling !ops for
+ }
+ if (defined($::ignored{$tgt}) && ($::ignored{$tgt} >= $::RISKS{'opalert'})) {
+ if (ASM::Util->notRestricted(lc $event->{nick}, "noops")) {
if (lc $event->{to}->[0] eq '##linux') {
$conn->privmsg($event->{nick}, "I've already been recently asked to summon op attention. " .
"In the future, please use /msg $conn->{_nick} !ops $event->{to}->[0] reasonGoesHere" .
@@ -576,19 +546,54 @@
$conn->privmsg($event->{nick}, "Sorry, it looks like you've tried to use the !ops command " .
"via PM but haven't specified a target. Try again with /msg $conn->{_nick} " .
"!ops #channelGoesHere ReasonGoesHere");
- return;
} else {
$conn->privmsg($event->{nick}, "I've already recently notified $tgt ops.");
}
}
}
+ return;
}
- else {
+ if (ASM::Util->notRestricted(lc $event->{nick}, "noops")) {
+ my $tgt = lc $event->{to}->[0];
+ $tgt = lc $1 if (defined($1));
+ my $msg = $1;
+ $msg = $2 if defined($2);
+ if (lc $event->{to}->[0] eq '##linux') {
+ $conn->privmsg($event->{nick}, "I've summoned op attention. In the future, please use /msg " .
+ "$conn->{_nick} !ops $event->{to}->[0] reasonGoesHere - this allows ops to " .
+ "be notified while minimizing channel hostility.");
+ } elsif ((lc $event->{to}->[0] eq '#wikipedia-en-help') && (!defined($msg))) {
+ $conn->privmsg($event->{nick}, "I've summoned op attention, but in the future, please specify " .
+ "a reason, e.g. !ops reasongoeshere - so ops know what is going on. Thanks! :)");
+ } elsif (lc $event->{to}->[0] eq lc $conn->{_nick}) {
+ if (lc $tgt eq lc $conn->{_nick}) { # they privmsged the bot without providing a target
+ $conn->privmsg($event->{nick}, "Sorry, it looks like you've tried to use the !ops command " .
+ "via PM but haven't specified a target. Try again with /msg $conn->{_nick} " .
+ "!ops #channelGoesHere ReasonGoesHere");
+ return;
+ } else {
+ $conn->privmsg($event->{nick}, "Thanks, I'm notifying $tgt ops.");
+ }
+ }
+ my $hilite=ASM::Util->commaAndify(ASM::Util->getAlert($tgt, 'opalert', 'hilights'));
+ my $txtz = "[\x02$tgt\x02] - $event->{nick} wants op attention";
+ if ((time-$::sc{$tgt}{users}{lc $event->{nick}}{jointime}) > 90) {
+# return; #they've been on the channel for less than 90 seconds, probably nuisance botspam
+ $txtz = "$txtz ($msg) $hilite !att-$tgt-opalert";
+ }
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.");
+ ASM::Util->sendLongMsg($conn, \@tgts, $txtz);
+ $::log->incident($tgt, "$tgt: $event->{nick} requested op attention\n");
+ } else {
+ unless (defined($::ignored{$tgt}) && ($::ignored{$tgt} >= $::RISKS{'opalert'})) {
+ 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.");
+ }
}
}
+ $::ignored{$tgt} = $::RISKS{'opalert'};
+ $conn->schedule(45, sub { delete($::ignored{$tgt}) if $::ignored{$tgt} == $::RISKS{'opalert'} });
]]>
</command>
<command cmd="^;blacklist (.*)" flag="s">
diff --git a/modules/inspect.pl b/modules/inspect.pl
index afaba44..c64a855 100644
--- a/modules/inspect.pl
+++ b/modules/inspect.pl
@@ -86,10 +86,10 @@ sub inspect {
) {
my @tgts = ASM::Util->getAlert($chan, $dct{$id}{risk}, 'msgs');
ASM::Util->sendLongMsg($conn, \@tgts, $txtz);
- $conn->schedule(45, sub { delete($::ignored{$chan})}) unless defined($::ignored{$chan});
+ $conn->schedule(45, sub { delete($::ignored{$chan}) if $::ignored{$chan} == $::RISKS{$dct{$id}{risk}} });
$::ignored{$chan} = $::RISKS{$dct{$id}{risk}};
}
-# $::log->incident($chan, "$chan: $dct{$id}{risk} risk: $event->{nick} - $nicereason\n");
+ $::log->incident($chan, "$chan: $dct{$id}{risk} risk: $event->{nick} - $nicereason\n");
delete $dct{$id}{xresult};
}
}