From 48382de91647e02d8a249ac87ee55167c6a806af Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Tue, 5 Aug 2014 23:15:11 +0000 Subject: [PATCH] Add ability to set maximum number of newlines allowed before truncating for preserve newlines --- PBot/Interpreter.pm | 8 +++++--- PBot/VERSION.pm | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/PBot/Interpreter.pm b/PBot/Interpreter.pm index a271ae00..650ee583 100644 --- a/PBot/Interpreter.pm +++ b/PBot/Interpreter.pm @@ -162,12 +162,14 @@ sub handle_result { $result =~ s/[\n\r]/ /g unless $preserve_newlines; $result =~ s/[ \t]+/ /g unless $preserve_whitespace; + my $max_lines = $self->{pbot}->{registry}->get_value($from, 'max_newlines'); + $max_lines = 4 if not defined $max_lines; my $lines = 0; + foreach my $line (split /[\n\r]/, $result) { - if (++$lines >= 4) { + if (++$lines >= $max_lines) { my $link = paste_sprunge("[" . (defined $from ? $from : "stdin") . "] <$nick> $text\n\n$original_result"); - $line = "And that's all I have to say about that. See $link for full text."; - $pbot->{conn}->privmsg($from, $line); + $pbot->{conn}->privmsg($from, "And that's all I have to say about that. See $link for full text."); last; } diff --git a/PBot/VERSION.pm b/PBot/VERSION.pm index 46e5059e..5f7966b0 100644 --- a/PBot/VERSION.pm +++ b/PBot/VERSION.pm @@ -13,7 +13,7 @@ use warnings; # These are set automatically by the build/commit script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 769, + BUILD_REVISION => 770, BUILD_DATE => "2014-08-05", };