add Net::Telnet explicitly
[spider.git] / perl / DXCommandmode.pm
index cda7690415ce9f56539c009894eea3ca4c421268..f9d9c9f08b53f8b4c458f572457d7f59ed6a06c4 100644 (file)
@@ -31,7 +31,7 @@ use WCY;
 use Sun;
 use Internet;
 use Script;
-
+use Net::Telnet;
 
 use strict;
 use vars qw(%Cache %cmd_cache $errstr %aliases $scriptbase $maxerrors %nothereslug $maxbadcount);
@@ -47,7 +47,7 @@ $maxbadcount = 3;                             # no of bad words allowed before disconnection
 
 use vars qw($VERSION $BRANCH);
 $VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
-$BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/ ) || 0;
+$BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/  || (0,0));
 $main::build += $VERSION;
 $main::branch += $BRANCH;
 
@@ -470,7 +470,7 @@ sub run_cmd
                        return ();
                }
        }
-       return (@ans);
+       return map {s/([^\s])\s+$/$1/; $_} @ans;
 }
 
 #
@@ -646,7 +646,7 @@ sub clear_cmd_cache
        no strict 'refs';
        
        for (keys %Cache) {
-               undef *{$_};
+               undef *{$_} unless /cmd_cache/;
                dbg("Undefining cmd $_") if isdbg('command');
        }
        %cmd_cache = ();
@@ -814,11 +814,31 @@ sub dx_spot
 
 
        my $t = ztime($_[2]);
+       my $loc;
+       my $clth = $self->{consort} eq 'local' ? 29 : 30;
+       my $comment = substr $_[3], 0, $clth; 
+       $comment .= ' ' x ($clth - length($comment));
        my $ref = DXUser->get_current($_[4]);
-       my $loc = $ref->qra if $ref && $ref->qra && $self->{user}->wantgrid;
-       $loc = ' ' . substr($loc, 0, 4) if $loc;
+       if ($ref) {
+               $loc = $ref->qra || '' if $self->{user}->wantgrid; 
+               $loc = ' ' . substr($loc, 0, 4) if $loc;
+       } 
        $loc = "" unless $loc;
-       my $buf = sprintf "DX de %-7.7s%11.1f  %-12.12s %-*s $t$loc", "$_[4]:", $_[0], $_[1], $self->{consort} eq 'local' ? 29 : 30, $_[3];
+
+       # USDB stuff
+       if ($USDB::present && $self->{user}->wantusstate) {
+               my ($city, $state) = USDB::get($_[4]);
+               if ($state) {
+                       $loc = ' ' . $state;
+               }
+               ($city, $state) = USDB::get($_[1]);
+               if ($state) {
+                       $comment = substr($comment, 0,  $self->{consort} eq 'local' ? 26 : 27) . ' ' . $state; 
+               }
+       }
+
+       my $buf = sprintf "DX de %-7.7s%11.1f  %-12.12s %-s $t$loc", "$_[4]:", $_[0], $_[1], $comment;
+       
        $buf .= "\a\a" if $self->{beep};
        $buf =~ s/\%5E/^/g;
        $self->local_send('X', $buf);