diff --git a/lib/PBot/Plugin/RunCommand.pm b/lib/PBot/Plugin/RunCommand.pm index 5ea47637..528bac24 100644 --- a/lib/PBot/Plugin/RunCommand.pm +++ b/lib/PBot/Plugin/RunCommand.pm @@ -55,24 +55,32 @@ sub cmd_runcmd { my $lines = 0; while (pump $h) { - if ($out =~ s/^(.*?)\n//) { - $self->{pbot}->{conn}->privmsg($context->{from}, $1); - $lines++; - } + $lines += $self->send_lines($context, \$out); } finish $h; - if (length $out) { - my @lines = split /\n/, $out; + $lines += $self->send_lines($context, \$out); - foreach my $line (@lines) { + return "No output." if not $lines; +} + +sub send_lines { + my ($self, $context, $buffer) = @_; + + my ($line, $lines); + + while ($$buffer =~ s/(.{1,370})//) { + $line = $1; + $line =~ s/^\s+|\s+$//g; + + if (length $line) { $self->{pbot}->{conn}->privmsg($context->{from}, $line); $lines++; } } - return "No output." if not $lines; + return $lines; } 1; diff --git a/lib/PBot/VERSION.pm b/lib/PBot/VERSION.pm index e08ff03c..caada57c 100644 --- a/lib/PBot/VERSION.pm +++ b/lib/PBot/VERSION.pm @@ -25,8 +25,8 @@ use PBot::Imports; # These are set by the /misc/update_version script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 4340, - BUILD_DATE => "2021-08-02", + BUILD_REVISION => 4341, + BUILD_DATE => "2021-08-04", }; sub initialize {}