mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-29 23:39:24 +01:00
ChanOpCommands: unban *
and unmute *
now clears banlists; clean-up output of ban
and mute
with multiple targets
This commit is contained in:
parent
d11cfa8362
commit
04585d3ae1
@ -57,11 +57,8 @@ sub dumpbans {
|
|||||||
sub get_banlist {
|
sub get_banlist {
|
||||||
my ($self, $event_type, $event) = @_;
|
my ($self, $event_type, $event) = @_;
|
||||||
my $channel = lc $event->{event}->{args}[1];
|
my $channel = lc $event->{event}->{args}[1];
|
||||||
|
|
||||||
return 0 if not $self->{pbot}->{chanops}->can_gain_ops($channel);
|
return 0 if not $self->{pbot}->{chanops}->can_gain_ops($channel);
|
||||||
|
|
||||||
delete $self->{banlist}->{$channel};
|
delete $self->{banlist}->{$channel};
|
||||||
|
|
||||||
$self->{pbot}->{logger}->log("Retrieving banlist for $channel.\n");
|
$self->{pbot}->{logger}->log("Retrieving banlist for $channel.\n");
|
||||||
$event->{conn}->sl("mode $channel +bq");
|
$event->{conn}->sl("mode $channel +bq");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -241,7 +241,7 @@ sub mode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
my ($channel, $modes, $args) = $self->{pbot}->{interpreter}->split_args($stuff->{arglist}, 3);
|
my ($channel, $modes, $args) = $self->{pbot}->{interpreter}->split_args($stuff->{arglist}, 3);
|
||||||
my @targets = split /\s+/, $args;
|
my @targets = split /\s+/, $args if defined $args;
|
||||||
my $modifier;
|
my $modifier;
|
||||||
my $i = 0;
|
my $i = 0;
|
||||||
my $arg = 0;
|
my $arg = 0;
|
||||||
@ -402,32 +402,31 @@ sub ban_user {
|
|||||||
my $sep = '';
|
my $sep = '';
|
||||||
my @targets = split /,/, $target;
|
my @targets = split /,/, $target;
|
||||||
my $immediately = @targets > 1 ? 0 : 1;
|
my $immediately = @targets > 1 ? 0 : 1;
|
||||||
|
my $duration;
|
||||||
foreach my $t (@targets) {
|
foreach my $t (@targets) {
|
||||||
my $mask = lc $self->{pbot}->{chanops}->nick_to_banmask($t);
|
my $mask = lc $self->{pbot}->{chanops}->nick_to_banmask($t);
|
||||||
|
|
||||||
if ($no_length && exists $self->{pbot}->{chanops}->{unban_timeout}->{hash}->{$channel}
|
if ($no_length && exists $self->{pbot}->{chanops}->{unban_timeout}->{hash}->{$channel}
|
||||||
&& exists $self->{pbot}->{chanops}->{unban_timeout}->{hash}->{$channel}->{$mask}) {
|
&& exists $self->{pbot}->{chanops}->{unban_timeout}->{hash}->{$channel}->{$mask}) {
|
||||||
my $timeout = $self->{pbot}->{chanops}->{unban_timeout}->{hash}->{$channel}->{$mask}->{timeout};
|
my $timeout = $self->{pbot}->{chanops}->{unban_timeout}->{hash}->{$channel}->{$mask}->{timeout};
|
||||||
my $duration = duration($timeout - gettimeofday);
|
my $d = duration($timeout - gettimeofday);
|
||||||
|
$result .= "$sep$mask has $d remaining on their $channel ban";
|
||||||
$result .= "$sep$mask has $duration remaining on their $channel ban";
|
|
||||||
$sep = '; ';
|
$sep = '; ';
|
||||||
} else {
|
} else {
|
||||||
$self->{pbot}->{chanops}->ban_user_timed("$nick!$user\@$host", undef, $mask, $channel, $length, $immediately);
|
$self->{pbot}->{chanops}->ban_user_timed("$nick!$user\@$host", undef, $mask, $channel, $length, $immediately);
|
||||||
|
$duration = $length > 0 ? duration $length : 'all eternity';
|
||||||
my $duration;
|
if ($immediately) {
|
||||||
if ($length > 0) {
|
|
||||||
$duration = duration($length);
|
|
||||||
} else {
|
|
||||||
$duration = 'all eternity';
|
|
||||||
}
|
|
||||||
|
|
||||||
$result .= "$sep$mask banned in $channel for $duration";
|
$result .= "$sep$mask banned in $channel for $duration";
|
||||||
$sep = '; ';
|
$sep = '; ';
|
||||||
|
} else {
|
||||||
|
$result .= "$sep$mask";
|
||||||
|
$sep = ', ';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (not $immediately) {
|
if (not $immediately) {
|
||||||
|
$result .= " banned in $channel for $duration";
|
||||||
$self->{pbot}->{chanops}->check_ban_queue;
|
$self->{pbot}->{chanops}->check_ban_queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -465,13 +464,21 @@ sub unban_user {
|
|||||||
$immediately = 0 if @targets > 1;
|
$immediately = 0 if @targets > 1;
|
||||||
|
|
||||||
foreach my $t (@targets) {
|
foreach my $t (@targets) {
|
||||||
|
if ($t eq '*') {
|
||||||
|
$channel = lc $channel;
|
||||||
|
if (exists $self->{pbot}->{bantracker}->{banlist}->{$channel} && exists $self->{pbot}->{bantracker}->{banlist}->{$channel}->{'+b'}) {
|
||||||
|
$immediately = 0;
|
||||||
|
foreach my $banmask (keys %{ $self->{pbot}->{bantracker}->{banlist}->{$channel}->{'+b'} }) {
|
||||||
|
$self->{pbot}->{chanops}->unban_user($banmask, $channel, $immediately);
|
||||||
|
}
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
$self->{pbot}->{chanops}->unban_user($t, $channel, $immediately);
|
$self->{pbot}->{chanops}->unban_user($t, $channel, $immediately);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (@targets > 1) {
|
|
||||||
$self->{pbot}->{chanops}->check_unban_queue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$self->{pbot}->{chanops}->check_unban_queue if not $immediately;
|
||||||
return "/msg $nick $target has been unbanned from $channel.";
|
return "/msg $nick $target has been unbanned from $channel.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -525,32 +532,31 @@ sub mute_user {
|
|||||||
my $sep = '';
|
my $sep = '';
|
||||||
my @targets = split /,/, $target;
|
my @targets = split /,/, $target;
|
||||||
my $immediately = @targets > 1 ? 0 : 1;
|
my $immediately = @targets > 1 ? 0 : 1;
|
||||||
|
my $duration;
|
||||||
foreach my $t (@targets) {
|
foreach my $t (@targets) {
|
||||||
my $mask = lc $self->{pbot}->{chanops}->nick_to_banmask($t);
|
my $mask = lc $self->{pbot}->{chanops}->nick_to_banmask($t);
|
||||||
|
|
||||||
if ($no_length && exists $self->{pbot}->{chanops}->{unmute_timeout}->{hash}->{$channel}
|
if ($no_length && exists $self->{pbot}->{chanops}->{unmute_timeout}->{hash}->{$channel}
|
||||||
&& exists $self->{pbot}->{chanops}->{unmute_timeout}->{hash}->{$channel}->{$mask}) {
|
&& exists $self->{pbot}->{chanops}->{unmute_timeout}->{hash}->{$channel}->{$mask}) {
|
||||||
my $timeout = $self->{pbot}->{chanops}->{unmute_timeout}->{hash}->{$channel}->{$mask}->{timeout};
|
my $timeout = $self->{pbot}->{chanops}->{unmute_timeout}->{hash}->{$channel}->{$mask}->{timeout};
|
||||||
my $duration = duration($timeout - gettimeofday);
|
my $d = duration($timeout - gettimeofday);
|
||||||
|
$result .= "$sep$mask has $d remaining on their $channel mute";
|
||||||
$result .= "$sep$mask has $duration remaining on their $channel mute";
|
|
||||||
$sep = '; ';
|
$sep = '; ';
|
||||||
} else {
|
} else {
|
||||||
$self->{pbot}->{chanops}->mute_user_timed("$nick!$user\@$host", undef, $t, $channel, $length, $immediately);
|
$self->{pbot}->{chanops}->mute_user_timed("$nick!$user\@$host", undef, $t, $channel, $length, $immediately);
|
||||||
|
$duration = $length > 0 ? duration $length : 'all eternity';
|
||||||
my $duration;
|
if ($immediately) {
|
||||||
if ($length > 0) {
|
|
||||||
$duration = duration($length);
|
|
||||||
} else {
|
|
||||||
$duration = 'all eternity';
|
|
||||||
}
|
|
||||||
|
|
||||||
$result .= "$sep$mask muted in $channel for $duration";
|
$result .= "$sep$mask muted in $channel for $duration";
|
||||||
$sep = '; ';
|
$sep = '; ';
|
||||||
|
} else {
|
||||||
|
$result .= "$sep$mask";
|
||||||
|
$sep = ', ';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (not $immediately) {
|
if (not $immediately) {
|
||||||
|
$result .= " muted in $channel for $duration";
|
||||||
$self->{pbot}->{chanops}->check_ban_queue;
|
$self->{pbot}->{chanops}->check_ban_queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -588,13 +594,21 @@ sub unmute_user {
|
|||||||
$immediately = 0 if @targets > 1;
|
$immediately = 0 if @targets > 1;
|
||||||
|
|
||||||
foreach my $t (@targets) {
|
foreach my $t (@targets) {
|
||||||
|
if ($t eq '*') {
|
||||||
|
$channel = lc $channel;
|
||||||
|
if (exists $self->{pbot}->{bantracker}->{banlist}->{$channel} && exists $self->{pbot}->{bantracker}->{banlist}->{$channel}->{'+q'}) {
|
||||||
|
$immediately = 0;
|
||||||
|
foreach my $banmask (keys %{ $self->{pbot}->{bantracker}->{banlist}->{$channel}->{'+q'} }) {
|
||||||
|
$self->{pbot}->{chanops}->unmute_user($banmask, $channel, $immediately);
|
||||||
|
}
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
$self->{pbot}->{chanops}->unmute_user($t, $channel, $immediately);
|
$self->{pbot}->{chanops}->unmute_user($t, $channel, $immediately);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (@targets > 1) {
|
|
||||||
$self->{pbot}->{chanops}->check_unban_queue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$self->{pbot}->{chanops}->check_unban_queue if not $immediately;
|
||||||
return "/msg $nick $target has been unmuted in $channel.";
|
return "/msg $nick $target has been unmuted in $channel.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user