comparison skillbot.pl @ 47:31a4d4cab76f

Adding timezone field to friends file, used for !eta
author Dominic Cleal <dominic@computerkb.co.uk>
date Sat, 20 Dec 2008 11:45:26 +0000
parents bfd2b428d131
children 0fa8fe61aca1
comparison
equal deleted inserted replaced
46:bfd2b428d131 47:31a4d4cab76f
238 if (skill_finish_in_downtime($f->{skill})) { 238 if (skill_finish_in_downtime($f->{skill})) {
239 $downtime = ", coincides with downtime"; 239 $downtime = ", coincides with downtime";
240 } 240 }
241 241
242 my $finish = DateTime->from_epoch( 242 my $finish = DateTime->from_epoch(
243 epoch => $f->{skill}->finish_time); 243 epoch => $f->{skill}->finish_time,
244 time_zone => $f->{tz});
244 245
245 $text = sprintf("Currently training %s %s ". 246 $text = sprintf("Currently training %s %s ".
246 "(finish in %s, %s%s)", 247 "(finish in %s, %s%s)",
247 $f->{skill}->name, $f->{skill}->level, 248 $f->{skill}->name, $f->{skill}->level,
248 $f->{skill}->time_remaining, 249 $f->{skill}->time_remaining,
395 396
396 =pod 397 =pod
397 398
398 Read a list of friends from the friends_file. Format is: 399 Read a list of friends from the friends_file. Format is:
399 400
400 user_id api_key IRC_nick character_name 401 user_id api_key IRC_nick timezone character_name
401 402
402 Start a line with # for a comment. Character name is optional, if left 403 Start a line with # for a comment. Character name is optional, if left
403 out then all characters will be monitored. 404 out then all characters will be monitored.
404 405
405 =cut 406 =cut
411 412
412 while (<FF>) { 413 while (<FF>) {
413 chomp; 414 chomp;
414 next if (/^#/); 415 next if (/^#/);
415 416
416 if (/^([0-9]+)\s+([a-z0-9]{64})\s+(\S+)(\s+(.+))?/i) { 417 if (/^([0-9]+)\s+([a-z0-9]{64})\s+(\S+)\s+(\S+)(\s+(.+))?/i) {
417 my $uid = $1; 418 my $uid = $1;
418 my $key = $2; 419 my $key = $2;
419 my $nick = $3; 420 my $nick = $3;
420 my $c = $5; 421 my $tz = $4;
422 my $c = $6;
421 423
422 if (! $frienduids{$uid}) { 424 if (! $frienduids{$uid}) {
423 my $api = WebService::EveOnline->new( { user_id => $uid, 425 my $api = WebService::EveOnline->new( { user_id => $uid,
424 api_key => $key } ); 426 api_key => $key } );
425 427
427 foreach my $character ($api->characters) { 429 foreach my $character ($api->characters) {
428 next if defined $c && $c ne $character->name; 430 next if defined $c && $c ne $character->name;
429 push @friends, { 431 push @friends, {
430 char => $character, 432 char => $character,
431 api => $api, 433 api => $api,
432 nick => $nick 434 nick => $nick,
435 tz => $tz
433 }; 436 };
434 $loaded++; 437 $loaded++;
435 } 438 }
436 439
437 if (defined $c && $loaded eq 0) 440 if (defined $c && $loaded eq 0)