Mercurial > hg > skillbot
comparison skillbot.pl @ 7:6b73a2781c15
Skill completion notifications done
author | Dominic Cleal <dominic@computerkb.co.uk> |
---|---|
date | Sat, 06 Dec 2008 15:09:54 +0000 |
parents | dddb84241032 |
children | cb6e21f2d514 |
comparison
equal
deleted
inserted
replaced
6:f0f55a4999b7 | 7:6b73a2781c15 |
---|---|
340 my $self = shift; | 340 my $self = shift; |
341 | 341 |
342 open(FF, "< $config{friends_file}") or die "Couldn't open friends_file: $!"; | 342 open(FF, "< $config{friends_file}") or die "Couldn't open friends_file: $!"; |
343 | 343 |
344 while (<FF>) { | 344 while (<FF>) { |
345 chomp; | |
345 next if (/^#/); | 346 next if (/^#/); |
346 | 347 |
347 if (/^([^\t]+)\t+([0-9]+)\t+([A-F0-9]{64})\t+([^\t]+)/i) { | 348 if (/^([^\t]+)\t+([0-9]+)\t+([A-F0-9]{64})\t+([^\t]+)/i) { |
348 my $c = $1; | 349 my $c = $1; |
349 my $uid = $2; | 350 my $uid = $2; |
367 next; | 368 next; |
368 } | 369 } |
369 | 370 |
370 $friends{$c}->{api} = $api; | 371 $friends{$c}->{api} = $api; |
371 | 372 |
372 irc_debug("EVE: Adding new friend '%s' =~ %s", $c, $nick); | 373 irc_debug("EVE: Adding new friend '%s', nick %s", $c, $nick); |
373 } | 374 } |
374 | 375 |
375 $friends{$c}->{nick} = $nick; | 376 $friends{$c}->{nick} = $nick; |
376 } | 377 } |
377 } | 378 } |
399 | 400 |
400 irc_debug("Character %s is training %s (%s)", | 401 irc_debug("Character %s is training %s (%s)", |
401 $friends{$f}->{char}->name, $skill->name, | 402 $friends{$f}->{char}->name, $skill->name, |
402 $skill->time_remaining); | 403 $skill->time_remaining); |
403 | 404 |
404 my $text = $skill->name; | 405 $friends{$f}->{skill} = $skill; |
406 | |
407 my $text = sprintf("%s has completed training skill %s %s", | |
408 $friends{$f}->{char}->name, | |
409 $skill->name, $skill->level); | |
410 | |
405 if ($text =~ /[\n\r]/) { | 411 if ($text =~ /[\n\r]/) { |
406 $text =~ s/[\n\r]/ /g; | 412 $text =~ s/[\n\r]/ /g; |
407 } | 413 } |
408 | 414 |
409 $self->notice('#' . $config{channel}, sprintf("[%s] %s", $friends{$f}->{nick}, | 415 irc_debug("In %lu seconds, announcing: %s", $skill->finish_time - time(), $text); |
410 encode("utf8", $text))); | 416 add_one_shot_timer($skill->finish_time - time(), sub { |
417 $self->notice('#' . $config{channel}, sprintf("[%s] %s", | |
418 $friends{$f}->{nick}, encode("utf8", $text))); | |
419 }); | |
411 } | 420 } |
412 } | 421 } |
413 | 422 |
414 END { | 423 END { |
415 cleanup_and_die(); | 424 cleanup_and_die(); |