# HG changeset patch # User Dominic Cleal # Date 1228576194 0 # Node ID 6b73a2781c15b859be8fb5b1b34f6c4c97acfe1d # Parent f0f55a4999b728cd61e57fc63b759e0cba1dea3e Skill completion notifications done diff -r f0f55a4999b7 -r 6b73a2781c15 skillbot.pl --- a/skillbot.pl Sat Dec 06 15:09:42 2008 +0000 +++ b/skillbot.pl Sat Dec 06 15:09:54 2008 +0000 @@ -342,6 +342,7 @@ open(FF, "< $config{friends_file}") or die "Couldn't open friends_file: $!"; while () { + chomp; next if (/^#/); if (/^([^\t]+)\t+([0-9]+)\t+([A-F0-9]{64})\t+([^\t]+)/i) { @@ -369,7 +370,7 @@ $friends{$c}->{api} = $api; - irc_debug("EVE: Adding new friend '%s' =~ %s", $c, $nick); + irc_debug("EVE: Adding new friend '%s', nick %s", $c, $nick); } $friends{$c}->{nick} = $nick; @@ -401,13 +402,21 @@ $friends{$f}->{char}->name, $skill->name, $skill->time_remaining); - my $text = $skill->name; + $friends{$f}->{skill} = $skill; + + my $text = sprintf("%s has completed training skill %s %s", + $friends{$f}->{char}->name, + $skill->name, $skill->level); + if ($text =~ /[\n\r]/) { $text =~ s/[\n\r]/ /g; } - $self->notice('#' . $config{channel}, sprintf("[%s] %s", $friends{$f}->{nick}, - encode("utf8", $text))); + irc_debug("In %lu seconds, announcing: %s", $skill->finish_time - time(), $text); + add_one_shot_timer($skill->finish_time - time(), sub { + $self->notice('#' . $config{channel}, sprintf("[%s] %s", + $friends{$f}->{nick}, encode("utf8", $text))); + }); } }