mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-26 13:59:47 +01:00
ProcessManager: clean up kill
command; add can-kill
to admin
cap group
This commit is contained in:
parent
42dbf468b2
commit
1a2d4064a1
@ -25,6 +25,7 @@ sub initialize {
|
||||
my ($self, %conf) = @_;
|
||||
$self->{pbot}->{commands}->register(sub { $self->ps_cmd(@_) }, 'ps', 0);
|
||||
$self->{pbot}->{commands}->register(sub { $self->kill_cmd(@_) }, 'kill', 1);
|
||||
$self->{pbot}->{capabilities}->add('admin', 'can-kill');
|
||||
$self->{processes} = {};
|
||||
}
|
||||
|
||||
@ -44,18 +45,13 @@ sub ps_cmd {
|
||||
sub kill_cmd {
|
||||
my ($self, $from, $nick, $user, $host, $arguments, $stuff) = @_;
|
||||
my $usage = "Usage: kill <pids...>";
|
||||
|
||||
my @pids;
|
||||
while (1) {
|
||||
my $pid = $self->{pbot}->{interpreter}->shift_arg($stuff->{arglist}) // last;
|
||||
return "No such pid $pid." if not exists $self->{processes}->{$pid};
|
||||
push @pids, $pid;
|
||||
}
|
||||
return $usage if not @pids;
|
||||
|
||||
foreach my $pid (@pids) {
|
||||
return "No such pid $pid." if not exists $self->{processes}->{$pid};
|
||||
}
|
||||
|
||||
kill 'INT', @pids;
|
||||
return "Killed.";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user