]> dxcluster.net Git - spider.git/commitdiff
make sh/contest async
authorDirk Koopman <djk@tobit.co.uk>
Tue, 27 Dec 2011 15:19:34 +0000 (15:19 +0000)
committerDirk Koopman <djk@tobit.co.uk>
Tue, 27 Dec 2011 15:19:34 +0000 (15:19 +0000)
cmd/show/contest.pl
cmd/show/qrz.pl
cmd/show/wm7d.pl
perl/DXCommandmode.pm
perl/Messages
perl/Version.pm

index 4b3e68ba813e0b5b3004a9dd07db520de385fd12..f29bbfe40d2214e3da83083637bfa425434d4d52 100644 (file)
@@ -13,7 +13,7 @@ my ($self, $line) = @_;
 
 my @out;
 
-my $mon;;
+my $mon;
 
 # trying to make the syntax abit more user friendly...
 # and yes, I have been here and it *is* all my fault (dirk)
@@ -40,32 +40,22 @@ my $port = 80;
 my $url = $Internet::contest_url || "http://www.sk3bg.se/contest/text";
 $url .= "/$filename";
 
-my $t = new Net::Telnet (Telnetmode => 0);
-eval {
-    $t->open(Host => $host, Port => $port, Timeout => 15);
-    };
-
-if (!$t || $@) {
-    push @out, $self->msg('e18','sk3bg.se');
-} else {
-    my $s = "GET $url";
-    $t->print($s);
-    my $notfound = $t->getline(Timeout => 10);
-    if ($notfound =~ /404 Object Not Found/) {
-           return (1, "there is no contest info for $mon")
-       } else {
-           push @out, $notfound;
-       }
-    while (!$t->eof) {
-       eval { 
-           push @out, $t->getline(Timeout => 10);
-       };
-       if ($@) {
-           push @out, $self->msg('e18', 'sk3bg.se');
-           last;    
-       }
-    }
-}
-$t->close;
+push @out,  $self->msg('http1', 'sk3bg.se', "$filename");
+
+$self->http_get($host, $url, sub
+                               {
+                                       my ($response, $header, $body) = @_;
+                                       my @out;
+
+                                       if ($response =~ /^4/) {
+                                               push @out, "There is no contest info $mon";
+                                       } elsif ($response =~ /^5/) {
+                                               push @out, $self->msg('e18','sk3bg.se');
+                                       } else {
+                                               push @out, split /\r?\n/, $body;
+                                       }
+                                       $self->send_ans(@out);
+                               }
+                          );
 
 return (1, @out);
index a5d14138c38a0a791e909801c181ac3c683cbcf0..5aef18283d9dda8abe147817810768356793f3aa 100644 (file)
@@ -29,7 +29,7 @@ foreach $l (@list) {
        }
 
        Log('call', "$call: show/qrz \U$l");
-       push @out,  $self->msg('http1', "show/qrz \U$l");
+       push @out,  $self->msg('http1', 'qrz.com', "\U$l");
 
        $self->http_get($host, $s, sub
                                        {
@@ -40,27 +40,31 @@ foreach $l (@list) {
                                                        dbg("qrz response: $response");
                                                        dbg("qrz body: $body");
                                                }
-                                               Log('call', "$call: show/qrz \U$body");
-                                               my $state = "blank";
-                                               foreach my $result (split /\r?\n/, $body) {
-                                                       dbg("qrz: $result") if isdbg('qrz') && $result;
-                                                       if ($state eq 'blank' && $result =~ /^<Callsign>/i) {
-                                                               $state = 'go';
-                                                       } elsif ($state eq 'go') {
-                                                               next if $result =~ m|<user>|;
-                                                               next if $result =~ m|<u_views>|;
-                                                               next if $result =~ m|<locref>|;
-                                                               next if $result =~ m|<ccode>|;
-                                                               next if $result =~ m|<dxcc>|;
-                                                               last if $result =~ m|</Callsign>|;
-                                                               my ($tag, $data) = $result =~ m|^\s*<(\w+)>(.*)</|;
-                                                               push @out, sprintf "%10s: $data", $tag;
-                                                       }
-                                               }
-                                               if (@out) {
-                                                       unshift @out, $self->msg('http2', "show/qrz \U$l");
+                                               if ($response =~ /^5/) {
+                                                       push @out, $self->msg('e18',"qrz.com $!");
                                                } else {
-                                                       push @out, $self->msg('e3', 'show/qrz', uc $l);
+                                                       Log('call', "$call: show/qrz \U$body");
+                                                       my $state = "blank";
+                                                       foreach my $result (split /\r?\n/, $body) {
+                                                               dbg("qrz: $result") if isdbg('qrz') && $result;
+                                                               if ($state eq 'blank' && $result =~ /^<Callsign>/i) {
+                                                                       $state = 'go';
+                                                               } elsif ($state eq 'go') {
+                                                                       next if $result =~ m|<user>|;
+                                                                       next if $result =~ m|<u_views>|;
+                                                                       next if $result =~ m|<locref>|;
+                                                                       next if $result =~ m|<ccode>|;
+                                                                       next if $result =~ m|<dxcc>|;
+                                                                       last if $result =~ m|</Callsign>|;
+                                                                       my ($tag, $data) = $result =~ m|^\s*<(\w+)>(.*)</|;
+                                                                       push @out, sprintf "%10s: $data", $tag;
+                                                               }
+                                                       }
+                                                       if (@out) {
+                                                               unshift @out, $self->msg('http2', "show/qrz \U$l");
+                                                       } else {
+                                                               push @out, $self->msg('e3', 'show/qrz', uc $l);
+                                                       }
                                                }
                                                $self->send_ans(@out);
                                        }
index 6dfb5b14172a8885511fd9fa97055eb19565c6e4..291823d7f8be2aa903844fb6d89130a37e48f4a2 100644 (file)
@@ -21,7 +21,8 @@ my $port = 5000;
 my $cmdprompt = '/query->.*$/';
 
 my($info, $t);
-                                    
+
+use Net::Telnet;
 $t = new Net::Telnet;
 $info =  $t->open(Host    => $target,
                  Port    => $port,
index a9777cbf0929b2da31cc5d3b76fa30929e6e55cb..a27d8d3060b842cd1618c4bbc67c583fc041d2bc 100644 (file)
@@ -36,7 +36,6 @@ use WCY;
 use Sun;
 use Internet;
 use Script;
-use Net::Telnet;
 use QSL;
 use DB_File;
 use VE7CC;
index 22551f00595c6b87e573f1b2dd6ebddb5b59ce5d..77e818e31c362e7d3a387ac43c4ca176e488fd9d 100644 (file)
@@ -150,7 +150,7 @@ package DXM;
                                hnodee1 => 'Please enter your Home Node, set/homenode <your home DX Cluster>',
                                hnodee2 => 'Failed to set homenode on $_[0]',
                                hnode => 'Your Homenode is now \"$_[0]\"',
-                               http1 => '$_[0] working ...',
+                               http1 => 'Searching $_[0] for $_[1] ...',
                                http2 => '$_[0] returned:',
                                init1 => 'sent initialisation message to $_[0]',
                                iso => '$_[0] Isolated',
index 3088501f0c37b5d933c93f398755742e6b5bb3a6..fdfe4d13b6aaae21860b46becd9ce05abacc00d3 100644 (file)
@@ -11,7 +11,7 @@ use vars qw($version $subversion $build $gitversion);
 
 $version = '1.56';
 $subversion = '0';
-$build = '10';
-$gitversion = '370d356';
+$build = '11';
+$gitversion = 'ed2d469';
 
 1;