1 # contest.pl - contest calendar from www.sk3bg.se/contest
2 # used with 1 argument: sh/contest <yearandmonth>
3 # e g sh/contest 2002sep
4 # Tommy Johansson (SM3OSM) 2002-07-23
5 # New version using Net::Telnet 2003-03-09
10 my ($self, $line) = @_;
12 #return (1, "usage: sh/contest [<month>] [<year>], e g sh/contest sep 2012") unless $line;
21 # trying to make the syntax abit more user friendly...
22 # and yes, I have been here and it *is* all my fault (dirk)
25 ($y) = $line =~ /(\d+)/;
26 ($m) = $line =~ /([a-z]{3})/;
34 $m = lc $DXUtil::month[$m];
36 $y += 2000 if $y <= 50;
37 $y += 1900 if $y > 50 && $y <= 99;
38 $m = substr $m, 0, 3 if length $m > 3;
39 $m = 'oct' if $m eq 'okt';
40 $m = 'may' if $m eq 'mai' || $m eq 'maj';
43 dbg("sh/contest: month=$mon") if isdbg('contest');
45 my $filename = "c" . $mon . ".txt";
46 my $host = $Internet::contest_host || 'www.sk3bg.se';
49 dbg("sh/contest: host=$host:$port") if isdbg('contest');
51 my $url = $Internet::contest_url || "/contest/text";
54 dbg("sh/contest: url=$url") if isdbg("contest");
56 my $t = new Net::Telnet (Telnetmode => 0);
57 eval { $t->open(Host => $host, Port => $port, Timeout => 15); };
60 push @out, $self->msg('e18','sk3bg.se');
62 my $s = "GET $url HTTP/1.0";
63 dbg("sh/contest: get='$s'") if isdbg('contest');
66 $t->print("Host: $host\n");
69 my $notfound = $t->getline(Timeout => 10);
70 if (!$notfound || $notfound =~ /404 Object Not Found/) {
71 push @out, "there is no contest info for $mon at $host/$url";
77 eval { push @out, $t->getline(Timeout => 10); };
79 push @out, $self->msg('e18', 'sk3bg.se');