changeset 57:fabae7870b52

Avoid updating during downtime windows
author Dominic Cleal <dominic@computerkb.co.uk>
date Sun, 28 Dec 2008 16:41:53 +0000
parents c604d8d6ccc5
children 7d43407a9214
files skillbot.pl
diffstat 1 files changed, 9 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/skillbot.pl	Sun Dec 28 16:38:57 2008 +0000
+++ b/skillbot.pl	Sun Dec 28 16:41:53 2008 +0000
@@ -240,7 +240,7 @@
 			my $text;
 			if (defined $f->{skill}) {
 				my $downtime = '';
-				if (skill_finish_in_downtime($f->{skill_finish})) {
+				if (timestamp_in_downtime($f->{skill_finish})) {
 					$downtime = ", coincides with downtime";
 				}
 
@@ -481,6 +481,9 @@
 	my $self = shift;
 	my $f = shift;
 
+    # Don't attempt updates during downtime, can cause crash
+	return if (timestamp_in_downtime(time));
+
 	my $skill = $f->{char_api}->skill->in_training;
 	
 	# Nothing training
@@ -524,7 +527,7 @@
 	$f->{skill_name} = sprintf("%s %d", $skill->name, $skill->level);
 
 	# Check if the finish time is within scheduled EVE downtime
-	if (skill_finish_in_downtime($f->{skill_finish}))
+	if (timestamp_in_downtime($f->{skill_finish}))
 	{
 		$self->privmsg('#' . $config{channel}, sprintf(
 					   "\002%s:\002 Completion time of %s's %s " .
@@ -561,16 +564,16 @@
 
 =pod
 
-Indicate whether the passed skill object is due to finish during a normal,
+Indicate whether the passed timestamp is due to finish during a normal,
 scheduled downtime window.
 
 =cut
-sub skill_finish_in_downtime
+sub timestamp_in_downtime
 {
-	my $skill = shift;
+	my $ts = shift;
 
 	# Check if the finish time is within 11:00-11:59 (EVE downtime)
-	return ([gmtime($skill)]->[2] == 11);
+	return ([gmtime($ts)]->[2] == 11);
 }
 
 END {