Add ability to set maximum number of newlines allowed before truncating for preserve newlines

This commit is contained in:
Pragmatic Software 2014-08-05 23:15:11 +00:00
parent dddc9c3be9
commit 48382de916
2 changed files with 6 additions and 4 deletions

View File

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

View File

@ -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",
};