mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-27 13:12:42 +01:00
Fix factoid case duplication; enable me/my for pipes
This commit is contained in:
parent
6d7df6901f
commit
3b36634fa9
@ -78,7 +78,7 @@ sub execute_module {
|
||||
$stuff->{arguments} = $self->{pbot}->{factoids}->expand_special_vars($stuff->{from}, $stuff->{nick}, $stuff->{root_keyword}, $stuff->{arguments});
|
||||
$stuff->{arguments} = quotemeta $stuff->{arguments};
|
||||
|
||||
if ($stuff->{command} eq 'code-factoid' or exists $self->{pbot}->{factoids}->{factoids}->hash->{$channel}->{$trigger}->{unquote_spaces}) {
|
||||
if ($stuff->{special} eq 'code-factoid' or exists $self->{pbot}->{factoids}->{factoids}->hash->{$channel}->{$trigger}->{unquote_spaces}) {
|
||||
$stuff->{arguments} =~ s/\\ / /g;
|
||||
}
|
||||
|
||||
@ -194,7 +194,7 @@ sub module_pipe_reader {
|
||||
return if $stuff->{result} =~ m/(?:no results)/i;
|
||||
}
|
||||
|
||||
if ($stuff->{command} eq 'code-factoid') {
|
||||
if ($stuff->{special} eq 'code-factoid') {
|
||||
$stuff->{result} =~ s/\s+$//g;
|
||||
$self->{pbot}->{logger}->log("No text result from code-factoid.\n") and return if not length $stuff->{result};
|
||||
|
||||
@ -209,7 +209,7 @@ sub module_pipe_reader {
|
||||
$self->{pbot}->{interpreter}->handle_result($stuff, $stuff->{result});
|
||||
} else {
|
||||
# don't override nick if already set
|
||||
if ($stuff->{command} ne 'code-factoid' and exists $self->{pbot}->{factoids}->{factoids}->hash->{$stuff->{channel}}->{$stuff->{trigger}}->{add_nick} and $self->{pbot}->{factoids}->{factoids}->hash->{$stuff->{channel}}->{$stuff->{trigger}}->{add_nick} != 0) {
|
||||
if ($stuff->{special} ne 'code-factoid' and exists $self->{pbot}->{factoids}->{factoids}->hash->{$stuff->{channel}}->{$stuff->{trigger}}->{add_nick} and $self->{pbot}->{factoids}->{factoids}->hash->{$stuff->{channel}}->{$stuff->{trigger}}->{add_nick} != 0) {
|
||||
$stuff->{nickoverride} = $stuff->{nick};
|
||||
} else {
|
||||
# extract nick-like thing from module result
|
||||
|
@ -684,7 +684,6 @@ sub execute_code_factoid_using_safe {
|
||||
}
|
||||
|
||||
sub execute_code_factoid_using_vm {
|
||||
# my ($self, $nick, $user, $host, $from, $chan, $root_keyword, $keyword, $arguments, $lang, $code, $tonick) = @_;
|
||||
my ($self, $stuff) = @_;
|
||||
|
||||
unless (exists $self->{factoids}->hash->{$stuff->{channel}}->{$stuff->{keyword}}->{interpolate} and $self->{factoids}->hash->{$stuff->{channel}}->{$stuff->{keyword}}->{interpolate} eq '0') {
|
||||
@ -700,7 +699,7 @@ sub execute_code_factoid_using_vm {
|
||||
|
||||
my $json = encode_json \%h;
|
||||
|
||||
$stuff->{command} = 'code-factoid';
|
||||
$stuff->{special} = 'code-factoid';
|
||||
$stuff->{root_channel} = $stuff->{channel};
|
||||
$stuff->{keyword} = 'compiler';
|
||||
$stuff->{arguments} = $json;
|
||||
@ -710,7 +709,8 @@ sub execute_code_factoid_using_vm {
|
||||
}
|
||||
|
||||
sub execute_code_factoid {
|
||||
return execute_code_factoid_using_vm(@_);
|
||||
my ($self, @args) = @_;
|
||||
return $self->execute_code_factoid_using_vm(@args);
|
||||
}
|
||||
|
||||
sub interpreter {
|
||||
@ -728,8 +728,7 @@ sub interpreter {
|
||||
return undef if not length $stuff->{keyword} or $stuff->{interpret_depth} > $self->{pbot}->{registry}->get_value('interpreter', 'max_recursion');
|
||||
|
||||
$stuff->{from} = lc $stuff->{from};
|
||||
|
||||
#$self->{pbot}->{logger}->log("factoids interpreter: kw: [$keyword] args: [$arguments] from: [$from], ref_from: [" . (defined $ref_from ? $ref_from : "undef") . "]\n");
|
||||
$self->{special} = "";
|
||||
|
||||
# search for factoid against global channel and current channel (from unless ref_from is defined)
|
||||
my $original_keyword = $stuff->{keyword};
|
||||
@ -807,6 +806,11 @@ sub interpreter {
|
||||
}
|
||||
}
|
||||
|
||||
$stuff->{keyword} = $keyword;
|
||||
$stuff->{trigger} = $keyword;
|
||||
$stuff->{channel} = $channel;
|
||||
$stuff->{original_keyword} = $original_keyword;
|
||||
|
||||
return undef if $stuff->{referenced} and $self->{factoids}->hash->{$channel}->{$keyword}->{noembed};
|
||||
|
||||
if (exists $self->{factoids}->hash->{$channel}->{$keyword}->{last_referenced_on}) {
|
||||
@ -836,17 +840,12 @@ sub interpreter {
|
||||
|
||||
if ($action =~ m{^/code\s+([^\s]+)\s+(.+)$}i) {
|
||||
my ($lang, $code) = ($1, $2);
|
||||
$stuff->{channel} = $channel;
|
||||
$stuff->{lang} = $lang;
|
||||
$stuff->{code} = $code;
|
||||
$self->execute_code_factoid($stuff);
|
||||
return "";
|
||||
}
|
||||
|
||||
$stuff->{channel} = $channel;
|
||||
$stuff->{keyword} = $keyword;
|
||||
$stuff->{original_keyword} = $original_keyword;
|
||||
|
||||
return $self->handle_action($stuff, $action);
|
||||
}
|
||||
|
||||
@ -862,7 +861,7 @@ sub handle_action {
|
||||
|
||||
return "" if not length $action;
|
||||
|
||||
my ($channel, $keyword) = ($stuff->{channel}, $stuff->{keyword});
|
||||
my ($channel, $keyword) = ($stuff->{channel}, $stuff->{trigger});
|
||||
|
||||
unless (exists $self->{factoids}->hash->{$channel}->{$keyword}->{interpolate} and $self->{factoids}->hash->{$channel}->{$keyword}->{interpolate} eq '0') {
|
||||
$action = $self->expand_factoid_vars($stuff->{from}, $stuff->{nick}, $stuff->{root_keyword}, $action);
|
||||
@ -914,7 +913,7 @@ sub handle_action {
|
||||
$action = $self->expand_action_arguments($action, $stuff->{arguments}, $stuff->{nick});
|
||||
}
|
||||
|
||||
return $action if $stuff->{command} eq 'code-factoid';
|
||||
return $action if $stuff->{special} eq 'code-factoid';
|
||||
|
||||
if ($self->{factoids}->hash->{$channel}->{$keyword}->{type} eq 'module') {
|
||||
my $preserve_whitespace = $self->{factoids}->hash->{$channel}->{$keyword}->{preserve_whitespace};
|
||||
|
@ -262,7 +262,7 @@ sub interpret {
|
||||
|
||||
$stuff->{prepend} = '/say ' unless exists $self->{pipe};
|
||||
|
||||
$stuff->{arguments} = $args;
|
||||
$arguments = $args;
|
||||
$stuff->{pipe} = $pipe;
|
||||
$stuff->{pipe_rest} = $rest;
|
||||
$got_pipe = 1;
|
||||
@ -273,7 +273,7 @@ sub interpret {
|
||||
|
||||
$stuff->{nickoverride} = $stuff->{nick} if defined $stuff->{nickoverride} and lc $stuff->{nickoverride} eq 'me';
|
||||
|
||||
if ((not exists $stuff->{pipe}) and $keyword !~ /^(?:factrem|forget|set|factdel|factadd|add|factfind|find|factshow|show|forget|factdel|factset|factchange|change|msg|tell|cc|eval|u|udict|ud|actiontrigger|urban|perl)$/) {
|
||||
if ($keyword !~ /^(?:factrem|forget|set|factdel|factadd|add|factfind|find|factshow|show|forget|factdel|factset|factchange|change|msg|tell|cc|eval|u|udict|ud|actiontrigger|urban|perl)$/) {
|
||||
$keyword =~ s/(\w+)([?!.]+)$/$1/;
|
||||
$arguments =~ s/(?<![\w\/\-\\])me\b/$stuff->{nick}/gi if defined $arguments && $stuff->{interpret_depth} <= 2;
|
||||
$arguments =~ s/(?<![\w\/\-\\])my\b/$stuff->{nick}'s/gi if defined $arguments && $stuff->{interpret_depth} <= 2;
|
||||
@ -300,12 +300,12 @@ sub interpret {
|
||||
return undef;
|
||||
}
|
||||
|
||||
$stuff->{keyword} = $keyword;
|
||||
if (not exists $stuff->{root_keyword}) {
|
||||
$stuff->{root_keyword} = $keyword;
|
||||
}
|
||||
|
||||
$stuff->{arguments} = $arguments unless $got_pipe;
|
||||
$stuff->{keyword} = $keyword;
|
||||
$stuff->{arguments} = $arguments;
|
||||
|
||||
return $self->SUPER::execute_all($stuff);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user