X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=cmd%2Fshow%2Fcontest.pl;h=f29bbfe40d2214e3da83083637bfa425434d4d52;hb=209156e38a1a136ba8c8cf0e9df122eb63c8f2c9;hp=4b3e68ba813e0b5b3004a9dd07db520de385fd12;hpb=ed2d469812ca5ab82baab7f8b4795660e01ef539;p=spider.git diff --git a/cmd/show/contest.pl b/cmd/show/contest.pl index 4b3e68ba..f29bbfe4 100644 --- a/cmd/show/contest.pl +++ b/cmd/show/contest.pl @@ -13,7 +13,7 @@ my ($self, $line) = @_; my @out; -my $mon;; +my $mon; # trying to make the syntax abit more user friendly... # and yes, I have been here and it *is* all my fault (dirk) @@ -40,32 +40,22 @@ my $port = 80; my $url = $Internet::contest_url || "http://www.sk3bg.se/contest/text"; $url .= "/$filename"; -my $t = new Net::Telnet (Telnetmode => 0); -eval { - $t->open(Host => $host, Port => $port, Timeout => 15); - }; - -if (!$t || $@) { - push @out, $self->msg('e18','sk3bg.se'); -} else { - my $s = "GET $url"; - $t->print($s); - my $notfound = $t->getline(Timeout => 10); - if ($notfound =~ /404 Object Not Found/) { - return (1, "there is no contest info for $mon") - } else { - push @out, $notfound; - } - while (!$t->eof) { - eval { - push @out, $t->getline(Timeout => 10); - }; - if ($@) { - push @out, $self->msg('e18', 'sk3bg.se'); - last; - } - } -} -$t->close; +push @out, $self->msg('http1', 'sk3bg.se', "$filename"); + +$self->http_get($host, $url, sub + { + my ($response, $header, $body) = @_; + my @out; + + if ($response =~ /^4/) { + push @out, "There is no contest info $mon"; + } elsif ($response =~ /^5/) { + push @out, $self->msg('e18','sk3bg.se'); + } else { + push @out, split /\r?\n/, $body; + } + $self->send_ans(@out); + } + ); return (1, @out);