Improve handling of newlines in factoids

This commit is contained in:
Pragmatic Software 2019-08-06 10:38:46 -07:00
parent 36cb4db040
commit b7f2c188bc
2 changed files with 14 additions and 8 deletions

View File

@ -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';

View File

@ -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*(?<!\\);;\s*(.*)/) {
if ($stuff->{command} =~ m/^(.*?)\s*(?<!\\);;\s*(.*)/ms) {
$stuff->{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/(?<!\\)\|\s*\{\s*[^}]+\}\s*$/) {
my ($pipe, $rest) = $self->extract_bracketed($arguments, '{', '}', '|', 1);
$arguments =~ s/\s*(?<!\\)\|\s*{(\Q$pipe\E)}.*$//;
$arguments =~ s/\s*(?<!\\)\|\s*{(\Q$pipe\E)}.*$//s;
$pipe =~ s/^\s+|\s+$//g;
if (exists $stuff->{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;