44ad0a30b89f7eb6a2d8df12ec22c9e73b40fdd0
[spider.git] / cmd / show / 425.pl
1 #
2 # Query the 425 Database server for a callsign
3 #
4 # from an idea by Leo,IZ5FSA and 425DxNews Group
5 #
6 # $Id$
7 #
8 my ($self, $line) = @_;
9 my @list = map {uc} split /\s+/, $line;               # generate a list of callsigns
10 my $op;
11 my $call = $self->call;
12 my @out;
13
14 return (1, $self->msg('e24')) unless $Internet::allow;
15 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;
16
17 my $target = "www.ari.it";
18 my $port = 80;
19 my $url = "http://www.ari.it";
20
21 use Net::Telnet;
22 my $t = new Net::Telnet;
23 eval {$t->open( Host     => $target,
24                 Port     => $port,
25                 Timeout  => 30);
26 };
27
28 if (!$t || $@) {
29         push @out, $self->msg('e18', 'Open(ARI.org)');
30 } else {
31         dbg($list[0]."|".$list[1]) if isdbg('425');
32         if ($list[0] eq "CAL") {
33                 $op="op=cal";
34         }
35         elsif ($list[0] eq "BULL") {
36                 $op="op=bull&query=".$list[1];
37         }
38         else {
39                 $op="op=search&query=".$list[0];
40         }
41         my $s = "GET $url/hf/dx-news/iz5fsa/spider.php?$op HTTP/1.0\n"
42         ."User-Agent:DxSpider;$main::version;$main::build;$^O;$main::mycall;$call;$list[0]\n\n";
43         dbg($s) if isdbg('425');
44         $t->print($s);
45         Log('call', "$call: show/425 \U$op");
46         my $state = "blank";
47         my $count = 1;
48         while (my $result = eval { $t->getline(Timeout => 30) } || $@) {
49                 dbg($result) if isdbg('425') && $result;
50                 ++$count;
51                 if ($count > 9) {
52                         push @out, $result;
53                 }
54         }
55         $t->close;
56         push @out, $self->msg('e3', 'Search(ARI.org)', uc $op) unless @out;
57 }
58
59 return (1, @out);