added sh/wm7d and sh/db0sdx
[spider.git] / cmd / show / wm7d.pl
diff --git a/cmd/show/wm7d.pl b/cmd/show/wm7d.pl
new file mode 100644 (file)
index 0000000..72e2d80
--- /dev/null
@@ -0,0 +1,43 @@
+#
+# Query the WM7D Database server for a callsign
+#
+# Largely based on "sh/qrz" and info in the Net::Telnet documentation
+#
+# Copyright (c) 2002 Charlie Carroll K1XX
+#
+# $Id$
+#
+
+# wm7d accepts only single callsign
+my ($self, $line) = @_;
+my $call = $self->call;
+my @out;
+
+# send 'e24' if allow in Internet.pm is not set to 1
+return (1, $self->msg('e24')) unless $Internet::allow;
+return (1, "SHOW/WM7D <callsign>, e.g. SH/WM7D k1xx") unless $line;
+my $target = 'www.wm7d.net';
+my $port = 5000;
+my $cmdprompt = '/query->.*$/';
+
+my($info, $t);
+                                    
+$t = new Net::Telnet;
+$info =  $t->open(Host    => $target,
+                 Port    => $port,
+                 Timeout => 20);
+
+if (!$info) {
+       push @out, $self->msg('e18', 'WM7D.net');
+} else {
+        ## Wait for prompt and respond with callsign.
+        $t->waitfor($cmdprompt);
+       $t->print($line);
+        ($info) = $t->waitfor($cmdprompt);
+    
+       # Log the lookup
+       Log('call', "$call: show/wm7d \U$line");
+       $t->close;
+       push @out, $info;
+}
+return (1, @out);