]> gb7djk.dxcluster.net Git - spider.git/blob - cmd/show/qrz.pl
remove finishes and derive disconnect instead
[spider.git] / cmd / show / qrz.pl
1 #
2 # Query the QRZ Database server for a callsign
3 #
4 # from an idea by Steve Franke K9AN and information from Angel EA7WA
5 #
6 # $Id$
7 #
8 my ($self, $line) = @_;
9 my @list = split /\s+/, $line;                # generate a list of callsigns
10 my $l;
11 my $call = $self->call;
12 my @out;
13
14 return (1, $self->msg('e24')) unless $Internet::allow;
15 return (1, "SHOW/QRZ <callsign>, e.g. SH/QRZ g1tlh") unless @list;
16
17 use Net::Telnet;
18
19 my $t = new Net::Telnet;
20
21 foreach $l (@list) {
22         $t->open(Host     =>  "qrz.com",
23                          Port     =>  80,
24                          Timeout  =>  15);
25         if ($t) {
26                 my $s = "GET /dxcluster.cgi?callsign=$l\&uid=$Internet::qrz_uid\&pw=$Internet::qrz_pw HTTP/1.0\n\n";
27 #               print $s;
28                 $t->print($s);
29                 Log('call', "$call: show/qrz \U$l");
30                 my $state = "blank";
31                 while (my $result = $t->getline) {
32 #                       print $result;
33                         if ($state eq 'blank' && $result =~ /^\s*Callsign\s*:/i) {
34                                 $state = 'go';
35                         } elsif ($state eq 'go') {
36                                 next if $result =~ /^\s*Usage\s*:/i;
37                                 chomp $result;
38                                 push @out, $result;
39                         }
40                 }
41                 $t->close;
42                 push @out, $self->msg('e3', 'qrz.com', uc $l) unless @out;
43         } else {
44                 push @out, $self->msg('e18', 'QRZ.com');
45         }
46 }
47
48 return (1, @out);