skillbot

changeset 57:fabae7870b52

Avoid updating during downtime windows
author Dominic Cleal <dominic@computerkb.co.uk>
date Sun Dec 28 16:41:53 2008 +0000 (2008-12-28)
parents c604d8d6ccc5
children 7d43407a9214
files skillbot.pl
line diff
     1.1 --- a/skillbot.pl	Sun Dec 28 16:38:57 2008 +0000
     1.2 +++ b/skillbot.pl	Sun Dec 28 16:41:53 2008 +0000
     1.3 @@ -240,7 +240,7 @@
     1.4  			my $text;
     1.5  			if (defined $f->{skill}) {
     1.6  				my $downtime = '';
     1.7 -				if (skill_finish_in_downtime($f->{skill_finish})) {
     1.8 +				if (timestamp_in_downtime($f->{skill_finish})) {
     1.9  					$downtime = ", coincides with downtime";
    1.10  				}
    1.11  
    1.12 @@ -481,6 +481,9 @@
    1.13  	my $self = shift;
    1.14  	my $f = shift;
    1.15  
    1.16 +    # Don't attempt updates during downtime, can cause crash
    1.17 +	return if (timestamp_in_downtime(time));
    1.18 +
    1.19  	my $skill = $f->{char_api}->skill->in_training;
    1.20  	
    1.21  	# Nothing training
    1.22 @@ -524,7 +527,7 @@
    1.23  	$f->{skill_name} = sprintf("%s %d", $skill->name, $skill->level);
    1.24  
    1.25  	# Check if the finish time is within scheduled EVE downtime
    1.26 -	if (skill_finish_in_downtime($f->{skill_finish}))
    1.27 +	if (timestamp_in_downtime($f->{skill_finish}))
    1.28  	{
    1.29  		$self->privmsg('#' . $config{channel}, sprintf(
    1.30  					   "\002%s:\002 Completion time of %s's %s " .
    1.31 @@ -561,16 +564,16 @@
    1.32  
    1.33  =pod
    1.34  
    1.35 -Indicate whether the passed skill object is due to finish during a normal,
    1.36 +Indicate whether the passed timestamp is due to finish during a normal,
    1.37  scheduled downtime window.
    1.38  
    1.39  =cut
    1.40 -sub skill_finish_in_downtime
    1.41 +sub timestamp_in_downtime
    1.42  {
    1.43 -	my $skill = shift;
    1.44 +	my $ts = shift;
    1.45  
    1.46  	# Check if the finish time is within 11:00-11:59 (EVE downtime)
    1.47 -	return ([gmtime($skill)]->[2] == 11);
    1.48 +	return ([gmtime($ts)]->[2] == 11);
    1.49  }
    1.50  
    1.51  END {