If you never played go do not click this link, you still can be saved from this drug
Just hacked this simple script to poll for my turns to move on http://www.dragongoserver.net/. To my taste the script is a bit ugly but it works.
#!/usr/bin/perl
use strict;
use warnings;
my $go = DragonGoServer->new;
$go->login($ENV{DRAGONGO_LOGIN}, $ENV{DRAGONGO_PASSWORD});
while(1) {
$go->read_status;
sleep 480;
}
package DragonGoServer;
use base qw(WWW::Mechanize);
sub redirect_ok { 1 }
sub login {
my $self = shift;
my ($login, $password) = @_;
$self->get('http://www.dragongoserver.net/');
$self->submit_form(form_name => 'loginform',
fields => { userid => $login,
passwd => $password });
}
sub read_status {
my $self = shift;
$self->get('http://www.dragongoserver.net/status.php');
if($self->content =~/Your turn to move in the following games/) {
print "Your turn to move in the following games:\n";
my $re = qr!game\.php\?gid= (\d+)
.*?
userinfo\.php\?uid=\d+.*? <font.*?> (.*?) </font>
!x;
my $content = $self->content;
while($content =~/\G[\s\S]*?$re/g) {
print "Game #$1, player '$2'\n";
}
print "\n"
}
}
Yet another go addict 0 Comments More | Login | Reply /