diff Ikariam.pm @ 10:f590b5ea5e55

fixed bug of sheep.pl
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Wed, 08 Oct 2008 09:55:43 +0800
parents ae412d1f7761
children 59f2c435760c
line wrap: on
line diff
--- a/Ikariam.pm	Wed Oct 08 04:30:32 2008 +0800
+++ b/Ikariam.pm	Wed Oct 08 09:55:43 2008 +0800
@@ -185,6 +185,21 @@
         or die "gunzip failed: $GunzipError\n";
 
     my $html = HTML::TagParser->new($c);
+
+    # find inactivity and vacation
+    my %status;
+    foreach my $class (qw/inactivity vacation/)
+    {
+        @elems = $html->getElementsByAttribute("class", $class);
+        foreach my $elem (@elems) {
+            if($elem->innerText() =~ /^(.*?) \((\w)\)/) {
+                $status{$1} = $2;
+                # printf("%s\n", $elem->innerText());
+            }
+        }
+    }
+
+    # find content
     my @elems = $html->getElementsByClassName( "cityinfo" );
     my @cities;
     foreach my $elem (@elems) {
@@ -203,6 +218,14 @@
             $info{'user'} = $1;
             $info{'cityId'} = $2;
         }
+
+        # update status;
+        if(defined($status{$info{'cityname'}})) {
+            $info{'status'} = $status{$info{'cityname'}};
+        } else {
+            $info{'status'} = undef;
+        }
+        # print(Dumper(\%info));
         push @cities, \%info;
     }