mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-26 13:59:47 +01:00
Improve output of blacklist and ignorelist commands
This commit is contained in:
parent
3e88db4505
commit
be47b2cbf2
@ -161,12 +161,16 @@ sub blacklist {
|
|||||||
when($_ eq "list" or $_ eq "show") {
|
when($_ eq "list" or $_ eq "show") {
|
||||||
my $text = "Blacklist:\n";
|
my $text = "Blacklist:\n";
|
||||||
my $entries = 0;
|
my $entries = 0;
|
||||||
foreach my $channel (keys %{ $self->{blacklist} }) {
|
foreach my $channel (sort keys %{ $self->{blacklist} }) {
|
||||||
|
if ($channel eq '.*') {
|
||||||
|
$text .= " all channels:\n";
|
||||||
|
} else {
|
||||||
$text .= " $channel:\n";
|
$text .= " $channel:\n";
|
||||||
foreach my $mask (keys %{ $self->{blacklist}->{$channel} }) {
|
}
|
||||||
$text .= " $mask,\n";
|
foreach my $mask (sort keys %{ $self->{blacklist}->{$channel} }) {
|
||||||
$entries++;
|
$text .= " $mask,\n";
|
||||||
}
|
$entries++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$text .= "none" if $entries == 0;
|
$text .= "none" if $entries == 0;
|
||||||
return $text;
|
return $text;
|
||||||
|
@ -44,7 +44,7 @@ sub add {
|
|||||||
my $self = shift;
|
my $self = shift;
|
||||||
my ($hostmask, $channel, $length) = @_;
|
my ($hostmask, $channel, $length) = @_;
|
||||||
|
|
||||||
if($length == -1) {
|
if($length < 0) {
|
||||||
$self->{ignore_list}->{$hostmask}->{$channel} = -1;
|
$self->{ignore_list}->{$hostmask}->{$channel} = -1;
|
||||||
} else {
|
} else {
|
||||||
$self->{ignore_list}->{$hostmask}->{$channel} = gettimeofday + $length;
|
$self->{ignore_list}->{$hostmask}->{$channel} = gettimeofday + $length;
|
||||||
|
@ -9,6 +9,7 @@ use warnings;
|
|||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
use Time::HiRes qw(gettimeofday);
|
use Time::HiRes qw(gettimeofday);
|
||||||
|
use Time::Duration;
|
||||||
use Carp ();
|
use Carp ();
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
@ -53,9 +54,9 @@ sub ignore_user {
|
|||||||
my $text = "Ignored: ";
|
my $text = "Ignored: ";
|
||||||
my $sep = "";
|
my $sep = "";
|
||||||
|
|
||||||
foreach my $ignored (keys %{ $self->{pbot}->{ignorelist}->{ignore_list} }) {
|
foreach my $ignored (sort keys %{ $self->{pbot}->{ignorelist}->{ignore_list} }) {
|
||||||
foreach my $channel (keys %{ ${ $self->{pbot}->{ignorelist}->{ignore_list} }{$ignored} }) {
|
foreach my $channel (sort keys %{ ${ $self->{pbot}->{ignorelist}->{ignore_list} }{$ignored} }) {
|
||||||
$text .= $sep . "[$ignored]->[$channel]->[" . (${ $self->{pbot}->{ignorelist}->{ignore_list} }{$ignored}{$channel} == -1 ? -1 : int(gettimeofday - ${ $self->{pbot}->{ignorelist}->{ignore_list} }{$ignored}{$channel})) . "]";
|
$text .= $sep . "$ignored [$channel] " . ($self->{pbot}->{ignorelist}->{ignore_list}->{$ignored}->{$channel} < 0 ? "perm" : duration($self->{pbot}->{ignorelist}->{ignore_list}->{$ignored}->{$channel} - gettimeofday));
|
||||||
$sep = ";\n";
|
$sep = ";\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -70,9 +71,16 @@ sub ignore_user {
|
|||||||
$length = -1; # permanently
|
$length = -1; # permanently
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{pbot}->{logger}->log("$nick added [$target][$channel] to ignore list for $length seconds\n");
|
|
||||||
$self->{pbot}->{ignorelist}->add($target, $channel, $length);
|
$self->{pbot}->{ignorelist}->add($target, $channel, $length);
|
||||||
return "/msg $nick [$target][$channel] added to ignore list for $length seconds";
|
|
||||||
|
if ($length >= 0) {
|
||||||
|
$length = "for " . duration($length);
|
||||||
|
} else {
|
||||||
|
$length = "permanently";
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{pbot}->{logger}->log("$nick added [$target][$channel] to ignore list $length\n");
|
||||||
|
return "/msg $nick [$target][$channel] added to ignore list $length";
|
||||||
}
|
}
|
||||||
|
|
||||||
sub unignore_user {
|
sub unignore_user {
|
||||||
|
Loading…
Reference in New Issue
Block a user