mirror of
https://github.com/pragma-/pbot.git
synced 2025-02-18 14:30:40 +01:00
Support command substitution
This commit is contained in:
parent
8b2f64bf84
commit
43d227d1a9
@ -254,6 +254,17 @@ sub interpret {
|
|||||||
$self->{pbot}->{logger}->log("Truncating keyword to 30 chars: $keyword\n");
|
$self->{pbot}->{logger}->log("Truncating keyword to 30 chars: $keyword\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# parse out a substituted command
|
||||||
|
if (defined $arguments && $arguments =~ s/(?<!\\)&\{\s*([^}]+)\}/&{subcmd}/) {
|
||||||
|
my $command = $1;
|
||||||
|
push @{$stuff->{subcmd}}, "$keyword $arguments";
|
||||||
|
$stuff->{command} = $command;
|
||||||
|
my $result = $self->interpret($stuff);
|
||||||
|
$stuff->{result} = $result;
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# parse out a pipe unless escaped
|
# parse out a pipe unless escaped
|
||||||
if (defined $arguments && $arguments =~ m/(?<!\\)\|\s*\{\s*[^}]+\}\s*$/) {
|
if (defined $arguments && $arguments =~ m/(?<!\\)\|\s*\{\s*[^}]+\}\s*$/) {
|
||||||
$arguments =~ m/(.*?)\s*(?<!\\)\|\s*\{\s*([^}]+)\}(.*)/s;
|
$arguments =~ m/(.*?)\s*(?<!\\)\|\s*\{\s*([^}]+)\}(.*)/s;
|
||||||
@ -364,6 +375,22 @@ sub handle_result {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (exists $stuff->{subcmd}) {
|
||||||
|
my $command = pop @{$stuff->{subcmd}};
|
||||||
|
|
||||||
|
if (@{$stuff->{subcmd}} == 0) {
|
||||||
|
delete $stuff->{subcmd};
|
||||||
|
}
|
||||||
|
|
||||||
|
$command =~ s/&\{subcmd\}/$result/;
|
||||||
|
|
||||||
|
$stuff->{command} = $command;
|
||||||
|
$result = $self->interpret($stuff);
|
||||||
|
$stuff->{result}= $result;
|
||||||
|
$self->handle_result($stuff);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if ($stuff->{pipe} and not $stuff->{authorized}) {
|
if ($stuff->{pipe} and not $stuff->{authorized}) {
|
||||||
my ($pipe, $pipe_rest) = ($stuff->{pipe}, $stuff->{pipe_rest});
|
my ($pipe, $pipe_rest) = ($stuff->{pipe}, $stuff->{pipe_rest});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user