# HG changeset patch # User Dominic Cleal # Date 1228953878 0 # Node ID bf685f1a545f4743cfa3cad53d5618ef723fa72c # Parent 2f9832b6dededcbf7fea706df35f18c90a437be6 Adding detection of downtime windows diff -r 2f9832b6dede -r bf685f1a545f skillbot.pl --- a/skillbot.pl Wed Dec 10 22:35:48 2008 +0000 +++ b/skillbot.pl Thu Dec 11 00:04:38 2008 +0000 @@ -231,11 +231,19 @@ for my $f (@friends) { if ((defined $2 && lc($f->{char}->name) eq lc($2)) || (!defined $2 && $f->{nick} eq $their_nick)) { - my $text = (defined $f->{skill} - ? sprintf("Currently training %s %s (finish in %s)", + my $text; + if (defined $f->{skill}) { + my $downtime = undef; + if (skill_finish_in_downtime($f->{skill})) { + $downtime = ", coincides with downtime"; + } + + $text = sprintf("Currently training %s %s (finish in %s%s)", $f->{skill}->name, $f->{skill}->level, - $f->{skill}->time_remaining) - : "No skill currently training"); + $f->{skill}->time_remaining, $downtime) + } else { + $text = "No skill currently training"; + } $self->privmsg('#' . $config{channel}, sprintf( "\002%s:\002 %s", $f->{char}->name, @@ -494,6 +502,16 @@ $f->{skill} = $skill; + # Check if the finish time is within scheduled EVE downtime + if (skill_finish_in_downtime($f->{skill})) + { + $self->privmsg('#' . $config{channel}, sprintf( + "\002%s:\002 Training completion time of %s %lu will " . + "coincide with scheduled downtime at %s", + $f->{nick}, $f->{skill}->name, $f->{skill}->level, + scalar(gmtime($f->{skill}->finish_time)))); + } + my $text = sprintf("%s has completed training skill %s %s", $f->{char}->name, $skill->name, $skill->level); @@ -517,6 +535,20 @@ }); } +=pod + +Indicate whether the passed skill object is due to finish during a normal, +scheduled downtime window. + +=cut +sub skill_finish_in_downtime +{ + my $skill = shift; + + # Check if the finish time is within 11:00-11:59 (EVE downtime) + return ([gmtime($skill->finish_time)]->[2] == 11); +} + END { cleanup_and_die(); }