compiler_vm: print "Same output" only if same output is within 10 minutes of last snippet otherwise print actual output again

This commit is contained in:
Pragmatic Software 2014-04-03 07:47:19 +00:00
parent b2544d9d5a
commit 8a7c539e0f
2 changed files with 17 additions and 9 deletions

View File

@ -13,8 +13,8 @@ use warnings;
# These are set automatically by the build/commit script
use constant {
BUILD_NAME => "PBot",
BUILD_REVISION => 538,
BUILD_DATE => "2014-04-02",
BUILD_REVISION => 539,
BUILD_DATE => "2014-04-03",
};
1;

View File

@ -8,6 +8,7 @@ use IPC::Open2;
use Text::Balanced qw(extract_bracketed extract_delimited);
use IO::Socket;
use LWP::UserAgent;
use Time::HiRes qw/gettimeofday/;
my $debug = 0;
@ -1144,20 +1145,27 @@ if(defined $got_paste or (defined $got_run and $got_run eq "paste")) {
if(open FILE, "< history/$channel.last-output") {
my $last_output;
my $time = <FILE>;
while(my $line = <FILE>) {
$last_output .= $line;
}
close FILE;
if(gettimeofday - $time > 60 * 10) {
close FILE;
} else {
while(my $line = <FILE>) {
$last_output .= $line;
}
close FILE;
if($last_output eq $output) {
print "$nick: Same output.\n";
exit 0;
if($last_output eq $output) {
print "$nick: Same output.\n";
exit 0;
}
}
}
print "$nick: $output\n";
open FILE, "> history/$channel.last-output" or die "Couldn't open $channel.last-output: $!";
my $now = gettimeofday;
print FILE "$now\n";
print FILE "$output";
close FILE;