2 # Query the WM7D Database server for a callsign
4 # Was Largely based on "sh/qrz"
6 # Original Copyright (c) 2002 Charlie Carroll K1XX
8 # Async version (c) Dirk Koopman G1TLH
17 my $buf = $conn->{msg};
21 dbg "state $conn->{state} '$msg' '$buf'" if isdbg('wm7d');
23 $conn->{_wm7d} ||= [];
25 if ($conn->{state} eq 'waitfor') {
26 if ($msg =~ /utc$/ ) {
27 $conn->send_later("$conn->{target_call}\n");
28 $conn->{state} = 'working';
30 } elsif ($conn->{state} eq 'working') {
31 if ($conn->{msg} =~ /^\rquery->\s*$/) {
32 $conn->send_later("QUIT\n");
33 $conn->{state} = 'ending';
35 return if $msg =~ /^query->/;
36 push @{$conn->{_wm7d}}, $msg;
38 return if $msg =~ /^query->/ || $msg =~ /bye/;
39 # $conn->handle_raw($msg);
40 push @{$conn->{_wm7d}}, $msg;
50 $dxchan->send(map {"$conn->{prefix}$_"} @{$conn->{_wm7d}});
53 # wm7d accepts only single callsign
57 my ($self, $line) = @_;
58 my $call = $self->call;
64 # send 'e24' if allow in Internet.pm is not set to 1
65 return (1, $self->msg('e24')) unless $Internet::allow;
66 return (1, "SHOW/WM7D <callsign>, e.g. SH/WM7D k1xx") unless $line;
67 my $target = $Internet::wm7d_url || 'www.wm7d.net';
69 my $cmdprompt = '/query->.*$/';
71 Log('call', "$call: show/wm7d \U$line");
73 my $conn = AsyncMsg->raw($self, $target, $port,
74 handler => \&waitfor, prefix=>'wm7d> ', on_disc =>\&on_disc);
76 $conn->{state} = 'waitfor';
77 $conn->{target_call} = $line;
79 push @out, $self->msg('m21', "show/wm7d");
81 push @out, $self->msg('e18', 'WM7D.net');