mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-25 20:22:37 +01:00
Add ability to set maximum number of newlines allowed before truncating for preserve newlines
This commit is contained in:
parent
dddc9c3be9
commit
48382de916
@ -162,12 +162,14 @@ sub handle_result {
|
|||||||
$result =~ s/[\n\r]/ /g unless $preserve_newlines;
|
$result =~ s/[\n\r]/ /g unless $preserve_newlines;
|
||||||
$result =~ s/[ \t]+/ /g unless $preserve_whitespace;
|
$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;
|
my $lines = 0;
|
||||||
|
|
||||||
foreach my $line (split /[\n\r]/, $result) {
|
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");
|
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, "And that's all I have to say about that. See $link for full text.");
|
||||||
$pbot->{conn}->privmsg($from, $line);
|
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ use warnings;
|
|||||||
# These are set automatically by the build/commit script
|
# These are set automatically by the build/commit script
|
||||||
use constant {
|
use constant {
|
||||||
BUILD_NAME => "PBot",
|
BUILD_NAME => "PBot",
|
||||||
BUILD_REVISION => 769,
|
BUILD_REVISION => 770,
|
||||||
BUILD_DATE => "2014-08-05",
|
BUILD_DATE => "2014-08-05",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user