X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=cmd%2Fshow%2Fcontest.pl;h=451a55daa528c9417135bef207ba2f54b049f427;hb=d0b55caa8a609da9ccc5ea59bb376795a99d04b5;hp=4b3e68ba813e0b5b3004a9dd07db520de385fd12;hpb=2cb165bafb996974e2bc11ab68eb1bcec9a45e47;p=spider.git diff --git a/cmd/show/contest.pl b/cmd/show/contest.pl index 4b3e68ba..451a55da 100644 --- a/cmd/show/contest.pl +++ b/cmd/show/contest.pl @@ -2,70 +2,63 @@ # used with 1 argument: sh/contest # e g sh/contest 2002sep # Tommy Johansson (SM3OSM) 2002-07-23 -# New version using Net::Telnet 2003-03-09 -# # +# New version use AsyncMsg (c) Dirk Koopman G1TLH # -my ($self, $line) = @_; +sub handle +{ + my ($self, $line) = @_; + + return (1, $self->msg('e24')) unless $Internet::allow; -#return (1, "usage: sh/contest , e g sh/contest 2002sep ") unless $line; + my @out; -my @out; + #$DB::single = 1; -my $mon;; -# trying to make the syntax abit more user friendly... -# and yes, I have been here and it *is* all my fault (dirk) -$line = lc $line; -my ($m,$y) = $line =~ /^([a-z]+)\s*(\d+)/; -($y,$m) = $line =~ /^(\d+)\s*([a-z]+)/ unless $y && $m; -unless ($y && $m) { - ($m,$y) = (gmtime)[4,5]; - $m = lc $DXUtil::month[$m]; - $y += 1900; -} -$y += 2000 if $y <= 50; -$y += 1900 if $y > 50 && $y <= 99; -$m = substr $m, 0, 3 if length $m > 3; -$m = 'oct' if $m eq 'okt'; -$m = 'may' if $m eq 'mai' || $m eq 'maj'; -$mon = "$y$m"; + # trying to make the syntax abit more user friendly... + # and yes, I have been here and it *is* all my fault (dirk) + $line = lc $line; + my ($m,$y); + ($y) = $line =~ /(\d+)/; + ($m) = $line =~ /([a-z]{3})/; + + unless ($y) { + ($y) = (gmtime)[5]; + $y += 1900; + } + unless ($m) { + ($m) = (gmtime)[4]; + $m = lc $DXUtil::month[$m]; + } + $y += 2000 if $y <= 50; + $y += 1900 if $y > 50 && $y <= 99; + $m = substr $m, 0, 3 if length $m > 3; + $m = 'oct' if $m eq 'okt'; + $m = 'may' if $m eq 'mai' || $m eq 'maj'; + my $mon = "$y$m"; -dbg($mon) if isdbg('contest'); + dbg("sh/contest: month=$mon") if isdbg('contest'); -my $filename = "c" . $mon . ".txt"; -my $host = $Internet::contest_host || 'www.sk3bg.se'; -my $port = 80; -my $url = $Internet::contest_url || "http://www.sk3bg.se/contest/text"; -$url .= "/$filename"; + my $filename = "c" . $mon . ".txt"; + my $host = $Internet::contest_host || 'www.sk3bg.se'; + my $port = 80; -my $t = new Net::Telnet (Telnetmode => 0); -eval { - $t->open(Host => $host, Port => $port, Timeout => 15); - }; + dbg("sh/contest: host=$host:$port") if isdbg('contest'); -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; + my $url = $Internet::contest_url || "/contest/text"; + $url .= "/$filename"; + + dbg("sh/contest: url=$url") if isdbg("contest"); + + my $r = AsyncMsg->get($self->call, $host, $url, prefix=>'ctst> '); + if ($r) { + push @out, $self->msg('m21', "show/contest"); } - while (!$t->eof) { - eval { - push @out, $t->getline(Timeout => 10); - }; - if ($@) { - push @out, $self->msg('e18', 'sk3bg.se'); - last; + else { + push @out, $self->msg('e18','sk3bg.se'); } - } -} -$t->close; -return (1, @out); + return (1, @out); +}