fix sending msgs to g1tlh-2 (and not to g1tlh, - and 2)
[spider.git] / cmd / send.pl
index 3c08ddbbb483bac93a733cfe4f7e81ccb64613c5..9154d34b6f8966edb3fd4760106abf54966ede4c 100644 (file)
@@ -32,8 +32,9 @@ $loc->{rrreq} = '0';
 
 if ($self->state eq "prompt") {
 
-       my @f = split /\s+/, $line;
-
+       my @f = split /([\s\@\$])/, $line;
+       @f = map {s/\s+//g; length $_ ? $_ : ()} @f;
+       
        # any thing after send?
        return (1, $self->msg('e6')) if !@f;
 
@@ -92,6 +93,16 @@ if ($self->state eq "prompt") {
                        ;
                } elsif ($notincalls && ($f eq 'RR')) {
                        $loc->{rrreq} = '1';
+               } elsif ($f eq '<' && @f) {     # this is bbs syntax  for from call
+                       $loc->{from} = uc shift @f;
+               } elsif (($f =~ /^[\@\.\#\$]$/ || $f eq '.#') && @f) {       # this is bbs syntax, for send it 'to node'
+                       shift @f;
+               } elsif ($f =~ /^\$/) {     # this is bbs syntax  for a bid
+                       next;
+               } elsif ($f =~ /^<(\S+)/) {     # this is bbs syntax  for from call
+                       $loc->{from} = $1;
+               } elsif ($f =~ /^\$\S+/) {     # this is bbs syntax  for bid
+                       ;
                } else {
 
                        # callsign ?
@@ -130,12 +141,19 @@ if ($self->state eq "prompt") {
                delete $self->{loc};
                return (1, $self->msg('e6'));
        }
+       $loc->{from} ||= $self->call;
+       unless (is_callsign($loc->{from})) {
+               delete $self->{loc};
+               return (1, $self->msg('e22', $loc->{from}));
+       }
 
        # find me and set the state and the function on my state variable to
        # keep calling me for every line until I relinquish control
        $self->func("DXMsg::do_send_stuff");
        $self->state('send1');
        push @out, $self->msg('m1');
+} else {
+       push @out, $self->msg('m17', $self->state);
 }
 
 return (1, @out);