3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-25 04:02:37 +01:00

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 # These are set automatically by the build/commit script
use constant { use constant {
BUILD_NAME => "PBot", BUILD_NAME => "PBot",
BUILD_REVISION => 538, BUILD_REVISION => 539,
BUILD_DATE => "2014-04-02", BUILD_DATE => "2014-04-03",
}; };
1; 1;

View File

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