added show/425 command
[spider.git] / cmd / show / wm7d.pl
1 #
2 # Query the WM7D Database server for a callsign
3 #
4 # Largely based on "sh/qrz" and info in the Net::Telnet documentation
5 #
6 # Copyright (c) 2002 Charlie Carroll K1XX
7 #
8 # $Id$
9 #
10
11 # wm7d accepts only single callsign
12 my ($self, $line) = @_;
13 my $call = $self->call;
14 my @out;
15
16 # send 'e24' if allow in Internet.pm is not set to 1
17 return (1, $self->msg('e24')) unless $Internet::allow;
18 return (1, "SHOW/WM7D <callsign>, e.g. SH/WM7D k1xx") unless $line;
19 my $target = $Internet::wm7d_url || 'www.wm7d.net';
20 my $port = 5000;
21 my $cmdprompt = '/query->.*$/';
22
23 my($info, $t);
24                                     
25 $t = new Net::Telnet;
26 $info =  $t->open(Host    => $target,
27                   Port    => $port,
28                   Timeout => 20);
29
30 if (!$info) {
31         push @out, $self->msg('e18', 'WM7D.net');
32 } else {
33         ## Wait for prompt and respond with callsign.
34         $t->waitfor($cmdprompt);
35         $t->print($line);
36         ($info) = $t->waitfor($cmdprompt);
37     
38         # Log the lookup
39         Log('call', "$call: show/wm7d \U$line");
40         $t->close;
41         push @out, split /[\r\n]+/, $info;
42 }
43 return (1, @out);