3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-24 19:52:34 +01:00

Improve handling of white-space when splitting output on new-lines

This commit is contained in:
Pragmatic Software 2014-08-11 07:32:24 +00:00
parent c03a1288b6
commit 321fdc401c
2 changed files with 9 additions and 3 deletions

View File

@ -166,7 +166,13 @@ sub handle_result {
$max_lines = 4 if not defined $max_lines;
my $lines = 0;
foreach my $line (split /[\n\r]/, $result) {
my $stripped_line;
foreach my $line (split /[\n\r]+/, $result) {
$stripped_line = $line;
$stripped_line =~ s/^\s+//;
$stripped_line =~ s/\s+$//;
next if not length $stripped_line;
if (++$lines >= $max_lines) {
my $link = paste_sprunge("[" . (defined $from ? $from : "stdin") . "] <$nick> $text\n\n$original_result");
$pbot->{conn}->privmsg($from, "And that's all I have to say about that. See $link for full text.");

View File

@ -13,8 +13,8 @@ use warnings;
# These are set automatically by the build/commit script
use constant {
BUILD_NAME => "PBot",
BUILD_REVISION => 772,
BUILD_DATE => "2014-08-09",
BUILD_REVISION => 773,
BUILD_DATE => "2014-08-11",
};
1;