add show/motd command
[spider.git] / perl / DXCommandmode.pm
index 854a635496e058a651896d04bc8f412a381f84ea..6fde1742b6067b8b3b1d717bfdbe073b51c5c29f 100644 (file)
@@ -133,23 +133,8 @@ sub start
                $self->{registered} = 1;
        }
 
-
-       # decide which motd to send
-       my $motd;
-       unless ($self->{registered}) {
-               $motd = "${main::motd}_nor_$self->{lang}";
-               $motd = "${main::motd}_nor" unless -e $motd;
-       }
-       $motd = "${main::motd}_$self->{lang}" unless $motd && -e $motd;
-       $motd = $main::motd unless $motd && -e $motd;
-       if ($self->conn->{csort} eq 'ax25') {
-               if ($motd) {
-                       $motd = "${motd}_ax25" if -e "${motd}_ax25";
-               } else {
-                       $motd = "${main::motd}_ax25" if -e "${main::motd}_ax25";
-               }
-       }
-       $self->send_file($motd) if -e $motd;
+       # send the relevant MOTD
+       $self->send_motd;
 
        # sort out privilege reduction
        $self->{priv} = 0 if $line =~ /^(ax|te)/ && !$self->conn->{usedpasswd};
@@ -218,7 +203,7 @@ sub start
        foreach my $call (@{$user->buddies}) {
                my $ref = Route::User::get($call);
                if ($ref) {
-                       foreach my $node (@{$ref->parent}) {
+                       foreach my $node ($ref->parents) {
                                $self->send($self->msg($node eq $main::mycall ? 'loginb' : 'loginbn', $call, $node));
                        } 
                }
@@ -1226,5 +1211,27 @@ sub print_find_reply
        my $sort = $flag == 2 ? "External" : "Local";
        $self->send("$sort $target found at $node in $ms ms" );
 }
+
+# send the most relevant motd
+sub send_motd
+{
+       my $self = shift;
+       my $motd;
+
+       unless ($self->{registered}) {
+               $motd = "${main::motd}_nor_$self->{lang}";
+               $motd = "${main::motd}_nor" unless -e $motd;
+       }
+       $motd = "${main::motd}_$self->{lang}" unless $motd && -e $motd;
+       $motd = $main::motd unless $motd && -e $motd;
+       if ($self->conn->{csort} eq 'ax25') {
+               if ($motd) {
+                       $motd = "${motd}_ax25" if -e "${motd}_ax25";
+               } else {
+                       $motd = "${main::motd}_ax25" if -e "${main::motd}_ax25";
+               }
+       }
+       $self->send_file($motd) if -e $motd;
+}
 1;
 __END__