mirror of
https://github.com/pragma-/pbot.git
synced 2025-10-19 09:37:24 +02:00
Improve code-factoids
- now processes command substitutions, pipes, and splits - indentation and newlines preserved
This commit is contained in:
parent
8f1ac5b5ba
commit
3219c3d008
@ -70,7 +70,7 @@ sub execute($self, $context) {
|
|||||||
my $json = encode_json \%args;
|
my $json = encode_json \%args;
|
||||||
|
|
||||||
# update context details
|
# update context details
|
||||||
$context->{special} = 'code-factoid'; # ensure handle_result(), etc, process this as a code-factoid
|
$context->{special}->{$context->{stack_depth}} = 'code-factoid'; # ensure handle_result(), etc, process this as a code-factoid
|
||||||
$context->{root_channel} = $context->{channel}; # override root channel to current channel
|
$context->{root_channel} = $context->{channel}; # override root channel to current channel
|
||||||
$context->{keyword} = 'vm-client'; # code-factoid uses `vm-client` command to invoke vm
|
$context->{keyword} = 'vm-client'; # code-factoid uses `vm-client` command to invoke vm
|
||||||
$context->{arguments} = $json; # set arguments to json string as `vm-client` expects
|
$context->{arguments} = $json; # set arguments to json string as `vm-client` expects
|
||||||
|
@ -388,7 +388,7 @@ sub handle_action($self, $context, $action) {
|
|||||||
|
|
||||||
unless ($self->{pbot}->{factoids}->{data}->{storage}->get_data($channel, $keyword, 'require_explicit_args')) {
|
unless ($self->{pbot}->{factoids}->{data}->{storage}->get_data($channel, $keyword, 'require_explicit_args')) {
|
||||||
my $args = $context->{arguments};
|
my $args = $context->{arguments};
|
||||||
$command .= " $args" if length $args and not $context->{special} eq 'code-factoid';
|
$command .= " $args" if length $args and not $context->{special}->{$context->{stack_depth}} eq 'code-factoid';
|
||||||
$context->{arguments} = '';
|
$context->{arguments} = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -448,14 +448,20 @@ sub handle_action($self, $context, $action) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# action is a code factoid
|
# action is a code factoid
|
||||||
if ($action =~ m{^/code\s+([^\s]+)\s+(.+)$}msi) {
|
if ($action =~ m{^/code\s+(\S+)\s+(.+)$}msi) {
|
||||||
my ($lang, $code) = ($1, $2);
|
my ($lang, $code) = ($1, $2);
|
||||||
$context->{lang} = $lang;
|
my $depth = $context->{stack_depth};
|
||||||
$context->{code} = $code;
|
$context->{code_args}->{$depth} = $context->{arguments};
|
||||||
return $self->{pbot}->{factoids}->{code}->execute($context);
|
$context->{special}->{$depth} = 'code-factoid';
|
||||||
|
$context->{command} = "/code $lang $code";
|
||||||
|
return $self->{pbot}->{interpreter}->interpret($context);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $action if $context->{special} eq 'code-factoid';
|
if ($context->{special}->{$context->{stack_depth}} eq 'code-factoid') {
|
||||||
|
# code-factoid completed
|
||||||
|
delete $context->{special}->{$context->{stack_depth}};
|
||||||
|
return $action;
|
||||||
|
}
|
||||||
|
|
||||||
if ($self->{pbot}->{factoids}->{data}->{storage}->get_data($channel, $keyword, 'type') eq 'applet') {
|
if ($self->{pbot}->{factoids}->{data}->{storage}->get_data($channel, $keyword, 'type') eq 'applet') {
|
||||||
$context->{root_keyword} = $keyword unless defined $context->{root_keyword};
|
$context->{root_keyword} = $keyword unless defined $context->{root_keyword};
|
||||||
|
@ -154,11 +154,11 @@ sub process_line($self, $from, $nick, $user, $host, $text, $tags = '', $is_comma
|
|||||||
# "!command"
|
# "!command"
|
||||||
$command = $1;
|
$command = $1;
|
||||||
$context->{addressed} = 1; # command explicitly invoked
|
$context->{addressed} = 1; # command explicitly invoked
|
||||||
} elsif ($cmd_text =~ m/^.?\s*$botnick\s*[,:]\s+(.+)$/i) {
|
} elsif ($cmd_text =~ m/^$botnick\s*[,:]\s+(.+)$/i) {
|
||||||
# "botnick: command"
|
# "botnick: command"
|
||||||
$command = $1;
|
$command = $1;
|
||||||
$context->{addressed} = 1; # command explicitly invoked
|
$context->{addressed} = 1; # command explicitly invoked
|
||||||
} elsif ($cmd_text =~ m/^.?\s*$botnick\s+(.+)$/i) {
|
} elsif ($cmd_text =~ m/^$botnick\s+(.+)$/i) {
|
||||||
# "botnick command"
|
# "botnick command"
|
||||||
$command = $1;
|
$command = $1;
|
||||||
$context->{addressed} = 0; # command NOT explicitly invoked (silence disambig/errors)
|
$context->{addressed} = 0; # command NOT explicitly invoked (silence disambig/errors)
|
||||||
@ -261,6 +261,9 @@ sub process_line($self, $from, $nick, $user, $host, $text, $tags = '', $is_comma
|
|||||||
delete $context->{pipe};
|
delete $context->{pipe};
|
||||||
delete $context->{pipe_next};
|
delete $context->{pipe_next};
|
||||||
delete $context->{add_nick};
|
delete $context->{add_nick};
|
||||||
|
delete $context->{special};
|
||||||
|
delete $context->{code};
|
||||||
|
delete $context->{lang};
|
||||||
}
|
}
|
||||||
|
|
||||||
# return number of commands processed
|
# return number of commands processed
|
||||||
@ -279,11 +282,10 @@ sub interpret($self, $context) {
|
|||||||
# debug flag to trace $context location and contents
|
# debug flag to trace $context location and contents
|
||||||
if ($self->{pbot}->{registry}->get_value('general', 'debugcontext')) {
|
if ($self->{pbot}->{registry}->get_value('general', 'debugcontext')) {
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
$Data::Dumper::Sortkeys = sub { [sort grep { not /(?:cmdlist|arglist)/ } keys %$context] };
|
$Data::Dumper::Sortkeys = 1;
|
||||||
$Data::Dumper::Indent = 2;
|
$Data::Dumper::Indent = 2;
|
||||||
$self->{pbot}->{logger}->log("Interpreter::interpret\n");
|
$self->{pbot}->{logger}->log("Interpreter::interpret\n");
|
||||||
$self->{pbot}->{logger}->log(Dumper $context);
|
$self->{pbot}->{logger}->log(Dumper $context);
|
||||||
$Data::Dumper::Sortkeys = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# enforce recursion limit
|
# enforce recursion limit
|
||||||
@ -310,11 +312,6 @@ sub interpret($self, $context) {
|
|||||||
|
|
||||||
$context->{cmdlist} = $cmdlist;
|
$context->{cmdlist} = $cmdlist;
|
||||||
|
|
||||||
# create context command history if non-existent
|
|
||||||
if (not exists $context->{commands}) {
|
|
||||||
$context->{commands} = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
# add command to context command history
|
# add command to context command history
|
||||||
push @{$context->{commands}}, $context->{command};
|
push @{$context->{commands}}, $context->{command};
|
||||||
|
|
||||||
@ -341,7 +338,7 @@ sub interpret($self, $context) {
|
|||||||
$recipient = $cmdlist->[1];
|
$recipient = $cmdlist->[1];
|
||||||
} else {
|
} else {
|
||||||
# normal command, split into keywords and arguments while preserving quotes
|
# normal command, split into keywords and arguments while preserving quotes
|
||||||
($keyword, $arguments) = $self->split_args($cmdlist, 2, 0, 1);
|
($keyword, $arguments) = $context->{command} =~ m/^\s*(\S+)\s*(.*)$/ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
# limit keyword length (in bytes)
|
# limit keyword length (in bytes)
|
||||||
@ -382,66 +379,77 @@ sub interpret($self, $context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# find factoid channel for dont-replace-pronouns metadata
|
my $special = $context->{special}->{$context->{stack_depth}};
|
||||||
my ($fact_channel, $fact_trigger);
|
|
||||||
my @factoids = $self->{pbot}->{factoids}->{data}->find($context->{from}, $keyword, exact_trigger => 1);
|
|
||||||
|
|
||||||
if (@factoids == 1) {
|
if (not $special) {
|
||||||
# found the factoid's channel
|
if ($keyword =~ m,^/,) {
|
||||||
($fact_channel, $fact_trigger) = @{$factoids[0]};
|
$special = $keyword;
|
||||||
} else {
|
}
|
||||||
# match the factoid in the current channel if it exists
|
}
|
||||||
foreach my $f (@factoids) {
|
|
||||||
if ($f->[0] eq $context->{from}) {
|
my ($fact_channel, $fact_trigger);
|
||||||
($fact_channel, $fact_trigger) = ($f->[0], $f->[1]);
|
|
||||||
last;
|
unless ($special) {
|
||||||
|
# find factoid channel for dont-replace-pronouns metadata
|
||||||
|
my @factoids = $self->{pbot}->{factoids}->{data}->find($context->{from}, $keyword, exact_trigger => 1);
|
||||||
|
|
||||||
|
if (@factoids == 1) {
|
||||||
|
# found the factoid's channel
|
||||||
|
($fact_channel, $fact_trigger) = @{$factoids[0]};
|
||||||
|
} else {
|
||||||
|
# match the factoid in the current channel if it exists
|
||||||
|
foreach my $f (@factoids) {
|
||||||
|
if ($f->[0] eq $context->{from}) {
|
||||||
|
($fact_channel, $fact_trigger) = ($f->[0], $f->[1]);
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# and otherwise assume global if it doesn't exist (FIXME: what to do if there isn't a global one?)
|
||||||
|
if (not defined $fact_channel) {
|
||||||
|
($fact_channel, $fact_trigger) = ('.*', $keyword);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# and otherwise assume global if it doesn't exist (FIXME: what to do if there isn't a global one?)
|
if ($self->{pbot}->{commands}->get_meta($keyword, 'suppress-no-output')
|
||||||
if (not defined $fact_channel) {
|
or $self->{pbot}->{factoids}->{data}->get_meta($fact_channel, $fact_trigger, 'suppress-no-output'))
|
||||||
($fact_channel, $fact_trigger) = ('.*', $keyword);
|
{
|
||||||
}
|
$context->{'suppress_no_output'} = 1;
|
||||||
}
|
} else {
|
||||||
|
delete $context->{'suppress_no_output'};
|
||||||
if ($self->{pbot}->{commands}->get_meta($keyword, 'suppress-no-output')
|
|
||||||
or $self->{pbot}->{factoids}->{data}->get_meta($fact_channel, $fact_trigger, 'suppress-no-output'))
|
|
||||||
{
|
|
||||||
$context->{'suppress_no_output'} = 1;
|
|
||||||
} else {
|
|
||||||
delete $context->{'suppress_no_output'};
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($self->{pbot}->{commands}->get_meta($keyword, 'dont-replace-pronouns')
|
|
||||||
or $self->{pbot}->{factoids}->{data}->get_meta($fact_channel, $fact_trigger, 'dont-replace-pronouns'))
|
|
||||||
{
|
|
||||||
$context->{'dont-replace-pronouns'} = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
# replace pronouns like "i", "my", etc, with "nick", "nick's", etc
|
|
||||||
if (not $context->{'dont-replace-pronouns'}) {
|
|
||||||
# if command recipient is "me" then replace it with invoker's nick
|
|
||||||
# e.g., "!tell me about date" or "!give me date", etc
|
|
||||||
if (defined $context->{nickprefix} and lc $context->{nickprefix} eq 'me') {
|
|
||||||
$context->{nickprefix} = $context->{nick};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# strip trailing sentence-ending punctuators from $keyword
|
if ($self->{pbot}->{commands}->get_meta($keyword, 'dont-replace-pronouns')
|
||||||
# TODO: why are we doing this? why here? why at all?
|
or $self->{pbot}->{factoids}->{data}->get_meta($fact_channel, $fact_trigger, 'dont-replace-pronouns'))
|
||||||
$keyword =~ s/(\w+)[?!.]+$/$1/;
|
{
|
||||||
|
$context->{'dont-replace-pronouns'} = 1;
|
||||||
|
}
|
||||||
|
|
||||||
# replace pronouns in $arguments.
|
# replace pronouns like "i", "my", etc, with "nick", "nick's", etc
|
||||||
# but only on the top-level command (not on subsequent recursions).
|
if (not $context->{'dont-replace-pronouns'}) {
|
||||||
# all pronouns can be escaped to prevent replacement, e.g. "!give \me date"
|
# if command recipient is "me" then replace it with invoker's nick
|
||||||
if (length $arguments and $context->{interpret_depth} <= 1) {
|
# e.g., "!tell me about date" or "!give me date", etc
|
||||||
$arguments =~ s/(?<![\w\/\-\\])i am\b/$context->{nick} is/gi;
|
if (defined $context->{nickprefix} and lc $context->{nickprefix} eq 'me') {
|
||||||
$arguments =~ s/(?<![\w\/\-\\])me\b/$context->{nick}/gi;
|
$context->{nickprefix} = $context->{nick};
|
||||||
$arguments =~ s/(?<![\w\/\-\\])my\b/$context->{nick}'s/gi;
|
}
|
||||||
|
|
||||||
# unescape any escaped pronouns
|
# strip trailing sentence-ending punctuators from $keyword
|
||||||
$arguments =~ s/\\i am\b/i am/gi;
|
# TODO: why are we doing this? why here? why at all?
|
||||||
$arguments =~ s/\\my\b/my/gi;
|
$keyword =~ s/(\w+)[?!.]+$/$1/;
|
||||||
$arguments =~ s/\\me\b/me/gi;
|
|
||||||
|
# replace pronouns in $arguments.
|
||||||
|
# but only on the top-level command (not on subsequent recursions).
|
||||||
|
# all pronouns can be escaped to prevent replacement, e.g. "!give \me date"
|
||||||
|
if (length $arguments and $context->{interpret_depth} <= 1) {
|
||||||
|
$arguments =~ s/(?<![\w\/\-\\])i am\b/$context->{nick} is/gi;
|
||||||
|
$arguments =~ s/(?<![\w\/\-\\])me\b/$context->{nick}/gi;
|
||||||
|
$arguments =~ s/(?<![\w\/\-\\])my\b/$context->{nick}'s/gi;
|
||||||
|
|
||||||
|
# unescape any escaped pronouns
|
||||||
|
$arguments =~ s/\\i am\b/i am/gi;
|
||||||
|
$arguments =~ s/\\my\b/my/gi;
|
||||||
|
$arguments =~ s/\\me\b/me/gi;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -515,8 +523,8 @@ sub interpret($self, $context) {
|
|||||||
|
|
||||||
# the bot doesn't like performing bot commands on itself
|
# the bot doesn't like performing bot commands on itself
|
||||||
# unless dont-protect-self is true
|
# unless dont-protect-self is true
|
||||||
if (not $self->{pbot}->{commands}->get_meta($keyword, 'dont-protect-self')
|
if (!$special && !$self->{pbot}->{commands}->get_meta($keyword, 'dont-protect-self')
|
||||||
and not $self->{pbot}->{factoids}->{data}->get_meta($fact_channel, $fact_trigger, 'dont-protect-self'))
|
&& !$self->{pbot}->{factoids}->{data}->get_meta($fact_channel, $fact_trigger, 'dont-protect-self'))
|
||||||
{
|
{
|
||||||
my $botnick = $self->{pbot}->{conn}->nick;
|
my $botnick = $self->{pbot}->{conn}->nick;
|
||||||
|
|
||||||
@ -550,6 +558,16 @@ sub interpret($self, $context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# if code factoid, let handle_action finish up substitutions, pipes,
|
||||||
|
# splits, etc, and then invoke the code factoid without updating
|
||||||
|
# $context's keyword or arguments
|
||||||
|
if ($keyword eq '/code') {
|
||||||
|
# there is no result yet until code factoid is invoked
|
||||||
|
# right now we're just finishing up substitions, pipes, etc
|
||||||
|
$context->{'code-factoid'} = 1;
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
# set the contextual root root keyword.
|
# set the contextual root root keyword.
|
||||||
# this is the keyword first used to invoke this command. it is not updated
|
# this is the keyword first used to invoke this command. it is not updated
|
||||||
# on subsequent command interpreter recursions.
|
# on subsequent command interpreter recursions.
|
||||||
@ -577,7 +595,7 @@ sub interpret($self, $context) {
|
|||||||
delete $context->{args_utf8};
|
delete $context->{args_utf8};
|
||||||
|
|
||||||
# reset the special behavior
|
# reset the special behavior
|
||||||
$context->{special} = '';
|
$context->{special}->{$context->{stack_depth}} = '';
|
||||||
|
|
||||||
# execute all registered interpreters
|
# execute all registered interpreters
|
||||||
my $result;
|
my $result;
|
||||||
@ -612,12 +630,24 @@ sub handle_result($self, $context, $result = $context->{result}) {
|
|||||||
# debug flag to trace $context location and contents
|
# debug flag to trace $context location and contents
|
||||||
if ($self->{pbot}->{registry}->get_value('general', 'debugcontext')) {
|
if ($self->{pbot}->{registry}->get_value('general', 'debugcontext')) {
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
$Data::Dumper::Sortkeys = sub { [sort grep { not /(?:cmdlist|arglist)/ } keys %$context] };
|
$Data::Dumper::Sortkeys = 1;
|
||||||
$Data::Dumper::Indent = 2;
|
$Data::Dumper::Indent = 2;
|
||||||
$self->{pbot}->{logger}->log("Interpreter::handle_result [$result]\n");
|
$self->{pbot}->{logger}->log("Interpreter::handle_result [$result]\n");
|
||||||
$self->{pbot}->{logger}->log(Dumper $context);
|
$self->{pbot}->{logger}->log(Dumper $context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($context->{'code-factoid'}) {
|
||||||
|
delete $context->{'code-factoid'}; # code-factoid handled
|
||||||
|
# execute code factoid
|
||||||
|
if ($context->{command} =~ m/^\/code (\S+) (.*)/ms) {
|
||||||
|
$context->{lang} = $1;
|
||||||
|
$context->{code} = $2;
|
||||||
|
$context->{arguments} = $context->{code_args}->{$context->{stack_depth}};
|
||||||
|
# ProcessManager's process pipe reader will handle the result
|
||||||
|
return $self->{pbot}->{factoids}->{code}->execute($context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# ensure we have a command result to work with
|
# ensure we have a command result to work with
|
||||||
if (!defined $result || $context->{'skip-handle-result'}) {
|
if (!defined $result || $context->{'skip-handle-result'}) {
|
||||||
$self->{pbot}->{logger}->log("Skipping handle_result\n");
|
$self->{pbot}->{logger}->log("Skipping handle_result\n");
|
||||||
@ -885,11 +915,10 @@ sub output_result($self, $context) {
|
|||||||
# debug flag to trace $context location and contents
|
# debug flag to trace $context location and contents
|
||||||
if ($self->{pbot}->{registry}->get_value('general', 'debugcontext')) {
|
if ($self->{pbot}->{registry}->get_value('general', 'debugcontext')) {
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
$Data::Dumper::Sortkeys = sub { [sort grep { not /(?:cmdlist|arglist)/ } keys %$context] };
|
$Data::Dumper::Sortkeys = 1;
|
||||||
$Data::Dumper::Indent = 2;
|
$Data::Dumper::Indent = 2;
|
||||||
$self->{pbot}->{logger}->log("Interpreter::output_result\n");
|
$self->{pbot}->{logger}->log("Interpreter::output_result\n");
|
||||||
$self->{pbot}->{logger}->log(Dumper $context);
|
$self->{pbot}->{logger}->log(Dumper $context);
|
||||||
$Data::Dumper::Sortkeys = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
my $output = $context->{output};
|
my $output = $context->{output};
|
||||||
@ -1341,7 +1370,7 @@ sub split_line($self, $line, %opts) {
|
|||||||
$token .= $ch;
|
$token .= $ch;
|
||||||
next;
|
next;
|
||||||
} else {
|
} else {
|
||||||
if ($opts{keep_spaces} && $ch eq "\n") {
|
if ($opts{keep_spaces} && ($ch eq "\n" || $ch eq "\t")) {
|
||||||
$token .= $ch;
|
$token .= $ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,16 @@ sub remove_process($self, $pid) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub execute_process($self, $context, $subref, $timeout = undef, $reader_subref = undef) {
|
sub execute_process($self, $context, $subref, $timeout = undef, $reader_subref = undef) {
|
||||||
# don't fork again if we're already a forked process
|
# debug flag to trace $context location and contents
|
||||||
|
if ($self->{pbot}->{registry}->get_value('general', 'debugcontext')) {
|
||||||
|
use Data::Dumper;
|
||||||
|
$Data::Dumper::Indent = 2;
|
||||||
|
$Data::Dumper::Sortkeys = 1;
|
||||||
|
$self->{pbot}->{logger}->log("ProcessManager::execute_process\n");
|
||||||
|
$self->{pbot}->{logger}->log(Dumper $context);
|
||||||
|
}
|
||||||
|
|
||||||
|
# don't fork again if we're already child
|
||||||
if (defined $context->{pid} and $context->{pid} == 0) {
|
if (defined $context->{pid} and $context->{pid} == 0) {
|
||||||
$self->{pbot}->{logger}->log("execute_process: Re-using PID $context->{pid} for new process\n");
|
$self->{pbot}->{logger}->log("execute_process: Re-using PID $context->{pid} for new process\n");
|
||||||
$subref->($context);
|
$subref->($context);
|
||||||
@ -63,6 +72,8 @@ sub execute_process($self, $context, $subref, $timeout = undef, $reader_subref =
|
|||||||
# fork new process
|
# fork new process
|
||||||
$context->{pid} = fork;
|
$context->{pid} = fork;
|
||||||
|
|
||||||
|
$self->{pbot}->{logger}->log("=-=-=-=-=-=-= FORK PID $context->{pid} =-=-=-=-=-=-=-=\n");
|
||||||
|
|
||||||
if (not defined $context->{pid}) {
|
if (not defined $context->{pid}) {
|
||||||
# fork failed
|
# fork failed
|
||||||
$self->{pbot}->{logger}->log("Could not fork process: $!\n");
|
$self->{pbot}->{logger}->log("Could not fork process: $!\n");
|
||||||
@ -143,10 +154,19 @@ sub execute_process($self, $context, $subref, $timeout = undef, $reader_subref =
|
|||||||
sub process_pipe_reader($self, $pid, $buf) {
|
sub process_pipe_reader($self, $pid, $buf) {
|
||||||
# retrieve context object from child
|
# retrieve context object from child
|
||||||
my $context = decode_json $buf or do {
|
my $context = decode_json $buf or do {
|
||||||
$self->{pbot}->{logger}->log("Failed to decode bad json: [$buf]\n");
|
$self->{pbot}->{logger}->log("ProcessManager::process_pipe_reader: Failed to decode bad json: [$buf]\n");
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# debug flag to trace $context location and contents
|
||||||
|
if ($self->{pbot}->{registry}->get_value('general', 'debugcontext')) {
|
||||||
|
use Data::Dumper;
|
||||||
|
$Data::Dumper::Indent = 2;
|
||||||
|
$Data::Dumper::Sortkeys = 1;
|
||||||
|
$self->{pbot}->{logger}->log("ProcessManager::process_pipe_reader ($pid)\n");
|
||||||
|
$self->{pbot}->{logger}->log(Dumper $context);
|
||||||
|
}
|
||||||
|
|
||||||
# context is no longer forked
|
# context is no longer forked
|
||||||
delete $context->{pid};
|
delete $context->{pid};
|
||||||
|
|
||||||
@ -165,8 +185,10 @@ sub process_pipe_reader($self, $pid, $buf) {
|
|||||||
return if $context->{result} =~ m/(?:no results)/i;
|
return if $context->{result} =~ m/(?:no results)/i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$self->{pbot}->{logger}->log("process pipe handling result [$context->{result}]\n");
|
||||||
|
|
||||||
# handle code factoid result
|
# handle code factoid result
|
||||||
if (exists $context->{special} and $context->{special} eq 'code-factoid') {
|
if (exists $context->{special} and $context->{special}->{$context->{stack_depth}} eq 'code-factoid') {
|
||||||
$context->{result} =~ s/\s+$//g;
|
$context->{result} =~ s/\s+$//g;
|
||||||
$context->{original_keyword} = $context->{root_keyword};
|
$context->{original_keyword} = $context->{root_keyword};
|
||||||
$context->{result} = $self->{pbot}->{factoids}->{interpreter}->handle_action($context, $context->{result});
|
$context->{result} = $self->{pbot}->{factoids}->{interpreter}->handle_action($context, $context->{result});
|
||||||
|
@ -25,7 +25,7 @@ use PBot::Imports;
|
|||||||
# These are set by the /misc/update_version script
|
# These are set by the /misc/update_version script
|
||||||
use constant {
|
use constant {
|
||||||
BUILD_NAME => "PBot",
|
BUILD_NAME => "PBot",
|
||||||
BUILD_REVISION => 4894,
|
BUILD_REVISION => 4895,
|
||||||
BUILD_DATE => "2025-09-25",
|
BUILD_DATE => "2025-09-25",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user