mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-17 01:19:31 +01:00
Plugin/Date: use existing context when launching date applet
This preserves the pipe/cmd-substitution/etc to allow post-processing of the `date` output. Interpreter: Reset `interpreted` contextual metadata when handling result to allow recursion for continued command processing.
This commit is contained in:
parent
7f49321e29
commit
54ef6b14ce
@ -96,7 +96,9 @@ sub launch_applet($self, $context) {
|
||||
|
||||
my $start = gettimeofday;
|
||||
$self->{pbot}->{logger}->log("Starting applet run @cmdline\n");
|
||||
|
||||
run \@cmdline, \$stdin, \$stdout, \$stderr, timeout($timeout);
|
||||
|
||||
my $duration = sprintf "%0.3f", gettimeofday - $start;
|
||||
$self->{pbot}->{logger}->log("Finished applet run @cmdline; duration: $duration\n");
|
||||
|
||||
|
@ -585,9 +585,12 @@ sub interpret($self, $context) {
|
||||
# sends final command output to appropriate queues.
|
||||
# use context result if no result argument given.
|
||||
sub handle_result($self, $context, $result = $context->{result}) {
|
||||
# condensation of consecutive whitespace is disable by default
|
||||
# condensation of consecutive whitespace is disabled by default
|
||||
$context->{'condense-whitespace'} //= 0;
|
||||
|
||||
# reset interpreted to allow pipes/command-substitutions to finish
|
||||
delete $context->{'interpreted'};
|
||||
|
||||
# debug flag to trace $context location and contents
|
||||
if ($self->{pbot}->{registry}->get_value('general', 'debugcontext')) {
|
||||
use Data::Dumper;
|
||||
|
@ -78,23 +78,16 @@ sub cmd_date($self, $context) {
|
||||
return "No timezone set or user account does not exist.";
|
||||
}
|
||||
|
||||
# execute `date_applet`
|
||||
my $newcontext = {
|
||||
from => $context->{from},
|
||||
nick => $context->{nick},
|
||||
user => $context->{user},
|
||||
host => $context->{host},
|
||||
hostmask => $context->{hostmask},
|
||||
command => "date_applet $timezone",
|
||||
root_channel => $context->{from},
|
||||
root_keyword => "date_applet",
|
||||
keyword => "date_applet",
|
||||
arguments => "$timezone",
|
||||
};
|
||||
# override command fields to execute date_applet
|
||||
$context->{keyword} = "date_applet";
|
||||
$context->{command} = "date_applet $timezone";
|
||||
$context->{arguments} = $timezone;
|
||||
|
||||
# tell Interpreter::interpret() that this command has been interpreted
|
||||
$context->{interpreted} = 1;
|
||||
|
||||
$self->{pbot}->{applets}->execute_applet($newcontext);
|
||||
# fork to execute applet
|
||||
$self->{pbot}->{applets}->execute_applet($context);
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -25,7 +25,7 @@ use PBot::Imports;
|
||||
# These are set by the /misc/update_version script
|
||||
use constant {
|
||||
BUILD_NAME => "PBot",
|
||||
BUILD_REVISION => 4838,
|
||||
BUILD_REVISION => 4839,
|
||||
BUILD_DATE => "2024-11-05",
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user