From 8ba0664b8502032a1a4808ccdb654b4c5ceb7674 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Thu, 5 Oct 2017 14:31:00 -0700 Subject: [PATCH] Improve parsing of embedded factoids --- PBot/Interpreter.pm | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/PBot/Interpreter.pm b/PBot/Interpreter.pm index 3e6e5668..8519f3de 100644 --- a/PBot/Interpreter.pm +++ b/PBot/Interpreter.pm @@ -113,6 +113,19 @@ sub process_line { $preserve_whitespace = 1; my $nick_override = $self->{pbot}->{nicklist}->is_present($from, $nick_override); $processed += 100; + } elsif($cmd_text =~ s/^$bot_trigger(.*)$//) { + $command = $1; + $processed += 100; + } elsif ($cmd_text =~ s/\B$bot_trigger`([^`]+)// || $cmd_text =~ s/\B$bot_trigger\{([^}]+)//) { + my $cmd = $1; + my ($nick) = $cmd_text =~ m/^([^ ,:;]+)/; + $nick = $self->{pbot}->{nicklist}->is_present($from, $nick); + if ($nick) { + $command = "tell $nick about $cmd"; + } else { + $command = $cmd; + } + $referenced = 1; } elsif($cmd_text =~ s/^\s*([^,:\(\)\+\*\/ ]+)[,:]?\s+$bot_trigger(.*)$//) { $nick_override = $1; $command = $2; @@ -135,16 +148,6 @@ sub process_line { } elsif($cmd_text =~ s/^(.*?),?\s*$botnick[?!.]*$//i) { $command = $1; $processed += 100; - } elsif ($cmd_text =~ s/\B$bot_trigger`([^`]+)// || $cmd_text =~ s/\B$bot_trigger\{([^}]+)//) { - my $cmd = $1; - my ($nick) = $cmd_text =~ m/^([^ ,:;]+)/; - $nick = $self->{pbot}->{nicklist}->is_present($from, $nick); - if ($nick) { - $command = "tell $nick about $cmd"; - } else { - $command = $cmd; - } - $referenced = 1; } last if not defined $command and not defined $has_code;