See Changes
[spider.git] / cmd / show / 425.pl
index 353f2b9d914ac01d4ee3caa134de5fa2c0a176ab..05a9d07ac9ba95e0f81567a5cd7f52e91433b6e5 100644 (file)
@@ -5,55 +5,43 @@
 #
 #
 #
-my ($self, $line) = @_;
-my @list = map {uc} split /\s+/, $line;               # generate a list of callsigns
-my $op;
-my $call = $self->call;
-my @out;
 
-return (1, $self->msg('e24')) unless $Internet::allow;
-return (1, "SHOW/425 <callsign>\nSHOW/425 CAL\nSHOW/425 BULL <bulletin number>\n e.g. SH/425 IQ5BL, SH/425 CAL, SH/425 BUL 779\n") unless @list;
+sub handle
+{
+       my ($self, $line) = @_;
+       my @list = map {uc} split /\s+/, $line; # generate a list of callsigns
+       my $op;
+       my $call = $self->call;
+       my @out;
 
-my $target = "www.ari.it";
-my $port = 80;
-my $url = "http://www.ari.it";
+       return (1, $self->msg('e24')) unless $Internet::allow;
+       return (1, "SHOW/425 <callsign>\nSHOW/425 CAL\nSHOW/425 BULL <bulletin number>\n e.g. SH/425 IQ5BL, SH/425 CAL, SH/425 BUL 779\n") unless @list;
 
-use Net::Telnet;
-my $t = new Net::Telnet;
-eval {$t->open( Host     => $target,
-                Port     => $port,
-                Timeout  => 30);
-};
+       my $target = $Internet::dx425_url || 'https://www.425dxn.org';
+       my $port = 80;
 
-if (!$t || $@) {
+       dbg('sh/425: args=' . join('|', @list)) if isdbg('425');
+       if ($list[0] eq "CAL") {
+               $op="op=cal";
+       } elsif ($list[0] eq "BULL") {
+               $op="op=bull&query=$list[1]";
+       } else {
+               $op="op=search&query=$list[0]";
+       }
+       
+       my $path = "/spider.php?$op";
+
+       dbg("sh/425: target='$target' path='$path'") if isdbg('425'); 
+       
+       Log('call', "$call: show/425 \U$op");
+       my $conn = AsyncMsg->get($self, $target, $path, prefix=>'425> ', 'User-Agent' => qq{DxSpider;$main::version;$main::build;$^O;$main::mycall;$call;$list[0]});
+       
+       if ($conn) {
+               push @out, $self->msg('m21', "show/425");
+       } else {
         push @out, $self->msg('e18', 'Open(ARI.org)');
-} else {
-        dbg($list[0]."|".$list[1]) if isdbg('425');
-        if ($list[0] eq "CAL") {
-                $op="op=cal";
-        }
-        elsif ($list[0] eq "BULL") {
-                $op="op=bull&query=".$list[1];
-        }
-        else {
-                $op="op=search&query=".$list[0];
-        }
-       my $s = "GET $url/hf/dx-news/spider.php?$op HTTP/1.0\n" 
-        ."User-Agent:DxSpider;$main::version;$main::build;$^O;$main::mycall;$call;$list[0]\n\n";
-        dbg($s) if isdbg('425');
-        $t->print($s);
-        Log('call', "$call: show/425 \U$op");
-        my $state = "blank";
-        my $count = 1;
-        while (my $result = eval { $t->getline(Timeout => 30) } || $@) {
-                dbg($result) if isdbg('425') && $result;
-                ++$count;
-                if ($count > 9) {
-                        push @out, $result;
-                }
-        }
-        $t->close;
-        push @out, $self->msg('e3', 'Search(ARI.org)', uc $op) unless @out;
+       }
+
+       return (1, @out);
 }
 
-return (1, @out);