mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-05 19:49:32 +01:00
Plugin/RunCommand: improve pumping and handle lines longer than maximum IRC mesasge length
This commit is contained in:
parent
4c5492f5e9
commit
5c43b46477
@ -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;
|
||||
|
@ -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 {}
|
||||
|
Loading…
Reference in New Issue
Block a user