mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-20 02:49:49 +01:00
ChanOps/ChanOpCommands: make checkban/checkmute API
This commit is contained in:
parent
b30c41e31e
commit
2d38f71682
@ -304,77 +304,22 @@ sub checkban {
|
||||
my ($self, $from, $nick, $user, $host, $arguments, $stuff) = @_;
|
||||
my ($target, $channel) = $self->{pbot}->{interpreter}->split_args($stuff->{arglist}, 2);
|
||||
|
||||
if (not defined $target) {
|
||||
return "Usage: checkban <mask> [channel]";
|
||||
}
|
||||
return "Usage: checkban <mask> [channel]" if not defined $target;
|
||||
$channel = $from if not defined $channel;
|
||||
|
||||
if (not defined $channel) {
|
||||
$channel = $from;
|
||||
}
|
||||
|
||||
if ($channel !~ /^#/) {
|
||||
return "Please specify a channel.";
|
||||
}
|
||||
|
||||
$channel = lc $channel;
|
||||
$target = lc $target;
|
||||
|
||||
my $mask = lc $self->{pbot}->{chanops}->nick_to_banmask($target);
|
||||
|
||||
if (exists $self->{pbot}->{chanops}->{unban_timeout}->{hash}->{$channel}
|
||||
&& exists $self->{pbot}->{chanops}->{unban_timeout}->{hash}->{$channel}->{$mask}) {
|
||||
my $timeout = $self->{pbot}->{chanops}->{unban_timeout}->{hash}->{$channel}->{$mask}->{timeout};
|
||||
my $owner = $self->{pbot}->{chanops}->{unban_timeout}->{hash}->{$channel}->{$mask}->{owner};
|
||||
my $reason = $self->{pbot}->{chanops}->{unban_timeout}->{hash}->{$channel}->{$mask}->{reason};
|
||||
my $duration = concise duration($timeout - gettimeofday);
|
||||
|
||||
my $result = "$mask banned in $channel ";
|
||||
$result .= "by $owner " if defined $owner;
|
||||
$result .= "for $reason " if defined $reason;
|
||||
$result .= "($duration remaining)";
|
||||
return $result;
|
||||
} else {
|
||||
return "$mask has no ban timeout";
|
||||
}
|
||||
return "Please specify a channel." if $channel !~ /^#/;
|
||||
return $self->{pbot}->{chanops}->checkban($channel, $target);
|
||||
}
|
||||
|
||||
sub checkmute {
|
||||
my ($self, $from, $nick, $user, $host, $arguments, $stuff) = @_;
|
||||
my ($target, $channel) = $self->{pbot}->{interpreter}->split_args($stuff->{arglist}, 2);
|
||||
|
||||
if (not defined $target) {
|
||||
return "Usage: checkmute <mask> [channel]";
|
||||
}
|
||||
return "Usage: checkmute <mask> [channel]" if not defined $target;
|
||||
$channel = $from if not defined $channel;
|
||||
|
||||
if (not defined $channel) {
|
||||
$channel = $from;
|
||||
}
|
||||
|
||||
if ($channel !~ /^#/) {
|
||||
return "Please specify a channel.";
|
||||
}
|
||||
|
||||
$channel = lc $channel;
|
||||
$target = lc $target;
|
||||
|
||||
my $mask = lc $self->{pbot}->{chanops}->nick_to_banmask($target);
|
||||
|
||||
if (exists $self->{pbot}->{chanops}->{unmute_timeout}->{hash}->{$channel}
|
||||
&& exists $self->{pbot}->{chanops}->{unmute_timeout}->{hash}->{$channel}->{$mask}) {
|
||||
my $timeout = $self->{pbot}->{chanops}->{unmute_timeout}->{hash}->{$channel}->{$mask}->{timeout};
|
||||
my $owner = $self->{pbot}->{chanops}->{unmute_timeout}->{hash}->{$channel}->{$mask}->{owner};
|
||||
my $reason = $self->{pbot}->{chanops}->{unmute_timeout}->{hash}->{$channel}->{$mask}->{reason};
|
||||
my $duration = concise duration($timeout - gettimeofday);
|
||||
|
||||
my $result = "$mask muted in $channel ";
|
||||
$result .= "by $owner " if defined $owner;
|
||||
$result .= "for $reason " if defined $reason;
|
||||
$result .= "($duration remaining)";
|
||||
|
||||
return "$mask has $duration remaining on their $channel mute";
|
||||
} else {
|
||||
return "$mask has no mute timeout";
|
||||
}
|
||||
return "Please specify a channel." if $channel !~ /^#/;
|
||||
return $self->{pbot}->{chanops}->checkmute($channel, $target);
|
||||
}
|
||||
|
||||
sub ban_user {
|
||||
|
@ -16,6 +16,7 @@ use feature 'unicode_strings';
|
||||
|
||||
use PBot::ChanOpCommands;
|
||||
use Time::HiRes qw(gettimeofday);
|
||||
use Time::Duration qw(concise duration);
|
||||
|
||||
sub new {
|
||||
if (ref($_[1]) eq 'HASH') {
|
||||
@ -251,6 +252,30 @@ sub ban_user_timed {
|
||||
}
|
||||
}
|
||||
|
||||
sub checkban {
|
||||
my ($self, $channel, $target) = @_;
|
||||
$channel = lc $channel;
|
||||
$target = lc $target;
|
||||
|
||||
my $mask = lc $self->nick_to_banmask($target);
|
||||
|
||||
if (exists $self->{unban_timeout}->{hash}->{$channel}
|
||||
&& exists $self->{unban_timeout}->{hash}->{$channel}->{$mask}) {
|
||||
my $timeout = $self->{unban_timeout}->{hash}->{$channel}->{$mask}->{timeout};
|
||||
my $owner = $self->{unban_timeout}->{hash}->{$channel}->{$mask}->{owner};
|
||||
my $reason = $self->{unban_timeout}->{hash}->{$channel}->{$mask}->{reason};
|
||||
my $duration = concise duration($timeout - gettimeofday);
|
||||
|
||||
my $result = "$mask banned in $channel ";
|
||||
$result .= "by $owner " if defined $owner;
|
||||
$result .= "for $reason " if defined $reason;
|
||||
$result .= "($duration remaining)";
|
||||
return $result;
|
||||
} else {
|
||||
return "$mask has no ban timeout.";
|
||||
}
|
||||
}
|
||||
|
||||
sub mute_user {
|
||||
my $self = shift;
|
||||
my ($mask, $channel, $immediately) = @_;
|
||||
@ -292,6 +317,32 @@ sub mute_user_timed {
|
||||
}
|
||||
}
|
||||
|
||||
sub checkmute {
|
||||
my ($self, $channel, $target) = @_;
|
||||
|
||||
$channel = lc $channel;
|
||||
$target = lc $target;
|
||||
|
||||
my $mask = lc $self->nick_to_banmask($target);
|
||||
|
||||
if (exists $self->{unmute_timeout}->{hash}->{$channel}
|
||||
&& exists $self->{unmute_timeout}->{hash}->{$channel}->{$mask}) {
|
||||
my $timeout = $self->{unmute_timeout}->{hash}->{$channel}->{$mask}->{timeout};
|
||||
my $owner = $self->{unmute_timeout}->{hash}->{$channel}->{$mask}->{owner};
|
||||
my $reason = $self->{unmute_timeout}->{hash}->{$channel}->{$mask}->{reason};
|
||||
my $duration = concise duration($timeout - gettimeofday);
|
||||
|
||||
my $result = "$mask muted in $channel ";
|
||||
$result .= "by $owner " if defined $owner;
|
||||
$result .= "for $reason " if defined $reason;
|
||||
$result .= "($duration remaining)";
|
||||
|
||||
return "$mask has $duration remaining on their $channel mute";
|
||||
} else {
|
||||
return "$mask has no mute timeout.";
|
||||
}
|
||||
}
|
||||
|
||||
sub join_channel {
|
||||
my ($self, $channels) = @_;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user