mirror of https://github.com/pragma-/pbot.git
ChanOpCommands: `mode` now skips existing modes when used with wildcard; unsetting modes via wildcard now skips admins/whitelisted users
This commit is contained in:
parent
a255ea1b1b
commit
2a6f98c02d
|
@ -110,6 +110,7 @@ sub mode {
|
||||||
my $target = $targets[$arg++] // "";
|
my $target = $targets[$arg++] // "";
|
||||||
|
|
||||||
if (($mode eq 'v' or $mode eq 'o') and $target =~ m/\*/) {
|
if (($mode eq 'v' or $mode eq 'o') and $target =~ m/\*/) {
|
||||||
|
# wildcard used; find all matching nicks; test against whitelist, etc
|
||||||
my $q_target = lc quotemeta $target;
|
my $q_target = lc quotemeta $target;
|
||||||
$q_target =~ s/\\\*/.*/g;
|
$q_target =~ s/\\\*/.*/g;
|
||||||
$channel = lc $channel;
|
$channel = lc $channel;
|
||||||
|
@ -120,6 +121,22 @@ sub mode {
|
||||||
|
|
||||||
foreach my $n (keys %{$self->{pbot}->{nicklist}->{nicklist}->{$channel}}) {
|
foreach my $n (keys %{$self->{pbot}->{nicklist}->{nicklist}->{$channel}}) {
|
||||||
if ($n =~ m/^$q_target$/) {
|
if ($n =~ m/^$q_target$/) {
|
||||||
|
my $nick_data = $self->{pbot}->{nicklist}->{nicklist}->{$channel}->{$n};
|
||||||
|
|
||||||
|
if ($modifier eq '-') {
|
||||||
|
# removing mode -- check against whitelist, etc
|
||||||
|
next if $n eq $self->{pbot}->{registry}->get_value('irc', 'botnick');
|
||||||
|
next if $self->{pbot}->{antiflood}->whitelisted($channel, $nick_data->{hostmask});
|
||||||
|
next if $self->{pbot}->{admins}->loggedin($channel, $nick_data->{hostmask});
|
||||||
|
}
|
||||||
|
|
||||||
|
# skip nick if already has mode set/unset
|
||||||
|
if ($modifier eq '+') {
|
||||||
|
next if exists $nick_data->{"+$mode"};
|
||||||
|
} else {
|
||||||
|
next unless exists $nick_data->{"+$mode"};
|
||||||
|
}
|
||||||
|
|
||||||
$new_modes = $modifier if not length $new_modes;
|
$new_modes = $modifier if not length $new_modes;
|
||||||
$new_modes .= $mode;
|
$new_modes .= $mode;
|
||||||
$new_targets .= "$self->{pbot}->{nicklist}->{nicklist}->{$channel}->{$n}->{nick} ";
|
$new_targets .= "$self->{pbot}->{nicklist}->{nicklist}->{$channel}->{$n}->{nick} ";
|
||||||
|
@ -134,6 +151,7 @@ sub mode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
# no wildcard used; explicit mode requested - no whitelist checking
|
||||||
$new_modes .= $mode;
|
$new_modes .= $mode;
|
||||||
$new_targets .= "$target " if length $target;
|
$new_targets .= "$target " if length $target;
|
||||||
$i++;
|
$i++;
|
||||||
|
|
Loading…
Reference in New Issue