From b7f2c188bcc572d2c37659473f63147f28b6859e Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Tue, 6 Aug 2019 10:38:46 -0700 Subject: [PATCH] Improve handling of newlines in factoids --- PBot/Factoids.pm | 7 ++++--- PBot/Interpreter.pm | 15 ++++++++++----- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/PBot/Factoids.pm b/PBot/Factoids.pm index 6821617c..b62b70e0 100644 --- a/PBot/Factoids.pm +++ b/PBot/Factoids.pm @@ -311,7 +311,7 @@ sub find_factoid { if ($keyword =~ m/^\Q$trigger\E$/i) { $self->{pbot}->{logger}->log("return $channel: $trigger\n") if $debug; - if ($opts{find_alias} && $self->{factoids}->hash->{$channel}->{$trigger}->{action} =~ /^\/call\s+(.*)$/) { + if ($opts{find_alias} && $self->{factoids}->hash->{$channel}->{$trigger}->{action} =~ /^\/call\s+(.*)$/ms) { my $command; if (length $arguments) { $command = "$1 $arguments"; @@ -466,7 +466,7 @@ sub expand_factoid_vars { my ($var_chan, $var) = ($factoids[0]->[0], $factoids[0]->[1]); - if ($self->{factoids}->hash->{$var_chan}->{$var}->{action} =~ m{^/call (.*)}) { + if ($self->{factoids}->hash->{$var_chan}->{$var}->{action} =~ m{^/call (.*)}ms) { $test_v = $1; next if ++$recurse > 100; goto ALIAS; @@ -973,8 +973,9 @@ sub handle_action { } # Check if it's an alias - if ($action =~ /^\/call\s+(.*)$/) { + if ($action =~ /^\/call\s+(.*)$/ms) { my $command = $1; + $command =~ s/\n$//; unless ($self->{factoids}->hash->{$channel}->{$keyword}->{'require_explicit_args'}) { my $args = $stuff->{arguments}; $command .= " $args" if length $args and not $stuff->{special} eq 'code-factoid'; diff --git a/PBot/Interpreter.pm b/PBot/Interpreter.pm index 77aa2069..5e2ecc24 100644 --- a/PBot/Interpreter.pm +++ b/PBot/Interpreter.pm @@ -182,8 +182,12 @@ sub process_line { $stuff->{text} = $text; $stuff->{command} = $command; - $stuff->{nickoverride} = $nick_override if $nick_override; - $stuff->{force_nickoverride} = 1 if $nick_override; + + if ($nick_override) { + $stuff->{nickoverride} = $nick_override; + $stuff->{force_nickoverride} = 1; + } + $stuff->{referenced} = $embedded; $stuff->{interpret_depth} = 1; $stuff->{preserve_whitespace} = $preserve_whitespace; @@ -220,12 +224,13 @@ sub interpret { } # check for splitted commands - if ($stuff->{command} =~ m/^(.*?)\s*(?{command} =~ m/^(.*?)\s*(?{command} = $1; $stuff->{command_split} = $2; } my $cmdlist = $self->make_args($stuff->{command}); + if ($self->arglist_size($cmdlist) >= 4 and lc $cmdlist->[0] eq 'tell' and (lc $cmdlist->[2] eq 'about' or lc $cmdlist->[2] eq 'the')) { # tell nick about cmd [args] $stuff->{nickoverride} = $cmdlist->[1]; @@ -269,7 +274,7 @@ sub interpret { if (defined $arguments && $arguments =~ m/(?extract_bracketed($arguments, '{', '}', '|', 1); - $arguments =~ s/\s*(?{pipe}) { @@ -652,7 +657,7 @@ sub split_line { next; } - if ($ch eq ' ') { + if ($ch eq ' ' or $ch eq "\n" or $ch eq "\t") { if (++$spaces > 1 and $opts{keep_spaces}) { $token .= $ch; next;