mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-25 13:29:29 +01:00
Increase indentation size
This commit is contained in:
parent
46fdd01ccd
commit
6b93005808
@ -69,10 +69,10 @@ sub preprocess_code {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unless($self->{got_run} and $self->{copy_code}) {
|
unless($self->{got_run} and $self->{copy_code}) {
|
||||||
open FILE, ">> $RealBin/../log.txt";
|
open LOG, ">> $RealBin/../log.txt";
|
||||||
print FILE localtime() . "\n";
|
print LOG localtime() . "\n";
|
||||||
print FILE "$self->{nick} $self->{channel}: [" . $self->{arguments} . "] " . $self->{cmdline_options} . "$self->{code}\n";
|
print LOG "$self->{nick} $self->{channel}: [" . $self->{arguments} . "] " . $self->{cmdline_options} . "$self->{code}\n";
|
||||||
close FILE;
|
close LOG;
|
||||||
}
|
}
|
||||||
|
|
||||||
# replace \n outside of quotes with literal newline
|
# replace \n outside of quotes with literal newline
|
||||||
@ -140,11 +140,11 @@ sub postprocess_output {
|
|||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
unless($self->{got_run} and $self->{copy_code}) {
|
unless($self->{got_run} and $self->{copy_code}) {
|
||||||
open FILE, ">> $RealBin/../log.txt";
|
open LOG, ">> $RealBin/../log.txt";
|
||||||
print FILE "--------------------------post processing----------------------------------------------\n";
|
print LOG "--------------------------post processing----------------------------------------------\n";
|
||||||
print FILE localtime() . "\n";
|
print LOG localtime() . "\n";
|
||||||
print FILE "$self->{output}\n";
|
print LOG "$self->{output}\n";
|
||||||
close FILE;
|
close LOG;
|
||||||
}
|
}
|
||||||
|
|
||||||
# backspace
|
# backspace
|
||||||
@ -173,12 +173,12 @@ sub show_output {
|
|||||||
my $output = $self->{output};
|
my $output = $self->{output};
|
||||||
|
|
||||||
unless ($self->{got_run} and $self->{copy_code}) {
|
unless ($self->{got_run} and $self->{copy_code}) {
|
||||||
open FILE, ">> $RealBin/../log.txt";
|
open LOG, ">> $RealBin/../log.txt";
|
||||||
print FILE "------------------------show output------------------------------------------------\n";
|
print LOG "------------------------show output------------------------------------------------\n";
|
||||||
print FILE localtime() . "\n";
|
print LOG localtime() . "\n";
|
||||||
print FILE "$output\n";
|
print LOG "$output\n";
|
||||||
print FILE "========================================================================\n";
|
print LOG "========================================================================\n";
|
||||||
close FILE;
|
close LOG;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exists $self->{options}->{'-paste'} or (defined $self->{got_run} and $self->{got_run} eq 'paste')) {
|
if (exists $self->{options}->{'-paste'} or (defined $self->{got_run} and $self->{got_run} eq 'paste')) {
|
||||||
@ -237,17 +237,17 @@ sub show_output {
|
|||||||
exit 0;
|
exit 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($self->{channel} =~ m/^#/ and length $output > 22 and open FILE, "< $RealBin/../history/$self->{channel}-$self->{lang}.last-output") {
|
if($self->{channel} =~ m/^#/ and length $output > 22 and open LOG, "< $RealBin/../history/$self->{channel}-$self->{lang}.last-output") {
|
||||||
my $last_output;
|
my $last_output;
|
||||||
my $time = <FILE>;
|
my $time = <LOG>;
|
||||||
|
|
||||||
if(gettimeofday - $time > 60 * 4) {
|
if(gettimeofday - $time > 60 * 4) {
|
||||||
close FILE;
|
close LOG;
|
||||||
} else {
|
} else {
|
||||||
while(my $line = <FILE>) {
|
while(my $line = <LOG>) {
|
||||||
$last_output .= $line;
|
$last_output .= $line;
|
||||||
}
|
}
|
||||||
close FILE;
|
close LOG;
|
||||||
|
|
||||||
if((not $self->{factoid}) and defined $last_output and $last_output eq $output) {
|
if((not $self->{factoid}) and defined $last_output and $last_output eq $output) {
|
||||||
print "Same output.\n";
|
print "Same output.\n";
|
||||||
@ -258,11 +258,11 @@ sub show_output {
|
|||||||
|
|
||||||
print "$output\n";
|
print "$output\n";
|
||||||
|
|
||||||
open FILE, "> $RealBin/../history/$self->{channel}-$self->{lang}.last-output" or die "Couldn't open $self->{channel}-$self->{lang}.last-output: $!";
|
open LOG, "> $RealBin/../history/$self->{channel}-$self->{lang}.last-output" or die "Couldn't open $self->{channel}-$self->{lang}.last-output: $!";
|
||||||
my $now = gettimeofday;
|
my $now = gettimeofday;
|
||||||
print FILE "$now\n";
|
print LOG "$now\n";
|
||||||
print FILE "$output";
|
print LOG "$output";
|
||||||
close FILE;
|
close LOG;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub paste_ixio {
|
sub paste_ixio {
|
||||||
@ -359,12 +359,7 @@ sub execute {
|
|||||||
$cmdline =~ s/\$sourcefile/$self->{sourcefile}/g;
|
$cmdline =~ s/\$sourcefile/$self->{sourcefile}/g;
|
||||||
$cmdline =~ s/\$execfile/$self->{execfile}/g;
|
$cmdline =~ s/\$execfile/$self->{execfile}/g;
|
||||||
|
|
||||||
my $options;
|
my $options = length $self->{cmdline_options} ? $self->{cmdline_options} : $self->{default_options};
|
||||||
if (length $self->{cmdline_options}) {
|
|
||||||
$options = $self->{cmdline_options};
|
|
||||||
} else {
|
|
||||||
$options = $self->{default_options};
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((not exists $self->{options}->{'-paste'}) and (not defined $self->{got_run} or $self->{got_run} ne 'paste')) {
|
if ((not exists $self->{options}->{'-paste'}) and (not defined $self->{got_run} or $self->{got_run} ne 'paste')) {
|
||||||
if (exists $self->{options_nopaste}) {
|
if (exists $self->{options_nopaste}) {
|
||||||
@ -384,10 +379,10 @@ sub execute {
|
|||||||
$cmdline =~ s/\$options\s+//;
|
$cmdline =~ s/\$options\s+//;
|
||||||
}
|
}
|
||||||
|
|
||||||
open FILE, ">> $RealBin/../log.txt";
|
open LOG, ">> $RealBin/../log.txt";
|
||||||
print FILE "---------------------executing---------------------------------------------------\n";
|
print LOG "---------------------executing---------------------------------------------------\n";
|
||||||
print FILE localtime() . "\n";
|
print LOG localtime() . "\n";
|
||||||
print FILE "$cmdline\n$stdin\n$pretty_code\n";
|
print LOG "$cmdline\n$stdin\n$pretty_code\n";
|
||||||
|
|
||||||
my $compile_in = {
|
my $compile_in = {
|
||||||
lang => $self->{lang},
|
lang => $self->{lang},
|
||||||
@ -404,9 +399,7 @@ sub execute {
|
|||||||
$compile_in->{'persist-key'} = $self->{'persist-key'} if length $self->{'persist-key'};
|
$compile_in->{'persist-key'} = $self->{'persist-key'} if length $self->{'persist-key'};
|
||||||
|
|
||||||
my $compile_json = encode_json($compile_in);
|
my $compile_json = encode_json($compile_in);
|
||||||
print STDERR "outgoing json: $compile_json\n";
|
|
||||||
$compile_json .= encode('UTF-8', "\n:end:\n");
|
$compile_json .= encode('UTF-8', "\n:end:\n");
|
||||||
print STDERR "outgoing json after concat: $compile_json\n";
|
|
||||||
|
|
||||||
my $length = length $compile_json;
|
my $length = length $compile_json;
|
||||||
my $sent = 0;
|
my $sent = 0;
|
||||||
@ -414,42 +407,40 @@ sub execute {
|
|||||||
my $chunk_size = $length < $chunk_max ? $length : $chunk_max;
|
my $chunk_size = $length < $chunk_max ? $length : $chunk_max;
|
||||||
my $chunks_sent = 0;
|
my $chunks_sent = 0;
|
||||||
|
|
||||||
#print FILE "Sending $length bytes [$compile_json] to vm_server\n";
|
#print LOG "Sending $length bytes [$compile_json] to vm_server\n";
|
||||||
|
|
||||||
$chunk_size -= 1; # account for newline in syswrite
|
$chunk_size -= 1; # account for newline in syswrite
|
||||||
|
|
||||||
while ($chunks_sent < $length) {
|
while ($chunks_sent < $length) {
|
||||||
my $chunk = substr $compile_json, $chunks_sent, $chunk_size;
|
my $chunk = substr $compile_json, $chunks_sent, $chunk_size;
|
||||||
#print FILE "Sending chunk [$chunk]\n";
|
#print LOG "Sending chunk [$chunk]\n";
|
||||||
$chunks_sent += length $chunk;
|
$chunks_sent += length $chunk;
|
||||||
|
|
||||||
my $ret = syswrite($vm, $chunk);
|
my $ret = syswrite($vm, $chunk);
|
||||||
|
|
||||||
if (not defined $ret) {
|
if (not defined $ret) {
|
||||||
print FILE "Error sending: $!\n";
|
print LOG "Error sending: $!\n";
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($ret == 0) {
|
if ($ret == 0) {
|
||||||
print FILE "Sent 0 bytes. Sleep 1 sec and try again\n";
|
print LOG "Sent 0 bytes. Sleep 1 sec and try again\n";
|
||||||
sleep 1;
|
sleep 1;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sent += $ret;
|
$sent += $ret;
|
||||||
print FILE "Sent $ret bytes, so far $sent ...\n";
|
print LOG "Sent $ret bytes, so far $sent ...\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
#print FILE "Done sending!\n";
|
#print LOG "Done sending!\n";
|
||||||
close FILE;
|
close LOG;
|
||||||
|
|
||||||
my $result = "";
|
my $result = "";
|
||||||
my $got_result = 0;
|
my $got_result = 0;
|
||||||
|
|
||||||
while(my $line = <$vm_output>) {
|
while(my $line = <$vm_output>) {
|
||||||
utf8::decode($line);
|
utf8::decode($line);
|
||||||
print STDERR "Read from vm [$line]\n";
|
|
||||||
|
|
||||||
$line =~ s/[\r\n]+$//;
|
$line =~ s/[\r\n]+$//;
|
||||||
last if $line =~ /^result:end$/;
|
last if $line =~ /^result:end$/;
|
||||||
|
|
||||||
@ -489,10 +480,6 @@ sub process_standard_options {
|
|||||||
|
|
||||||
my @opt_args = $self->split_line($self->{code}, preserve_escapes => 1, keep_spaces => 0);
|
my @opt_args = $self->split_line($self->{code}, preserve_escapes => 1, keep_spaces => 0);
|
||||||
|
|
||||||
use Data::Dumper;
|
|
||||||
print STDERR "code:\n$self->{code}\n";
|
|
||||||
print STDERR "opt_arg: ", Dumper \@opt_args;
|
|
||||||
|
|
||||||
my $getopt_error;
|
my $getopt_error;
|
||||||
local $SIG{__WARN__} = sub {
|
local $SIG{__WARN__} = sub {
|
||||||
$getopt_error = shift;
|
$getopt_error = shift;
|
||||||
@ -570,9 +557,9 @@ sub process_interactive_edit {
|
|||||||
if($subcode =~ s/^\s*copy\s+(\S+)\s*//) {
|
if($subcode =~ s/^\s*copy\s+(\S+)\s*//) {
|
||||||
my $copy = $1;
|
my $copy = $1;
|
||||||
|
|
||||||
if(open FILE, "< $RealBin/../history/$copy-$self->{lang}.hist") {
|
if(open LOG, "< $RealBin/../history/$copy-$self->{lang}.hist") {
|
||||||
$copy_code = <FILE>;
|
$copy_code = <LOG>;
|
||||||
close FILE;
|
close LOG;
|
||||||
goto COPY_ERROR if not $copy_code;;
|
goto COPY_ERROR if not $copy_code;;
|
||||||
chomp $copy_code;
|
chomp $copy_code;
|
||||||
} else {
|
} else {
|
||||||
@ -595,12 +582,12 @@ sub process_interactive_edit {
|
|||||||
$self->{channel} = $1;
|
$self->{channel} = $1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(open FILE, "< $RealBin/../history/$self->{channel}-$self->{lang}.hist") {
|
if(open LOG, "< $RealBin/../history/$self->{channel}-$self->{lang}.hist") {
|
||||||
while(my $line = <FILE>) {
|
while(my $line = <LOG>) {
|
||||||
chomp $line;
|
chomp $line;
|
||||||
push @last_code, $line;
|
push @last_code, $line;
|
||||||
}
|
}
|
||||||
close FILE;
|
close LOG;
|
||||||
}
|
}
|
||||||
|
|
||||||
unshift @last_code, $copy_code if defined $copy_code;
|
unshift @last_code, $copy_code if defined $copy_code;
|
||||||
@ -1019,15 +1006,15 @@ sub process_interactive_edit {
|
|||||||
unshift @last_code, $code;
|
unshift @last_code, $code;
|
||||||
}
|
}
|
||||||
|
|
||||||
open FILE, "> $RealBin/../history/$self->{channel}-$self->{lang}.hist";
|
open LOG, "> $RealBin/../history/$self->{channel}-$self->{lang}.hist";
|
||||||
|
|
||||||
my $i = 0;
|
my $i = 0;
|
||||||
foreach my $line (@last_code) {
|
foreach my $line (@last_code) {
|
||||||
last if(++$i > $self->{max_history});
|
last if(++$i > $self->{max_history});
|
||||||
print FILE "$line\n";
|
print LOG "$line\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
close FILE;
|
close LOG;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($got_diff) {
|
if ($got_diff) {
|
||||||
|
Loading…
Reference in New Issue
Block a user