# HG changeset patch # User df # Date 1228642942 0 # Node ID 276658826bc0d8237bf963e8da4618755a8024ad # Parent ba7303a5f42df1a45f6f51e90a9d352d16427ee9 Local commit, so dom can help me out. -- love perl diff -r ba7303a5f42d -r 276658826bc0 skillbot.pl --- a/skillbot.pl Sun Dec 07 08:47:25 2008 +0000 +++ b/skillbot.pl Sun Dec 07 09:42:22 2008 +0000 @@ -257,6 +257,14 @@ $self->privmsg('#' . $config{channel}, "Done"); } + # lists the chars in order of shortest training time + if ($msg =~ /^\!next/i) { + my $nreply = "Training: "; + my (@fc) = (order_friend_copy @friends); + + foreach (@fc) + $nreply .= $_->{char}->name . " (" . $_->{skill}->time_remaining . ") | "; + } } sub on_notice @@ -498,6 +506,23 @@ }); } +=pod + +Returns a copy of the input @friends that is ordered by training time +and doesnt contain any chars that are not in training. + +=cut +sub order_friend_copy +{ + my @friendcopy; + foreach ($_) + push(@friendcopy, $_) unless defined($_->{char}->skill->in_training); + + sort { $a->{skill}->finish_time <=> $b->{skill}->finish_time } @friendcopy; + + return @friendcopy; +} + END { cleanup_and_die(); }