mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-22 20:09:43 +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") {
|
||||
my $text = "Blacklist:\n";
|
||||
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";
|
||||
foreach my $mask (keys %{ $self->{blacklist}->{$channel} }) {
|
||||
$text .= " $mask,\n";
|
||||
$entries++;
|
||||
}
|
||||
}
|
||||
foreach my $mask (sort keys %{ $self->{blacklist}->{$channel} }) {
|
||||
$text .= " $mask,\n";
|
||||
$entries++;
|
||||
}
|
||||
}
|
||||
$text .= "none" if $entries == 0;
|
||||
return $text;
|
||||
|
@ -44,7 +44,7 @@ sub add {
|
||||
my $self = shift;
|
||||
my ($hostmask, $channel, $length) = @_;
|
||||
|
||||
if($length == -1) {
|
||||
if($length < 0) {
|
||||
$self->{ignore_list}->{$hostmask}->{$channel} = -1;
|
||||
} else {
|
||||
$self->{ignore_list}->{$hostmask}->{$channel} = gettimeofday + $length;
|
||||
|
@ -9,6 +9,7 @@ use warnings;
|
||||
use strict;
|
||||
|
||||
use Time::HiRes qw(gettimeofday);
|
||||
use Time::Duration;
|
||||
use Carp ();
|
||||
|
||||
sub new {
|
||||
@ -53,9 +54,9 @@ sub ignore_user {
|
||||
my $text = "Ignored: ";
|
||||
my $sep = "";
|
||||
|
||||
foreach my $ignored (keys %{ $self->{pbot}->{ignorelist}->{ignore_list} }) {
|
||||
foreach my $channel (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})) . "]";
|
||||
foreach my $ignored (sort keys %{ $self->{pbot}->{ignorelist}->{ignore_list} }) {
|
||||
foreach my $channel (sort keys %{ ${ $self->{pbot}->{ignorelist}->{ignore_list} }{$ignored} }) {
|
||||
$text .= $sep . "$ignored [$channel] " . ($self->{pbot}->{ignorelist}->{ignore_list}->{$ignored}->{$channel} < 0 ? "perm" : duration($self->{pbot}->{ignorelist}->{ignore_list}->{$ignored}->{$channel} - gettimeofday));
|
||||
$sep = ";\n";
|
||||
}
|
||||
}
|
||||
@ -70,9 +71,16 @@ sub ignore_user {
|
||||
$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);
|
||||
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 {
|
||||
|
Loading…
Reference in New Issue
Block a user