# HG changeset patch # User "Rex Tsai " # Date 1223456182 -28800 # Node ID 5635e75c92d0c3cee759f20276063cfb6ec44555 # Parent 9c52ae71c1cb9db55d4a88405c12d19bbbbfc964 the user profile is also cached for 1 hour. diff -r 9c52ae71c1cb -r 5635e75c92d0 enemy.pl --- a/enemy.pl Wed Oct 08 16:22:54 2008 +0800 +++ b/enemy.pl Wed Oct 08 16:56:22 2008 +0800 @@ -22,6 +22,10 @@ foreach my $city ($u->cities) { my $island = Ikariam::Island->retrieve($city->island); printf("Name: %s\n", $city->cityname); + if(defined($city->status)) + { + printf("Status: <<<%s>>>\n", $city->status); + } printf("Level: %s\n", $city->citylevel); printf("Island: %s\n", $island->name); printf("Location: [%s:%s] http://s2.ikariam.tw/index.php?view=island&id=%s\n", $island->x, $island->y, $island->id); diff -r 9c52ae71c1cb -r 5635e75c92d0 scan.pl --- a/scan.pl Wed Oct 08 16:22:54 2008 +0800 +++ b/scan.pl Wed Oct 08 16:56:22 2008 +0800 @@ -27,12 +27,16 @@ } printf("city %d %s saved\n", $city->{cityId}, $city->{cityname}); - - # Download user profile. - foreach my $x (qw/score army_score_main trader_score_secondary/) + if(my $user = Ikariam::User->retrieve($city->{user})) { - my $users = $::i->viewScore($x, $city->{owner}, 0); - saveUser($users); + if($user->time le (time - 60*60)) { + # Download user profile. + foreach my $x (qw/score army_score_main trader_score_secondary/) + { + my $users = $::i->viewScore($x, $city->{owner}, 0); + saveUser($users); + } + } } } } @@ -41,21 +45,22 @@ { my $users = shift; - foreach my $user (values(%{$users})) + foreach my $h_user (values(%{$users})) { # print(Dumper($user)); - printf("Saving user %s\n", $user->{'name'}); - $user->{'time'} = time; - if(my $c = Ikariam::User->retrieve($user->{id})) + printf("Saving user %s\n", $h_user->{'name'}); + $h_user->{'time'} = time; + my $user; + if($user = Ikariam::User->retrieve($h_user->{id})) { - foreach my $i (keys(%$user)) { - eval($c->$i($user->{$i})); + foreach my $i (keys(%$h_user)) { + # eval($c->$i($h_user->{$i})); + $user->set($i => $h_user->{$i}); } - $c->autoupdate(1); - $c->update(); } else { - Ikariam::User->insert($user); + $user = Ikariam::User->insert($h_user); } + $user->update(); } }