mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-20 02:49:49 +01:00
Capabilities: cap group
and cap ungroup
now accept multiple capabilities
This commit is contained in:
parent
410ce811ca
commit
12be1e87dd
@ -239,38 +239,51 @@ sub capcmd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
when ('group') {
|
when ('group') {
|
||||||
my $cap = $self->{pbot}->{interpreter}->shift_arg($stuff->{arglist});
|
my ($cap, $subcaps) = $self->{pbot}->{interpreter}->split_args($stuff->{arglist}, 2);
|
||||||
my $subcap = $self->{pbot}->{interpreter}->shift_arg($stuff->{arglist});
|
return "Usage: cap group <existing or new capability> <existing capabilities...>" if not defined $cap or not defined $subcaps;
|
||||||
return "Usage: cap group <existing or new capability> <existing capability>" if not defined $cap or not defined $subcap;
|
|
||||||
return "No such capability $subcap." if not $self->exists($subcap);
|
|
||||||
return "You cannot group a capability with itself." if lc $cap eq lc $subcap;
|
|
||||||
|
|
||||||
my $u = $self->{pbot}->{users}->loggedin($from, "$nick!$user\@$host");
|
my $u = $self->{pbot}->{users}->loggedin($from, "$nick!$user\@$host");
|
||||||
return "You must be logged into your user account to group capabilities together." if not defined $u;
|
return "You must be logged into your user account to group capabilities together." if not defined $u;
|
||||||
return "You must have the can-group-capabilities capability to group capabilities together." if not $self->userhas($u, 'can-group-capabilities');
|
return "You must have the can-group-capabilities capability to group capabilities together." if not $self->userhas($u, 'can-group-capabilities');
|
||||||
|
|
||||||
$self->add($cap, $subcap);
|
my @caps = split /\s+|,/, $subcaps;
|
||||||
return "Capability $subcap added to the $cap capability group.";
|
foreach my $c (@caps) {
|
||||||
|
return "No such capability $c." if not $self->exists($c);
|
||||||
|
return "You cannot group a capability with itself." if lc $cap eq lc $c;
|
||||||
|
$self->add($cap, $c);
|
||||||
|
}
|
||||||
|
if (@caps > 1) {
|
||||||
|
return "Capabilities " . join(', ', @caps) . " added to the $cap capability group.";
|
||||||
|
} else {
|
||||||
|
return "Capability $subcaps added to the $cap capability group.";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
when ('ungroup') {
|
when ('ungroup') {
|
||||||
my $cap = $self->{pbot}->{interpreter}->shift_arg($stuff->{arglist});
|
my ($cap, $subcaps) = $self->{pbot}->{interpreter}->split_args($stuff->{arglist}, 2);
|
||||||
my $subcap = $self->{pbot}->{interpreter}->shift_arg($stuff->{arglist});
|
return "Usage: cap ungroup <existing capability group> <grouped capabilities...>" if not defined $cap or not defined $subcaps;
|
||||||
return "Usage: cap ungroup <existing capability group> <grouped capability>" if not defined $cap or not defined $subcap;
|
|
||||||
return "No such capability $cap." if not $self->exists($cap);
|
return "No such capability $cap." if not $self->exists($cap);
|
||||||
return "No such capability $subcap." if not $self->exists($subcap);
|
|
||||||
|
|
||||||
my $u = $self->{pbot}->{users}->loggedin($from, "$nick!$user\@$host");
|
my $u = $self->{pbot}->{users}->loggedin($from, "$nick!$user\@$host");
|
||||||
return "You must be logged into your user account to remove capabilities from groups." if not defined $u;
|
return "You must be logged into your user account to remove capabilities from groups." if not defined $u;
|
||||||
return "You must have the can-ungroup-capabilities capability to remove capabilities from groups." if not $self->userhas($u, 'can-ungroup-capabilities');
|
return "You must have the can-ungroup-capabilities capability to remove capabilities from groups." if not $self->userhas($u, 'can-ungroup-capabilities');
|
||||||
|
|
||||||
return "Capability $subcap does not belong to the $cap capability group." if not $self->has($cap, $subcap);
|
my @caps = split /\s+|,/, $subcaps;
|
||||||
$self->remove($cap, $subcap);
|
foreach my $c (@caps) {
|
||||||
return "Capability $subcap removed from the $cap capability group.";
|
return "No such capability $c." if not $self->exists($c);
|
||||||
|
return "Capability $c does not belong to the $cap capability group." if not $self->has($cap, $c);
|
||||||
|
$self->remove($cap, $c);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (@caps > 1) {
|
||||||
|
return "Capabilities " . join(', ', @caps) . " removed from the $cap capability group.";
|
||||||
|
} else {
|
||||||
|
return "Capability $subcaps removed from the $cap capability group.";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
default {
|
default {
|
||||||
$result = "Usage: cap list [capability] | cap group <existing or new capability group> <existing capability> | cap ungroup <existing capability group> <grouped capability> | cap userhas <user> [capability] | cap whohas <capability>";
|
$result = "Usage: cap list [capability] | cap group <existing or new capability group> <existing capabilities...> | cap ungroup <existing capability group> <grouped capabilities...> | cap userhas <user> [capability] | cap whohas <capability>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
|
Loading…
Reference in New Issue
Block a user