3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-10-04 18:38:47 +02:00

Plugins/RestrictedMod: support user-capabilities

This commit is contained in:
Pragmatic Software 2020-02-04 23:55:58 -08:00
parent 52509f1786
commit 6453ff220e

View File

@ -86,16 +86,18 @@ sub generic_command {
if not $self->{pbot}->{chanops}->can_gain_ops($channel);
return "Voiced moderation is not enabled for this channel. Use `regset $channel.restrictedmod 1` to enable."
if not $self->{pbot}->{registry}->get_value($channel, 'restrictedmod');
my $hostmask = "$stuff->{nick}!$stuff->{user}\@$stuff->{host}";
my $admin = $self->{pbot}->{users}->loggedin_admin($channel, $hostmask);
my $user = $self->{pbot}->{users}->loggedin($channel, $hostmask) // { admin => 0, chanmod => 0};
my $voiced = $self->{pbot}->{nicklist}->get_meta($channel, $stuff->{nick}, '+v');
return "You must be voiced (usermode +v) or an admin to use this command." if not $voiced and not $admin;
if (not $voiced and not $self->{pbot}->{capabilities}->userhas($user, 'admin')
and not $self->{pbot}->{capabilities}->userhas($user, 'chanmod')) {
return "You must be voiced (usermode +v) or have the admin or chanmod capability to use this command.";
}
my $target = $self->{pbot}->{interpreter}->shift_arg($stuff->{arglist});
if (not defined $target) {
return "Missing target. Usage: mod $command <nick>";
}
return "Missing target. Usage: mod $command <nick>" if not defined $target;
if ($command eq 'unban') {
my $reason = $self->{pbot}->{chanops}->checkban($channel, $target);